diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -2054,7 +2054,8 @@ * 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 @@ 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 @@ * 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 @@ } break; } + font = NULL; } return (font); @@ -2123,7 +2132,7 @@ } if (font == NULL) - font = gfx_get_font(); + font = gfx_get_font(*rows, *cols, h, w); if (font != NULL) { *rows = height / font->vfbd_height;