TextParagraph.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="TextParagraph" inherits="RefCounted" version="4.0">
  3. <brief_description>
  4. Holds a paragraph of text.
  5. </brief_description>
  6. <description>
  7. Abstraction over [TextServer] for handling paragraph 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 paragraph (removes text and inline objects).
  38. </description>
  39. </method>
  40. <method name="clear_dropcap">
  41. <return type="void" />
  42. <description>
  43. Removes dropcap.
  44. </description>
  45. </method>
  46. <method name="draw" qualifiers="const">
  47. <return type="void" />
  48. <argument index="0" name="canvas" type="RID" />
  49. <argument index="1" name="pos" type="Vector2" />
  50. <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  51. <argument index="3" name="dc_color" type="Color" default="Color(1, 1, 1, 1)" />
  52. <description>
  53. Draw all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  54. </description>
  55. </method>
  56. <method name="draw_dropcap" qualifiers="const">
  57. <return type="void" />
  58. <argument index="0" name="canvas" type="RID" />
  59. <argument index="1" name="pos" type="Vector2" />
  60. <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  61. <description>
  62. Draw drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  63. </description>
  64. </method>
  65. <method name="draw_dropcap_outline" qualifiers="const">
  66. <return type="void" />
  67. <argument index="0" name="canvas" type="RID" />
  68. <argument index="1" name="pos" type="Vector2" />
  69. <argument index="2" name="outline_size" type="int" default="1" />
  70. <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  71. <description>
  72. Draw drop cap outline into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  73. </description>
  74. </method>
  75. <method name="draw_line" qualifiers="const">
  76. <return type="void" />
  77. <argument index="0" name="canvas" type="RID" />
  78. <argument index="1" name="pos" type="Vector2" />
  79. <argument index="2" name="line" type="int" />
  80. <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  81. <description>
  82. Draw single line of 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.
  83. </description>
  84. </method>
  85. <method name="draw_line_outline" qualifiers="const">
  86. <return type="void" />
  87. <argument index="0" name="canvas" type="RID" />
  88. <argument index="1" name="pos" type="Vector2" />
  89. <argument index="2" name="line" type="int" />
  90. <argument index="3" name="outline_size" type="int" default="1" />
  91. <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  92. <description>
  93. Draw outline of the single line of 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.
  94. </description>
  95. </method>
  96. <method name="draw_outline" qualifiers="const">
  97. <return type="void" />
  98. <argument index="0" name="canvas" type="RID" />
  99. <argument index="1" name="pos" type="Vector2" />
  100. <argument index="2" name="outline_size" type="int" default="1" />
  101. <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)" />
  102. <argument index="4" name="dc_color" type="Color" default="Color(1, 1, 1, 1)" />
  103. <description>
  104. Draw outlines of all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
  105. </description>
  106. </method>
  107. <method name="get_dropcap_lines" qualifiers="const">
  108. <return type="int" />
  109. <description>
  110. Returns number of lines used by dropcap.
  111. </description>
  112. </method>
  113. <method name="get_dropcap_rid" qualifiers="const">
  114. <return type="RID" />
  115. <description>
  116. Return drop cap text buffer RID.
  117. </description>
  118. </method>
  119. <method name="get_dropcap_size" qualifiers="const">
  120. <return type="Vector2" />
  121. <description>
  122. Returns drop cap bounding box size.
  123. </description>
  124. </method>
  125. <method name="get_line_ascent" qualifiers="const">
  126. <return type="float" />
  127. <argument index="0" name="line" type="int" />
  128. <description>
  129. Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
  130. </description>
  131. </method>
  132. <method name="get_line_count" qualifiers="const">
  133. <return type="int" />
  134. <description>
  135. Returns number of lines in the paragraph.
  136. </description>
  137. </method>
  138. <method name="get_line_descent" qualifiers="const">
  139. <return type="float" />
  140. <argument index="0" name="line" type="int" />
  141. <description>
  142. Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
  143. </description>
  144. </method>
  145. <method name="get_line_object_rect" qualifiers="const">
  146. <return type="Rect2" />
  147. <argument index="0" name="line" type="int" />
  148. <argument index="1" name="key" type="Variant" />
  149. <description>
  150. Returns bounding rectangle of the inline object.
  151. </description>
  152. </method>
  153. <method name="get_line_objects" qualifiers="const">
  154. <return type="Array" />
  155. <argument index="0" name="line" type="int" />
  156. <description>
  157. Returns array of inline objects in the line.
  158. </description>
  159. </method>
  160. <method name="get_line_range" qualifiers="const">
  161. <return type="Vector2i" />
  162. <argument index="0" name="line" type="int" />
  163. <description>
  164. Returns character range of the line.
  165. </description>
  166. </method>
  167. <method name="get_line_rid" qualifiers="const">
  168. <return type="RID" />
  169. <argument index="0" name="line" type="int" />
  170. <description>
  171. Returns TextServer line buffer RID.
  172. </description>
  173. </method>
  174. <method name="get_line_size" qualifiers="const">
  175. <return type="Vector2" />
  176. <argument index="0" name="line" type="int" />
  177. <description>
  178. Returns size of the bounding box of the line of text.
  179. </description>
  180. </method>
  181. <method name="get_line_underline_position" qualifiers="const">
  182. <return type="float" />
  183. <argument index="0" name="line" type="int" />
  184. <description>
  185. Returns pixel offset of the underline below the baseline.
  186. </description>
  187. </method>
  188. <method name="get_line_underline_thickness" qualifiers="const">
  189. <return type="float" />
  190. <argument index="0" name="line" type="int" />
  191. <description>
  192. Returns thickness of the underline.
  193. </description>
  194. </method>
  195. <method name="get_line_width" qualifiers="const">
  196. <return type="float" />
  197. <argument index="0" name="line" type="int" />
  198. <description>
  199. Returns width (for horizontal layout) or height (for vertical) of the line of text.
  200. </description>
  201. </method>
  202. <method name="get_non_wrapped_size" qualifiers="const">
  203. <return type="Vector2" />
  204. <description>
  205. Returns the size of the bounding box of the paragraph, without line breaks.
  206. </description>
  207. </method>
  208. <method name="get_rid" qualifiers="const">
  209. <return type="RID" />
  210. <description>
  211. Returns TextServer full string buffer RID.
  212. </description>
  213. </method>
  214. <method name="get_size" qualifiers="const">
  215. <return type="Vector2" />
  216. <description>
  217. Returns the size of the bounding box of the paragraph.
  218. </description>
  219. </method>
  220. <method name="get_spacing_bottom" qualifiers="const">
  221. <return type="int" />
  222. <description>
  223. Returns extra spacing at the bottom of the line. See [member Font.spacing_bottom].
  224. </description>
  225. </method>
  226. <method name="get_spacing_top" qualifiers="const">
  227. <return type="int" />
  228. <description>
  229. Returns extra spacing at the top of the line. See [member Font.spacing_top].
  230. </description>
  231. </method>
  232. <method name="hit_test" qualifiers="const">
  233. <return type="int" />
  234. <argument index="0" name="coords" type="Vector2" />
  235. <description>
  236. Returns caret character offset at the specified coordinates. This function always returns a valid position.
  237. </description>
  238. </method>
  239. <method name="resize_object">
  240. <return type="bool" />
  241. <argument index="0" name="key" type="Variant" />
  242. <argument index="1" name="size" type="Vector2" />
  243. <argument index="2" name="inline_align" type="int" enum="InlineAlign" default="5" />
  244. <description>
  245. Sets new size and alignment of embedded object.
  246. </description>
  247. </method>
  248. <method name="set_bidi_override">
  249. <return type="void" />
  250. <argument index="0" name="override" type="Array" />
  251. <description>
  252. Overrides BiDi for the structured text.
  253. Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
  254. </description>
  255. </method>
  256. <method name="set_dropcap">
  257. <return type="bool" />
  258. <argument index="0" name="text" type="String" />
  259. <argument index="1" name="fonts" type="Font" />
  260. <argument index="2" name="size" type="int" />
  261. <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)" />
  262. <argument index="4" name="opentype_features" type="Dictionary" default="{
  263. }" />
  264. <argument index="5" name="language" type="String" default="&quot;&quot;" />
  265. <description>
  266. Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
  267. </description>
  268. </method>
  269. <method name="tab_align">
  270. <return type="void" />
  271. <argument index="0" name="tab_stops" type="PackedFloat32Array" />
  272. <description>
  273. Aligns paragraph to the given tab-stops.
  274. </description>
  275. </method>
  276. </methods>
  277. <members>
  278. <member name="align" type="int" setter="set_align" getter="get_align" enum="HAlign" default="0">
  279. Paragraph horizontal alignment.
  280. </member>
  281. <member name="direction" type="int" setter="set_direction" getter="get_direction" enum="TextServer.Direction" default="0">
  282. Text writing direction.
  283. </member>
  284. <member name="flags" type="int" setter="set_flags" getter="get_flags" default="99">
  285. Line breaking and alignment rules. For more info see [TextServer].
  286. </member>
  287. <member name="max_lines_visible" type="int" setter="set_max_lines_visible" getter="get_max_lines_visible" default="-1">
  288. Limits the lines of text shown.
  289. </member>
  290. <member name="orientation" type="int" setter="set_orientation" getter="get_orientation" enum="TextServer.Orientation" default="0">
  291. Text orientation.
  292. </member>
  293. <member name="preserve_control" type="bool" setter="set_preserve_control" getter="get_preserve_control" default="false">
  294. If set to [code]true[/code] text will display control characters.
  295. </member>
  296. <member name="preserve_invalid" type="bool" setter="set_preserve_invalid" getter="get_preserve_invalid" default="true">
  297. If set to [code]true[/code] text will display invalid characters.
  298. </member>
  299. <member name="text_overrun_behavior" type="int" setter="set_text_overrun_behavior" getter="get_text_overrun_behavior" enum="TextParagraph.OverrunBehavior" default="0">
  300. Sets the clipping behavior when the text exceeds the paragraph's set width. See [enum OverrunBehavior] for a description of all modes.
  301. </member>
  302. <member name="width" type="float" setter="set_width" getter="get_width" default="-1.0">
  303. Paragraph width.
  304. </member>
  305. </members>
  306. <constants>
  307. <constant name="OVERRUN_NO_TRIMMING" value="0" enum="OverrunBehavior">
  308. No text trimming is performed.
  309. </constant>
  310. <constant name="OVERRUN_TRIM_CHAR" value="1" enum="OverrunBehavior">
  311. Trims the text per character.
  312. </constant>
  313. <constant name="OVERRUN_TRIM_WORD" value="2" enum="OverrunBehavior">
  314. Trims the text per word.
  315. </constant>
  316. <constant name="OVERRUN_TRIM_ELLIPSIS" value="3" enum="OverrunBehavior">
  317. Trims the text per character and adds an ellipsis to indicate that parts are hidden.
  318. </constant>
  319. <constant name="OVERRUN_TRIM_WORD_ELLIPSIS" value="4" enum="OverrunBehavior">
  320. Trims the text per word and adds an ellipsis to indicate that parts are hidden.
  321. </constant>
  322. </constants>
  323. </class>