bevy/crates/bevy_text/src
Rob Parrett fcc6b4ddff Fix text alignment for unbounded text (#17270)
Fixes #16783

Works around a `cosmic-text` bug or limitation by triggering a re-layout
with the calculated width from the first layout run. See linked issue.

Credit to @ickshonpe for the clever solution.

This has a significant performance impact only on unbounded text that
are not `JustifyText::Left`, which is still a bit of a bummer because
text2d performance in 0.15.1 is already not great. But this seems better
than alignment not working.

||many_text2d nfc re|many_text2d nfc re center|
|-|-|-|
|unbounded-layout-no-fix|3.06|3.10|
|unbounded-layout-fix|3.05  -0.2%|2.71 🟥 -12.5%|

I added a centered text to the `text2d` example.

`cargo run --example text2d`

We should look at other text examples and stress tests. I haven't tested
as thoroughly as I would like, so help testing that this doesn't break
something in UI would be appreciated.
2025-02-06 22:30:57 +01:00
..
bounds.rs Simpler lint fixes: makes ci lints work but disables a lint for now (#15376) 2024-09-24 11:42:59 +00:00
error.rs Remove thiserror from bevy_text (#15762) 2024-10-09 14:27:09 +00:00
FiraMono-subset.ttf add a default font (#8445) 2023-04-21 22:30:18 +00:00
font_atlas_set.rs Don't reëxport bevy_image from bevy_render (#16163) 2024-11-11 22:16:38 +01:00
font_atlas.rs Don't reëxport bevy_image from bevy_render (#16163) 2024-11-11 22:16:38 +01:00
font_loader.rs Remove thiserror from bevy_text (#15762) 2024-10-09 14:27:09 +00:00
font.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
glyph.rs Don't reëxport bevy_image from bevy_render (#16163) 2024-11-11 22:16:38 +01:00
lib.rs Add missing registration for TextEntity (#16649) 2025-01-03 19:15:53 +01:00
pipeline.rs Fix text alignment for unbounded text (#17270) 2025-02-06 22:30:57 +01:00
text2d.rs Text2d scalefactor change detection fix (#16264) 2024-11-16 15:30:16 +01:00
text_access.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
text.rs Adds some helpful methods to TextFont (#16370) 2024-11-19 22:10:25 +01:00