]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
fonts: Prefer a bigger font for high resolution screens
authorTakashi Iwai <tiwai@suse.de>
Thu, 7 Nov 2019 11:43:58 +0000 (19:43 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Thu, 28 Nov 2019 07:42:23 +0000 (02:42 -0500)
BugLink: https://bugs.launchpad.net/bugs/1851623
Although we may have multiple fonts in kernel, the small 8x16 font is
chosen as default usually unless user specify the boot option.  This
is suboptimal for monitors with high resolutions.

This patch tries to assign a bigger font for such a high resolution by
calculating some penalty value.  This won't change anything for a
standard monitor like Full HD (1920x1080), but for a high res monitor
like UHD 4K, a bigger font like TER16x32 will be chosen once when
enabled in Kconfig.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dfd19a5004eff03755967086aa04254c3d91b8ec)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
lib/fonts/fonts.c

index 269a829fcbb7091f7be1b0933c8bfddf57fd1ef3..0edd580a21596c912d7e9f03cd832623c7a288b0 100644 (file)
@@ -119,7 +119,7 @@ EXPORT_SYMBOL(find_font);
 const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
                                         u32 font_h)
 {
-       int i, c, cc;
+       int i, c, cc, res;
        const struct font_desc *f, *g;
 
        g = NULL;
@@ -140,6 +140,11 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
                if ((yres < 400) == (f->height <= 8))
                        c += 1000;
 
+               /* prefer a bigger font for high resolution */
+               res = (xres / f->width) * (yres / f->height) / 1000;
+               if (res > 20)
+                       c += 20 - res;
+
                if ((font_w & (1 << (f->width - 1))) &&
                    (font_h & (1 << (f->height - 1))))
                        c += 1000;