2
0

TextLine.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="TextLine" inherits="RefCounted" version="4.0">
  3. <brief_description>
  4. Holds a line of text.
  5. </brief_description>
  6. <description>
  7. Abstraction over [TextServer] for handling single line of text.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="add_object">
  13. <return type="bool" />
  14. <argument index="0" name="key" type="Variant" />
  15. <argument index="1" name="size" type="Vector2" />
  16. <argument index="2" name="inline_align" type="int" enum="InlineAlign" default="5" />
  17. <argument index="3" name="length" type="int" default="1" />
  18. <description>
  19. Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] object replacement characters.
  20. </description>
  21. </method>
  22. <method name="add_string">
  23. <return type="bool" />
  24. <argument index="0" name="text" type="String" />
  25. <argument index="1" name="fonts" type="Font" />
  26. <argument index="2" name="size" type="int" />
  27. <argument index="3" name="opentype_features" type="Dictionary" default="{
  28. }" />
  29. <argument index="4" name="language" type="String" default="&quot;&quot;" />
  30. <description>
  31. Adds text span and font to draw it.
  32. </description>
  33. </method>
  34. <method name="clear">
  35. <return type="void" />
  36. <description>
  37. Clears text line (removes text and inline objects).
  38. </description>
  39. </method>
  40. <method name="draw" qualifiers="const">
  41. <return type="void" />
  42. <argument index="0" name="canvas" type="RID" />
  43. <argument index="1" name="pos" type="Vector2" />
  44. <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  45. <description>
  46. Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  47. </description>
  48. </method>
  49. <method name="draw_outline" qualifiers="const">
  50. <return type="void" />
  51. <argument index="0" name="canvas" type="RID" />
  52. <argument index="1" name="pos" type="Vector2" />
  53. <argument index="2" name="outline_size" type="int" default="1" />
  54. <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  55. <description>
  56. Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  57. </description>
  58. </method>
  59. <method name="get_line_ascent" qualifiers="const">
  60. <return type="float" />
  61. <description>
  62. Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
  63. </description>
  64. </method>
  65. <method name="get_line_descent" qualifiers="const">
  66. <return type="float" />
  67. <description>
  68. Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
  69. </description>
  70. </method>
  71. <method name="get_line_underline_position" qualifiers="const">
  72. <return type="float" />
  73. <description>
  74. Returns pixel offset of the underline below the baseline.
  75. </description>
  76. </method>
  77. <method name="get_line_underline_thickness" qualifiers="const">
  78. <return type="float" />
  79. <description>
  80. Returns thickness of the underline.
  81. </description>
  82. </method>
  83. <method name="get_line_width" qualifiers="const">
  84. <return type="float" />
  85. <description>
  86. Returns width (for horizontal layout) or height (for vertical) of the text.
  87. </description>
  88. </method>
  89. <method name="get_object_rect" qualifiers="const">
  90. <return type="Rect2" />
  91. <argument index="0" name="key" type="Variant" />
  92. <description>
  93. Returns bounding rectangle of the inline object.
  94. </description>
  95. </method>
  96. <method name="get_objects" qualifiers="const">
  97. <return type="Array" />
  98. <description>
  99. Returns array of inline objects.
  100. </description>
  101. </method>
  102. <method name="get_rid" qualifiers="const">
  103. <return type="RID" />
  104. <description>
  105. Returns TextServer buffer RID.
  106. </description>
  107. </method>
  108. <method name="get_size" qualifiers="const">
  109. <return type="Vector2" />
  110. <description>
  111. Returns size of the bounding box of the text.
  112. </description>
  113. </method>
  114. <method name="hit_test" qualifiers="const">
  115. <return type="int" />
  116. <argument index="0" name="coords" type="float" />
  117. <description>
  118. Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
  119. </description>
  120. </method>
  121. <method name="resize_object">
  122. <return type="bool" />
  123. <argument index="0" name="key" type="Variant" />
  124. <argument index="1" name="size" type="Vector2" />
  125. <argument index="2" name="inline_align" type="int" enum="InlineAlign" default="5" />
  126. <description>
  127. Sets new size and alignment of embedded object.
  128. </description>
  129. </method>
  130. <method name="set_bidi_override">
  131. <return type="void" />
  132. <argument index="0" name="override" type="Array" />
  133. <description>
  134. Overrides BiDi for the structured text.
  135. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
  136. </description>
  137. </method>
  138. <method name="tab_align">
  139. <return type="void" />
  140. <argument index="0" name="tab_stops" type="PackedFloat32Array" />
  141. <description>
  142. Aligns text to the given tab-stops.
  143. </description>
  144. </method>
  145. </methods>
  146. <members>
  147. <member name="align" type="int" setter="set_align" getter="get_align" enum="HAlign" default="0">
  148. Text horizontal alignment.
  149. </member>
  150. <member name="direction" type="int" setter="set_direction" getter="get_direction" enum="TextServer.Direction" default="0">
  151. Text writing direction.
  152. </member>
  153. <member name="flags" type="int" setter="set_flags" getter="get_flags" default="3">
  154. Line Alignment rules. For more info see [TextServer].
  155. </member>
  156. <member name="orientation" type="int" setter="set_orientation" getter="get_orientation" enum="TextServer.Orientation" default="0">
  157. Text orientation.
  158. </member>
  159. <member name="preserve_control" type="bool" setter="set_preserve_control" getter="get_preserve_control" default="false">
  160. If set to [code]true[/code] text will display control characters.
  161. </member>
  162. <member name="preserve_invalid" type="bool" setter="set_preserve_invalid" getter="get_preserve_invalid" default="true">
  163. If set to [code]true[/code] text will display invalid characters.
  164. </member>
  165. <member name="text_overrun_behavior" type="int" setter="set_text_overrun_behavior" getter="get_text_overrun_behavior" enum="TextLine.OverrunBehavior" default="3">
  166. Sets the clipping behavior when the text exceeds the text line's set width. See [enum OverrunBehavior] for a description of all modes.
  167. </member>
  168. <member name="width" type="float" setter="set_width" getter="get_width" default="-1.0">
  169. Text line width.
  170. </member>
  171. </members>
  172. <constants>
  173. <constant name="OVERRUN_NO_TRIMMING" value="0" enum="OverrunBehavior">
  174. No text trimming is performed.
  175. </constant>
  176. <constant name="OVERRUN_TRIM_CHAR" value="1" enum="OverrunBehavior">
  177. Trims the text per character.
  178. </constant>
  179. <constant name="OVERRUN_TRIM_WORD" value="2" enum="OverrunBehavior">
  180. Trims the text per word.
  181. </constant>
  182. <constant name="OVERRUN_TRIM_ELLIPSIS" value="3" enum="OverrunBehavior">
  183. Trims the text per character and adds an ellipsis to indicate that parts are hidden.
  184. </constant>
  185. <constant name="OVERRUN_TRIM_WORD_ELLIPSIS" value="4" enum="OverrunBehavior">
  186. Trims the text per word and adds an ellipsis to indicate that parts are hidden.
  187. </constant>
  188. </constants>
  189. </class>