Function bevy_ui::widget::measure_text_system
source · pub fn measure_text_system(
last_scale_factor: Local<'_, f32>,
fonts: Res<'_, Assets<Font>>,
windows: Query<'_, '_, &Window, With<PrimaryWindow>>,
ui_scale: Res<'_, UiScale>,
text_query: Query<'_, '_, (Ref<'_, Text>, &mut ContentSize, &mut TextFlags), With<Node>>
)
Expand description
Generates a new Measure
for a text node on changes to its Text
component.
A Measure
is used by the UI’s layout algorithm to determine the appropriate amount of space
to provide for the text given the fonts, the text itself and the constraints of the layout.
- All measures are regenerated if the primary window’s scale factor or
UiScale
is changed. - Changes that only modify the colors of a
Text
do not require a newMeasure
. This system is only able to detect that aText
component has changed and will regenerate theMeasure
on color changes. This can be expensive, particularly for large blocks of text, and thebypass_change_detection
method should be called when only changing theText
’s colors.