mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
loader: loader can pick too large font
While calculating font size based on EDID data, we can end up selecting too large font and too small terminal. Add check to prevent it. Tested by: bz, ziaee Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D50258
This commit is contained in:
parent
206198289e
commit
5e25f7b099
1 changed files with 12 additions and 3 deletions
|
|
@ -2054,7 +2054,8 @@ gfx_get_ppi(void)
|
|||
* not smaller than calculated size value.
|
||||
*/
|
||||
static vt_font_bitmap_data_t *
|
||||
gfx_get_font(void)
|
||||
gfx_get_font(teken_unit_t rows, teken_unit_t cols, teken_unit_t height,
|
||||
teken_unit_t width)
|
||||
{
|
||||
unsigned ppi, size;
|
||||
vt_font_bitmap_data_t *font = NULL;
|
||||
|
|
@ -2077,6 +2078,14 @@ gfx_get_font(void)
|
|||
size = roundup(size * 2, 10) / 10;
|
||||
|
||||
STAILQ_FOREACH(fl, &fonts, font_next) {
|
||||
/*
|
||||
* Skip too large fonts.
|
||||
*/
|
||||
font = fl->font_data;
|
||||
if (height / font->vfbd_height < rows &&
|
||||
width / font->vfbd_width < cols)
|
||||
continue;
|
||||
|
||||
next = STAILQ_NEXT(fl, font_next);
|
||||
|
||||
/*
|
||||
|
|
@ -2084,7 +2093,6 @@ gfx_get_font(void)
|
|||
* we have our font. Make sure, it actually is loaded.
|
||||
*/
|
||||
if (next == NULL || next->font_data->vfbd_height < size) {
|
||||
font = fl->font_data;
|
||||
if (font->vfbd_font == NULL ||
|
||||
fl->font_flags == FONT_RELOAD) {
|
||||
if (fl->font_load != NULL &&
|
||||
|
|
@ -2093,6 +2101,7 @@ gfx_get_font(void)
|
|||
}
|
||||
break;
|
||||
}
|
||||
font = NULL;
|
||||
}
|
||||
|
||||
return (font);
|
||||
|
|
@ -2123,7 +2132,7 @@ set_font(teken_unit_t *rows, teken_unit_t *cols, teken_unit_t h, teken_unit_t w)
|
|||
}
|
||||
|
||||
if (font == NULL)
|
||||
font = gfx_get_font();
|
||||
font = gfx_get_font(*rows, *cols, h, w);
|
||||
|
||||
if (font != NULL) {
|
||||
*rows = height / font->vfbd_height;
|
||||
|
|
|
|||
Loading…
Reference in a new issue