Table of Contents

Class Label

A control for displaying plain text.

Inheritance
Label

Remarks

A control for displaying plain text. 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 rich text formatting. For that, use RichTextLabel instead.

See Also

Properties

autowrap_mode

If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. To see how each mode behaves, see AutowrapMode.

var autowrap_mode : int = 0

Property Value

int

Remarks

  • void set_autowrap_mode(int value)
  • int get_autowrap_mode

clip_text

If true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.

var clip_text : bool = false

Property Value

bool

Remarks

  • void set_clip_text(bool value)
  • bool is_clipping_text

ellipsis_char

Ellipsis character used for text clipping.

var ellipsis_char : String = "…"

Property Value

String

Remarks

  • void set_ellipsis_char(String value)
  • String get_ellipsis_char

horizontal_alignment

Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the HorizontalAlignment constants.

var horizontal_alignment : int = 0

Property Value

int

Remarks

  • void set_horizontal_alignment(int value)
  • int get_horizontal_alignment

justification_flags

Line fill alignment rules. See JustificationFlag for more information.

var justification_flags : int = 163

Property Value

int

Remarks

  • void set_justification_flags(int value)
  • int get_justification_flags

label_settings

A LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.

var label_settings : LabelSettings

Property Value

LabelSettings

Remarks

language

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

var language : String = ""

Property Value

String

Remarks

lines_skipped

The number of the lines ignored and not displayed from the start of the text value.

var lines_skipped : int = 0

Property Value

int

Remarks

  • void set_lines_skipped(int value)
  • int get_lines_skipped

max_lines_visible

Limits the lines of text the node shows on screen.

var max_lines_visible : int = -1

Property Value

int

Remarks

  • void set_max_lines_visible(int value)
  • int get_max_lines_visible

paragraph_separator

String used as a paragraph separator. Each paragraph is processed independently, in its own BiDi context.

var paragraph_separator : String = "\\n"

Property Value

String

Remarks

  • void set_paragraph_separator(String value)
  • String get_paragraph_separator

structured_text_bidi_override

Set BiDi algorithm override for the structured text.

var structured_text_bidi_override : int = 0

Property Value

int

Remarks

  • void set_structured_text_bidi_override(int value)
  • int get_structured_text_bidi_override

structured_text_bidi_override_options

Set additional options for BiDi override.

var structured_text_bidi_override_options : Array = []

Property Value

Array

Remarks

  • void set_structured_text_bidi_override_options(Array value)
  • Array get_structured_text_bidi_override_options

tab_stops

Aligns text to the given tab-stops.

var tab_stops : PackedFloat32Array = PackedFloat32Array()

Property Value

PackedFloat32Array

Remarks

text

The text to display on screen.

var text : String = ""

Property Value

String

Remarks

text_direction

Base text writing direction.

var text_direction : int = 0

Property Value

int

Remarks

  • void set_text_direction(int value)
  • int get_text_direction

text_overrun_behavior

Sets the clipping behavior when the text exceeds the node's bounding rectangle. See OverrunBehavior for a description of all modes.

var text_overrun_behavior : int = 0

Property Value

int

Remarks

  • void set_text_overrun_behavior(int value)
  • int get_text_overrun_behavior

uppercase

If true, all the text displays as UPPERCASE.

var uppercase : bool = false

Property Value

bool

Remarks

  • void set_uppercase(bool value)
  • bool is_uppercase

vertical_alignment

Controls the text's vertical alignment. Supports top, center, bottom, and fill. Set it to one of the VerticalAlignment constants.

var vertical_alignment : int = 0

Property Value

int

Remarks

  • void set_vertical_alignment(int value)
  • int get_vertical_alignment

visible_characters

The number of characters to display. If set to -1, all characters are displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates visible_ratio accordingly.

var visible_characters : int = -1

Property Value

int

Remarks

  • void set_visible_characters(int value)
  • int get_visible_characters

visible_characters_behavior

Sets the clipping behavior when visible_characters or visible_ratio is set. See VisibleCharactersBehavior for more info.

var visible_characters_behavior : int = 0

Property Value

int

Remarks

  • void set_visible_characters_behavior(int value)
  • int get_visible_characters_behavior

visible_ratio

The fraction of characters to display, relative to the total number of characters (see get_total_character_count). If set to 1.0, all characters are displayed. If set to 0.5, only half of the characters will be displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates visible_characters accordingly.

var visible_ratio : float = 1.0

Property Value

float

Remarks

  • void set_visible_ratio(float value)
  • float get_visible_ratio

font_color

Theme Property

Default text Color of the Label.

 = ``Color(1, 1, 1, 1)``

Property Value

Color

font_outline_color

Theme Property

The color of text outline.

 = ``Color(0, 0, 0, 1)``

Property Value

Color

font_shadow_color

Theme Property

Color of the text's shadow effect.

 = ``Color(0, 0, 0, 0)``

Property Value

Color

line_spacing

Theme Property

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.

 = ``3``

Property Value

int

outline_size

Theme Property

Text outline size.

Note: If using a font with multichannel_signed_distance_field enabled, its msdf_pixel_range must be set to at least twice the value of outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.

Note: Using a value that is larger than half the font size is not recommended, as the font outline may fail to be fully closed in this case.

 = ``0``

Property Value

int

paragraph_spacing

Theme Property

Vertical space between paragraphs. Added on top of line_spacing.

 = ``0``

Property Value

int

shadow_offset_x

Theme Property

The horizontal offset of the text's shadow.

 = ``1``

Property Value

int

shadow_offset_y

Theme Property

The vertical offset of the text's shadow.

 = ``1``

Property Value

int

shadow_outline_size

Theme Property

The size of the shadow outline.

 = ``1``

Property Value

int

font

Theme Property

Font used for the Label's text.

Font font

Property Value

Font

font_size

Theme Property

Font size of the Label's text.

int font_size

Property Value

int

normal

Theme Property

Background StyleBox for the Label.

StyleBox normal

Property Value

StyleBox

Methods

get_character_bounds(int)

Qualifiers: const

Returns the bounding rectangle of the character at position pos in the label's local coordinate system. If the character is a non-visual character or pos is outside the valid range, an empty Rect2 is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned.

Rect2 get_character_bounds(int pos)

Parameters

pos int

get_line_count

Qualifiers: const

Returns the number of lines of text the Label has.

int get_line_count

get_line_height(int)

Qualifiers: const

Returns the height of the line line.

If line is set to -1, returns the biggest line height.

If there are no lines, returns font size in pixels.

int get_line_height(int line)

Parameters

line int

get_total_character_count

Qualifiers: const

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

int get_total_character_count

get_visible_line_count

Qualifiers: const

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

int get_visible_line_count