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
Remarks
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
Remarks
ellipsis_char
Ellipsis character used for text clipping.
var ellipsis_char : String = "…"
Property Value
Remarks
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
Remarks
justification_flags
Line fill alignment rules. See JustificationFlag for more information.
var justification_flags : int = 163
Property Value
Remarks
label_settings
A LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.
var label_settings : LabelSettings
Property Value
Remarks
- void set_label_settings(LabelSettings value)
- LabelSettings get_label_settings
language
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
var language : String = ""
Property Value
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
Remarks
max_lines_visible
Limits the lines of text the node shows on screen.
var max_lines_visible : int = -1
Property Value
Remarks
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
Remarks
structured_text_bidi_override
Set BiDi algorithm override for the structured text.
var structured_text_bidi_override : int = 0
Property Value
Remarks
structured_text_bidi_override_options
Set additional options for BiDi override.
var structured_text_bidi_override_options : Array = []
Property Value
Remarks
tab_stops
Aligns text to the given tab-stops.
var tab_stops : PackedFloat32Array = PackedFloat32Array()
Property Value
Remarks
- void set_tab_stops(PackedFloat32Array value)
- PackedFloat32Array get_tab_stops
text
The text to display on screen.
var text : String = ""
Property Value
Remarks
text_direction
Base text writing direction.
var text_direction : int = 0
Property Value
Remarks
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
Remarks
uppercase
If true
, all the text displays as UPPERCASE.
var uppercase : bool = false
Property Value
Remarks
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
Remarks
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
Remarks
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
Remarks
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
Remarks
font_color
Theme Property
Default text Color of the Label.
= ``Color(1, 1, 1, 1)``
Property Value
font_outline_color
Theme Property
The color of text outline.
= ``Color(0, 0, 0, 1)``
Property Value
font_shadow_color
Theme Property
Color of the text's shadow effect.
= ``Color(0, 0, 0, 0)``
Property Value
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
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
paragraph_spacing
Theme Property
Vertical space between paragraphs. Added on top of line_spacing.
= ``0``
Property Value
shadow_offset_x
Theme Property
The horizontal offset of the text's shadow.
= ``1``
Property Value
shadow_offset_y
Theme Property
The vertical offset of the text's shadow.
= ``1``
Property Value
shadow_outline_size
Theme Property
The size of the shadow outline.
= ``1``
Property Value
font
Theme Property
Font used for the Label's text.
Font font
Property Value
font_size
Theme Property
Font size of the Label's text.
int font_size
Property Value
normal
Theme Property
Background StyleBox for the Label.
StyleBox normal
Property Value
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