Class reference
Label
Inherits Control
A control for displaying plain text.
Description
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.
Properties
int autowrap_mode = 0
int autowrap_mode = 0If 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.
int autowrap_trim_flags = 192
int autowrap_trim_flags = 192Autowrap space trimming flags. See TextServer.BREAK_TRIM_START_EDGE_SPACES and TextServer.BREAK_TRIM_END_EDGE_SPACES for more info.
bool clip_text = false
bool clip_text = falseIf true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
String ellipsis_char = "…"
String ellipsis_char = "…"Ellipsis character used for text clipping.
int horizontal_alignment = 0
int horizontal_alignment = 0Controls the text's horizontal alignment. Supports left, center, right, and fill (also known as justify).
int justification_flags = 163
int justification_flags = 163Line fill alignment rules.
LabelSettings label_settings
LabelSettings label_settingsA LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.
String language = ""
String language = ""Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
int lines_skipped = 0
int lines_skipped = 0The number of the lines ignored and not displayed from the start of the text value.
int max_lines_visible = -1
int max_lines_visible = -1Limits the lines of text the node shows on screen.
int mouse_filter = 2
int mouse_filter = 2String paragraph_separator = "\\n"
String paragraph_separator = "\\n"String used as a paragraph separator. Each paragraph is processed independently, in its own BiDi context.
int size_flags_vertical = 4
int size_flags_vertical = 4int structured_text_bidi_override = 0
int structured_text_bidi_override = 0Set BiDi algorithm override for the structured text.
Array structured_text_bidi_override_options = []
Array structured_text_bidi_override_options = []Set additional options for BiDi override.
PackedFloat32Array tab_stops = PackedFloat32Array()
PackedFloat32Array tab_stops = PackedFloat32Array()Aligns text to the given tab-stops.
String text = ""
String text = ""The text to display on screen.
int text_direction = 0
int text_direction = 0Base text writing direction.
int text_overrun_behavior = 0
int text_overrun_behavior = 0The clipping behavior when the text exceeds the node's bounding rectangle.
bool uppercase = false
bool uppercase = falseIf true, all the text displays as UPPERCASE.
int vertical_alignment = 0
int vertical_alignment = 0Controls the text's vertical alignment. Supports top, center, bottom, and fill.
int visible_characters = -1
int visible_characters = -1The 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. Note: Characters are counted as Unicode codepoints. A single visible grapheme may contain multiple codepoints (e.g. certain emoji use three codepoints). A single codepoint may contain two UTF-16 characters, which are used in C# strings.
int visible_characters_behavior = 0
int visible_characters_behavior = 0The clipping behavior when visible_characters or visible_ratio is set.
float visible_ratio = 1.0
float visible_ratio = 1.0The 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.
Methods
Rect2 get_character_bounds(int pos) const
Rect2 get_character_bounds(int pos) constReturns 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.
int get_line_count() const
int get_line_count() constReturns the number of lines of text the Label has.
int get_line_height(int line = -1) const
int get_line_height(int line = -1) constReturns 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_total_character_count() const
int get_total_character_count() constReturns the total number of printable characters in the text (excluding spaces and newlines).
int get_visible_line_count() const
int get_visible_line_count() constReturns the number of lines shown. Useful if the Label's height cannot currently display all lines.
Theme properties
Color font_color = Color(1, 1, 1, 1)
Color font_color = Color(1, 1, 1, 1)Color font_outline_color = Color(0, 0, 0, 1)
Color font_outline_color = Color(0, 0, 0, 1)The color of text outline.
Color font_shadow_color = Color(0, 0, 0, 0)
Color font_shadow_color = Color(0, 0, 0, 0)Color of the text's shadow effect.
int line_spacing = 3
int line_spacing = 3Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
int outline_size = 0
int outline_size = 0Text outline size. Note: If using a font with FontFile.multichannel_signed_distance_field enabled, its FontFile.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.
int paragraph_spacing = 0
int paragraph_spacing = 0Vertical space between paragraphs. Added on top of line_spacing.
int shadow_offset_x = 1
int shadow_offset_x = 1The horizontal offset of the text's shadow.
int shadow_offset_y = 1
int shadow_offset_y = 1The vertical offset of the text's shadow.
int shadow_outline_size = 1
int shadow_outline_size = 1The size of the shadow outline.
Font font
Font fontint font_size
int font_sizeFont size of the Label's text.
StyleBox focus
StyleBox focusStyleBox used when the Label is focused (when used with assistive apps).
StyleBox normal
StyleBox normal