:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the TextLine.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_TextLine: TextLine ======== **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Holds a line of text. Description ----------- Abstraction over :ref:`TextServer` for handling single line of text. Properties ---------- +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`HorizontalAlignment` | :ref:`alignment` | ``0`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`Direction` | :ref:`direction` | ``0`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`int` | :ref:`flags` | ``3`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`Orientation` | :ref:`orientation` | ``0`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`preserve_control` | ``false`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`preserve_invalid` | ``true`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`OverrunBehavior` | :ref:`text_overrun_behavior` | ``3`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ | :ref:`float` | :ref:`width` | ``-1.0`` | +-------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+ Methods ------- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`add_object` **(** :ref:`Variant` key, :ref:`Vector2` size, :ref:`InlineAlignment` inline_align=5, :ref:`int` length=1 **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`add_string` **(** :ref:`String` text, :ref:`Font` fonts, :ref:`int` size, :ref:`Dictionary` opentype_features={}, :ref:`String` language="", :ref:`Variant` meta=null **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw` **(** :ref:`RID` canvas, :ref:`Vector2` pos, :ref:`Color` color=Color(1, 1, 1, 1) **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw_outline` **(** :ref:`RID` canvas, :ref:`Vector2` pos, :ref:`int` outline_size=1, :ref:`Color` color=Color(1, 1, 1, 1) **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_line_ascent` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_line_descent` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_line_underline_position` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_line_underline_thickness` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_line_width` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Rect2` | :ref:`get_object_rect` **(** :ref:`Variant` key **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_objects` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`get_rid` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_size` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`hit_test` **(** :ref:`float` coords **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`resize_object` **(** :ref:`Variant` key, :ref:`Vector2` size, :ref:`InlineAlignment` inline_align=5 **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_bidi_override` **(** :ref:`Array` override **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`tab_align` **(** :ref:`PackedFloat32Array` tab_stops **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Enumerations ------------ .. _enum_TextLine_OverrunBehavior: .. _class_TextLine_constant_OVERRUN_NO_TRIMMING: .. _class_TextLine_constant_OVERRUN_TRIM_CHAR: .. _class_TextLine_constant_OVERRUN_TRIM_WORD: .. _class_TextLine_constant_OVERRUN_TRIM_ELLIPSIS: .. _class_TextLine_constant_OVERRUN_TRIM_WORD_ELLIPSIS: enum **OverrunBehavior**: - **OVERRUN_NO_TRIMMING** = **0** --- No text trimming is performed. - **OVERRUN_TRIM_CHAR** = **1** --- Trims the text per character. - **OVERRUN_TRIM_WORD** = **2** --- Trims the text per word. - **OVERRUN_TRIM_ELLIPSIS** = **3** --- Trims the text per character and adds an ellipsis to indicate that parts are hidden. - **OVERRUN_TRIM_WORD_ELLIPSIS** = **4** --- Trims the text per word and adds an ellipsis to indicate that parts are hidden. Property Descriptions --------------------- .. _class_TextLine_property_alignment: - :ref:`HorizontalAlignment` **alignment** +-----------+---------------------------------+ | *Default* | ``0`` | +-----------+---------------------------------+ | *Setter* | set_horizontal_alignment(value) | +-----------+---------------------------------+ | *Getter* | get_horizontal_alignment() | +-----------+---------------------------------+ ---- .. _class_TextLine_property_direction: - :ref:`Direction` **direction** +-----------+----------------------+ | *Default* | ``0`` | +-----------+----------------------+ | *Setter* | set_direction(value) | +-----------+----------------------+ | *Getter* | get_direction() | +-----------+----------------------+ Text writing direction. ---- .. _class_TextLine_property_flags: - :ref:`int` **flags** +-----------+------------------+ | *Default* | ``3`` | +-----------+------------------+ | *Setter* | set_flags(value) | +-----------+------------------+ | *Getter* | get_flags() | +-----------+------------------+ Line Alignment rules. For more info see :ref:`TextServer`. ---- .. _class_TextLine_property_orientation: - :ref:`Orientation` **orientation** +-----------+------------------------+ | *Default* | ``0`` | +-----------+------------------------+ | *Setter* | set_orientation(value) | +-----------+------------------------+ | *Getter* | get_orientation() | +-----------+------------------------+ Text orientation. ---- .. _class_TextLine_property_preserve_control: - :ref:`bool` **preserve_control** +-----------+-----------------------------+ | *Default* | ``false`` | +-----------+-----------------------------+ | *Setter* | set_preserve_control(value) | +-----------+-----------------------------+ | *Getter* | get_preserve_control() | +-----------+-----------------------------+ If set to ``true`` text will display control characters. ---- .. _class_TextLine_property_preserve_invalid: - :ref:`bool` **preserve_invalid** +-----------+-----------------------------+ | *Default* | ``true`` | +-----------+-----------------------------+ | *Setter* | set_preserve_invalid(value) | +-----------+-----------------------------+ | *Getter* | get_preserve_invalid() | +-----------+-----------------------------+ If set to ``true`` text will display invalid characters. ---- .. _class_TextLine_property_text_overrun_behavior: - :ref:`OverrunBehavior` **text_overrun_behavior** +-----------+----------------------------------+ | *Default* | ``3`` | +-----------+----------------------------------+ | *Setter* | set_text_overrun_behavior(value) | +-----------+----------------------------------+ | *Getter* | get_text_overrun_behavior() | +-----------+----------------------------------+ Sets the clipping behavior when the text exceeds the text line's set width. See :ref:`OverrunBehavior` for a description of all modes. ---- .. _class_TextLine_property_width: - :ref:`float` **width** +-----------+------------------+ | *Default* | ``-1.0`` | +-----------+------------------+ | *Setter* | set_width(value) | +-----------+------------------+ | *Getter* | get_width() | +-----------+------------------+ Text line width. Method Descriptions ------------------- .. _class_TextLine_method_add_object: - :ref:`bool` **add_object** **(** :ref:`Variant` key, :ref:`Vector2` size, :ref:`InlineAlignment` inline_align=5, :ref:`int` length=1 **)** Adds inline object to the text buffer, ``key`` must be unique. In the text, object is represented as ``length`` object replacement characters. ---- .. _class_TextLine_method_add_string: - :ref:`bool` **add_string** **(** :ref:`String` text, :ref:`Font` fonts, :ref:`int` size, :ref:`Dictionary` opentype_features={}, :ref:`String` language="", :ref:`Variant` meta=null **)** Adds text span and font to draw it. ---- .. _class_TextLine_method_clear: - void **clear** **(** **)** Clears text line (removes text and inline objects). ---- .. _class_TextLine_method_draw: - void **draw** **(** :ref:`RID` canvas, :ref:`Vector2` pos, :ref:`Color` color=Color(1, 1, 1, 1) **)** |const| Draw text into a canvas item at a given position, with ``color``. ``pos`` specifies the top left corner of the bounding box. ---- .. _class_TextLine_method_draw_outline: - void **draw_outline** **(** :ref:`RID` canvas, :ref:`Vector2` pos, :ref:`int` outline_size=1, :ref:`Color` color=Color(1, 1, 1, 1) **)** |const| Draw text into a canvas item at a given position, with ``color``. ``pos`` specifies the top left corner of the bounding box. ---- .. _class_TextLine_method_get_line_ascent: - :ref:`float` **get_line_ascent** **(** **)** |const| Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical). ---- .. _class_TextLine_method_get_line_descent: - :ref:`float` **get_line_descent** **(** **)** |const| Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical). ---- .. _class_TextLine_method_get_line_underline_position: - :ref:`float` **get_line_underline_position** **(** **)** |const| Returns pixel offset of the underline below the baseline. ---- .. _class_TextLine_method_get_line_underline_thickness: - :ref:`float` **get_line_underline_thickness** **(** **)** |const| Returns thickness of the underline. ---- .. _class_TextLine_method_get_line_width: - :ref:`float` **get_line_width** **(** **)** |const| Returns width (for horizontal layout) or height (for vertical) of the text. ---- .. _class_TextLine_method_get_object_rect: - :ref:`Rect2` **get_object_rect** **(** :ref:`Variant` key **)** |const| Returns bounding rectangle of the inline object. ---- .. _class_TextLine_method_get_objects: - :ref:`Array` **get_objects** **(** **)** |const| Returns array of inline objects. ---- .. _class_TextLine_method_get_rid: - :ref:`RID` **get_rid** **(** **)** |const| Returns TextServer buffer RID. ---- .. _class_TextLine_method_get_size: - :ref:`Vector2` **get_size** **(** **)** |const| Returns size of the bounding box of the text. ---- .. _class_TextLine_method_hit_test: - :ref:`int` **hit_test** **(** :ref:`float` coords **)** |const| Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position. ---- .. _class_TextLine_method_resize_object: - :ref:`bool` **resize_object** **(** :ref:`Variant` key, :ref:`Vector2` size, :ref:`InlineAlignment` inline_align=5 **)** Sets new size and alignment of embedded object. ---- .. _class_TextLine_method_set_bidi_override: - void **set_bidi_override** **(** :ref:`Array` override **)** Overrides BiDi for the structured text. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately. ---- .. _class_TextLine_method_tab_align: - void **tab_align** **(** :ref:`PackedFloat32Array` tab_stops **)** Aligns text to the given tab-stops. .. |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.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`