diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 547ed6bfce..062532e377 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -222,7 +222,7 @@ pub fn extract_text2d_sprite( /// [`ResMut>`](Assets) -- This system only adds new [`Image`] assets. /// It does not modify or observe existing ones. pub fn update_text2d_layout( - mut last_scale_factor: Local, + mut last_scale_factor: Local>, // Text items which should be reprocessed again, generally when the font hasn't loaded yet. mut queue: Local, mut textures: ResMut>, @@ -245,13 +245,15 @@ pub fn update_text2d_layout( // TODO: Support window-independent scaling: https://github.com/bevyengine/bevy/issues/5621 let scale_factor = windows .get_single() + .ok() .map(|window| window.resolution.scale_factor()) - .unwrap_or(1.0); + .or(*last_scale_factor) + .unwrap_or(1.); let inverse_scale_factor = scale_factor.recip(); - let factor_changed = *last_scale_factor != scale_factor; - *last_scale_factor = scale_factor; + let factor_changed = *last_scale_factor != Some(scale_factor); + *last_scale_factor = Some(scale_factor); for (entity, block, bounds, text_layout_info, mut computed) in &mut text_query { if factor_changed