grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Serbinenko <phcoder@gmail.com>
To: grub-devel@gnu.org
Cc: Vladimir Serbinenko <phcoder@gmail.com>
Subject: [PATCH 1/3] Add grub_font_get_no_fallback
Date: Thu, 16 May 2024 22:31:51 +0300	[thread overview]
Message-ID: <20240516193153.4595-1-phcoder@gmail.com> (raw)

This allows the caller to handle the fallback

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 grub-core/font/font.c | 21 ++++++++++++++++-----
 include/grub/font.h   |  2 ++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/grub-core/font/font.c b/grub-core/font/font.c
index 18de52562..ea01db01b 100644
--- a/grub-core/font/font.c
+++ b/grub-core/font/font.c
@@ -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)
diff --git a/include/grub/font.h b/include/grub/font.h
index 708fa42ac..e6a43f8fc 100644
--- a/include/grub/font.h
+++ b/include/grub/font.h
@@ -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);
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2024-05-16 19:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 19:31 Vladimir Serbinenko [this message]
2024-05-16 19:31 ` [PATCH 2/3] gfxmenu: Add missing error handling Vladimir Serbinenko
2024-05-16 19:31 ` [PATCH 3/3] Improve font fallback scanning and validation for gfxterm Vladimir Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240516193153.4595-1-phcoder@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).