bevy/crates
Rob Parrett 5c0e13f29b
Fix text alignment for unbounded text (#17270)
# Objective

Fixes #16783

## Solution

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.

## Performance

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%|

## Testing

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-01-11 05:45:32 +00:00
..
bevy_a11y Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_animation Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_app Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_asset Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_audio bevy_audio: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17119) 2025-01-06 19:09:08 +00:00
bevy_color Add the original source for Oklab conversions (#17199) 2025-01-07 00:41:33 +00:00
bevy_core_pipeline Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_dev_tools Upstream DebugPickingPlugin from bevy_mod_picking (#17177) 2025-01-07 05:19:50 +00:00
bevy_diagnostic bevy_diagnostic: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17186) 2025-01-06 19:29:59 +00:00
bevy_dylib Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ecs Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_encase_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_gilrs bevy_gilrs: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17245) 2025-01-09 06:25:45 +00:00
bevy_gizmos Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_gltf Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_hierarchy bevy_hierarchy: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17286) 2025-01-10 19:37:58 +00:00
bevy_image bevy_image: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17289) 2025-01-11 04:11:07 +00:00
bevy_input Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_input_focus Add a simple directional UI navigation example (#17224) 2025-01-09 21:15:28 +00:00
bevy_internal Make bevy_remote feature enable serialize feature (#17260) 2025-01-10 20:31:41 +00:00
bevy_log bevy_log: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17246) 2025-01-09 06:26:04 +00:00
bevy_macro_utils Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_math Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_mesh bevy_mesh: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17218) 2025-01-09 06:29:36 +00:00
bevy_mikktspace Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_pbr Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_picking Make sprite picking opt-in (#17225) 2025-01-09 18:11:44 +00:00
bevy_ptr bevy_ptr: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17214) 2025-01-07 18:46:53 +00:00
bevy_reflect Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_remote Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_render Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_scene Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_sprite Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_state bevy_state: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17288) 2025-01-10 19:44:49 +00:00
bevy_tasks Improve Compiler Errors for bevy_tasks (#17296) 2025-01-11 02:35:09 +00:00
bevy_text Fix text alignment for unbounded text (#17270) 2025-01-11 05:45:32 +00:00
bevy_time bevy_time: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17210) 2025-01-09 06:29:42 +00:00
bevy_transform bevy_transform: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17284) 2025-01-10 19:38:05 +00:00
bevy_ui Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_utils Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_window Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
bevy_winit Add a simple directional UI navigation example (#17224) 2025-01-09 21:15:28 +00:00