-
-
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
Text2d misalignment fix #14270
Text2d misalignment fix #14270
Conversation
…he glpyhs horizontally so that the left edge of the leftmost glyph is at 0.
@tigregalis would you mind taking a look if you get a chance? |
cosmic-text is positioning the glyphs within the rectangle given by the bounds. For example, consider text that is centred, I think the approach in this PR is good... with one caveat I think we should revisit later: it's the text content, not the text box, that is anchored. When you "shrink to fit", the bounds are exclusively for wrapping behaviour, not for giving the
Should this always be the behaviour? There may be scenarios where we want the text box itself to be anchored, not the text content only, but we haven't got a way of representing that currently.
|
Yep, the reasons I went with this approach are entirely pragmatic, it works for both Bevy 14 with
Yeah agree with all of this. The text2d api is not intuitive at all. IIRC I made most of the changes that lead to the current design and my concerns were all about bugs and consistency. I don't remember thinking much about usability or more complex layout composition at all. The tricky thing to get right with a redesign is that most of the use cases for text2d are very trivial and any sort of layout support just gets in their way. Possibly we could have two distinct bundles ( |
Seconding this: there's a few different use cases that got all mashed together. Billboarded text in 3D and text decals on e.g. walls are also related. |
What counts as layout here? Line breaking? Presumably even trivial use cases would want the text to be shaped? |
Just think of floating score and damage numbers. Don't even need spaces, just got to be simple and efficient so that if everything in the game blows up and dies it can display ten thousand animated damage labels without any slowdown or hiccups. |
Closed in favour of #17365 |
Objective
Fixes #14266
Solution
In
update_text2d_layout
after generating the layout translate all the glpyhs horizontally so that the left edge of the leftmost glyph is at 0.Not sure if this the best method but it avoids the need for seperate fixes for ab_gyph and cosmic text.
Testing
This covers all the cases I think: