Label
Inherits:Control<CanvasItem<Node<Object
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, useRichTextLabel instead.
Tutorials
Properties
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
mouse_filter |
| |
| ||
size_flags_vertical |
| |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Methods
get_line_height(line:int = -1)const | |
Theme Properties
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
Property Descriptions
AutowrapModeautowrap_mode =0
🔗
AutowrapModeget_autowrap_mode()
If set to something other thanTextServer.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, seeAutowrapMode.
boolis_clipping_text()
Iftrue
, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
Stringget_ellipsis_char()
Ellipsis character used for text clipping.
HorizontalAlignmenthorizontal_alignment =0
🔗
HorizontalAlignmentget_horizontal_alignment()
Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of theHorizontalAlignment constants.
BitField[JustificationFlag]justification_flags =163
🔗
voidset_justification_flags(value:BitField[JustificationFlag])
BitField[JustificationFlag]get_justification_flags()
Line fill alignment rules. SeeJustificationFlag for more information.
LabelSettingslabel_settings🔗
LabelSettingsget_label_settings()
ALabelSettings resource that can be shared between multipleLabel nodes. Takes priority over theme properties.
Stringget_language()
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
intget_lines_skipped()
The number of the lines ignored and not displayed from the start of thetext value.
intget_max_lines_visible()
Limits the lines of text the node shows on screen.
Stringparagraph_separator ="\\n"
🔗
Stringget_paragraph_separator()
String used as a paragraph separator. Each paragraph is processed independently, in its own BiDi context.
StructuredTextParserstructured_text_bidi_override =0
🔗
voidset_structured_text_bidi_override(value:StructuredTextParser)
StructuredTextParserget_structured_text_bidi_override()
Set BiDi algorithm override for the structured text.
Arraystructured_text_bidi_override_options =[]
🔗
Arrayget_structured_text_bidi_override_options()
Set additional options for BiDi override.
PackedFloat32Arraytab_stops =PackedFloat32Array()
🔗
PackedFloat32Arrayget_tab_stops()
Aligns text to the given tab-stops.
Note: The returned array iscopied and any changes to it will not update the original property value. SeePackedFloat32Array for more details.
Stringget_text()
The text to display on screen.
TextDirectiontext_direction =0
🔗
TextDirectionget_text_direction()
Base text writing direction.
OverrunBehaviortext_overrun_behavior =0
🔗
OverrunBehaviorget_text_overrun_behavior()
Sets the clipping behavior when the text exceeds the node's bounding rectangle. SeeOverrunBehavior for a description of all modes.
boolis_uppercase()
Iftrue
, all the text displays as UPPERCASE.
VerticalAlignmentvertical_alignment =0
🔗
VerticalAlignmentget_vertical_alignment()
Controls the text's vertical alignment. Supports top, center, bottom, and fill. Set it to one of theVerticalAlignment constants.
intget_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 updatesvisible_ratio accordingly.
VisibleCharactersBehaviorvisible_characters_behavior =0
🔗
voidset_visible_characters_behavior(value:VisibleCharactersBehavior)
VisibleCharactersBehaviorget_visible_characters_behavior()
Sets the clipping behavior whenvisible_characters orvisible_ratio is set. SeeVisibleCharactersBehavior for more info.
floatget_visible_ratio()
The fraction of characters to display, relative to the total number of characters (seeget_total_character_count()). If set to1.0
, all characters are displayed. If set to0.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 updatesvisible_characters accordingly.
Method Descriptions
Rect2get_character_bounds(pos:int)const🔗
Returns the bounding rectangle of the character at positionpos
in the label's local coordinate system. If the character is a non-visual character orpos
is outside the valid range, an emptyRect2 is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned.
Returns the number of lines of text the Label has.
intget_line_height(line:int = -1)const🔗
Returns the height of the lineline
.
Ifline
is set to-1
, returns the biggest line height.
If there are no lines, returns font size in pixels.
intget_total_character_count()const🔗
Returns the total number of printable characters in the text (excluding spaces and newlines).
intget_visible_line_count()const🔗
Returns the number of lines shown. Useful if theLabel's height cannot currently display all lines.
Theme Property Descriptions
Colorfont_color =Color(1,1,1,1)
🔗
Default textColor of theLabel.
Colorfont_outline_color =Color(0,0,0,1)
🔗
The color of text outline.
Colorfont_shadow_color =Color(0,0,0,0)
🔗
Color of the text's shadow effect.
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
Text outline size.
Note: If using a font withFontFile.multichannel_signed_distance_field enabled, itsFontFile.msdf_pixel_range must be set to at leasttwice the value ofoutline_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.
Vertical space between paragraphs. Added on top ofline_spacing.
The horizontal offset of the text's shadow.
The vertical offset of the text's shadow.
The size of the shadow outline.
Font used for theLabel's text.
Font size of theLabel's text.
BackgroundStyleBox for theLabel.