class_textline.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/TextLine.xml.
  6. .. _class_TextLine:
  7. TextLine
  8. ========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Holds a line of text.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Abstraction over :ref:`TextServer<class_TextServer>` for handling a single line of text.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  21. | :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` | :ref:`alignment<class_TextLine_property_alignment>` | ``0`` |
  22. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  23. | :ref:`Direction<enum_TextServer_Direction>` | :ref:`direction<class_TextLine_property_direction>` | ``0`` |
  24. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  25. | |bitfield|\<:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`\> | :ref:`flags<class_TextLine_property_flags>` | ``3`` |
  26. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  27. | :ref:`Orientation<enum_TextServer_Orientation>` | :ref:`orientation<class_TextLine_property_orientation>` | ``0`` |
  28. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`preserve_control<class_TextLine_property_preserve_control>` | ``false`` |
  30. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`preserve_invalid<class_TextLine_property_preserve_invalid>` | ``true`` |
  32. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  33. | :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` | :ref:`text_overrun_behavior<class_TextLine_property_text_overrun_behavior>` | ``3`` |
  34. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  35. | :ref:`float<class_float>` | :ref:`width<class_TextLine_property_width>` | ``-1.0`` |
  36. +---------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------+
  37. .. rst-class:: classref-reftable-group
  38. Methods
  39. -------
  40. .. table::
  41. :widths: auto
  42. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`add_object<class_TextLine_method_add_object>` **(** :ref:`Variant<class_Variant>` key, :ref:`Vector2<class_Vector2>` size, :ref:`InlineAlignment<enum_@GlobalScope_InlineAlignment>` inline_align=5, :ref:`int<class_int>` length=1, :ref:`float<class_float>` baseline=0.0 **)** |
  44. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`add_string<class_TextLine_method_add_string>` **(** :ref:`String<class_String>` text, :ref:`Font<class_Font>` font, :ref:`int<class_int>` font_size, :ref:`String<class_String>` language="", :ref:`Variant<class_Variant>` meta=null **)** |
  46. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`clear<class_TextLine_method_clear>` **(** **)** |
  48. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`draw<class_TextLine_method_draw>` **(** :ref:`RID<class_RID>` canvas, :ref:`Vector2<class_Vector2>` pos, :ref:`Color<class_Color>` color=Color(1, 1, 1, 1) **)** |const| |
  50. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`draw_outline<class_TextLine_method_draw_outline>` **(** :ref:`RID<class_RID>` canvas, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` outline_size=1, :ref:`Color<class_Color>` color=Color(1, 1, 1, 1) **)** |const| |
  52. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`get_line_ascent<class_TextLine_method_get_line_ascent>` **(** **)** |const| |
  54. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`float<class_float>` | :ref:`get_line_descent<class_TextLine_method_get_line_descent>` **(** **)** |const| |
  56. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`float<class_float>` | :ref:`get_line_underline_position<class_TextLine_method_get_line_underline_position>` **(** **)** |const| |
  58. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`float<class_float>` | :ref:`get_line_underline_thickness<class_TextLine_method_get_line_underline_thickness>` **(** **)** |const| |
  60. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`float<class_float>` | :ref:`get_line_width<class_TextLine_method_get_line_width>` **(** **)** |const| |
  62. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Rect2<class_Rect2>` | :ref:`get_object_rect<class_TextLine_method_get_object_rect>` **(** :ref:`Variant<class_Variant>` key **)** |const| |
  64. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Array<class_Array>` | :ref:`get_objects<class_TextLine_method_get_objects>` **(** **)** |const| |
  66. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`RID<class_RID>` | :ref:`get_rid<class_TextLine_method_get_rid>` **(** **)** |const| |
  68. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector2<class_Vector2>` | :ref:`get_size<class_TextLine_method_get_size>` **(** **)** |const| |
  70. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`int<class_int>` | :ref:`hit_test<class_TextLine_method_hit_test>` **(** :ref:`float<class_float>` coords **)** |const| |
  72. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`resize_object<class_TextLine_method_resize_object>` **(** :ref:`Variant<class_Variant>` key, :ref:`Vector2<class_Vector2>` size, :ref:`InlineAlignment<enum_@GlobalScope_InlineAlignment>` inline_align=5, :ref:`float<class_float>` baseline=0.0 **)** |
  74. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`set_bidi_override<class_TextLine_method_set_bidi_override>` **(** :ref:`Array<class_Array>` override **)** |
  76. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`tab_align<class_TextLine_method_tab_align>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` tab_stops **)** |
  78. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. .. rst-class:: classref-section-separator
  80. ----
  81. .. rst-class:: classref-descriptions-group
  82. Property Descriptions
  83. ---------------------
  84. .. _class_TextLine_property_alignment:
  85. .. rst-class:: classref-property
  86. :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` **alignment** = ``0``
  87. .. rst-class:: classref-property-setget
  88. - void **set_horizontal_alignment** **(** :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` value **)**
  89. - :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` **get_horizontal_alignment** **(** **)**
  90. Sets text alignment within the line as if the line was horizontal.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_TextLine_property_direction:
  94. .. rst-class:: classref-property
  95. :ref:`Direction<enum_TextServer_Direction>` **direction** = ``0``
  96. .. rst-class:: classref-property-setget
  97. - void **set_direction** **(** :ref:`Direction<enum_TextServer_Direction>` value **)**
  98. - :ref:`Direction<enum_TextServer_Direction>` **get_direction** **(** **)**
  99. Text writing direction.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_TextLine_property_flags:
  103. .. rst-class:: classref-property
  104. |bitfield|\<:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`\> **flags** = ``3``
  105. .. rst-class:: classref-property-setget
  106. - void **set_flags** **(** |bitfield|\<:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`\> value **)**
  107. - |bitfield|\<:ref:`JustificationFlag<enum_TextServer_JustificationFlag>`\> **get_flags** **(** **)**
  108. Line alignment rules. For more info see :ref:`TextServer<class_TextServer>`.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_TextLine_property_orientation:
  112. .. rst-class:: classref-property
  113. :ref:`Orientation<enum_TextServer_Orientation>` **orientation** = ``0``
  114. .. rst-class:: classref-property-setget
  115. - void **set_orientation** **(** :ref:`Orientation<enum_TextServer_Orientation>` value **)**
  116. - :ref:`Orientation<enum_TextServer_Orientation>` **get_orientation** **(** **)**
  117. Text orientation.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_TextLine_property_preserve_control:
  121. .. rst-class:: classref-property
  122. :ref:`bool<class_bool>` **preserve_control** = ``false``
  123. .. rst-class:: classref-property-setget
  124. - void **set_preserve_control** **(** :ref:`bool<class_bool>` value **)**
  125. - :ref:`bool<class_bool>` **get_preserve_control** **(** **)**
  126. If set to ``true`` text will display control characters.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_TextLine_property_preserve_invalid:
  130. .. rst-class:: classref-property
  131. :ref:`bool<class_bool>` **preserve_invalid** = ``true``
  132. .. rst-class:: classref-property-setget
  133. - void **set_preserve_invalid** **(** :ref:`bool<class_bool>` value **)**
  134. - :ref:`bool<class_bool>` **get_preserve_invalid** **(** **)**
  135. If set to ``true`` text will display invalid characters.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_TextLine_property_text_overrun_behavior:
  139. .. rst-class:: classref-property
  140. :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` **text_overrun_behavior** = ``3``
  141. .. rst-class:: classref-property-setget
  142. - void **set_text_overrun_behavior** **(** :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` value **)**
  143. - :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` **get_text_overrun_behavior** **(** **)**
  144. Sets the clipping behavior when the text exceeds the text line's set width. See :ref:`OverrunBehavior<enum_TextServer_OverrunBehavior>` for a description of all modes.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_TextLine_property_width:
  148. .. rst-class:: classref-property
  149. :ref:`float<class_float>` **width** = ``-1.0``
  150. .. rst-class:: classref-property-setget
  151. - void **set_width** **(** :ref:`float<class_float>` value **)**
  152. - :ref:`float<class_float>` **get_width** **(** **)**
  153. Text line width.
  154. .. rst-class:: classref-section-separator
  155. ----
  156. .. rst-class:: classref-descriptions-group
  157. Method Descriptions
  158. -------------------
  159. .. _class_TextLine_method_add_object:
  160. .. rst-class:: classref-method
  161. :ref:`bool<class_bool>` **add_object** **(** :ref:`Variant<class_Variant>` key, :ref:`Vector2<class_Vector2>` size, :ref:`InlineAlignment<enum_@GlobalScope_InlineAlignment>` inline_align=5, :ref:`int<class_int>` length=1, :ref:`float<class_float>` baseline=0.0 **)**
  162. Adds inline object to the text buffer, ``key`` must be unique. In the text, object is represented as ``length`` object replacement characters.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_TextLine_method_add_string:
  166. .. rst-class:: classref-method
  167. :ref:`bool<class_bool>` **add_string** **(** :ref:`String<class_String>` text, :ref:`Font<class_Font>` font, :ref:`int<class_int>` font_size, :ref:`String<class_String>` language="", :ref:`Variant<class_Variant>` meta=null **)**
  168. Adds text span and font to draw it.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_TextLine_method_clear:
  172. .. rst-class:: classref-method
  173. void **clear** **(** **)**
  174. Clears text line (removes text and inline objects).
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_TextLine_method_draw:
  178. .. rst-class:: classref-method
  179. void **draw** **(** :ref:`RID<class_RID>` canvas, :ref:`Vector2<class_Vector2>` pos, :ref:`Color<class_Color>` color=Color(1, 1, 1, 1) **)** |const|
  180. Draw text into a canvas item at a given position, with ``color``. ``pos`` specifies the top left corner of the bounding box.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_TextLine_method_draw_outline:
  184. .. rst-class:: classref-method
  185. void **draw_outline** **(** :ref:`RID<class_RID>` canvas, :ref:`Vector2<class_Vector2>` pos, :ref:`int<class_int>` outline_size=1, :ref:`Color<class_Color>` color=Color(1, 1, 1, 1) **)** |const|
  186. Draw text into a canvas item at a given position, with ``color``. ``pos`` specifies the top left corner of the bounding box.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_TextLine_method_get_line_ascent:
  190. .. rst-class:: classref-method
  191. :ref:`float<class_float>` **get_line_ascent** **(** **)** |const|
  192. Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_TextLine_method_get_line_descent:
  196. .. rst-class:: classref-method
  197. :ref:`float<class_float>` **get_line_descent** **(** **)** |const|
  198. Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_TextLine_method_get_line_underline_position:
  202. .. rst-class:: classref-method
  203. :ref:`float<class_float>` **get_line_underline_position** **(** **)** |const|
  204. Returns pixel offset of the underline below the baseline.
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_TextLine_method_get_line_underline_thickness:
  208. .. rst-class:: classref-method
  209. :ref:`float<class_float>` **get_line_underline_thickness** **(** **)** |const|
  210. Returns thickness of the underline.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_TextLine_method_get_line_width:
  214. .. rst-class:: classref-method
  215. :ref:`float<class_float>` **get_line_width** **(** **)** |const|
  216. Returns width (for horizontal layout) or height (for vertical) of the text.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_TextLine_method_get_object_rect:
  220. .. rst-class:: classref-method
  221. :ref:`Rect2<class_Rect2>` **get_object_rect** **(** :ref:`Variant<class_Variant>` key **)** |const|
  222. Returns bounding rectangle of the inline object.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_TextLine_method_get_objects:
  226. .. rst-class:: classref-method
  227. :ref:`Array<class_Array>` **get_objects** **(** **)** |const|
  228. Returns array of inline objects.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_TextLine_method_get_rid:
  232. .. rst-class:: classref-method
  233. :ref:`RID<class_RID>` **get_rid** **(** **)** |const|
  234. Returns TextServer buffer RID.
  235. .. rst-class:: classref-item-separator
  236. ----
  237. .. _class_TextLine_method_get_size:
  238. .. rst-class:: classref-method
  239. :ref:`Vector2<class_Vector2>` **get_size** **(** **)** |const|
  240. Returns size of the bounding box of the text.
  241. .. rst-class:: classref-item-separator
  242. ----
  243. .. _class_TextLine_method_hit_test:
  244. .. rst-class:: classref-method
  245. :ref:`int<class_int>` **hit_test** **(** :ref:`float<class_float>` coords **)** |const|
  246. Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
  247. .. rst-class:: classref-item-separator
  248. ----
  249. .. _class_TextLine_method_resize_object:
  250. .. rst-class:: classref-method
  251. :ref:`bool<class_bool>` **resize_object** **(** :ref:`Variant<class_Variant>` key, :ref:`Vector2<class_Vector2>` size, :ref:`InlineAlignment<enum_@GlobalScope_InlineAlignment>` inline_align=5, :ref:`float<class_float>` baseline=0.0 **)**
  252. Sets new size and alignment of embedded object.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_TextLine_method_set_bidi_override:
  256. .. rst-class:: classref-method
  257. void **set_bidi_override** **(** :ref:`Array<class_Array>` override **)**
  258. Overrides BiDi for the structured text.
  259. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_TextLine_method_tab_align:
  263. .. rst-class:: classref-method
  264. void **tab_align** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` tab_stops **)**
  265. Aligns text to the given tab-stops.
  266. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  267. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  268. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  269. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  270. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  271. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  272. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`