From 2e53f3b7753f6e5f76c04e6e77c4d7445113eea0 Mon Sep 17 00:00:00 2001 From: DanielJin21 Date: Sun, 5 Feb 2023 18:15:22 +0000 Subject: [PATCH] Don't ignore UI scale for text (#7510) # Objective Fixes #7476. UI scale was being incorrectly ignored when a primary window exists. ## Solution Always take into account UI scale, regardless of whether a primary window exists. Tested locally on @forbjok 's minimal repro project https://github.com/forbjok/bevy_ui_repro with this patch, and the issue is fixed on my machine. --- crates/bevy_ui/src/widget/text.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 9371c0e339..9f650c4c32 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -65,10 +65,12 @@ pub fn text_system( )>, ) { // TODO: Support window-independent scaling: https://github.com/bevyengine/bevy/issues/5621 - let scale_factor = windows + let window_scale_factor = windows .get_single() .map(|window| window.resolution.scale_factor()) - .unwrap_or(ui_scale.scale); + .unwrap_or(1.); + + let scale_factor = ui_scale.scale * window_scale_factor; let inv_scale_factor = 1. / scale_factor;