bbcode_in_richtextlabel.rst 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. .. _doc_bbcode_in_richtextlabel:
  2. BBCode in RichTextLabel
  3. =======================
  4. Introduction
  5. ------------
  6. :ref:`class_Label` nodes are great for displaying basic text, but they have limitations.
  7. If you want to change the color of the text, or its alignment, you can only do that to
  8. the entire label. You can't make a part of the text have another color, or have a part
  9. of the text centered. To get around these limitations, you would use a :ref:`class_RichTextLabel`.
  10. :ref:`class_RichTextLabel` allows for complex formatting of text using a markup syntax or
  11. the built-in API. It uses BBCodes for the markup syntax, a system of tags that designate
  12. formatting rules for a part of the text. You may be familiar with them if you ever used
  13. forums (also known as `bulletin boards`, hence the "BB" in "BBCode").
  14. Unlike Label, RichTextLabel also comes with its own vertical scrollbar. This
  15. scrollbar is automatically displayed if the text does not fit within the
  16. control's size. The scrollbar can be disabled by unchecking the
  17. **Scroll Active** property in the RichTextLabel inspector.
  18. Note that the BBCode tags can also be used to some extent for other use cases:
  19. - BBCode can be used to :ref:`format comments in the XML source of the class reference <doc_class_reference_bbcode>`.
  20. - BBCode can be used in :ref:`GDScript documentation comments <doc_gdscript_documentation_comments_bbcode_and_class_reference>`.
  21. - BBCode can be used when :ref:`printing rich text to the Output bottom panel <doc_output_panel_printing_rich_text>`.
  22. .. seealso::
  23. You can see how BBCode in RichTextLabel works in action using the
  24. `Rich Text Label with BBCode demo project <https://github.com/godotengine/godot-demo-projects/tree/master/gui/rich_text_bbcode>`__.
  25. Using BBCode
  26. ------------
  27. By default, :ref:`class_RichTextLabel` functions like a normal :ref:`class_Label`.
  28. It has the :ref:`property_text <class_RichTextLabel_property_text>` property, which you can
  29. edit to have uniformly formatted text. To be able to use BBCode for rich text formatting,
  30. you need to turn on the BBCode mode by setting :ref:`bbcode_enabled <class_RichTextLabel_property_bbcode_enabled>`.
  31. After that, you can edit the :ref:`text <class_RichTextLabel_property_text>`
  32. property using available tags. Both properties are located at the top of the inspector
  33. after selecting a RichTextLabel node.
  34. .. image:: img/bbcode_in_richtextlabel_inspector.webp
  35. For example, ``BBCode [color=green]test[/color]`` would render the word "test" with
  36. a green color.
  37. .. image:: img/bbcode_in_richtextlabel_basic_example.webp
  38. Most BBCodes consist of 3 parts: the opening tag, the content and the closing
  39. tag. The opening tag delimits the start of the formatted part, and can also
  40. carry some configuration options. Some opening tags, like the ``color`` one
  41. shown above, also require a value to work. Other opening tags may accept
  42. multiple options (separated by spaces within the opening tag). The closing tag
  43. delimits the end of the formatted part. In some cases, both the closing tag and
  44. the content can be omitted.
  45. Unlike BBCode in HTML, leading/trailing whitespace is not removed by a
  46. RichTextLabel upon display. Duplicate spaces are also displayed as-is in the
  47. final output. This means that when displaying a code block in a RichTextLabel,
  48. you don't need to use a preformatted text tag.
  49. .. code-block:: none
  50. [tag]content[/tag]
  51. [tag=value]content[/tag]
  52. [tag option1=value1 option2=value2]content[/tag]
  53. [tag][/tag]
  54. [tag]
  55. .. note::
  56. RichTextLabel doesn't support entangled BBCode tags. For example, instead of
  57. using:
  58. ::
  59. [b]bold[i]bold italic[/b]italic[/i]
  60. Use:
  61. ::
  62. [b]bold[i]bold italic[/i][/b][i]italic[/i]
  63. .. _doc_bbcode_in_richtextlabel_handling_user_input_safely:
  64. Handling user input safely
  65. --------------------------
  66. In a scenario where users may freely input text (such as chat in a multiplayer
  67. game), you should make sure users cannot use arbitrary BBCode tags that will be
  68. parsed by RichTextLabel. This is to avoid inappropriate use of formatting, which
  69. can be problematic if ``[url]`` tags are handled by your RichTextLabel (as players
  70. may be able to create clickable links to phishing sites or similar).
  71. Using RichTextLabel's ``[lb]`` and/or ``[rb]`` tags, we can replace the opening and/or
  72. closing brackets of any BBCode tag in a message with those escaped tags. This
  73. prevents users from using BBCode that will be parsed as tags – instead, the
  74. BBCode will be displayed as text.
  75. .. figure:: img/bbcode_in_richtextlabel_escaping_user_input.webp
  76. :align: center
  77. :alt: Example of unescaped user input resulting in BBCode injection (2nd line) and escaped user input (3rd line)
  78. Example of unescaped user input resulting in BBCode injection (2nd line) and escaped user input (3rd line)
  79. The above image was created using the following script:
  80. ::
  81. extends RichTextLabel
  82. func _ready():
  83. append_chat_line("Player 1", "Hello world!")
  84. append_chat_line("Player 2", "Hello [color=red]BBCode injection[/color] (no escaping)!")
  85. append_chat_line_escaped("Player 2", "Hello [color=red]BBCode injection[/color] (with escaping)!")
  86. # Returns escaped BBCode that won't be parsed by RichTextLabel as tags.
  87. func escape_bbcode(bbcode_text):
  88. # We only need to replace opening brackets to prevent tags from being parsed.
  89. return bbcode_text.replace("[", "[lb]")
  90. # Appends the user's message as-is, without escaping. This is dangerous!
  91. func append_chat_line(username, message):
  92. append_text("%s: [color=green]%s[/color]\n" % [username, message])
  93. # Appends the user's message with escaping.
  94. # Remember to escape both the player name and message contents.
  95. func append_chat_line_escaped(username, message):
  96. append_text("%s: [color=green]%s[/color]\n" % [escape_bbcode(username), escape_bbcode(message)])
  97. Stripping BBCode tags
  98. ---------------------
  99. For certain use cases, it can be desired to remove BBCode tags from the string.
  100. This is useful when displaying the RichTextLabel's text in another Control that
  101. does not support BBCode (such as a tooltip):
  102. .. code::
  103. extends RichTextLabel
  104. func _ready():
  105. var regex = RegEx.new()
  106. regex.compile("\\[.*?\\]")
  107. var text_without_tags = regex.sub(text, "", true)
  108. # `text_without_tags` contains the text with all BBCode tags removed.
  109. .. note::
  110. Removing BBCode tags entirely isn't advised for user input, as it can
  111. modify the displayed text without users understanding why part of their
  112. message was removed.
  113. :ref:`Escaping user input <doc_bbcode_in_richtextlabel_handling_user_input_safely>`
  114. should be preferred instead.
  115. Performance
  116. -----------
  117. In most cases, you can use BBCode directly as-is since text formatting is rarely
  118. a heavy task. However, with particularly large RichTextLabels (such as console
  119. logs spanning thousands of lines), you may encounter stuttering during gameplay
  120. when the RichTextLabel's text is updated.
  121. There are several ways to alleviate this:
  122. - Use the ``append_text()`` function instead of appending to the ``text``
  123. property. This function will only parse BBCode for the added text, rather than
  124. parsing BBCode from the entire ``text`` property.
  125. - Use ``push_[tag]()`` and ``pop()`` functions to add tags to RichTextLabel instead of
  126. using BBCode.
  127. - Enable the **Threading > Threaded** property in RichTextLabel. This won't
  128. speed up processing, but it will prevent the main thread from blocking, which
  129. avoids stuttering during gameplay. Only enable threading if it's actually
  130. needed in your project, as threading has some overhead.
  131. .. _doc_bbcode_in_richtextlabel_use_functions:
  132. Using push_[tag]() and pop() functions instead of BBCode
  133. --------------------------------------------------------
  134. If you don't want to use BBCode for performance reasons, you can use functions
  135. provided by RichTextLabel to create formatting tags without writing BBCode in
  136. the text.
  137. Every BBCode tag (including effects) has a ``push_[tag]()`` function (where
  138. ``[tag]`` is the tag's name). There are also a few convenience functions
  139. available, such as ``push_bold_italics()`` that combines both ``push_bold()``
  140. and ``push_italics()`` into a single tag. See the
  141. :ref:`RichTextLabel class reference <class_RichTextLabel>` for a complete list of
  142. ``push_[tag]()`` functions.
  143. The ``pop()`` function is used to end *any* tag. Since BBCode is a tag *stack*,
  144. using ``pop()`` will close the most recently started tags first.
  145. The following script will result in the same visual output as using
  146. ``BBCode [color=green]test [i]example[/i][/color]``:
  147. ::
  148. extends RichTextLabel
  149. func _ready():
  150. append_text("BBCode ") # Trailing space separates words from each other.
  151. push_color(Color.GREEN)
  152. append_text("test ") # Trailing space separates words from each other.
  153. push_italics()
  154. append_text("example")
  155. pop() # Ends the tag opened by `push_italics()`.
  156. pop() # Ends the tag opened by `push_color()`.
  157. .. warning::
  158. Do **not** set the ``text`` property directly when using formatting functions.
  159. Appending to the ``text`` property will erase all modifications made to the
  160. RichTextLabel using the ``append_text()``, ``push_[tag]()`` and ``pop()``
  161. functions.
  162. Reference
  163. ---------
  164. .. seealso::
  165. *Some* of these BBCode tags can be used in tooltips for ``@export`` script
  166. variables as well as in the XML source of the class reference. For more
  167. information, see :ref:`Class reference BBCode <doc_class_reference_bbcode>`.
  168. .. list-table::
  169. :class: wrap-normal
  170. :width: 100%
  171. :widths: 60 40
  172. * - Tag
  173. - Example
  174. * - | **b**
  175. | Makes ``{text}`` use the bold (or bold italics) font of ``RichTextLabel``.
  176. - ``[b]{text}[/b]``
  177. * - | **i**
  178. | Makes ``{text}`` use the italics (or bold italics) font of ``RichTextLabel``.
  179. - ``[i]{text}[/i]``
  180. * - | **u**
  181. | Makes ``{text}`` underlined.
  182. - ``[u]{text}[/u]``
  183. * - | **s**
  184. | Makes ``{text}`` strikethrough.
  185. - ``[s]{text}[/s]``
  186. * - | **code**
  187. | Makes ``{text}`` use the mono font of ``RichTextLabel``.
  188. - ``[code]{text}[/code]``
  189. * - | **char**
  190. | Adds Unicode character with hexadecimal UTF-32 ``{codepoint}``.
  191. - ``[char={codepoint}]``
  192. * - | **p**
  193. | Adds new paragraph with ``{text}``. Supports configuration options,
  194. see :ref:`doc_bbcode_in_richtextlabel_paragraph_options`.
  195. - | ``[p]{text}[/p]``
  196. | ``[p {options}]{text}[/p]``
  197. * - | **center**
  198. | Makes ``{text}`` horizontally centered.
  199. | Same as ``[p align=center]``.
  200. - ``[center]{text}[/center]``
  201. * - | **left**
  202. | Makes ``{text}`` horizontally left-aligned.
  203. | Same as ``[p align=left]``.
  204. - ``[left]{text}[/left]``
  205. * - | **right**
  206. | Makes ``{text}`` horizontally right-aligned.
  207. | Same as ``[p align=right]``.
  208. - ``[right]{text}[/right]``
  209. * - | **fill**
  210. | Makes ``{text}`` fill the full width of ``RichTextLabel``.
  211. | Same as ``[p align=fill]``.
  212. - ``[fill]{text}[/fill]``
  213. * - | **indent**
  214. | Indents ``{text}`` once.
  215. The indentation width is the same as with ``[ul]`` or ``[ol]``, but without a bullet point.
  216. - ``[indent]{text}[/indent]``
  217. * - | **url**
  218. | Creates a hyperlink (underlined and clickable text). Can contain optional
  219. ``{text}`` or display ``{link}`` as is.
  220. | **Must be handled with the "meta_clicked" signal to have an effect,** see :ref:`doc_bbcode_in_richtextlabel_handling_url_tag_clicks`.
  221. - | ``[url]{link}[/url]``
  222. | ``[url={link}]{text}[/url]``
  223. * - | **hint**
  224. | Creates a tooltip hint that is displayed when hovering the text with the mouse.
  225. Tooltip text should not be quoted (quotes will appear as-is in the tooltip otherwise).
  226. - | ``[hint={tooltip text displayed on hover}]{text}[/hint]``
  227. * - | **img**
  228. | Inserts an image from the ``{path}`` (can be any valid :ref:`class_Texture2D` resource).
  229. | If ``{width}`` is provided, the image will try to fit that width maintaining
  230. the aspect ratio.
  231. | If both ``{width}`` and ``{height}`` are provided, the image will be scaled
  232. to that size.
  233. | Add ``%`` to the end of ``{width}`` or ``{height}`` value to specify it as percentages of the control width instead of pixels.
  234. | If ``{valign}`` configuration is provided, the image will try to align to the
  235. surrounding text, see :ref:`doc_bbcode_in_richtextlabel_image_and_table_alignment`.
  236. | Supports configuration options, see :ref:`doc_bbcode_in_richtextlabel_image_options`.
  237. - | ``[img]{path}[/img]``
  238. | ``[img={width}]{path}[/img]``
  239. | ``[img={width}x{height}]{path}[/img]``
  240. | ``[img={valign}]{path}[/img]``
  241. | ``[img {options}]{path}[/img]``
  242. * - | **font**
  243. | Makes ``{text}`` use a font resource from the ``{path}``.
  244. | Supports configuration options, see :ref:`doc_bbcode_in_richtextlabel_font_options`.
  245. - | ``[font={path}]{text}[/font]``
  246. | ``[font {options}]{text}[/font]``
  247. * - | **font_size**
  248. | Use custom font size for ``{text}``.
  249. - ``[font_size={size}]{text}[/font_size]``
  250. * - | **dropcap**
  251. | Use a different font size and color for ``{text}``, while making the tag's contents
  252. span multiple lines if it's large enough.
  253. | A `drop cap <https://www.computerhope.com/jargon/d/dropcap.htm>`__ is typically one
  254. uppercase character, but ``[dropcap]`` supports containing multiple characters.
  255. ``margins`` values are comma-separated and can be positive, zero or negative.
  256. Negative top and bottom margins are particularly useful to allow the rest of
  257. the paragraph to display below the dropcap.
  258. - ``[dropcap font={font} font_size={size} color={color} outline_size={size} outline_color={color} margins={left},{top},{right},{bottom}]{text}[/dropcap]``
  259. * - | **opentype_features**
  260. | Enables custom OpenType font features for ``{text}``. Features must be provided as
  261. a comma-separated ``{list}``.
  262. - | ``[opentype_features={list}]``
  263. | ``{text}``
  264. | ``[/opentype_features]``
  265. * - | **lang**
  266. | Overrides the language for ``{text}`` that is set by the **BiDi > Language** property
  267. in :ref:`class_RichTextLabel`. ``{code}`` must be an ISO :ref:`language code <doc_locales>`.
  268. This can be used to enforce the use of a specific script for a language without
  269. starting a new paragraph. Some font files may contain script-specific substitutes,
  270. in which case they will be used.
  271. - ``[lang={code}]{text}[/lang]``
  272. * - | **color**
  273. | Changes the color of ``{text}``. Color must be provided by a common name (see
  274. :ref:`doc_bbcode_in_richtextlabel_named_colors`) or using the HEX format (e.g.
  275. ``#ff00ff``, see :ref:`doc_bbcode_in_richtextlabel_hex_colors`).
  276. - ``[color={code/name}]{text}[/color]``
  277. * - | **bgcolor**
  278. | Draws the color behind ``{text}``. This can be used to highlight text.
  279. Accepts same values as the ``color`` tag.
  280. - ``[bgcolor={code/name}]{text}[/bgcolor]``
  281. * - | **fgcolor**
  282. | Draws the color in front of ``{text}``. This can be used to "redact" text by using
  283. an opaque foreground color. Accepts same values as the ``color`` tag.
  284. - ``[fgcolor={code/name}]{text}[/fgcolor]``
  285. * - | **outline_size**
  286. | Use custom font outline size for ``{text}``.
  287. - | ``[outline_size={size}]``
  288. | ``{text}``
  289. | ``[/outline_size]``
  290. * - | **outline_color**
  291. | Use custom outline color for ``{text}``. Accepts same values as the ``color`` tag.
  292. - | ``[outline_color={code/name}]``
  293. | ``{text}``
  294. | ``[/outline_color]``
  295. * - | **table**
  296. | Creates a table with the ``{number}`` of columns. Use the ``cell`` tag to define
  297. table cells.
  298. | If ``{valign}`` configuration is provided, the table will try to align to the
  299. surrounding text, see :ref:`doc_bbcode_in_richtextlabel_image_and_table_alignment`.
  300. | If baseline alignment is used, the table is aligned to the baseline of the row with index ``{alignment_row}`` (zero-based).
  301. - | ``[table={number}]{cells}[/table]``
  302. | ``[table={number},{valign}]{cells}[/table]``
  303. | ``[table={number},{valign},{alignment_row}]{cells}[/table]``
  304. * - | **cell**
  305. | Adds a cell with ``{text}`` to the table.
  306. | If ``{ratio}`` is provided, the cell will try to expand to that value proportionally
  307. to other cells and their ratio values.
  308. | Supports configuration options, see :ref:`doc_bbcode_in_richtextlabel_cell_options`.
  309. - | ``[cell]{text}[/cell]``
  310. | ``[cell={ratio}]{text}[/cell]``
  311. | ``[cell {options}]{text}[/cell]``
  312. * - | **ul**
  313. | Adds an unordered list. List ``{items}`` must be provided by putting one item per
  314. line of text.
  315. | The bullet point can be customized using the ``{bullet}`` parameter,
  316. see :ref:`doc_bbcode_in_richtextlabel_unordered_list_bullet`.
  317. - | ``[ul]{items}[/ul]``
  318. | ``[ul bullet={bullet}]{items}[/ul]``
  319. * - | **ol**
  320. | Adds an ordered (numbered) list of the given ``{type}`` (see :ref:`doc_bbcode_in_richtextlabel_list_types`).
  321. List ``{items}`` must be provided by putting one item per line of text.
  322. - ``[ol type={type}]{items}[/ol]``
  323. * - | **lb**, **rb**
  324. | Adds ``[`` and ``]`` respectively. Allows escaping BBCode markup.
  325. | These are self-closing tags, which means you do not need to close them
  326. (and there is no ``[/lb]`` or ``[/rb]`` closing tag).
  327. - | ``[lb]b[rb]text[lb]/b[rb]`` will display as ``[b]text[/b]``.
  328. * - | Several Unicode control characters can be added using their own self-closing tags.
  329. | This can result in easier maintenance compared to pasting those
  330. | control characters directly in the text.
  331. - | ``[lrm]`` (left-to-right mark), ``[rlm]`` (right-to-left mark), ``[lre]`` (left-to-right embedding),
  332. | ``[rle]`` (right-to-left embedding), ``[lro]`` (left-to-right override), ``[rlo]`` (right-to-left override),
  333. | ``[pdf]`` (pop directional formatting), ``[alm]`` (Arabic letter mark), ``[lri]`` (left-to-right isolate),
  334. | ``[rli]`` (right-to-left isolate), ``[fsi]`` (first strong isolate), ``[pdi]`` (pop directional isolate),
  335. | ``[zwj]`` (zero-width joiner), ``[zwnj]`` (zero-width non-joiner), ``[wj]`` (word joiner),
  336. | ``[shy]`` (soft hyphen)
  337. .. note::
  338. Tags for bold (``[b]``) and italics (``[i]``) formatting work best if the
  339. appropriate custom fonts are set up in the RichTextLabelNode's theme
  340. overrides. If no custom bold or italic fonts are defined,
  341. `faux bold and italic fonts <https://fonts.google.com/knowledge/glossary/faux_fake_pseudo_synthesized>`__
  342. will be generated by Godot. These fonts rarely look good in comparison to hand-made bold/italic font variants.
  343. The monospaced (``[code]``) tag **only** works if a custom font is set up in
  344. the RichTextLabel node's theme overrides. Otherwise, monospaced text will use the regular font.
  345. There are no BBCode tags to control vertical centering of text yet.
  346. Options can be skipped for all tags.
  347. .. _doc_bbcode_in_richtextlabel_paragraph_options:
  348. Paragraph options
  349. ~~~~~~~~~~~~~~~~~
  350. - **align**
  351. +-----------+----------------------------------------------------------------------------------------+
  352. | `Values` | ``left`` (or ``l``), ``center`` (or ``c``), ``right`` (or ``r``), ``fill`` (or ``f``) |
  353. +-----------+----------------------------------------------------------------------------------------+
  354. | `Default` | ``left`` |
  355. +-----------+----------------------------------------------------------------------------------------+
  356. Text horizontal alignment.
  357. - **bidi_override**, **st**
  358. +-----------+--------------------------------------------------------------------------------------------------------------+
  359. | `Values` | ``default`` (of ``d``), ``uri`` (or ``u``), ``file`` (or ``f``), ``email`` (or ``e``), ``list`` (or ``l``), |
  360. | | ``none`` (or ``n``), ``custom`` (or ``c``) |
  361. +-----------+--------------------------------------------------------------------------------------------------------------+
  362. | `Default` | ``default`` |
  363. +-----------+--------------------------------------------------------------------------------------------------------------+
  364. Structured text override.
  365. - **justification_flags**, **jst**
  366. +-----------+--------------------------------------------------------------------------------------------------------+
  367. | `Values` | Comma-separated list of the following values: |
  368. | | ``kashida`` (or ``k``), ``word`` (or ``w``), ``trim`` (or ``tr``), ``after_last_tab`` (or ``lt``), |
  369. | | ``skip_last`` (or ``sl``), ``skip_last_with_chars`` (or ``sv``), ``do_not_skip_single`` (or ``ns``). |
  370. +-----------+--------------------------------------------------------------------------------------------------------+
  371. | `Default` | ``word,kashida,skip_last,do_not_skip_single`` |
  372. +-----------+--------------------------------------------------------------------------------------------------------+
  373. Justification (fill alignment) option. See :ref:`class_TextServer` for more details.
  374. - **direction**, **dir**
  375. +-----------+-----------------------------------------------------------------+
  376. | `Values` | ``ltr`` (or ``l``), ``rtl`` (or ``r``), ``auto`` (or ``a``) |
  377. +-----------+-----------------------------------------------------------------+
  378. | `Default` | Inherit |
  379. +-----------+-----------------------------------------------------------------+
  380. Base BiDi direction.
  381. - **language**, **lang**
  382. +-----------+--------------------------------------------+
  383. | `Values` | ISO language codes. See :ref:`doc_locales` |
  384. +-----------+--------------------------------------------+
  385. | `Default` | Inherit |
  386. +-----------+--------------------------------------------+
  387. Locale override. Some font files may contain script-specific substitutes, in which case they will be used.
  388. - **tab_stops**
  389. +-----------+----------------------------------------------------+
  390. | `Values` | List of floating-point numbers, e.g. ``10.0,30.0`` |
  391. +-----------+----------------------------------------------------+
  392. | `Default` | Width of the space character in the font |
  393. +-----------+----------------------------------------------------+
  394. Overrides the horizontal offsets for each tab character. When the end of the
  395. list is reached, the tab stops will loop over. For example, if you set
  396. ``tab_stops`` to ``10.0,30.0``, the first tab will be at ``10`` pixels, the
  397. second tab will be at ``10 + 30 = 40`` pixels, and the third tab will be at
  398. ``10 + 30 + 10 = 50`` pixels from the origin of the RichTextLabel.
  399. .. _doc_bbcode_in_richtextlabel_handling_url_tag_clicks:
  400. Handling ``[url]`` tag clicks
  401. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  402. By default, ``[url]`` tags do nothing when clicked. This is to allow flexible use
  403. of ``[url]`` tags rather than limiting them to opening URLs in a web browser.
  404. To handle clicked ``[url]`` tags, connect the ``RichTextLabel`` node's
  405. :ref:`meta_clicked <class_RichTextLabel_signal_meta_clicked>` signal to a script function.
  406. For example, the following method can be connected to ``meta_clicked`` to open
  407. clicked URLs using the user's default web browser::
  408. # This assumes RichTextLabel's `meta_clicked` signal was connected to
  409. # the function below using the signal connection dialog.
  410. func _richtextlabel_on_meta_clicked(meta):
  411. # `meta` is not guaranteed to be a String, so convert it to a String
  412. # to avoid script errors at runtime.
  413. OS.shell_open(str(meta))
  414. For more advanced use cases, it's also possible to store JSON in an ``[url]``
  415. tag's option and parse it in the function that handles the ``meta_clicked`` signal.
  416. For example:
  417. .. code-block:: none
  418. [url={"example": "value"}]JSON[/url]
  419. .. _doc_bbcode_in_richtextlabel_image_options:
  420. Image options
  421. ~~~~~~~~~~~~~
  422. - **color**
  423. +-----------+--------------------------------------------+
  424. | `Values` | Color name or color in HEX format |
  425. +-----------+--------------------------------------------+
  426. | `Default` | Inherit |
  427. +-----------+--------------------------------------------+
  428. Color tint of the image (modulation).
  429. - **height**
  430. +-----------+--------------------------------------------+
  431. | `Values` | Integer number |
  432. +-----------+--------------------------------------------+
  433. | `Default` | Inherit |
  434. +-----------+--------------------------------------------+
  435. Target height of the image in pixels, add ``%`` to the end of value to specify it as percentages of the control width instead of pixels.
  436. - **width**
  437. +-----------+--------------------------------------------+
  438. | `Values` | Integer number |
  439. +-----------+--------------------------------------------+
  440. | `Default` | Inherit |
  441. +-----------+--------------------------------------------+
  442. Target width of the image, add ``%`` to the end of value to specify it as percentages of the control width instead of pixels.
  443. - **region**
  444. +-----------+--------------------------------------------+
  445. | `Values` | x,y,width,height in pixels |
  446. +-----------+--------------------------------------------+
  447. | `Default` | Inherit |
  448. +-----------+--------------------------------------------+
  449. Region rect of the image. This can be used to display a single image from a spritesheet.
  450. - **pad**
  451. +-----------+--------------------------------------------+
  452. | `Values` | ``false``, ``true`` |
  453. +-----------+--------------------------------------------+
  454. | `Default` | ``false`` |
  455. +-----------+--------------------------------------------+
  456. If set to ``true``, and the image is smaller than the size specified by ``width`` and ``height``, the image padding is added to match the size instead of upscaling.
  457. - **tooltip**
  458. +-----------+--------------------------------------------+
  459. | `Values` | String |
  460. +-----------+--------------------------------------------+
  461. | `Default` | |
  462. +-----------+--------------------------------------------+
  463. Image tooltip.
  464. .. _doc_bbcode_in_richtextlabel_image_and_table_alignment:
  465. Image and table vertical alignment
  466. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  467. When a vertical alignment value is provided with the ``[img]`` or ``[table]`` tag
  468. the image/table will try to align itself against the surrounding text. Alignment is
  469. performed using a vertical point of the image and a vertical point of the text.
  470. There are 3 possible points on the image (``top``, ``center``, and ``bottom``) and 4
  471. possible points on the text and table (``top``, ``center``, ``baseline``, and ``bottom``),
  472. which can be used in any combination.
  473. To specify both points, use their full or short names as a value of the image/table tag:
  474. .. code-block:: none
  475. text [img=top,bottom]...[/img] text
  476. text [img=center,center]...[/img] text
  477. .. image:: img/bbcode_in_richtextlabel_image_align.webp
  478. .. code-block:: none
  479. text [table=3,center]...[/table] text # Center to center.
  480. text [table=3,top,bottom]...[/table] text # Top of the table to the bottom of text.
  481. text [table=3,baseline,baseline,1]...[/table] text # Baseline of the second row (rows use zero-based indexing) to the baseline of text.
  482. .. image:: img/bbcode_in_richtextlabel_table_align.webp
  483. You can also specify just one value (``top``, ``center``, or ``bottom``) to make
  484. use of a corresponding preset (``top-top``, ``center-center``, and ``bottom-bottom``
  485. respectively).
  486. Short names for the values are ``t`` (``top``), ``c`` (``center``), ``l`` (``baseline``),
  487. and ``b`` (``bottom``).
  488. .. _doc_bbcode_in_richtextlabel_font_options:
  489. Font options
  490. ~~~~~~~~~~~~
  491. - **name**, **n**
  492. +-----------+--------------------------------------------+
  493. | `Values` | A valid Font resource path. |
  494. +-----------+--------------------------------------------+
  495. | `Default` | Inherit |
  496. +-----------+--------------------------------------------+
  497. Font resource path.
  498. - **size**, **s**
  499. +-----------+--------------------------------------------+
  500. | `Values` | Number in pixels. |
  501. +-----------+--------------------------------------------+
  502. | `Default` | Inherit |
  503. +-----------+--------------------------------------------+
  504. Custom font size.
  505. - **glyph_spacing**, **gl**
  506. +-----------+--------------------------------------------+
  507. | `Values` | Number in pixels. |
  508. +-----------+--------------------------------------------+
  509. | `Default` | Inherit |
  510. +-----------+--------------------------------------------+
  511. Extra spacing for each glyph.
  512. - **space_spacing**, **sp**
  513. +-----------+--------------------------------------------+
  514. | `Values` | Number in pixels. |
  515. +-----------+--------------------------------------------+
  516. | `Default` | Inherit |
  517. +-----------+--------------------------------------------+
  518. Extra spacing for the space character.
  519. - **top_spacing**, **top**
  520. +-----------+--------------------------------------------+
  521. | `Values` | Number in pixels. |
  522. +-----------+--------------------------------------------+
  523. | `Default` | Inherit |
  524. +-----------+--------------------------------------------+
  525. Extra spacing at the top of the line.
  526. - **bottom_spacing**, **bt**
  527. +-----------+--------------------------------------------+
  528. | `Values` | Number in pixels. |
  529. +-----------+--------------------------------------------+
  530. | `Default` | Inherit |
  531. +-----------+--------------------------------------------+
  532. Extra spacing at the bottom of the line.
  533. - **embolden**, **emb**
  534. +-----------+--------------------------------------------+
  535. | `Values` | Floating-point number. |
  536. +-----------+--------------------------------------------+
  537. | `Default` | ``0.0`` |
  538. +-----------+--------------------------------------------+
  539. Font embolden strength, if it is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
  540. - **face_index**, **fi**
  541. +-----------+--------------------------------------------+
  542. | `Values` | Integer number. |
  543. +-----------+--------------------------------------------+
  544. | `Default` | ``0`` |
  545. +-----------+--------------------------------------------+
  546. An active face index in the TrueType / OpenType collection.
  547. - **slant**, **sln**
  548. +-----------+--------------------------------------------+
  549. | `Values` | Floating-point number. |
  550. +-----------+--------------------------------------------+
  551. | `Default` | ``0.0`` |
  552. +-----------+--------------------------------------------+
  553. Font slant strength, positive values slant glyphs to the right. Negative values to the left.
  554. - **opentype_variation**, **otv**
  555. +-----------+------------------------------------------------------+
  556. | `Values` | Comma-separated list of the OpenType variation tags. |
  557. +-----------+------------------------------------------------------+
  558. | `Default` | |
  559. +-----------+------------------------------------------------------+
  560. Font OpenType variation coordinates. See `OpenType variation tags <https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg>`__.
  561. Note: The value should be enclosed in ``"`` to allow using ``=`` inside it:
  562. .. code-block:: none
  563. [font otv="wght=200,wdth=400"] # Sets variable font weight and width.
  564. - **opentype_features**, **otf**
  565. +-----------+----------------------------------------------------+
  566. | `Values` | Comma-separated list of the OpenType feature tags. |
  567. +-----------+----------------------------------------------------+
  568. | `Default` | |
  569. +-----------+----------------------------------------------------+
  570. Font OpenType features. See `OpenType features tags <https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags>`__.
  571. Note: The value should be enclosed in ``"`` to allow using ``=`` inside it:
  572. .. code-block:: none
  573. [font otf="calt=0,zero=1"] # Disable contextual alternates, enable slashed zero.
  574. .. _doc_bbcode_in_richtextlabel_named_colors:
  575. Named colors
  576. ~~~~~~~~~~~~
  577. For tags that allow specifying a color by name, you can use names of the constants from
  578. the built-in :ref:`class_Color` class. Named classes can be specified in a number of
  579. styles using different casings: ``DARK_RED``, ``DarkRed``, and ``darkred`` will give
  580. the same exact result.
  581. See this image for a list of color constants:
  582. .. image:: /img/color_constants.png
  583. `View at full size <https://raw.githubusercontent.com/godotengine/godot-docs/master/img/color_constants.png>`__
  584. .. _doc_bbcode_in_richtextlabel_hex_colors:
  585. Hexadecimal color codes
  586. ~~~~~~~~~~~~~~~~~~~~~~~
  587. For opaque RGB colors, any valid 6-digit hexadecimal code is supported, e.g.
  588. ``[color=#ffffff]white[/color]``. Shorthand RGB color codes such as ``#6f2``
  589. (equivalent to ``#66ff22``) are also supported.
  590. For transparent RGB colors, any RGBA 8-digit hexadecimal code can be used,
  591. e.g. ``[color=#ffffff88]translucent white[/color]``. Note that the alpha channel
  592. is the **last** component of the color code, not the first one. Short RGBA
  593. color codes such as ``#6f28`` (equivalent to ``#66ff2288``) are supported as well.
  594. .. _doc_bbcode_in_richtextlabel_cell_options:
  595. Cell options
  596. ~~~~~~~~~~~~
  597. - **expand**
  598. +-----------+--------------------------------------------+
  599. | `Values` | Integer number |
  600. +-----------+--------------------------------------------+
  601. | `Default` | 1 |
  602. +-----------+--------------------------------------------+
  603. Cell expansion ratio. This defines which cells will try to expand to
  604. proportionally to other cells and their expansion ratios.
  605. - **border**
  606. +-----------+--------------------------------------------+
  607. | `Values` | Color name or color in HEX format |
  608. +-----------+--------------------------------------------+
  609. | `Default` | Inherit |
  610. +-----------+--------------------------------------------+
  611. Cell border color.
  612. - **bg**
  613. +-----------+--------------------------------------------+
  614. | `Values` | Color name or color in HEX format |
  615. +-----------+--------------------------------------------+
  616. | `Default` | Inherit |
  617. +-----------+--------------------------------------------+
  618. Cell background color. For alternating odd/even row backgrounds,
  619. you can use ``bg=odd_color,even_color``.
  620. - **padding**
  621. +-----------+--------------------------------------------+
  622. | `Values` | 4 comma-separated floating-point numbers |
  623. +-----------+--------------------------------------------+
  624. | `Default` | 0, 0, 0, 0 |
  625. +-----------+--------------------------------------------+
  626. Left, top, right, and bottom cell padding.
  627. .. _doc_bbcode_in_richtextlabel_unordered_list_bullet:
  628. Unordered list bullet
  629. ~~~~~~~~~~~~~~~~~~~~~
  630. By default, the ``[ul]`` tag uses the ``U+2022`` "Bullet" Unicode glyph as the
  631. bullet character. This behavior is similar to web browsers. The bullet character
  632. can be customized using ``[ul bullet={bullet}]``. If provided, this ``{bullet}``
  633. parameter must be a *single* character with no enclosing quotes (for example,
  634. ``[bullet=*]``). Additional characters are ignored. The bullet character's
  635. width does not affect the list's formatting.
  636. See `Bullet (typography) on Wikipedia <https://en.wikipedia.org/wiki/Bullet_(typography)>`__
  637. for a list of common bullet characters that you can paste directly in the ``bullet`` parameter.
  638. .. _doc_bbcode_in_richtextlabel_list_types:
  639. Ordered list types
  640. ~~~~~~~~~~~~~~~~~~
  641. Ordered lists can be used to automatically mark items with numbers
  642. or letters in ascending order. This tag supports the following
  643. type options:
  644. - ``1`` - Numbers, using language specific numbering system if possible.
  645. - ``a``, ``A`` - Lower and upper case Latin letters.
  646. - ``i``, ``I`` - Lower and upper case Roman numerals.
  647. Text effects
  648. ------------
  649. BBCode can also be used to create different text effects that can optionally be
  650. animated. Five customizable effects are provided out of the box, and you can
  651. easily create your own. By default, animated effects will pause
  652. :ref:`when the SceneTree is paused <doc_pausing_games>`. You can change this
  653. behavior by adjusting the RichTextLabel's **Process > Mode** property.
  654. All examples below mention the default values for options in the listed tag format.
  655. .. note::
  656. Text effects that move characters' position may result in characters being
  657. clipped by the RichTextLabel node bounds.
  658. You can resolve this by disabling **Control > Layout > Clip Contents** in
  659. the inspector after selecting the RichTextLabel node, or ensuring there is
  660. enough margin added around the text by using line breaks above and below the
  661. line using the effect.
  662. Pulse
  663. ~~~~~
  664. .. image:: img/bbcode_in_richtextlabel_effect_pulse.webp
  665. Pulse creates an animated pulsing effect that multiplies each character's
  666. opacity and color. It can be used to bring attention to specific text. Its tag
  667. format is ``[pulse freq=1.0 color=#ffffff40 ease=-2.0]{text}[/pulse]``.
  668. ``freq`` controls the frequency of the half-pulsing cycle (higher is faster). A
  669. full pulsing cycle takes ``2 * (1.0 / freq)`` seconds. ``color`` is the target
  670. color multiplier for blinking. The default mostly fades out text, but not
  671. entirely. ``ease`` is the easing function exponent to use. Negative values
  672. provide in-out easing, which is why the default is ``-2.0``.
  673. Wave
  674. ~~~~
  675. .. image:: img/bbcode_in_richtextlabel_effect_wave.webp
  676. Wave makes the text go up and down. Its tag format is
  677. ``[wave amp=50.0 freq=5.0 connected=1]{text}[/wave]``.
  678. ``amp`` controls how high and low the effect goes, and ``freq`` controls how
  679. fast the text goes up and down. A ``freq`` value of ``0`` will result in no
  680. visible waves, and negative ``freq`` values won't display any waves either. If
  681. ``connected`` is ``1`` (default), glyphs with ligatures will be moved together.
  682. If ``connected`` is ``0``, each glyph is moved individually even if they are
  683. joined by ligatures. This can work around certain rendering issues with font
  684. ligatures.
  685. Tornado
  686. ~~~~~~~
  687. .. image:: img/bbcode_in_richtextlabel_effect_tornado.webp
  688. Tornado makes the text move around in a circle. Its tag format is
  689. ``[tornado radius=10.0 freq=1.0 connected=1]{text}[/tornado]``.
  690. ``radius`` is the radius of the circle that controls the offset, ``freq`` is how
  691. fast the text moves in a circle. A ``freq`` value of ``0`` will pause the
  692. animation, while negative ``freq`` will play the animation backwards. If
  693. ``connected`` is ``1`` (default), glyphs with ligatures will be moved together.
  694. If ``connected`` is ``0``, each glyph is moved individually even if they are
  695. joined by ligatures. This can work around certain rendering issues with font
  696. ligatures.
  697. Shake
  698. ~~~~~
  699. .. image:: img/bbcode_in_richtextlabel_effect_shake.webp
  700. Shake makes the text shake. Its tag format is
  701. ``[shake rate=20.0 level=5 connected=1]{text}[/shake]``.
  702. ``rate`` controls how fast the text shakes, ``level`` controls how far the text
  703. is offset from the origin. If ``connected`` is ``1`` (default), glyphs with
  704. ligatures will be moved together. If ``connected`` is ``0``, each glyph is moved
  705. individually even if they are joined by ligatures. This can work around certain
  706. rendering issues with font ligatures.
  707. Fade
  708. ~~~~
  709. .. image:: img/bbcode_in_richtextlabel_effect_fade.webp
  710. Fade creates a static fade effect that multiplies each character's opacity.
  711. Its tag format is ``[fade start=4 length=14]{text}[/fade]``.
  712. ``start`` controls the starting position of the falloff relative to where the fade
  713. command is inserted, ``length`` controls over how many characters should the fade
  714. out take place.
  715. Rainbow
  716. ~~~~~~~
  717. .. image:: img/bbcode_in_richtextlabel_effect_rainbow.webp
  718. Rainbow gives the text a rainbow color that changes over time. Its tag format is
  719. ``[rainbow freq=1.0 sat=0.8 val=0.8]{text}[/rainbow]``.
  720. ``freq`` is the number of full rainbow cycles per second, ``sat`` is the
  721. saturation of the rainbow, ``val`` is the value of the rainbow. A ``freq`` value
  722. of ``0`` will pause the animation, while negative ``freq`` will play the
  723. animation backwards.
  724. Font outlines are *not* affected by the rainbow effect (they keep their original color).
  725. Existing font colors are overridden by the rainbow effect. However, CanvasItem's
  726. **Modulate** and **Self Modulate** properties will affect how the rainbow effect
  727. looks, as modulation multiplies its final colors.
  728. Custom BBCode tags and text effects
  729. -----------------------------------
  730. You can extend the :ref:`class_RichTextEffect` resource type to create your own custom
  731. BBCode tags. Create a new script file that extends the :ref:`class_RichTextEffect` resource type
  732. and give the script a ``class_name`` so that the effect can be selected in the inspector.
  733. Add the ``@tool`` annotation to your GDScript file if you wish to have these custom effects
  734. run within the editor itself. The RichTextLabel does not need to have a script attached,
  735. nor does it need to be running in ``tool`` mode. The new effect can be registered in
  736. the Inspector by adding it to the **Markup > Custom Effects** array, or in code with the
  737. :ref:`install_effect() <class_RichTextLabel_method_install_effect>` method:
  738. .. figure:: img/bbcode_in_richtextlabel_selecting_custom_richtexteffect.webp
  739. :align: center
  740. :alt: Selecting a custom RichTextEffect after saving a script that extends RichTextEffect with a ``class_name``
  741. Selecting a custom RichTextEffect after saving a script that extends RichTextEffect with a ``class_name``
  742. .. warning::
  743. If the custom effect is not registered within the RichTextLabel's
  744. **Markup > Custom Effects** property, no effect will be visible and the original
  745. tag will be left as-is.
  746. There is only one function that you need to extend: ``_process_custom_fx(char_fx)``.
  747. Optionally, you can also provide a custom BBCode identifier by adding a member
  748. name ``bbcode``. The code will check the ``bbcode`` property automatically or will
  749. use the name of the file to determine what the BBCode tag should be.
  750. ``_process_custom_fx``
  751. ~~~~~~~~~~~~~~~~~~~~~~
  752. This is where the logic of each effect takes place and is called once per glyph
  753. during the draw phase of text rendering. This passes in a :ref:`class_CharFXTransform`
  754. object, which holds a few variables to control how the associated glyph is rendered:
  755. - ``identity`` specifies which custom effect is being processed. You should use that for
  756. code flow control.
  757. - ``outline`` is ``true`` if effect is called for drawing text outline.
  758. - ``range`` tells you how far into a given custom effect block you are in as an
  759. index.
  760. - ``elapsed_time`` is the total amount of time the text effect has been running.
  761. - ``visible`` will tell you whether the glyph is visible or not and will also allow you
  762. to hide a given portion of text.
  763. - ``offset`` is an offset position relative to where the given glyph should render under
  764. normal circumstances.
  765. - ``color`` is the color of a given glyph.
  766. - ``glyph_index`` and ``font`` is glyph being drawn and font data resource used to draw it.
  767. - Finally, ``env`` is a :ref:`class_Dictionary` of parameters assigned to a given custom
  768. effect. You can use :ref:`get() <class_Dictionary_method_get>` with an optional default value
  769. to retrieve each parameter, if specified by the user. For example ``[custom_fx spread=0.5
  770. color=#FFFF00]test[/custom_fx]`` would have a float ``spread`` and Color ``color``
  771. parameters in its ``env`` Dictionary. See below for more usage examples.
  772. The last thing to note about this function is that it is necessary to return a boolean
  773. ``true`` value to verify that the effect processed correctly. This way, if there's a problem
  774. with rendering a given glyph, it will back out of rendering custom effects entirely until
  775. the user fixes whatever error cropped up in their custom effect logic.
  776. Here are some examples of custom effects:
  777. Ghost
  778. ~~~~~
  779. ::
  780. @tool
  781. extends RichTextEffect
  782. class_name RichTextGhost
  783. # Syntax: [ghost freq=5.0 span=10.0][/ghost]
  784. # Define the tag name.
  785. var bbcode = "ghost"
  786. func _process_custom_fx(char_fx):
  787. # Get parameters, or use the provided default value if missing.
  788. var speed = char_fx.env.get("freq", 5.0)
  789. var span = char_fx.env.get("span", 10.0)
  790. var alpha = sin(char_fx.elapsed_time * speed + (char_fx.range.x / span)) * 0.5 + 0.5
  791. char_fx.color.a = alpha
  792. return true
  793. Matrix
  794. ~~~~~~
  795. ::
  796. @tool
  797. extends RichTextEffect
  798. class_name RichTextMatrix
  799. # Syntax: [matrix clean=2.0 dirty=1.0 span=50][/matrix]
  800. # Define the tag name.
  801. var bbcode = "matrix"
  802. # Gets TextServer for retrieving font information.
  803. func get_text_server():
  804. return TextServerManager.get_primary_interface()
  805. func _process_custom_fx(char_fx):
  806. # Get parameters, or use the provided default value if missing.
  807. var clear_time = char_fx.env.get("clean", 2.0)
  808. var dirty_time = char_fx.env.get("dirty", 1.0)
  809. var text_span = char_fx.env.get("span", 50)
  810. var value = char_fx.glyph_index
  811. var matrix_time = fmod(char_fx.elapsed_time + (char_fx.range.x / float(text_span)), \
  812. clear_time + dirty_time)
  813. matrix_time = 0.0 if matrix_time < clear_time else \
  814. (matrix_time - clear_time) / dirty_time
  815. if matrix_time > 0.0:
  816. value = int(1 * matrix_time * (126 - 65))
  817. value %= (126 - 65)
  818. value += 65
  819. char_fx.glyph_index = get_text_server().font_get_glyph_index(char_fx.font, 1, value, 0)
  820. return true
  821. This will add a few new BBCode commands, which can be used like so:
  822. .. code-block:: none
  823. [center][ghost]This is a custom [matrix]effect[/matrix][/ghost] made in
  824. [pulse freq=5.0 height=2.0][pulse color=#00FFAA freq=2.0]GDScript[/pulse][/pulse].[/center]