Label

Inherits: Control < CanvasItem < Node < Object

Category: Core

Brief Description

Displays plain text in a line or wrapped inside a rectangle. For formatted text, use RichTextLabel.

Properties

Alignalign
boolautowrap
boolclip_text
intlines_skipped
intmax_lines_visible
floatpercent_visible
Stringtext
booluppercase
VAlignvalign
intvisible_characters

Methods

intget_line_count ( ) const
intget_line_height ( ) const
intget_total_character_count ( ) const
intget_visible_line_count ( ) const

Theme Properties

Fontfont
Colorfont_color
Colorfont_color_shadow
Colorfont_outline_modulate
intline_spacing
StyleBoxnormal
intshadow_as_outline
intshadow_offset_x
intshadow_offset_y

Enumerations

enum Align:

  • ALIGN_LEFT = 0 — Align rows to the left (default).
  • ALIGN_CENTER = 1 — Align rows centered.
  • ALIGN_RIGHT = 2 — Align rows to the right (default).
  • ALIGN_FILL = 3 — Expand row whitespaces to fit the width.

enum VAlign:

  • VALIGN_TOP = 0 — Align the whole text to the top.
  • VALIGN_CENTER = 1 — Align the whole text to the center.
  • VALIGN_BOTTOM = 2 — Align the whole text to the bottom.
  • VALIGN_FILL = 3 — Align the whole text by spreading the rows.

Description

Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment, and can wrap the text inside the node’s bounding rectangle. It doesn’t support bold, italics or other formatting. For that, use RichTextLabel instead.

Note that contrarily to most other Controls, Label’s Control.mouse_filter defaults to MOUSE_FILTER_IGNORE (i.e. it doesn’t react to mouse input events). This implies that a label won’t display any configured Control.hint_tooltip, unless you change its mouse filter.

Property Descriptions

Setterset_align(value)
Getterget_align()

Controls the text’s horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the ALIGN_* constants.


Setterset_autowrap(value)
Getterhas_autowrap()

If true, wraps the text inside the node’s bounding rectangle. If you resize the node, it will change its height automatically to show all the text. Default: false.


Setterset_clip_text(value)
Getteris_clipping_text()

If true, the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.


  • int lines_skipped
Setterset_lines_skipped(value)
Getterget_lines_skipped()

The node ignores the first lines_skipped lines before it starts to display text.


  • int max_lines_visible
Setterset_max_lines_visible(value)
Getterget_max_lines_visible()

Limits the lines of text the node shows on screen.


Setterset_percent_visible(value)
Getterget_percent_visible()

Limits the count of visible characters. If you set percent_visible to 50, only up to half of the text’s characters will display on screen. Useful to animate the text in a dialog box.


Setterset_text(value)
Getterget_text()

The text to display on screen.


Setterset_uppercase(value)
Getteris_uppercase()

If true, all the text displays as UPPERCASE.


Setterset_valign(value)
Getterget_valign()

Controls the text’s vertical align. Supports top, center, bottom, and fill. Set it to one of the VALIGN_* constants.


  • int visible_characters
Setterset_visible_characters(value)
Getterget_visible_characters()

Restricts the number of characters to display. Set to -1 to disable.

Method Descriptions

  • int get_line_count ( ) const

Returns the amount of lines of text the Label has.


  • int get_line_height ( ) const

Returns the font size in pixels.


  • int get_total_character_count ( ) const

Returns the total number of printable characters in the text (excluding spaces and newlines).


  • int get_visible_line_count ( ) const

Returns the number of lines shown. Useful if the Label ‘s height cannot currently display all lines.