From e47aeb77b70858a4ffeffd732f0cd9630b46bf24 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 13 Sep 2024 01:45:34 +0200 Subject: [PATCH] optionsutil: Switch to PostScript point Because that's what most people are probably thinking of. But, more importantly, it's what *FreeType* assumes ;). --- frontend/ui/data/optionsutil.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/ui/data/optionsutil.lua b/frontend/ui/data/optionsutil.lua index 0f4348cc3..437f15bf5 100644 --- a/frontend/ui/data/optionsutil.lua +++ b/frontend/ui/data/optionsutil.lua @@ -24,16 +24,20 @@ local function convertSizeTo(px, format) if format == "px" then return Screen:scaleBySize(px) elseif format == "pt" then - format_factor = 1 * (2660 / 1000) -- see https://www.wikiwand.com/en/Metric_typographic_units + -- PostScript point, + -- c.f., https://en.wikipedia.org/wiki/Metric_typographic_units + -- & https://freetype.org/freetype2/docs/glyphs/glyphs-2.html + format_factor = 72 elseif format == "in" then - format_factor = 1 / 25.4 + format_factor = 1 else -- i.e., Metric - format_factor = 1 + format_factor = 25.4 end - local display_dpi = Device:getDeviceScreenDPI() or Screen:getDPI() -- use device hardcoded dpi if available - return Screen:scaleBySize(px) / display_dpi * 25.4 * format_factor + -- We want the actual physical screen DPI if available, not a user override + local display_dpi = Device:getDeviceScreenDPI() or Screen:getDPI() + return Screen:scaleBySize(px) / display_dpi * format_factor end function optionsutil.formatFlexSize(value, unit)