[Complex Text Layouts] Update tutorials and documentation to match TextServer changes.

This commit is contained in:
bruvzg
2021-05-07 11:29:55 +03:00
parent 3f60675227
commit 20bcd1307a
14 changed files with 1483 additions and 68 deletions
+6 -4
View File
@@ -92,12 +92,13 @@ Vulkan renderer.
- Hard or soft shadows.
- Font rendering using bitmaps (BitmapFont) or rasterization using FreeType (DynamicFont).
- Font rendering using bitmaps or rasterization using FreeType.
- Bitmap fonts can be exported using tools like BMFont.
- DynamicFont supports monochrome fonts as well as colored fonts.
- Dynamic fonts supports monochrome fonts as well as colored fonts.
Supported formats are TTF and OTF.
- DynamicFont supports optional font outlines with adjustable width and color.
- Dynamic fonts supports optional font outlines with adjustable width and color.
- Dynamic fonts supports variable fonts and OpenType features.
- Support for font oversampling to keep fonts sharp at higher resolutions.
- GPU-based particles with support for custom particle shaders.
@@ -437,7 +438,8 @@ Internationalization
or :ref:`gettext <doc_localization_using_gettext>`.
- Use localized strings in your project automatically in GUI elements or by
using the ``tr()`` function.
- Support for right-to-left typesetting and text shaping planned in Godot 4.0.
- Support for bidirectional typesetting and text shaping and OpenType localized forms.
- Automatic UI mirroring for right-to-left locales.
Windowing and OS integration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File diff suppressed because it is too large Load Diff
+111
View File
@@ -0,0 +1,111 @@
:github_url: hide
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the TextServerManager.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_TextServerManager:
TextServerManager
=================
**Inherits:** :ref:`Object<class_Object>`
Manager for the font and complex text layout servers.
Description
-----------
``TextServerManager`` is the API backend for loading, enumeration and switching :ref:`TextServer<class_TextServer>`\ s.
Note: Switching text server at runtime is possible, but will invalidate all fonts and text buffers. Make sure to unload all controls, fonts, and themes before doing so.
Methods
-------
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`TextServer<class_TextServer>` | :ref:`find_interface<class_TextServerManager_method_find_interface>` **(** :ref:`String<class_String>` name **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`TextServer<class_TextServer>` | :ref:`get_interface<class_TextServerManager_method_get_interface>` **(** :ref:`int<class_int>` index **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_interface_count<class_TextServerManager_method_get_interface_count>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_interface_features<class_TextServerManager_method_get_interface_features>` **(** :ref:`int<class_int>` index **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_interface_name<class_TextServerManager_method_get_interface_name>` **(** :ref:`int<class_int>` index **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_interfaces<class_TextServerManager_method_get_interfaces>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`TextServer<class_TextServer>` | :ref:`get_primary_interface<class_TextServerManager_method_get_primary_interface>` **(** **)** |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`set_primary_interface<class_TextServerManager_method_set_primary_interface>` **(** :ref:`int<class_int>` index **)** |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
Method Descriptions
-------------------
.. _class_TextServerManager_method_find_interface:
- :ref:`TextServer<class_TextServer>` **find_interface** **(** :ref:`String<class_String>` name **)** |const|
Finds an interface by its name.
----
.. _class_TextServerManager_method_get_interface:
- :ref:`TextServer<class_TextServer>` **get_interface** **(** :ref:`int<class_int>` index **)** |const|
Returns the interface registered at a given index.
----
.. _class_TextServerManager_method_get_interface_count:
- :ref:`int<class_int>` **get_interface_count** **(** **)** |const|
Returns the number of interfaces currently registered.
----
.. _class_TextServerManager_method_get_interface_features:
- :ref:`int<class_int>` **get_interface_features** **(** :ref:`int<class_int>` index **)** |const|
Returns text server supported features (binary OR).
----
.. _class_TextServerManager_method_get_interface_name:
- :ref:`String<class_String>` **get_interface_name** **(** :ref:`int<class_int>` index **)** |const|
Returns the interface name registered at a given index.
----
.. _class_TextServerManager_method_get_interfaces:
- :ref:`Array<class_Array>` **get_interfaces** **(** **)** |const|
Returns a list of available interfaces the index and name of each interface.
----
.. _class_TextServerManager_method_get_primary_interface:
- :ref:`TextServer<class_TextServer>` **get_primary_interface** **(** **)** |const|
Returns the primary :ref:`TextServer<class_TextServer>` interface.
----
.. _class_TextServerManager_method_set_primary_interface:
- :ref:`bool<class_bool>` **set_primary_interface** **(** :ref:`int<class_int>` index **)**
Sets (and initializes it if required) interface registered at a given index as the primary. Invalidates all references to the fonts and text buffers.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
@@ -243,6 +243,10 @@ The editor translations originate from C++ strings, and may use:
Scene '%s' is currently being edited.↵
Changes will only take effect when reloaded.
.. note::
Only logical order of the characters matters, in the right-to-left text, format
specifiers may be displayed as ``s%``.
Online documentation (RST)
^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -36,19 +36,21 @@ Inspector. The default font for ``Control`` nodes is small and doesn't scale
well. There is a font file included in the game assets called
"Xolonium-Regular.ttf". To use this font, do the following:
1. Under "Custom Fonts", choose "New DynamicFont"
1. Under "Custom Fonts", choose "New Font"
.. image:: img/custom_font1.png
2. Click on the "DynamicFont" you added, and under "Font/Font Data", choose
"Load" and select the "Xolonium-Regular.ttf" file. You must also set the
font's ``Size``. A setting of ``64`` works well.
2. Click on the "Font" you added, and under "Font/Data/0",
choose "Load" and select the "Xolonium-Regular.ttf" file.
.. image:: img/custom_font2.png
Once you've done this on the ``ScoreLabel``, you can click the down arrow next
to the DynamicFont property and choose "Copy", then "Paste" it in the same place
to the Font property and choose "Copy", then "Paste" it in the same place
on the other two Control nodes.
Set "Custom Font Size" property of the ``ScoreLabel``. A setting of ``64`` works well.
.. image:: img/custom_font3.png
.. note:: **Anchors and Margins:** ``Control`` nodes have a position and size,
but they also have anchors and margins. Anchors define the origin -
Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

@@ -109,6 +109,75 @@ called the :ref:`TranslationServer <class_TranslationServer>`.
Translations can be added or removed during run-time;
the current language can also be changed at run-time.
Bidirectional text and UI Mirroring
-----------------------------------
Arabic and Hebrew are written from right to left (except for the numbers and Latin
words mixed in), and the user interface for these languages should be mirrored as well.
In some languages the shape of a glyph changes depending on the surrounding characters.
Support for bidirectional writing systems and UI mirroring is transparent, you don't
usually need to change anything or have any knowledge of the specific writing system.
For RTL languages, Godot will automatically do the following changes to the UI:
- Mirrors left/right anchors and margins.
- Swaps left and right text alignment.
- Mirrors horizontal order of the child controls in the containers, and items in Tree/ItemList controls.
- Uses mirrored order of the internal control elements (e.g. OptionButton dropdown button, checkbox alignment, List column order, Tree item icons and connecting line alignment, e.t.c.), in some cases mirrored controls use separate theme styles.
- Coordinate system is not mirrored, and non-UI nodes (sprites, e.t.c) are not affected.x
It is possible to override text and control layout direction by using the following control properties:
- ``text_direction``, sets the base text direction. When set to "auto", direction depends on the first strong directional character in the text according to the Unicode Bidirectional Algorithm,
- ``language``, overrides current project locale.
- ``structured_text_bidi_override property`` and ``_structured_text_parser callback``, enables special handling for structured text.
- ``layout_direction``, overrides control mirroring.
.. image:: img/ui_mirror.png
Adding break iterator data to exported project
----------------------------------------------
Some languages are written without spaces, and word and line breaking requires more than rules over character sequences.
Godot includes ICU rule and dictionary based, break iterator data, but this data is not included into exported projects by default.
To include it go to **Project → Project Settings → Localization → Text Server Data** and click **Install support data...**. Break iterator data is about 4 MB large.
.. image:: img/icu_data.png
Structured text BiDi override
-----------------------------
Unicode BiDi algorithm is designed to work with natural text and it's incapable of
handling text with the higher level order, like file names, URIs, email addresses,
regular expressions or source code.
.. image:: img/bidi_override.png
For example, the path for this shown directory structure will be displayed incorrectly
(top "LineEdit" control). "File" type structured text override splits text into segments,
then BiDi algorithm is applied to each of them individually to correctly display directory
names in any language and preserve correct order of the folders (bottom "LineEdit" control).
Custom callbacks provide a way to override BiDi for the other types of structured text.
Localizing numbers
------------------
Controls specifically designed for number input or output (e.g. ProgressBar, SpinBox)
will use localized numbering system automatically, for the other control
:ref:`TextServer.format_number(string, language) <class_TextServer_method_format_number>`
can be used to convert Western Arabic numbers (0..9) to the localized numbering system
and :ref:`TextServer.parse_number(string, language) <class_TextServer_method_parse_number>`
to convert it back.
Localizing icons and images
---------------------------
Icons with left and right pointing arrows which may need to be reversed for Arabic
and Hebrew locales, in case they indicate movement or direction (e.g. back/forward
buttons), otherwise they can remain the same.
Command line
------------
+124 -59
View File
@@ -50,45 +50,116 @@ markup. All changes to the text must be done in the BBCode parameter.
Reference
---------
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| Command | Tag | Description |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **bold** | ``[b]{text}[/b]`` | Makes {text} bold. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **italics** | ``[i]{text}[/i]`` | Makes {text} italics. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **underline** | ``[u]{text}[/u]`` | Makes {text} underline. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **strikethrough** | ``[s]{text}[/s]`` | Makes {text} strikethrough. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **code** | ``[code]{text}[/code]`` | Makes {text} use the code font (which is typically monospace). |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **center** | ``[center]{text}[/center]`` | Makes {text} horizontally centered. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **right** | ``[right]{text}[/right]`` | Makes {text} horizontally right-aligned. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **fill** | ``[fill]{text}[/fill]`` | Makes {text} fill the RichTextLabel's width. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **indent** | ``[indent]{text}[/indent]`` | Increase the indentation level of {text}. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **url** | ``[url]{url}[/url]`` | Show {url} as such, underline it and make it clickable. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **url (ref)** | ``[url=<url>]{text}[/url]`` | Makes {text} reference <url> (underlined and clickable). |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **image** | ``[img]{path}[/img]`` | Insert image at resource {path}. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **resized image** | ``[img=<width>]{path}[/img]`` | Insert image at resource {path} using <width> (keeps ratio). |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **resized image** | ``[img=<width>x<height>]{path}[/img]`` | Insert image at resource {path} using <width>×<height>. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **font** | ``[font=<path>]{text}[/font]`` | Use custom font at <path> for {text}. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **color** | ``[color=<code/name>]{text}[/color]`` | Change {text} color; use name or # format, such as ``#ff00ff``. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **table** | ``[table=<number>]{cells}[/table]`` | Creates a table with <number> of columns. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
| **cell** | ``[cell]{text}[/cell]`` | Adds cells with the {text} to the table. |
+-------------------+--------------------------------------------+-----------------------------------------------------------------+
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| Command | Tag | Description |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **bold** | ``[b]{text}[/b]`` | Makes {text} bold. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **italics** | ``[i]{text}[/i]`` | Makes {text} italics. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **underline** | ``[u]{text}[/u]`` | Makes {text} underline. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **strikethrough** | ``[s]{text}[/s]`` | Makes {text} strikethrough. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **code** | ``[code]{text}[/code]`` | Makes {text} use the code font (which is typically monospace). |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **p** | ``[p {options}]{text}[/p]`` | Adds new paragraph with {text}. See paragraph options for more info. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **center** | ``[center]{text}[/center]`` | Makes {text} horizontally centered. Same as ``[p align=center]``. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **left** | ``[left]{text}[/left]`` | Makes {text} horizontally right-aligned. Same as ``[p align=left]``. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **right** | ``[right]{text}[/right]`` | Makes {text} horizontally right-aligned. Same as ``[p align=right]``. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **fill** | ``[fill]{text}[/fill]`` | Makes {text} fill the RichTextLabel's width. Same as ``[p align=fill]``. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **indent** | ``[indent]{text}[/indent]`` | Increase the indentation level of {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **url** | ``[url]{url}[/url]`` | Show {url} as such, underline it and make it clickable. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **url (ref)** | ``[url=<url>]{text}[/url]`` | Makes {text} reference <url> (underlined and clickable). |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **image** | ``[img]{path}[/img]`` | Insert image at resource {path}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **resized image** | ``[img=<width>]{path}[/img]`` | Insert image at resource {path} using <width> (keeps ratio). |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **resized image** | ``[img=<width>x<height>]{path}[/img]`` | Insert image at resource {path} using <width>×<height>. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **aligned image** | ``[img align=<valign>]{path}[/img]`` | Insert image at resource {path} using <valign> vertical alignment. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **font** | ``[font=<path>]{text}[/font]`` | Use custom font at <path> for {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **font options** | ``[font {options}]{text}[/font]`` | Use custom font options for the {text}. See font options for more info. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **font size** | ``[font_size=nn]{text}[/font_size]`` | Use custom font size for {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **opentype features** | ``[opentype_features=ftr,ftr]{text}[/opentype_features]`` | Use custom OpenType font features (comma separated list) for {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **outline size** | ``[outline_size=<size>]{text}[/outline_size]`` | Use custom font outline size for {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **outline color** | ``[outline_color=<color>]{text}[/outline_color]`` | Use custom outline color for {text}. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **color** | ``[color=<code/name>]{text}[/color]`` | Change {text} color; use name or # format, such as ``#ff00ff``. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **table** | ``[table=<number>]{cells}[/table]`` | Creates a table with <number> of columns. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **cell** | ``[cell=<expand ratio>]{text}[/cell]`` | Adds cells with the {text} to the table. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **cell** | ``[cell {options}]{text}[/cell]`` | Adds cells with the {text} to the table. See cell options for more info. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **list** | ``[ul]{one item per line}[/ul]`` | Add unnumbered list. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **list** | ``[ol type=<type>]{one item per line}[/ol]`` | Add numbered list. See list types for more info. |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
| **unicode control** | ``[lrm]``, ``[rlm]``, ``[lre]``, ``[rle]``, ``[lro]``, | Adds Unicode control character. |
| | ``[rlo]``, ``[pdf]``, ``[alm]``, ``[lri]``, ``[rli]``, | |
| | ``[fsi]``, ``[pdi]``, ``[zwj]``, ``[zwnj]``, ``[wj]`` | |
+-----------------------+-----------------------------------------------------------+--------------------------------------------------------------------------+
Note: Options are optional for all tags.
Paragraph options
~~~~~~~~~~~~~~~~~
+----------------------------+---------------------------------------------------------------------------+----------------------------+
| Option | Supported Values | Description |
+----------------------------+---------------------------------------------------------------------------+----------------------------+
| ``align`` | ``left``, ``center``, ``right``, ``fill`` | Text horizontal alignment. |
+----------------------------+---------------------------------------------------------------------------+----------------------------+
| ``direction`` or ``dir`` | ``ltr``, ``rtl``, ``auto`` | Base BiDi direction. |
+----------------------------+---------------------------------------------------------------------------+----------------------------+
| ``language`` or ``lang`` | ISO language codes | Locale override. |
+----------------------------+---------------------------------------------------------------------------+----------------------------+
| ``bidi_override`` or `st` | ``default``, ``uri``, ``file``, ``email``, ``list``, ``none``, ``custom`` | Structured text override. |
+----------------------------+---------------------------------------------------------------------------+----------------------------+
Font options
~~~~~~~~~~~~
+----------------------------+-------------------------------------------------+
| Option | Description |
+----------------------------+-------------------------------------------------+
| ``name`` or ``n`` | Font resource path. |
+----------------------------+-------------------------------------------------+
| ``size`` or ``s`` | Font size. |
+----------------------------+-------------------------------------------------+
Cell options
~~~~~~~~~~~~
- ``expand`` - Column expansion ratio, the column expands in proportion to its expansion ratio versus the other columns' ratios.
- ``border`` - Sets cell border color.
- ``bg`` - Sets cell background color, for alternating odd/even row backgrounds use ``bg=odd_color,even_color``.
List types
~~~~~~~~~~
Supported list types:
- ``1`` - Numbers, using language specific numbering system if possible.
- ``a`` and ``A`` - Lower and upper case Latin letters.
- ``i`` and ``I`` - Lower and upper case Roman numerals.
Named colors
~~~~~~~~~~~~
@@ -107,11 +178,7 @@ In this case, note that the alpha channel is the **first** component of the colo
Image vertical offset
~~~~~~~~~~~~~~~~~~~~~
You use a custom font for your image in order to align it vertically.
1. Create a ``BitmapFont`` resource
2. Set this bitmap font with a positive value for the ``ascent`` property, that's your height offset
3. Set the BBCode tag this way: ``[font=<font-path>][img]{image-path}[/img][/font]``
Use ``[img=align]...[/img]`` to set vertical alignment of the image, where ``align`` is ``t`` (top), ``c`` (center) or ``b`` (bottom).
Animation effects
-----------------
@@ -186,21 +253,22 @@ use the name of the file to determine what the BBCode tag should be.
``_process_custom_fx``
~~~~~~~~~~~~~~~~~~~~~~
This is where the logic of each effect takes place and is called once per character
This is where the logic of each effect takes place and is called once per glyph
during the draw phase of text rendering. This passes in a :ref:`class_CharFXTransform`
object, which holds a few variables to control how the associated character is rendered:
object, which holds a few variables to control how the associated glyph is rendered:
- ``identity`` specifies which custom effect is being processed. You should use that for
code flow control.
- ``relative_index`` tells you how far into a given custom effect block you are in as an
- ``outline`` is ``true`` if effect is called for drawing text outline.
- ``range`` tells you how far into a given custom effect block you are in as an
index.
- ``absolute_index`` tells you how far into the entire text you are as an index.
- ``elapsed_time`` is the total amount of time the text effect has been running.
- ``visible`` will tell you whether the character is visible or not and will also allow you
- ``visible`` will tell you whether the glyph is visible or not and will also allow you
to hide a given portion of text.
- ``offset`` is an offset position relative to where the given character should render under
- ``offset`` is an offset position relative to where the given glyph should render under
normal circumstances.
- ``color`` is the color of a given character.
- ``color`` is the color of a given glyph.
- ``glyph_index`` and ``font`` is glyph being drawn and font data resource used to draw it.
- Finally, ``env`` is a :ref:`class_Dictionary` of parameters assigned to a given custom
effect. You can use :ref:`get() <class_Dictionary_method_get>` with an optional default value
to retrieve each parameter, if specified by the user. For example ``[custom_fx spread=0.5
@@ -209,7 +277,7 @@ object, which holds a few variables to control how the associated character is r
The last thing to note about this function is that it is necessary to return a boolean
``true`` value to verify that the effect processed correctly. This way, if there's a problem
with rendering a given character, it will back out of rendering custom effects entirely until
with rendering a given glyph, it will back out of rendering custom effects entirely until
the user fixes whatever error cropped up in their custom effect logic.
Here are some examples of custom effects:
@@ -284,20 +352,17 @@ Matrix
var dirty_time = char_fx.env.get("dirty", 1.0)
var text_span = char_fx.env.get("span", 50)
var value = char_fx.character
var matrix_time = fmod(char_fx.elapsed_time + (char_fx.absolute_index / float(text_span)), \
var matrix_time = fmod(char_fx.elapsed_time + (char_fx.range.x / float(text_span)), \
clear_time + dirty_time)
matrix_time = 0.0 if matrix_time < clear_time else \
(matrix_time - clear_time) / dirty_time
if value >= 65 && value < 126 && matrix_time > 0.0:
value -= 65
value = value + int(1 * matrix_time * (126 - 65))
if matrix_time > 0.0:
value = int(1 * matrix_time * (126 - 65))
value %= (126 - 65)
value += 65
char_fx.character = value
char_fx.glyph_index = TextServer.font_get_glyph_index(char_fx.font, value)
return true
This will add a few new BBCode commands, which can be used like so: