# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/linux/hotfix-fbcon-fonts.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-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; }