Skip to content

Commit dfd19a5

Browse files
tiwaigregkh
authored andcommitted
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@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 73a649d commit dfd19a5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎lib/fonts/fonts.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ EXPORT_SYMBOL(find_font);
106106
const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
107107
u32 font_h)
108108
{
109-
int i, c, cc;
109+
int i, c, cc, res;
110110
const struct font_desc *f, *g;
111111

112112
g = NULL;
@@ -127,6 +127,11 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
127127
if ((yres < 400) == (f->height <= 8))
128128
c += 1000;
129129

130+
/* prefer a bigger font for high resolution */
131+
res = (xres / f->width) * (yres / f->height) / 1000;
132+
if (res > 20)
133+
c += 20 - res;
134+
130135
if ((font_w & (1 << (f->width - 1))) &&
131136
(font_h & (1 << (f->height - 1))))
132137
c += 1000;

0 commit comments

Comments
 (0)