-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bevy_text] Enable shifting text position within a Text
component
#14030
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
f36aa72
to
0c3b9b8
Compare
Neat! I'm going to hold off on this until #10193 is merged: that should be mergeable soon and will interact with this. |
how does different text sections interact when they have offsets? how does it interact with general layout? |
The intention was that they would not interact at all, since the offsets would be added after typesetting inside of So you could use offsets to break the text outside of the text or UI layout |
I re-made this change on top of #10193. Looks like the implementation will be even simpler! TotalKrill/bevy@cosmic-text...zmbush:text-offset-cosmic I also added a usage example to the ui/text example Recording.2024-07-03.164506.mp4 |
This makes it possible to shift text (such as for animations), while still laying it out with `cosmic-text`.
@alice-i-cecile I have rebased this on top of the committed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine and the implementation is simple enough but it's no good I think. Having an offset field per TextSection
limits the sine wave example to one glpyh per TextSection
. I would rather have the offsets stored per glyph if we go this way.
But ideally you don't want to retain the offsets at all. Better alternatives are to either write a custom extraction function that calculates each glyph's position from its index and the elapsed time. Or make a system like the text_wave_system
in the example but rather than indirectly manipulating the positions using an offset field, just update the glyph positions stored in the TextLayoutInfo
component directly.
Objective
Text
to enable, for example, animations.Solution
Vec2
namedoffset
toTextSection
, which is added to the position of each glyph after the text layout.Testing
ui/text
exampletext-animation-example.mp4
Changelog
Added
offset
field toTextSection
that will be added to the position of each glyph.Migration Guide
TextSection
now contains the fieldoffset
(defaults toVec2(0.0, 0.0)
), which may cause previously exhaustively specifiedTextSection
s to fail to compile.