bevy_ui::widget

Function measure_text_system

Source
pub fn measure_text_system(
    scale_factors_buffer: Local<'_, EntityHashMap<f32>>,
    last_scale_factors: Local<'_, EntityHashMap<f32>>,
    fonts: Res<'_, Assets<Font>>,
    camera_query: Query<'_, '_, (Entity, &Camera)>,
    default_ui_camera: DefaultUiCamera<'_, '_>,
    ui_scale: Res<'_, UiScale>,
    text_query: Query<'_, '_, (Entity, Ref<'_, TextLayout>, &mut ContentSize, &mut TextNodeFlags, &mut ComputedTextBlock, Option<&TargetCamera>), With<Node>>,
    text_reader: TextUiReader<'_, '_>,
    text_pipeline: ResMut<'_, TextPipeline>,
    font_system: ResMut<'_, CosmicFontSystem>,
)
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.

  • Measures are regenerated if the target camera’s scale factor (or primary window if no specific target) or UiScale is changed.
  • Changes that only modify the colors of a Text do not require a new Measure. This system is only able to detect that a Text component has changed and will regenerate the Measure on color changes. This can be expensive, particularly for large blocks of text, and the bypass_change_detection method should be called when only changing the Text’s colors.