# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/linux/hotfix-fbcon-fonts.patch # Copyright (C) 2024 - 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c index 47e34950b665..efc3efabae79 100644 --- a/lib/fonts/fonts.c +++ b/lib/fonts/fonts.c @@ -108,6 +108,10 @@ EXPORT_SYMBOL(find_font); * chosen font. * */ + +#define TARGET_XRES 100 +#define TARGET_YRES 25 + const struct font_desc *get_default_font(int xres, int yres, unsigned long *font_w, unsigned long *font_h) @@ -116,9 +120,10 @@ const struct font_desc *get_default_font(int xres, int yres, const struct font_desc *f, *g; g = NULL; - cc = -10000; + cc = INT_MAX; for (i = 0; i < num_fonts; i++) { f = fonts[i]; +#if 0 c = f->pref; #if defined(__mc68000__) #ifdef CONFIG_FONT_PEARL_8x8 @@ -137,12 +142,15 @@ const struct font_desc *get_default_font(int xres, int yres, res = (xres / f->width) * (yres / f->height) / 1000; if (res > 20) c += 20 - res; +#endif + /* closest to ideal target res - TODO: maybe add yres */ + c = abs(TARGET_XRES - xres / f->width); if ((!font_w || test_bit(f->width - 1, font_w)) && (!font_h || test_bit(f->height - 1, font_h))) - c += 1000; + c /= 2; - if (c > cc) { + if (c < cc) { cc = c; g = f; }