bevy/crates/bevy_ui/src/widget
ickshonpe 9d9750b928
TextLayoutInfo::size should hold the drawn size of the text, and not a scaled value. (#7794)
# Objective

`TextLayoutInfo::size` isn't the drawn size of the text, but a scaled
value. This is fragile, counter-intuitive and makes it awkward to
retrieve the correct value.

## Solution

Multiply `TextLayoutInfo::size` by the reciprocal of the window's scale
factor after generating the text layout in `update_text2d_layout` and
`bevy_ui::widget::text_system`.

---

fixes: #7787

## Changelog

* Multiply `TextLayoutInfo::size` by the reciprocal of the scale factor
after text computation to reflect the actual size of the text as drawn.
* Reorder the operations in `extract_text2d_sprite` to apply the
alignment offset before the scale factor scaling.

## Migration Guide

The `size` value of `TextLayoutInfo` is stored in logical pixels and has
been renamed to `logical_size`. There is no longer any need to divide by
the window's scale factor to get the logical size.
2023-09-11 18:56:16 +00:00
..
button.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
image.rs Change UiScale to a tuple struct (#9444) 2023-08-16 18:18:50 +00:00
label.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
mod.rs Integrate AccessKit (#6874) 2023-03-01 22:45:04 +00:00
text.rs TextLayoutInfo::size should hold the drawn size of the text, and not a scaled value. (#7794) 2023-09-11 18:56:16 +00:00