From 854a60e971b4c8b32ee2c67290554c614b67e8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Standa=20Luke=C5=A1?= Date: Tue, 14 Jan 2025 22:14:57 +0100 Subject: [PATCH] Fix #255: text too small to be readable on Linux/X with weird screen If DPI is lower than 96, we just use the default 100% scaling, as the value is more likely to be driver issue than what the user wants. See discussion at https://github.com/shpaass/yafc-ce/issues/255#issuecomment-2508884418. Thanks @TheCasualObserver for, well, coming up with the fix. --- Yafc.UI/Core/Window.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Yafc.UI/Core/Window.cs b/Yafc.UI/Core/Window.cs index eb2f0e22..a49586a4 100644 --- a/Yafc.UI/Core/Window.cs +++ b/Yafc.UI/Core/Window.cs @@ -70,7 +70,10 @@ internal static int CalculateUnitsToPixels(int display) { _ = SDL.SDL_GetDisplayDPI(display, out float dpi, out _, out _); _ = SDL.SDL_GetDisplayBounds(display, out var rect); // 82x60 is the minimum screen size in units, plus some for borders - int desiredUnitsToPixels = dpi == 0 ? 13 : MathUtils.Round(dpi / 6.8f); + // DPI bellow 96 is more likely to be incorrectly reported value than desired, + // see discussion in https://github.com/shpaass/yafc-ce/issues/255#issuecomment-2508884418 + // => we treat is as "unknown" and revert to default 100% scaling + int desiredUnitsToPixels = dpi < 96 ? 13 : MathUtils.Round(dpi / 6.8f); if (desiredUnitsToPixels * 82f >= rect.w) { desiredUnitsToPixels = MathUtils.Floor(rect.w / 82f);