Describe the project you are working on:
Working on a 2D game that has messages that pop up from time to time. Almost all game implements text.
Describe the problem or limitation you are having in your project:
As a professional motion designer and a beginner coder, it is quite difficult doing text animation using BBCode inside GODOT's richtext nodes. The documentation for GODOT 3.2 concerning the "RichTextEffect" is limited and difficult to work with. It requires quite good math skills.
Describe how this feature / enhancement will help you overcome this problem or limitation:
With easier control over characters of a text, it will be much easier for me and other professional animators/motion designers to create the desired effect.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
The idea is to have the tools to build basic text animations


The node can contain any number of layers, all sitting in an array. Depending on how many states\modifications the text will go through using sliders: "range select".

The modifiers are seen as the layers. "Global Position of modifiers" is what it could like in the editor, the layers are barely visible behind the animation(just to have a visual of what that modifier/layer is doing to the text). so you would animate the slider of each layer sequentially to get that effect.
Adding tween easing(LINEAR, BOUNCE, BACK, ELASTIC, etc) could help avoid too many layers.

Here you could make adjustment on how this layer modifies your text, thus you can add the "AnimationPlayer" Node and keyframe the sliders.

Randomize feature!

Now dealing with multiple layers. No need to animate from the original text position, just animate from the previous layer text position.

