From c3fe866bb97771506dc540f72bc5a640b11fc771 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 15 Aug 2021 12:44:11 +0200 Subject: [PATCH] refactor(font): conditional compilation on macos Avoids ``` warning: unused variable: `points_per_inch` --> src/renderer/fonts/font_options.rs:94:9 | 94 | let points_per_inch = 72.0; | ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_points_per_inch` | = note: `#[warn(unused_variables)]` on by default ``` on macOS, which is innocuous but has been bugging me for a while. --- src/renderer/fonts/font_options.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/renderer/fonts/font_options.rs b/src/renderer/fonts/font_options.rs index e4ad2bf..6e41097 100644 --- a/src/renderer/fonts/font_options.rs +++ b/src/renderer/fonts/font_options.rs @@ -90,13 +90,12 @@ fn points_to_pixels(value: f32) -> f32 { // // In reality, this depends on DPI/PPI of monitor, but here we only care about converting // from points to pixels, so this is standard constant values. - let pixels_per_inch = 96.0; - let points_per_inch = 72.0; - // On macos points == pixels - #[cfg(target_os = "macos")] - let points_per_inch = 96.0; - - let pixels_per_point = pixels_per_inch / points_per_inch; - - value * pixels_per_point + if cfg!(target_os = "macos") { + // On macos points == pixels + value + } else { + let pixels_per_inch = 96.0; + let points_per_inch = 72.0; + value * (pixels_per_inch / points_per_inch) + } }