From f6780f19d3592077019872850d00e5eb9e92a22d Mon Sep 17 00:00:00 2001 From: Birh Burh Date: Wed, 12 Jun 2024 04:03:06 +0200 Subject: [PATCH] Fixed Metal backend with high_dpi = false --- src/native/macos.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/native/macos.rs b/src/native/macos.rs index fa32602d..e5f5604d 100644 --- a/src/native/macos.rs +++ b/src/native/macos.rs @@ -152,7 +152,10 @@ impl MacosDisplay { let dpi_scale: f64 = msg_send![self.window, backingScaleFactor]; d.dpi_scale = dpi_scale as f32; } else { - d.dpi_scale = 1.0; + let bounds: NSRect = msg_send![self.view, bounds]; + let backing_size: NSSize = msg_send![self.view, convertSizeToBacking: NSSize {width: bounds.size.width, height: bounds.size.height}]; + + d.dpi_scale = (backing_size.width / bounds.size.width) as f32; } let bounds: NSRect = msg_send![self.view, bounds];