:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Label.xml. .. _class_Label: Label ===== **Inherits:** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` Displays plain text in a line or wrapped inside a rectangle. For formatted text, use :ref:`RichTextLabel`. .. rst-class:: classref-introduction-group Description ----------- Label displays plain text on the screen. 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 formatting. For that, use :ref:`RichTextLabel` instead. \ **Note:** Contrarily to most other :ref:`Control`\ s, Label's :ref:`Control.mouse_filter` defaults to :ref:`Control.MOUSE_FILTER_IGNORE` (i.e. it doesn't react to mouse input events). This implies that a label won't display any configured :ref:`Control.hint_tooltip`, unless you change its mouse filter. \ **Note:** Unicode characters after ``0xffff`` (such as most emoji) are *not* supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0. .. rst-class:: classref-introduction-group Tutorials --------- - `2D Dodge The Creeps Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`Align` | :ref:`align` | ``0`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`autowrap` | ``false`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`clip_text` | ``false`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`int` | :ref:`lines_skipped` | ``0`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`int` | :ref:`max_lines_visible` | ``-1`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`MouseFilter` | mouse_filter | ``2`` (overrides :ref:`Control`) | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`float` | :ref:`percent_visible` | ``1.0`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`int` | size_flags_vertical | ``4`` (overrides :ref:`Control`) | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`String` | :ref:`text` | ``""`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`uppercase` | ``false`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`VAlign` | :ref:`valign` | ``0`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ | :ref:`int` | :ref:`visible_characters` | ``-1`` | +----------------------------------------------+--------------------------------------------------------------------+------------------------------------------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-----------------------+----------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_line_count` **(** **)** |const| | +-----------------------+----------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_line_height` **(** **)** |const| | +-----------------------+----------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_total_character_count` **(** **)** |const| | +-----------------------+----------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_visible_line_count` **(** **)** |const| | +-----------------------+----------------------------------------------------------------------------------------------------+ .. rst-class:: classref-reftable-group Theme Properties ---------------- .. table:: :widths: auto +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`Color` | :ref:`font_color` | ``Color( 1, 1, 1, 1 )`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`Color` | :ref:`font_color_shadow` | ``Color( 0, 0, 0, 0 )`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`Color` | :ref:`font_outline_modulate` | ``Color( 1, 1, 1, 1 )`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`line_spacing` | ``3`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`shadow_as_outline` | ``0`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`shadow_offset_x` | ``1`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`int` | :ref:`shadow_offset_y` | ``1`` | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`Font` | :ref:`font` | | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ | :ref:`StyleBox` | :ref:`normal` | | +---------------------------------+-----------------------------------------------------------------------------+-------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Label_Align: .. rst-class:: classref-enumeration enum **Align**: .. _class_Label_constant_ALIGN_LEFT: .. rst-class:: classref-enumeration-constant :ref:`Align` **ALIGN_LEFT** = ``0`` Align rows to the left (default). .. _class_Label_constant_ALIGN_CENTER: .. rst-class:: classref-enumeration-constant :ref:`Align` **ALIGN_CENTER** = ``1`` Align rows centered. .. _class_Label_constant_ALIGN_RIGHT: .. rst-class:: classref-enumeration-constant :ref:`Align` **ALIGN_RIGHT** = ``2`` Align rows to the right. .. _class_Label_constant_ALIGN_FILL: .. rst-class:: classref-enumeration-constant :ref:`Align` **ALIGN_FILL** = ``3`` Expand row whitespaces to fit the width. .. rst-class:: classref-item-separator ---- .. _enum_Label_VAlign: .. rst-class:: classref-enumeration enum **VAlign**: .. _class_Label_constant_VALIGN_TOP: .. rst-class:: classref-enumeration-constant :ref:`VAlign` **VALIGN_TOP** = ``0`` Align the whole text to the top. .. _class_Label_constant_VALIGN_CENTER: .. rst-class:: classref-enumeration-constant :ref:`VAlign` **VALIGN_CENTER** = ``1`` Align the whole text to the center. .. _class_Label_constant_VALIGN_BOTTOM: .. rst-class:: classref-enumeration-constant :ref:`VAlign` **VALIGN_BOTTOM** = ``2`` Align the whole text to the bottom. .. _class_Label_constant_VALIGN_FILL: .. rst-class:: classref-enumeration-constant :ref:`VAlign` **VALIGN_FILL** = ``3`` Align the whole text by spreading the rows. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Label_property_align: .. rst-class:: classref-property :ref:`Align` **align** = ``0`` .. rst-class:: classref-property-setget - void **set_align** **(** :ref:`Align` value **)** - :ref:`Align` **get_align** **(** **)** Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the :ref:`Align` constants. .. rst-class:: classref-item-separator ---- .. _class_Label_property_autowrap: .. rst-class:: classref-property :ref:`bool` **autowrap** = ``false`` .. rst-class:: classref-property-setget - void **set_autowrap** **(** :ref:`bool` value **)** - :ref:`bool` **has_autowrap** **(** **)** If ``true``, wraps the text inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. .. rst-class:: classref-item-separator ---- .. _class_Label_property_clip_text: .. rst-class:: classref-property :ref:`bool` **clip_text** = ``false`` .. rst-class:: classref-property-setget - void **set_clip_text** **(** :ref:`bool` value **)** - :ref:`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 ---- .. _class_Label_property_lines_skipped: .. rst-class:: classref-property :ref:`int` **lines_skipped** = ``0`` .. rst-class:: classref-property-setget - void **set_lines_skipped** **(** :ref:`int` value **)** - :ref:`int` **get_lines_skipped** **(** **)** The node ignores the first ``lines_skipped`` lines before it starts to display text. .. rst-class:: classref-item-separator ---- .. _class_Label_property_max_lines_visible: .. rst-class:: classref-property :ref:`int` **max_lines_visible** = ``-1`` .. rst-class:: classref-property-setget - void **set_max_lines_visible** **(** :ref:`int` value **)** - :ref:`int` **get_max_lines_visible** **(** **)** Limits the lines of text the node shows on screen. .. rst-class:: classref-item-separator ---- .. _class_Label_property_percent_visible: .. rst-class:: classref-property :ref:`float` **percent_visible** = ``1.0`` .. rst-class:: classref-property-setget - void **set_percent_visible** **(** :ref:`float` value **)** - :ref:`float` **get_percent_visible** **(** **)** Limits the amount of visible characters. If you set ``percent_visible`` to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box. .. rst-class:: classref-item-separator ---- .. _class_Label_property_text: .. rst-class:: classref-property :ref:`String` **text** = ``""`` .. rst-class:: classref-property-setget - void **set_text** **(** :ref:`String` value **)** - :ref:`String` **get_text** **(** **)** The text to display on screen. .. rst-class:: classref-item-separator ---- .. _class_Label_property_uppercase: .. rst-class:: classref-property :ref:`bool` **uppercase** = ``false`` .. rst-class:: classref-property-setget - void **set_uppercase** **(** :ref:`bool` value **)** - :ref:`bool` **is_uppercase** **(** **)** If ``true``, all the text displays as UPPERCASE. .. rst-class:: classref-item-separator ---- .. _class_Label_property_valign: .. rst-class:: classref-property :ref:`VAlign` **valign** = ``0`` .. rst-class:: classref-property-setget - void **set_valign** **(** :ref:`VAlign` value **)** - :ref:`VAlign` **get_valign** **(** **)** Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the :ref:`VAlign` constants. .. rst-class:: classref-item-separator ---- .. _class_Label_property_visible_characters: .. rst-class:: classref-property :ref:`int` **visible_characters** = ``-1`` .. rst-class:: classref-property-setget - void **set_visible_characters** **(** :ref:`int` value **)** - :ref:`int` **get_visible_characters** **(** **)** Restricts the number of characters to display. Set to -1 to disable. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Label_method_get_line_count: .. rst-class:: classref-method :ref:`int` **get_line_count** **(** **)** |const| Returns the amount of lines of text the Label has. .. rst-class:: classref-item-separator ---- .. _class_Label_method_get_line_height: .. rst-class:: classref-method :ref:`int` **get_line_height** **(** **)** |const| Returns the font size in pixels. .. rst-class:: classref-item-separator ---- .. _class_Label_method_get_total_character_count: .. rst-class:: classref-method :ref:`int` **get_total_character_count** **(** **)** |const| Returns the total number of printable characters in the text (excluding spaces and newlines). .. rst-class:: classref-item-separator ---- .. _class_Label_method_get_visible_line_count: .. rst-class:: classref-method :ref:`int` **get_visible_line_count** **(** **)** |const| 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 Theme Property Descriptions --------------------------- .. _class_Label_theme_color_font_color: .. rst-class:: classref-themeproperty :ref:`Color` **font_color** = ``Color( 1, 1, 1, 1 )`` Default text :ref:`Color` of the **Label**. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_color_font_color_shadow: .. rst-class:: classref-themeproperty :ref:`Color` **font_color_shadow** = ``Color( 0, 0, 0, 0 )`` :ref:`Color` of the text's shadow effect. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_color_font_outline_modulate: .. rst-class:: classref-themeproperty :ref:`Color` **font_outline_modulate** = ``Color( 1, 1, 1, 1 )`` The tint of :ref:`Font`'s outline. See :ref:`DynamicFont.outline_color`. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_constant_line_spacing: .. rst-class:: classref-themeproperty :ref:`int` **line_spacing** = ``3`` Vertical space between lines in multiline **Label**. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_constant_shadow_as_outline: .. rst-class:: classref-themeproperty :ref:`int` **shadow_as_outline** = ``0`` Boolean value. If set to 1 (``true``), the shadow will be displayed around the whole text as an outline. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_constant_shadow_offset_x: .. rst-class:: classref-themeproperty :ref:`int` **shadow_offset_x** = ``1`` The horizontal offset of the text's shadow. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_constant_shadow_offset_y: .. rst-class:: classref-themeproperty :ref:`int` **shadow_offset_y** = ``1`` The vertical offset of the text's shadow. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_font_font: .. rst-class:: classref-themeproperty :ref:`Font` **font** :ref:`Font` used for the **Label**'s text. .. rst-class:: classref-item-separator ---- .. _class_Label_theme_style_normal: .. rst-class:: classref-themeproperty :ref:`StyleBox` **normal** Background :ref:`StyleBox` for the **Label**. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`