Add grub_font_get_no_fallback
PATCH 1/3 Add grub_font_get_no_fallback
This allows the caller to handle the fallback
Signed-off-by Vladimir Serbinenko <[email protected]>
--- grub-core/font/font.c | 21 ++++++++++++++++----- include/grub/font.h | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-)
grub-core/font/font.c +16 -5
@@ -904,12 +904,8 @@ remove_font (grub_font_t font) } } -/* Get a font from the list of loaded fonts. This function will return -another font if the requested font is not available. If no fonts are -loaded, then a special 'null font' is returned, which contains no glyphs, -but is not a null pointer so the caller may omit checks for NULL. */ grub_font_t -grub_font_get (const char *font_name) +grub_font_get_no_fallback (const char *font_name) {struct grub_font_node *node;
@@ -920,6 +916,21 @@ grub_font_get (const char *font_name)return font; } +return NULL ; +} + +/* Get a font from the list of loaded fonts. This function will return +another font if the requested font is not available. If no fonts are +loaded, then a special 'null font' is returned, which contains no glyphs, +but is not a null pointer so the caller may omit checks for NULL. */ +grub_font_t +grub_font_get (const char *font_name) +{ +grub_font_t font =grub_font_get_no_fallback (font_name); + +if (font) +return font; +/* If no font by that name is found, return the first font in the list as a fallback. */ if (grub_font_list && grub_font_list->value)
include/grub/font.h +2 -0
@@ -107,6 +107,8 @@ grub_font_t EXPORT_FUNC(grub_font_load) (const char *filename);is returned as a fallback. */ grub_font_t EXPORT_FUNC (grub_font_get ) (const char *font_name); +grub_font_t EXPORT_FUNC (grub_font_get_no_fallback ) (const char *font_name); +const char *EXPORT_FUNC (grub_font_get_name ) (grub_font_t font);int EXPORT_FUNC (grub_font_get_max_char_width ) (grub_font_t font);
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 3/3 Improve font fallback scanning and validation for gfxterm
Choosing a font which is too large breaks gfxterm. Be more diligent in font choice. This being said it's better to specify the correct font explicitly in config when several fonts are loaded.
Signed-off-by Vladimir Serbinenko <[email protected]>
--- grub-core/gfxmenu/view.c | 7 +---- grub-core/term/gfxterm.c | 56 ++++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 17 deletions(-)
grub-core/gfxmenu/view.c +1 -6
@@ -524,12 +524,7 @@ init_terminal (grub_gfxmenu_view_t view) {grub_font_t terminal_font; - terminal_font =grub_font_get (view->terminal_font_name); -if (!terminal_font) - { -grub_error (GRUB_ERR_BAD_FONT ,"no font loaded" ); -return ; - } + terminal_font =grub_font_get_no_fallback (view->terminal_font_name);/* Check that terminal window size and position are sane. */ terminal_sanity_check (view);
grub-core/term/gfxterm.c +45 -11
90 lines not on this page · raw message
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/3 gfxmenu: Add missing error handling
In reply to Vladimir SerbinenkoWe don't currently handle errors from gfxterm
Signed-off-by Vladimir Serbinenko <[email protected]>
--- grub-core/gfxmenu/view.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
grub-core/gfxmenu/view.c +4 -1
@@ -539,7 +539,7 @@ init_terminal (grub_gfxmenu_view_t view)/* Note: currently there is no API for changing the gfxterm font on the fly, so whatever font the initially loaded theme specifies will be permanent. */ - grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY, + grub_err_t err = grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY, view->terminal_rect.x, view->terminal_rect.y, view->terminal_rect.width,
@@ -547,6 +547,9 @@ init_terminal (grub_gfxmenu_view_t view) view->double_repaint, terminal_font, view->terminal_border); +if (err) +return ; + grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box; }
Signature · 7 lines
2.39.2 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel