class_textline.rst 26 KB

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