[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190618203425.10723-4-tiwai@suse.de>
Date: Tue, 18 Jun 2019 22:34:25 +0200
From: Takashi Iwai <tiwai@...e.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH RFC 3/3] fonts: Prefer a bigger font for high resolution screens
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@...e.de>
---
lib/fonts/fonts.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/fonts/fonts.c b/lib/fonts/fonts.c
index a8e31e9d6fc5..e7258d8c252b 100644
--- a/lib/fonts/fonts.c
+++ b/lib/fonts/fonts.c
@@ -106,7 +106,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;
@@ -127,6 +127,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;
--
2.16.4
Powered by blists - more mailing lists