Make it possible to change character transform in RichTextEffect - #77819
Conversation
|
Just found myself wanting this, and came looking - nice timing! Can it be set up to scale from the center of the glyph by default? I imagine that would be desired in most cases. |
f7ec3e7 to
2ed1ea5
Compare
|
I did some cleanup and ran some experiments. The two problems I found:
Also, the text server, and some font-wide metrics like ascent and descent could be provided by CharFXTransform, as it is very likely that these will be asked for from scripting anyways. Those will get tackled in my next pass. For now enjoy one of my tests: charfxtransform.demo2.mp4 |
2ed1ea5 to
fd5b4b3
Compare
|
Had some more fun today: Effects can be stacked: (the lag at the beggining seems to be screen recording program) 44a4d9e5f939ef269f18b3bf1666f42e.mp4You can try out these by compiling and running this demo project: I am in a point where the feature would be good enough for my usage, but I feel like some feedback on this would be appreciated. some points to discuss:
I still haven't exposed font_size to the CharFXTransform object, so that will be part of my next push. |
e468e76 to
c766a9d
Compare
There was a problem hiding this comment.
Forward declarations should be created at the top of the file. (although it's interesting that you can inline them 🤔)
There was a problem hiding this comment.
This shouldn't be in the code. You could write a comment in the PR instead.
KoBeWi
left a comment
There was a problem hiding this comment.
I tested that it works, but I can't say if the implementation is 100% correct (looks fine to me tho). I mainly wonder if there is some negative performance impact if someone doesn't modify the transform, because the char is transformed regardless of that.
|
I've been thinking about something like this lately too! It would make text effects wayyyyy more versatile, and it would make godotengine/godot-proposals#7270 even more powerful! |
|
@0xafbf Are you able to address the review comments? The PR should also be rebased, and the commits squashed into one. |
|
yes, I'll update this pr by the end of the week |
502bd89 to
34671c7
Compare
Use absolute transforms for CharFX fix formatting
34671c7 to
eee95af
Compare
|
Hello, I updated the PR with some improvements:
I feel the same concern on pushing transform matrices per character. I don't know how to profile that very well, but I guess that adding a hundred of RichTextLabel should do the trick. I'll do that in my next pass For optimization, I have conflicting ideas on what approach to take:
In the end it may not be the worst thing to push one matrix per character, because in the end we can filter it so only happens when ItemFX are used (so for example documentation viewer wouldn't push matrices per character), and the rest of the strings that would use this would very likely not exceed a hundred of characters. I think we'll know better when I do the tests Also, Drawing shadows uses a different transform. On one hand I think that we can do some inverse transforms to find the location to layout the shadow so it is placed correctly when it is drawn. But that feels hacky and maybe not very valuable for the reason mentioned above. On the other hand I think that it would be cool to extend the RichTextEffect system to tell the user if the character being processed is a shadow, an outline, or the character itself, and let the user apply color and transform effects individually for each of these passes. That would be done out of the scope of this PR, and maybe require some changes on how the text render passes are issued. I include an updated version of the example project with some implemented effects to aid in testing: |
|
Thanks! |
|
In which version it will be added? 4.2? |
Make it possible to change character transform in RichTextEffect
Make it possible to change character transform in RichTextEffect


This PR adds a Transform2D field to the CharFXTransform object, this lets a subclass of RichTextEffect to specify custom transforms including rotations and scaling. Partially implements godotengine/godot-proposals#3417
charfxtransform.demo.mp4
Additionally, I moved an include so rebuilds are faster.