:github_url: hide

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the TLShapedString.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.

.. _class_TLShapedString:

TLShapedString
==============

**Inherits:** 

**Inherited By:** :ref:`TLShapedAttributedString<class_TLShapedAttributedString>`

**Category:** Core

Brief Description
-----------------

Holds shaped line of plain text.

Properties
----------

+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| int                                     | :ref:`base_direction<class_TLShapedString_property_base_direction>`     | 3         |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| :ref:`TLFontFamily<class_TLFontFamily>` | :ref:`base_font<class_TLShapedString_property_base_font>`               |           |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| int                                     | :ref:`base_font_size<class_TLShapedString_property_base_font_size>`     | 12        |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| String                                  | :ref:`base_font_style<class_TLShapedString_property_base_font_style>`   | "Regular" |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| String                                  | :ref:`features<class_TLShapedString_property_features>`                 | ""        |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| String                                  | :ref:`language<class_TLShapedString_property_language>`                 | "en"      |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`preserve_control<class_TLShapedString_property_preserve_control>` | false     |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+
| String                                  | :ref:`text<class_TLShapedString_property_text>`                         | ""        |
+-----------------------------------------+-------------------------------------------------------------------------+-----------+

Methods
-------

.. table::
   :class: longtable
   :widths: 7 20

   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`add_sstring<class_TLShapedString_method_add_sstring>` **(** :ref:`TLShapedString<class_TLShapedString>` text **)**                                                        |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`add_text<class_TLShapedString_method_add_text>` **(** String text **)**                                                                                                   |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`add_utf16<class_TLShapedString_method_add_utf16>` **(** PoolByteArray text **)**                                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`add_utf32<class_TLShapedString_method_add_utf32>` **(** PoolByteArray text **)**                                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`add_utf8<class_TLShapedString_method_add_utf8>` **(** PoolByteArray text **)**                                                                                            |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Array                                                   | :ref:`break_jst<class_TLShapedString_method_break_jst>` **(** **)** const                                                                                                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Array                                                   | :ref:`break_lines<class_TLShapedString_method_break_lines>` **(** float width, int flags **)** const                                                                            |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Array                                                   | :ref:`break_words<class_TLShapedString_method_break_words>` **(** **)** const                                                                                                   |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`char_count<class_TLShapedString_method_char_count>` **(** **)** const                                                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`clusters<class_TLShapedString_method_clusters>` **(** **)** const                                                                                                         |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`copy_properties<class_TLShapedString_method_copy_properties>` **(** :ref:`TLShapedString<class_TLShapedString>` source **)**                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`draw<class_TLShapedString_method_draw>` **(** RID canvas_item, Vector2 position, Color modulate **)**                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`draw_as_hex<class_TLShapedString_method_draw_as_hex>` **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)**                 |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Vector2                                                 | :ref:`draw_cluster<class_TLShapedString_method_draw_cluster>` **(** RID canvas_item, Vector2 position, int index, Color modulate **)**                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`draw_dbg<class_TLShapedString_method_draw_dbg>` **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)**                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`draw_logical_as_hex<class_TLShapedString_method_draw_logical_as_hex>` **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)** |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | bool                                                    | :ref:`empty<class_TLShapedString_method_empty>` **(** **)** const                                                                                                               |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`extend_to_width<class_TLShapedString_method_extend_to_width>` **(** float width, int flags **)**                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_ascent<class_TLShapedString_method_get_ascent>` **(** **)** const                                                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`TextDirection<enum_TLShapedString_TextDirection>` | :ref:`get_char_direction<class_TLShapedString_method_get_char_direction>` **(** int position **)** const                                                                        |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_ascent<class_TLShapedString_method_get_cluster_ascent>` **(** int index **)** const                                                                           |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | String                                                  | :ref:`get_cluster_debug_info<class_TLShapedString_method_get_cluster_debug_info>` **(** int index **)** const                                                                   |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_descent<class_TLShapedString_method_get_cluster_descent>` **(** int index **)** const                                                                         |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_cluster_end<class_TLShapedString_method_get_cluster_end>` **(** int index **)** const                                                                                 |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`TLFontFace<class_TLFontFace>`                     | :ref:`get_cluster_face<class_TLShapedString_method_get_cluster_face>` **(** int position **)** const                                                                            |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_face_size<class_TLShapedString_method_get_cluster_face_size>` **(** int position **)** const                                                                  |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_cluster_glyph<class_TLShapedString_method_get_cluster_glyph>` **(** int index, int glyph **)** const                                                                  |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Vector2                                                 | :ref:`get_cluster_glyph_advance<class_TLShapedString_method_get_cluster_glyph_advance>` **(** int index, int glyph **)** const                                                  |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Vector2                                                 | :ref:`get_cluster_glyph_offset<class_TLShapedString_method_get_cluster_glyph_offset>` **(** int index, int glyph **)** const                                                    |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_cluster_glyphs<class_TLShapedString_method_get_cluster_glyphs>` **(** int index **)** const                                                                           |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_height<class_TLShapedString_method_get_cluster_height>` **(** int index **)** const                                                                           |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_cluster_index<class_TLShapedString_method_get_cluster_index>` **(** int position **)** const                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_leading_edge<class_TLShapedString_method_get_cluster_leading_edge>` **(** int index **)** const                                                               |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Rect2                                                   | :ref:`get_cluster_rect<class_TLShapedString_method_get_cluster_rect>` **(** int index **)** const                                                                               |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_cluster_start<class_TLShapedString_method_get_cluster_start>` **(** int index **)** const                                                                             |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_trailing_edge<class_TLShapedString_method_get_cluster_trailing_edge>` **(** int index **)** const                                                             |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_cluster_width<class_TLShapedString_method_get_cluster_width>` **(** int index **)** const                                                                             |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Array                                                   | :ref:`get_cursor_positions<class_TLShapedString_method_get_cursor_positions>` **(** int position, int primary_dir **)** const                                                   |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_descent<class_TLShapedString_method_get_descent>` **(** **)** const                                                                                                   |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_height<class_TLShapedString_method_get_height>` **(** **)** const                                                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Array                                                   | :ref:`get_highlight_shapes<class_TLShapedString_method_get_highlight_shapes>` **(** int start, int end **)** const                                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`get_para_direction<class_TLShapedString_method_get_para_direction>` **(** **)** const                                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | PoolByteArray                                           | :ref:`get_utf16<class_TLShapedString_method_get_utf16>` **(** **)** const                                                                                                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | PoolByteArray                                           | :ref:`get_utf32<class_TLShapedString_method_get_utf32>` **(** **)** const                                                                                                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | PoolByteArray                                           | :ref:`get_utf8<class_TLShapedString_method_get_utf8>` **(** **)** const                                                                                                         |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | float                                                   | :ref:`get_width<class_TLShapedString_method_get_width>` **(** **)** const                                                                                                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`hit_test<class_TLShapedString_method_hit_test>` **(** float position **)** const                                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`hit_test_cluster<class_TLShapedString_method_hit_test_cluster>` **(** float position **)** const                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | bool                                                    | :ref:`is_valid<class_TLShapedString_method_is_valid>` **(** **)** const                                                                                                         |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`length<class_TLShapedString_method_length>` **(** **)** const                                                                                                             |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`next_safe_bound<class_TLShapedString_method_next_safe_bound>` **(** int position **)** const                                                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`pos_u16_to_wcs<class_TLShapedString_method_pos_u16_to_wcs>` **(** int position **)** const                                                                                |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`pos_wcs_to_u16<class_TLShapedString_method_pos_wcs_to_u16>` **(** int position **)** const                                                                                |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | int                                                     | :ref:`prev_safe_bound<class_TLShapedString_method_prev_safe_bound>` **(** int position **)** const                                                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`replace_sstring<class_TLShapedString_method_replace_sstring>` **(** int start, int end, :ref:`TLShapedString<class_TLShapedString>` text **)**                            |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`replace_text<class_TLShapedString_method_replace_text>` **(** int start, int end, String text **)**                                                                       |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`replace_utf16<class_TLShapedString_method_replace_utf16>` **(** int start, int end, PoolByteArray text **)**                                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`replace_utf32<class_TLShapedString_method_replace_utf32>` **(** int start, int end, PoolByteArray text **)**                                                              |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`replace_utf8<class_TLShapedString_method_replace_utf8>` **(** int start, int end, PoolByteArray text **)**                                                                |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`set_utf16<class_TLShapedString_method_set_utf16>` **(** PoolByteArray data **)**                                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`set_utf32<class_TLShapedString_method_set_utf32>` **(** PoolByteArray data **)**                                                                                          |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | void                                                    | :ref:`set_utf8<class_TLShapedString_method_set_utf8>` **(** PoolByteArray data **)**                                                                                            |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | bool                                                    | :ref:`shape<class_TLShapedString_method_shape>` **(** **)**                                                                                                                     |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`TLShapedString<class_TLShapedString>`             | :ref:`substr<class_TLShapedString_method_substr>` **(** int start, int end, int trim **)** const                                                                                |
   +---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Signals
-------

.. _class_TLShapedString_signal_string_changed:

- **string_changed** **(** **)**

Emitted when the text or/and other property of the string changes.

----

.. _class_TLShapedString_signal_string_shaped:

- **string_shaped** **(** **)**

Emitted when the text shaping process is completed.

Enumerations
------------

.. _enum_TLShapedString_TextDirection:

.. _class_TLShapedString_constant_TEXT_DIRECTION_LTR:

.. _class_TLShapedString_constant_TEXT_DIRECTION_RTL:

.. _class_TLShapedString_constant_TEXT_DIRECTION_LOCALE:

.. _class_TLShapedString_constant_TEXT_DIRECTION_AUTO:

.. _class_TLShapedString_constant_TEXT_DIRECTION_INVALID:

enum **TextDirection**:

- **TEXT_DIRECTION_LTR** = **0** --- Left-to-right text writing direction.

- **TEXT_DIRECTION_RTL** = **1** --- Right-to-left text writing direction.

- **TEXT_DIRECTION_LOCALE** = **2** --- Text writing direction is derived from the locale's script according to the CLDR metadata.

- **TEXT_DIRECTION_AUTO** = **3** --- Text writing direction is derived from the first character in the string with BiDi class L, R, or AL or locale's script if text is not strongly directional.

- **TEXT_DIRECTION_INVALID** = **4** --- Invalid text direction (Used as return value only).

----

.. _enum_TLShapedString_TextJustification:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_NONE:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_KASHIDA_AND_WHITESPACE:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_KASHIDA_ONLY:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_WHITESPACE_ONLY:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_KASHIDA_AND_WHITESPACE_AND_INTERCHAR:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_KASHIDA_AND_INTERCHAR:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_WHITESPACE_AND_INTERCHAR:

.. _class_TLShapedString_constant_TEXT_JUSTIFICATION_INTERCHAR_ONLY:

enum **TextJustification**:

- **TEXT_JUSTIFICATION_NONE** = **0** --- No text justification.

- **TEXT_JUSTIFICATION_KASHIDA_AND_WHITESPACE** = **1** --- Use kashida and white space elongation to justify text.

- **TEXT_JUSTIFICATION_KASHIDA_ONLY** = **2** --- Use kashida elongation to justify text.

- **TEXT_JUSTIFICATION_WHITESPACE_ONLY** = **3** --- Use white space elongation to justify text.

- **TEXT_JUSTIFICATION_KASHIDA_AND_WHITESPACE_AND_INTERCHAR** = **4** --- Use kashida, white space and inter character elongation to justify text.

- **TEXT_JUSTIFICATION_KASHIDA_AND_INTERCHAR** = **5** --- Use kashida and inter character elongation to justify text.

- **TEXT_JUSTIFICATION_WHITESPACE_AND_INTERCHAR** = **6** --- Use white space and inter character elongation to justify text.

- **TEXT_JUSTIFICATION_INTERCHAR_ONLY** = **7** --- Use inter character elongation to justify text.

----

.. _enum_TLShapedString_TextBreak:

.. _class_TLShapedString_constant_TEXT_BREAK_NONE:

.. _class_TLShapedString_constant_TEXT_BREAK_MANDATORY:

.. _class_TLShapedString_constant_TEXT_BREAK_MANDATORY_AND_WORD_BOUND:

.. _class_TLShapedString_constant_TEXT_BREAK_MANDATORY_AND_ANYWHERE:

enum **TextBreak**:

- **TEXT_BREAK_NONE** = **0** --- No line breaking.

- **TEXT_BREAK_MANDATORY** = **1** --- Break lines only at mandatory break points.

- **TEXT_BREAK_MANDATORY_AND_WORD_BOUND** = **2** --- Break lines at mandatory break points and word boundaries.

- **TEXT_BREAK_MANDATORY_AND_ANYWHERE** = **3** --- Break lines at mandatory break points and grapheme cluster boundaries.

----

.. _enum_TLShapedString_TextTrimMode:

.. _class_TLShapedString_constant_TEXT_TRIM_NONE:

.. _class_TLShapedString_constant_TEXT_TRIM_BREAK:

.. _class_TLShapedString_constant_TEXT_TRIM_BREAK_AND_WHITESPACE:

enum **TextTrimMode**:

- **TEXT_TRIM_NONE** = **0** --- No substring trimming.

- **TEXT_TRIM_BREAK** = **1** --- Trim line break characters for substring ends.

- **TEXT_TRIM_BREAK_AND_WHITESPACE** = **2** --- Trim line break and white space characters for substring ends.

Description
-----------

Note 1: Code points, Characters, Clusters and Glyphs



- A code point is a single encoding UTF-16 unit (Unicode character or half of the surrogate pair).

- A character is a full Unicode character.

- A grapheme cluster is the abstract unit of a writing system (a letter, a digit, or punctuation).

- A glyph is a shape used to render a character or a sequence of characters.



In general, code point, characters, clusters and glyphs do not have one-to-one correspondence.



Note 2: Encoding


		TLShapedString uses UTF-16 encoding, all positions accepted and returned by TLShapedString function are measured in UTF-16 code points.

Property Descriptions
---------------------

.. _class_TLShapedString_property_base_direction:

- int **base_direction**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------+
   | *Default* | 3                         |
   +-----------+---------------------------+
   | *Setter*  | set_base_direction(value) |
   +-----------+---------------------------+
   | *Getter*  | get_base_direction()      |
   +-----------+---------------------------+

Base text writing direction.

----

.. _class_TLShapedString_property_base_font:

- :ref:`TLFontFamily<class_TLFontFamily>` **base_font**

.. table::
   :class: longtable
   :widths: 7 20

   +----------+----------------------+
   | *Setter* | set_base_font(value) |
   +----------+----------------------+
   | *Getter* | get_base_font()      |
   +----------+----------------------+

Base font family reference.

----

.. _class_TLShapedString_property_base_font_size:

- int **base_font_size**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------+
   | *Default* | 12                        |
   +-----------+---------------------------+
   | *Setter*  | set_base_font_size(value) |
   +-----------+---------------------------+
   | *Getter*  | get_base_font_size()      |
   +-----------+---------------------------+

Font size.

----

.. _class_TLShapedString_property_base_font_style:

- String **base_font_style**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+----------------------------+
   | *Default* | "Regular"                  |
   +-----------+----------------------------+
   | *Setter*  | set_base_font_style(value) |
   +-----------+----------------------------+
   | *Getter*  | get_base_font_style()      |
   +-----------+----------------------------+

Style name (Regular, Bold, Italic, Oblique etc.).

----

.. _class_TLShapedString_property_features:

- String **features**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------+
   | *Default* | ""                  |
   +-----------+---------------------+
   | *Setter*  | set_features(value) |
   +-----------+---------------------+
   | *Getter*  | get_features()      |
   +-----------+---------------------+

Comma separated list of OpenType feature tags. More info: https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags.

----

.. _class_TLShapedString_property_language:

- String **language**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------+
   | *Default* | "en"                |
   +-----------+---------------------+
   | *Setter*  | set_language(value) |
   +-----------+---------------------+
   | *Getter*  | get_language()      |
   +-----------+---------------------+

Language code for line-breaking and text shaping algorithms.

----

.. _class_TLShapedString_property_preserve_control:

- bool **preserve_control**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-----------------------------+
   | *Default* | false                       |
   +-----------+-----------------------------+
   | *Setter*  | set_preserve_control(value) |
   +-----------+-----------------------------+
   | *Getter*  | get_preserve_control()      |
   +-----------+-----------------------------+

If ``true``, displays control character.

----

.. _class_TLShapedString_property_text:

- String **text**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-----------------+
   | *Default* | ""              |
   +-----------+-----------------+
   | *Setter*  | set_text(value) |
   +-----------+-----------------+
   | *Getter*  | get_text()      |
   +-----------+-----------------+

Text string.

Method Descriptions
-------------------

.. _class_TLShapedString_method_add_sstring:

- void **add_sstring** **(** :ref:`TLShapedString<class_TLShapedString>` text **)**

Appends shaped string.

----

.. _class_TLShapedString_method_add_text:

- void **add_text** **(** String text **)**

Appends plain text string.

----

.. _class_TLShapedString_method_add_utf16:

- void **add_utf16** **(** PoolByteArray text **)**

----

.. _class_TLShapedString_method_add_utf32:

- void **add_utf32** **(** PoolByteArray text **)**

----

.. _class_TLShapedString_method_add_utf8:

- void **add_utf8** **(** PoolByteArray text **)**

----

.. _class_TLShapedString_method_break_jst:

- Array **break_jst** **(** **)** const

----

.. _class_TLShapedString_method_break_lines:

- Array **break_lines** **(** float width, int flags **)** const

Breaks text into lines that fit within a specified width.

Returns Array of line boundaries.

----

.. _class_TLShapedString_method_break_words:

- Array **break_words** **(** **)** const

Breaks text into words.

Returns Array of word boundaries.

----

.. _class_TLShapedString_method_char_count:

- int **char_count** **(** **)** const

Returns number of characters in the string.

----

.. _class_TLShapedString_method_clusters:

- int **clusters** **(** **)** const

Returns number of grapheme clusters, clusters are indexed in visual order.

----

.. _class_TLShapedString_method_copy_properties:

- void **copy_properties** **(** :ref:`TLShapedString<class_TLShapedString>` source **)**

----

.. _class_TLShapedString_method_draw:

- void **draw** **(** RID canvas_item, Vector2 position, Color modulate **)**

Draws a string.

----

.. _class_TLShapedString_method_draw_as_hex:

- void **draw_as_hex** **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)**

``DEBUG:`` Draws a string using "hexbox" fallback font.

----

.. _class_TLShapedString_method_draw_cluster:

- Vector2 **draw_cluster** **(** RID canvas_item, Vector2 position, int index, Color modulate **)**

Draws single grapheme cluster. Returns advance.

----

.. _class_TLShapedString_method_draw_dbg:

- void **draw_dbg** **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)**

``DEBUG:`` Draws a string with additional debug information.

----

.. _class_TLShapedString_method_draw_logical_as_hex:

- void **draw_logical_as_hex** **(** RID canvas_item, Vector2 position, Color modulate, bool draw_brk_ops, bool draw_jst_ops **)**

``DEBUG:`` Draws logical character codes of the string with additional debug information.

----

.. _class_TLShapedString_method_empty:

- bool **empty** **(** **)** const

Returns ``true`` if the string is empty.

----

.. _class_TLShapedString_method_extend_to_width:

- float **extend_to_width** **(** float width, int flags **)**

Increase text width to the specified. Returns new line width.

----

.. _class_TLShapedString_method_get_ascent:

- float **get_ascent** **(** **)** const

Returns ascent of the line.

----

.. _class_TLShapedString_method_get_char_direction:

- :ref:`TextDirection<enum_TLShapedString_TextDirection>` **get_char_direction** **(** int position **)** const

Return writing direction of a character writing direction.

----

.. _class_TLShapedString_method_get_cluster_ascent:

- float **get_cluster_ascent** **(** int index **)** const

Returns cluster ascent.

----

.. _class_TLShapedString_method_get_cluster_debug_info:

- String **get_cluster_debug_info** **(** int index **)** const

----

.. _class_TLShapedString_method_get_cluster_descent:

- float **get_cluster_descent** **(** int index **)** const

Returns cluster descent.

----

.. _class_TLShapedString_method_get_cluster_end:

- int **get_cluster_end** **(** int index **)** const

Returns last character position corresponding cluster.

----

.. _class_TLShapedString_method_get_cluster_face:

- :ref:`TLFontFace<class_TLFontFace>` **get_cluster_face** **(** int position **)** const

Returns font face of the cluster.

----

.. _class_TLShapedString_method_get_cluster_face_size:

- float **get_cluster_face_size** **(** int position **)** const

Returns font size of the cluster. For non-attributed string it's always equal to base size.

----

.. _class_TLShapedString_method_get_cluster_glyph:

- int **get_cluster_glyph** **(** int index, int glyph **)** const

Returns glyph ID.

----

.. _class_TLShapedString_method_get_cluster_glyph_advance:

- Vector2 **get_cluster_glyph_advance** **(** int index, int glyph **)** const

Returns glyph advance.

----

.. _class_TLShapedString_method_get_cluster_glyph_offset:

- Vector2 **get_cluster_glyph_offset** **(** int index, int glyph **)** const

Returns glyph offset.

----

.. _class_TLShapedString_method_get_cluster_glyphs:

- int **get_cluster_glyphs** **(** int index **)** const

Returns number of glyphs in cluster.

----

.. _class_TLShapedString_method_get_cluster_height:

- float **get_cluster_height** **(** int index **)** const

Returns cluster height.

----

.. _class_TLShapedString_method_get_cluster_index:

- int **get_cluster_index** **(** int position **)** const

Returns cluster index corresponding to a specific character position in string.

----

.. _class_TLShapedString_method_get_cluster_leading_edge:

- float **get_cluster_leading_edge** **(** int index **)** const

Returns cluster leading edge offset in pixels.

----

.. _class_TLShapedString_method_get_cluster_rect:

- Rect2 **get_cluster_rect** **(** int index **)** const

Returns cluster bounding rectangle.

----

.. _class_TLShapedString_method_get_cluster_start:

- int **get_cluster_start** **(** int index **)** const

Returns first character position corresponding cluster.

----

.. _class_TLShapedString_method_get_cluster_trailing_edge:

- float **get_cluster_trailing_edge** **(** int index **)** const

Returns cluster trailing edge offset in pixels.

----

.. _class_TLShapedString_method_get_cluster_width:

- float **get_cluster_width** **(** int index **)** const

Returns cluster width.

----

.. _class_TLShapedString_method_get_cursor_positions:

- Array **get_cursor_positions** **(** int position, int primary_dir **)** const

Returns an Array of ``float`` (up to two elements) offsets corresponding to the strong and weak cursor, at the specified character position.

----

.. _class_TLShapedString_method_get_descent:

- float **get_descent** **(** **)** const

Returns descent of the line.

----

.. _class_TLShapedString_method_get_height:

- float **get_height** **(** **)** const

Returns height of the line.

----

.. _class_TLShapedString_method_get_highlight_shapes:

- Array **get_highlight_shapes** **(** int start, int end **)** const

Returns an Array of Rect2 enclosing the selection/highlight in the specified range.

----

.. _class_TLShapedString_method_get_para_direction:

- int **get_para_direction** **(** **)** const

Returns shaped string paragraph direction.

----

.. _class_TLShapedString_method_get_utf16:

- PoolByteArray **get_utf16** **(** **)** const

Returns raw text string in UTF-16 encoding.

----

.. _class_TLShapedString_method_get_utf32:

- PoolByteArray **get_utf32** **(** **)** const

Returns raw text string in UTF-32 encoding.

----

.. _class_TLShapedString_method_get_utf8:

- PoolByteArray **get_utf8** **(** **)** const

Returns raw text string in UTF-8 encoding.

----

.. _class_TLShapedString_method_get_width:

- float **get_width** **(** **)** const

Returns width of the line.

----

.. _class_TLShapedString_method_hit_test:

- int **hit_test** **(** float position **)** const

Returns a cursor position corresponding to the specified pixel offset.

----

.. _class_TLShapedString_method_hit_test_cluster:

- int **hit_test_cluster** **(** float position **)** const

Returns a cluster index corresponding to the specified pixel offset.

----

.. _class_TLShapedString_method_is_valid:

- bool **is_valid** **(** **)** const

Returns ``true`` if the string is shaped successfully.

----

.. _class_TLShapedString_method_length:

- int **length** **(** **)** const

Returns number of UTF-16 codepoints in the string.

----

.. _class_TLShapedString_method_next_safe_bound:

- int **next_safe_bound** **(** int position **)** const

Returns next whole character position in the string.

----

.. _class_TLShapedString_method_pos_u16_to_wcs:

- int **pos_u16_to_wcs** **(** int position **)** const

Returns character position (Characters)

----

.. _class_TLShapedString_method_pos_wcs_to_u16:

- int **pos_wcs_to_u16** **(** int position **)** const

Retruns character position (UTF-16 codepoints)

----

.. _class_TLShapedString_method_prev_safe_bound:

- int **prev_safe_bound** **(** int position **)** const

Returns previous whole character position in the string.

----

.. _class_TLShapedString_method_replace_sstring:

- void **replace_sstring** **(** int start, int end, :ref:`TLShapedString<class_TLShapedString>` text **)**

Replaces substring with contents of another shaped string.

----

.. _class_TLShapedString_method_replace_text:

- void **replace_text** **(** int start, int end, String text **)**

Replaces substring with text.

----

.. _class_TLShapedString_method_replace_utf16:

- void **replace_utf16** **(** int start, int end, PoolByteArray text **)**

Replaces substring with contents of the raw UTF-16 encoded string.

----

.. _class_TLShapedString_method_replace_utf32:

- void **replace_utf32** **(** int start, int end, PoolByteArray text **)**

Replaces substring with contents of the raw UTF-32 encoded string.

----

.. _class_TLShapedString_method_replace_utf8:

- void **replace_utf8** **(** int start, int end, PoolByteArray text **)**

Replaces substring with contents of the raw UTF-8 encoded string.

----

.. _class_TLShapedString_method_set_utf16:

- void **set_utf16** **(** PoolByteArray data **)**

Sets text to the contents of the raw UTF-16 encoded string.

----

.. _class_TLShapedString_method_set_utf32:

- void **set_utf32** **(** PoolByteArray data **)**

Sets text to the contents of the raw UTF-32 encoded string.

----

.. _class_TLShapedString_method_set_utf8:

- void **set_utf8** **(** PoolByteArray data **)**

Sets text to the contents of the raw UTF-8 encoded string.

----

.. _class_TLShapedString_method_shape:

- bool **shape** **(** **)**

Shapes string and returns ``true`` if the string is shaped successfully.

----

.. _class_TLShapedString_method_substr:

- :ref:`TLShapedString<class_TLShapedString>` **substr** **(** int start, int end, int trim **)** const

Returns part of the shaped string from the position ``start`` to ``end``, trims it according to ``trim`` parameter.