Describe implementation detail for your proposal (in code), if possible:
Currently my brain does not have the sufficient weight to comprehend this info in code format.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Up to a limited degree. I could generate new nodes each representing a substring, however, getting the data per character, such as position is not possible. I would have to use "Tool" mode to see if all my hundreds of node characters are positioned correctly, this would be time consuming.
Is there a reason why this should be core and not an add-on in the asset library?:
Have it as core so that you can avoid the clutter of extra files in your project. The ability to save it as ".tres" share with anyone wanting to implement cool text animations or titles in their projects, would provide quite useful among GODOT users in presentation, gaming, or any interactive media.
@Eoin-ONeill-Yokai has done an immense amount of work with RTL's text effects. If those effects are not possible using the current system, then maybe a "TextAnimator" node could be introduced. Similar to how we create particles with Particles2D. However, I don't see this being implemented in the core, but who knows nowadays.
From what I can gather, any effect which relies on changing the positions of characters in time is possible right now. RichTextEffect allows you to alter the position of each character however you want, in any way you want, using combinations of get_absolute_index,elapsed_time, and set_offset. Here is how I implemented a simple jump effect, for example. The only things I see that aren't currently possible is individual character scaling and individual character rotation, which would be needed to create all of these effects. Sharing custom effects are as simple as putting a file into your project then adding the scene/class to the RichTextLabel (See Eoin-ONeill-Yokai/Godot-RichTextEffect-SampleProject for an example of how to organize it).
Well it doesn't need to be implemented into core; add on is great too. I worked with @Eoin-ONeill-Yokai RichTextEffect, but it requires quite some time to understand it. Ease of use is fundamental of GODOT, so why not make it easier. a dedicated Range Selector, and Select by character | Word | Line | All would solve and complete the node. I was also trying to contact @Eoin-ONeill-Yokai , but had no luck.
You guys think if make the proposal look more defined and add in some game references, and uses, it could get some more attention?
I was also trying to contact @Eoin-ONeill-Yokai , but had no luck
I never got an email from you @shafnaz. At any rate, I've been keeping a close eye on this topic but hadn't found the time to respond. Also, it's worth noting, I'm getting a 404 on the images you uploaded. This might be on my end since I feel like github is failing to load various images for me, so bare with me as I'm mostly going by what you've described.
Ease of use is fundamental of GODOT, so why not make it easier.
Frankly, ease of use is a problem with RichTextEffect, but not a major one. It does require some knowledge of programming to implement text effects, but the text effects are made in a way that should be shareable between users and projects. Additionally, since these text effects are resources, you could do things like expose parameters to non programmers to get more mileage out of the behavior. For example, you could do some of what you are asking for by exposing an AnimationCurve as an editable property so that artists could design their own text oscillation. There are ways to make the existing system more artist friendly but some of those tasks are down to making a few defaults that achieve this functionality.
Generally speaking, like shaders or other "technical art" elements of a game, the way I envisioned this system was a simple way to expand the current set of BBCodes without having to jump into the C++ backend. So it's what I would consider a good start but not necessarily the final incarnation of a good extensible RichText system.
The problem with exposing effects with the animator system is that, currently, the tree of text elements in the RichTextLabel are not 'native' Godot objects and thus do not have a clean way of interfacing with the Godot animation nodes. I had previously weighed on allowing individual effect parameters (e.g. wave frequency) to be drivable in the animation system, but had to postpone those plans since I couldn't find a clean way to implement it immediately.
An additional nicety would be the ability to have "span" blocks in a rich text effect that allow for dynamic replacement of elements -- also exposed to the animation system.
The ability to save it as ".tres" share with anyone wanting to implement cool text animations or titles in their projects, would provide quite useful among GODOT users in presentation, gaming, or any interactive media.
This should already be possible with the current implementation. Text effects are resources and those resources should be able to have embedded / extended scripts for easy sharing between projects and users.
A dedicated Range Selector, and Select by character | Word | Line | All would solve and complete the node.
Unfortunately, with the way RichTextLabel is implemented currently, it's far easier said than done. Simply keeping track of where the user was in the current string took an extra few steps alone. More context could be provided to the user in RichTextEffect in the future, specifically an attribute like current word and current element. However, as of right now, effects are implemented on a per-character basis with some basic context of where you are in a given string.
The only things I see that aren't currently possible is individual character scaling and individual character rotation, which would be needed to create all of these effects.
Yes @golfinq, this is a good point. I think this is achievable in the next Godot version, but would need some additional work to Font::draw_char to allow for rotation which may take some time. Scaling would also need to be added to Font::draw_char but I think that a simple normalized nScale parameter would be good enough to get going there and probably wouldn't require too much of a refactor.
Anyway, back to the topic at hand. Here's how I feel about this:
Yes, there are ways that RichTextLabel and by extension RichTextEffect _could_ have some behavioral extensions. I also do think more exposure to the animation system would be ideal at some point. However, I also believe that achieving more dynamic text (string size changes, dynamic tree / element swapping) will actually require a larger refactor on the RichTextLabel class. Inheritance opportunities in which the child has direct access to the tree of text elements that make up a RichText would also be a nice target. I also think the RichTextLabel class needs fewer macros and more inline functions (so that it isn't a huge pain to navigate the c++ class since it lacks IDE type checks and more) and needs to be designed in a way that lets people have more custom behavior on what they want from their 'label' class. The only problem I have right now is that I haven't found a way to formalize my proposal for a new RichTextLabel. Additionally, it would also require a large change that would need to be reserved for a major version number (4.0? 5.0?) since it would almost certainly break compatibility with older projects.
I'm open for more discussion on this idea though. However, since I'm really just a contributor, any assistance with potential implementation on the C++ end of things would be really useful to me and would allow to push this idea from an idea to potential PR.
@Eoin-ONeill-Yokai Great response.
Indeed it does sound complicated integrating with GODOT's nodes. There is a lot of movement in GODOT development, so I'm sure in the near future we'll get to it. Amazing work so far.
By the way, couldn't email yours, but it was great to finally get your feedback on this topic.
@Eoin-ONeill-Yokai have you looked at #29762 ? It seems like they did something like you are suggesting with respect to the scaling.
I have been thinking about this, and while I don't think it warrants a pull-request yet, I was able to expose the low-level canvas_item_add_set_transform/FT_Set_Transform functions to RichTextEffect; the code is here (ignore the fact that it contains code from #35608). This allows for generic transformations on strings of text through the use of the CharFXTransform.set_transform() function. It does need testing esp. with multiple tags, and the way that freetype vs the visual server deal with these transformations may differ in ways I can't tell right now, and honestly this may not be the best approach. But hey I got some text to orbit, which is a start.
var transform = Transform2D(char_fx.elapsed_time,Vector2(0,0))
char_fx.set_transform(transform)

@golfinq That's very cool!
Yes, I've been following that (#29762) and I believe @reduz mentioned something regarding this to me over IRC. Before committing a lot of time to adding additional features to RichTextEffects, I think that the dust should settle over Font resources (DynamicFont and otherwise) which are currently under scrutiny for version 4.0.
So would that transform_fx also allow for scaling / matrix manipulation with you current implementation?
So would that transform_fx also allow for scaling / matrix manipulation with you current implementation?
From what I can tell, any generic transformation will work, which includes the power of matrix arithmetic.
Most helpful comment
@Eoin-ONeill-Yokai have you looked at #29762 ? It seems like they did something like you are suggesting with respect to the scaling.
I have been thinking about this, and while I don't think it warrants a pull-request yet, I was able to expose the low-level
canvas_item_add_set_transform/FT_Set_Transformfunctions toRichTextEffect; the code is here (ignore the fact that it contains code from #35608). This allows for generic transformations on strings of text through the use of theCharFXTransform.set_transform()function. It does need testing esp. with multiple tags, and the way that freetype vs the visual server deal with these transformations may differ in ways I can't tell right now, and honestly this may not be the best approach. But hey I got some text to orbit, which is a start.