Skip to content

Commit

Permalink
Fix #255: text too small to be readable on Linux/X with weird screen (#…
Browse files Browse the repository at this point in the history
…388)

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
#255 (comment).
Thanks @TheCasualObserver for, well, coming up with the.


I also considered making the check Linux only, as that is where the
issue was reported. However, DPI significantly < 96 either should not
ever be reported by other OSes, or if it really is correct (IDK, on big
old TVs, projectors), the display is still most likely going to be
viewed from further away. Pretending like it's normal 96 DPI screen will
be better in those cases as well. Nobody will ever want letters made of
6 pixels 😁 (I hope)
  • Loading branch information
shpaass authored Jan 15, 2025
2 parents 525f328 + 854a60e commit a15043b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Yafc.UI/Core/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a15043b

Please sign in to comment.