github_url: | hide |
---|
Inherits: :ref:`Control<class_Control>` < :ref:`CanvasItem<class_CanvasItem>` < :ref:`Node<class_Node>` < :ref:`Object<class_Object>`
A control for displaying plain text.
.. rst-class:: classref-introduction-group
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 :ref:`RichTextLabel<class_RichTextLabel>` instead.
.. rst-class:: classref-introduction-group
.. rst-class:: classref-reftable-group
.. rst-class:: classref-reftable-group
.. rst-class:: classref-reftable-group
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-property
:ref:`AutowrapMode<enum_TextServer_AutowrapMode>` autowrap_mode = 0
:ref:`🔗<class_Label_property_autowrap_mode>`
.. rst-class:: classref-property-setget
- |void| set_autowrap_mode(value: :ref:`AutowrapMode<enum_TextServer_AutowrapMode>`)
- :ref:`AutowrapMode<enum_TextServer_AutowrapMode>` get_autowrap_mode()
If set to something other than :ref:`TextServer.AUTOWRAP_OFF<class_TextServer_constant_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 :ref:`AutowrapMode<enum_TextServer_AutowrapMode>`.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` clip_text = false
:ref:`🔗<class_Label_property_clip_text>`
.. rst-class:: classref-property-setget
- |void| set_clip_text(value: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` is_clipping_text()
If true
, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`String<class_String>` ellipsis_char = "…"
:ref:`🔗<class_Label_property_ellipsis_char>`
.. rst-class:: classref-property-setget
- |void| set_ellipsis_char(value: :ref:`String<class_String>`)
- :ref:`String<class_String>` get_ellipsis_char()
Ellipsis character used for text clipping.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` horizontal_alignment = 0
:ref:`🔗<class_Label_property_horizontal_alignment>`
.. rst-class:: classref-property-setget
- |void| set_horizontal_alignment(value: :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>`)
- :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` get_horizontal_alignment()
Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` constants.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
|bitfield|[:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`] justification_flags = 163
:ref:`🔗<class_Label_property_justification_flags>`
.. rst-class:: classref-property-setget
- |void| set_justification_flags(value: |bitfield|[:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`])
- |bitfield|[:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`] get_justification_flags()
Line fill alignment rules. For more info see :ref:`JustificationFlag<enum_TextServer_JustificationFlag>`.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`LabelSettings<class_LabelSettings>` label_settings :ref:`🔗<class_Label_property_label_settings>`
.. rst-class:: classref-property-setget
- |void| set_label_settings(value: :ref:`LabelSettings<class_LabelSettings>`)
- :ref:`LabelSettings<class_LabelSettings>` get_label_settings()
A :ref:`LabelSettings<class_LabelSettings>` resource that can be shared between multiple Label nodes. Takes priority over theme properties.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`String<class_String>` language = ""
:ref:`🔗<class_Label_property_language>`
.. rst-class:: classref-property-setget
- |void| set_language(value: :ref:`String<class_String>`)
- :ref:`String<class_String>` get_language()
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`int<class_int>` lines_skipped = 0
:ref:`🔗<class_Label_property_lines_skipped>`
.. rst-class:: classref-property-setget
- |void| set_lines_skipped(value: :ref:`int<class_int>`)
- :ref:`int<class_int>` get_lines_skipped()
The number of the lines ignored and not displayed from the start of the :ref:`text<class_Label_property_text>` value.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`int<class_int>` max_lines_visible = -1
:ref:`🔗<class_Label_property_max_lines_visible>`
.. rst-class:: classref-property-setget
- |void| set_max_lines_visible(value: :ref:`int<class_int>`)
- :ref:`int<class_int>` get_max_lines_visible()
Limits the lines of text the node shows on screen.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` structured_text_bidi_override = 0
:ref:`🔗<class_Label_property_structured_text_bidi_override>`
.. rst-class:: classref-property-setget
- |void| set_structured_text_bidi_override(value: :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>`)
- :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` get_structured_text_bidi_override()
Set BiDi algorithm override for the structured text.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`Array<class_Array>` structured_text_bidi_override_options = []
:ref:`🔗<class_Label_property_structured_text_bidi_override_options>`
.. rst-class:: classref-property-setget
- |void| set_structured_text_bidi_override_options(value: :ref:`Array<class_Array>`)
- :ref:`Array<class_Array>` get_structured_text_bidi_override_options()
Set additional options for BiDi override.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`PackedFloat32Array<class_PackedFloat32Array>` tab_stops = PackedFloat32Array()
:ref:`🔗<class_Label_property_tab_stops>`
.. rst-class:: classref-property-setget
- |void| set_tab_stops(value: :ref:`PackedFloat32Array<class_PackedFloat32Array>`)
- :ref:`PackedFloat32Array<class_PackedFloat32Array>` get_tab_stops()
Aligns text to the given tab-stops.
Note: The returned array is copied and any changes to it will not update the original property value. See :ref:`PackedFloat32Array<class_PackedFloat32Array>` for more details.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`String<class_String>` text = ""
:ref:`🔗<class_Label_property_text>`
.. rst-class:: classref-property-setget
- |void| set_text(value: :ref:`String<class_String>`)
- :ref:`String<class_String>` get_text()
The text to display on screen.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`TextDirection<enum_Control_TextDirection>` text_direction = 0
:ref:`🔗<class_Label_property_text_direction>`
.. rst-class:: classref-property-setget
- |void| set_text_direction(value: :ref:`TextDirection<enum_Control_TextDirection>`)
- :ref:`TextDirection<enum_Control_TextDirection>` get_text_direction()
Base text writing direction.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` text_overrun_behavior = 0
:ref:`🔗<class_Label_property_text_overrun_behavior>`
.. rst-class:: classref-property-setget
- |void| set_text_overrun_behavior(value: :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>`)
- :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` get_text_overrun_behavior()
Sets the clipping behavior when the text exceeds the node's bounding rectangle. See :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` for a description of all modes.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` uppercase = false
:ref:`🔗<class_Label_property_uppercase>`
.. rst-class:: classref-property-setget
- |void| set_uppercase(value: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` is_uppercase()
If true
, all the text displays as UPPERCASE.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`VerticalAlignment<enum_@GlobalScope_VerticalAlignment>` vertical_alignment = 0
:ref:`🔗<class_Label_property_vertical_alignment>`
.. rst-class:: classref-property-setget
- |void| set_vertical_alignment(value: :ref:`VerticalAlignment<enum_@GlobalScope_VerticalAlignment>`)
- :ref:`VerticalAlignment<enum_@GlobalScope_VerticalAlignment>` get_vertical_alignment()
Controls the text's vertical alignment. Supports top, center, bottom, and fill. Set it to one of the :ref:`VerticalAlignment<enum_@GlobalScope_VerticalAlignment>` constants.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`int<class_int>` visible_characters = -1
:ref:`🔗<class_Label_property_visible_characters>`
.. rst-class:: classref-property-setget
- |void| set_visible_characters(value: :ref:`int<class_int>`)
- :ref:`int<class_int>` get_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 :ref:`visible_ratio<class_Label_property_visible_ratio>` accordingly.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`VisibleCharactersBehavior<enum_TextServer_VisibleCharactersBehavior>` visible_characters_behavior = 0
:ref:`🔗<class_Label_property_visible_characters_behavior>`
.. rst-class:: classref-property-setget
- |void| set_visible_characters_behavior(value: :ref:`VisibleCharactersBehavior<enum_TextServer_VisibleCharactersBehavior>`)
- :ref:`VisibleCharactersBehavior<enum_TextServer_VisibleCharactersBehavior>` get_visible_characters_behavior()
Sets the clipping behavior when :ref:`visible_characters<class_Label_property_visible_characters>` or :ref:`visible_ratio<class_Label_property_visible_ratio>` is set. See :ref:`VisibleCharactersBehavior<enum_TextServer_VisibleCharactersBehavior>` for more info.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`float<class_float>` visible_ratio = 1.0
:ref:`🔗<class_Label_property_visible_ratio>`
.. rst-class:: classref-property-setget
- |void| set_visible_ratio(value: :ref:`float<class_float>`)
- :ref:`float<class_float>` get_visible_ratio()
The fraction of characters to display, relative to the total number of characters (see :ref:`get_total_character_count<class_Label_method_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 :ref:`visible_characters<class_Label_property_visible_characters>` accordingly.
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-method
:ref:`Rect2<class_Rect2>` get_character_bounds(pos: :ref:`int<class_int>`) |const| :ref:`🔗<class_Label_method_get_character_bounds>`
Returns the bounding rectangle of the character at position pos
. If the character is a non-visual character or pos
is outside the valid range, an empty :ref:`Rect2<class_Rect2>` is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned.
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`int<class_int>` get_line_count() |const| :ref:`🔗<class_Label_method_get_line_count>`
Returns the number of lines of text the Label has.
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`int<class_int>` get_line_height(line: :ref:`int<class_int>` = -1) |const| :ref:`🔗<class_Label_method_get_line_height>`
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.
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`int<class_int>` get_total_character_count() |const| :ref:`🔗<class_Label_method_get_total_character_count>`
Returns the total number of printable characters in the text (excluding spaces and newlines).
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`int<class_int>` get_visible_line_count() |const| :ref:`🔗<class_Label_method_get_visible_line_count>`
Returns the number of lines shown. Useful if the Label's height cannot currently display all lines.
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` font_color = Color(1, 1, 1, 1)
:ref:`🔗<class_Label_theme_color_font_color>`
Default text :ref:`Color<class_Color>` of the Label.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` font_outline_color = Color(0, 0, 0, 1)
:ref:`🔗<class_Label_theme_color_font_outline_color>`
The color of text outline.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`Color<class_Color>` font_shadow_color = Color(0, 0, 0, 0)
:ref:`🔗<class_Label_theme_color_font_shadow_color>`
:ref:`Color<class_Color>` of the text's shadow effect.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` line_spacing = 3
:ref:`🔗<class_Label_theme_constant_line_spacing>`
Vertical space between lines in multiline Label.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` outline_size = 0
:ref:`🔗<class_Label_theme_constant_outline_size>`
Text outline size.
Note: If using a font with :ref:`FontFile.multichannel_signed_distance_field<class_FontFile_property_multichannel_signed_distance_field>` enabled, its :ref:`FontFile.msdf_pixel_range<class_FontFile_property_msdf_pixel_range>` must be set to at least twice the value of :ref:`outline_size<class_Label_theme_constant_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.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` shadow_offset_x = 1
:ref:`🔗<class_Label_theme_constant_shadow_offset_x>`
The horizontal offset of the text's shadow.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` shadow_offset_y = 1
:ref:`🔗<class_Label_theme_constant_shadow_offset_y>`
The vertical offset of the text's shadow.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` shadow_outline_size = 1
:ref:`🔗<class_Label_theme_constant_shadow_outline_size>`
The size of the shadow outline.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`Font<class_Font>` font :ref:`🔗<class_Label_theme_font_font>`
:ref:`Font<class_Font>` used for the Label's text.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`int<class_int>` font_size :ref:`🔗<class_Label_theme_font_size_font_size>`
Font size of the Label's text.
.. rst-class:: classref-item-separator
.. rst-class:: classref-themeproperty
:ref:`StyleBox<class_StyleBox>` normal :ref:`🔗<class_Label_theme_style_normal>`
Background :ref:`StyleBox<class_StyleBox>` for the Label.