From 9a04f0ead337f63f9a937982f011be8434ff0d41 Mon Sep 17 00:00:00 2001 From: Nazari Gonzalez Date: Sat, 8 Jun 2024 16:24:40 +0100 Subject: [PATCH] fix egui blurry text --- crates/notan_egui/src/plugin.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/notan_egui/src/plugin.rs b/crates/notan_egui/src/plugin.rs index 602a33c7..a023a2a5 100644 --- a/crates/notan_egui/src/plugin.rs +++ b/crates/notan_egui/src/plugin.rs @@ -18,6 +18,7 @@ pub struct EguiPlugin { platform_output: Option, latest_evt_was_touch: bool, needs_repaint: bool, + pixels_per_point: f32, } #[allow(clippy::derivable_impls)] @@ -29,6 +30,7 @@ impl Default for EguiPlugin { platform_output: Default::default(), latest_evt_was_touch: Default::default(), needs_repaint: Default::default(), + pixels_per_point: Default::default(), } } } @@ -294,6 +296,12 @@ impl Plugin for EguiPlugin { } fn update(&mut self, app: &mut App, _assets: &mut Assets) -> Result { + let dpi = app.window().dpi() as f32; + if dpi != self.pixels_per_point { + self.pixels_per_point = dpi; + self.ctx.set_pixels_per_point(self.pixels_per_point); + } + self.raw_input.time = Some(app.timer.elapsed_f32() as _); self.raw_input.predicted_dt = app.timer.delta_f32();