Blob Blame Raw
From c54df09cdb44ab19f9f7d5ece0f6568f4c19e46f Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Mon, 10 Dec 2012 16:07:33 +0100
Subject: [PATCH 061/364] 	* grub-core/term/gfxterm.c
 (grub_virtual_screen_setup): Get font as 	argument rather than font
 name. All users updated. 	(grub_gfxterm_set_window): Likewise.

---
 ChangeLog                |  6 ++++++
 grub-core/gfxmenu/view.c | 11 ++++++++++-
 grub-core/term/gfxterm.c | 18 ++++++++++--------
 include/grub/gfxterm.h   |  3 ++-
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4204678..7617678 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-10  Vladimir Serbinenko  <phcoder@gmail.com>
+
+	* grub-core/term/gfxterm.c (grub_virtual_screen_setup): Get font as
+	argument rather than font name. All users updated.
+	(grub_gfxterm_set_window): Likewise.
+
 2012-12-10  Vladimir Testov  <vladimir.testov@rosalab.ru>
 
 	* util/grub-mkfont.c (argp_parser): Fix a typo which prevented --asce
diff --git a/grub-core/gfxmenu/view.c b/grub-core/gfxmenu/view.c
index 9023fd3..c005773 100644
--- a/grub-core/gfxmenu/view.c
+++ b/grub-core/gfxmenu/view.c
@@ -361,6 +361,15 @@ grub_gfxmenu_draw_terminal_box (void)
 static void
 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;
+    }
+
   term_rect.width = view->screen.width * 7 / 10;
   term_rect.height = view->screen.height * 7 / 10;
 
@@ -375,7 +384,7 @@ init_terminal (grub_gfxmenu_view_t view)
   grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY, term_rect.x,
 			   term_rect.y,
 			   term_rect.width, term_rect.height,
-			   view->double_repaint, view->terminal_font_name, 3);
+			   view->double_repaint, terminal_font, 3);
   grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box;
 }
 
diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
index c995b84..12567d1 100644
--- a/grub-core/term/gfxterm.c
+++ b/grub-core/term/gfxterm.c
@@ -201,7 +201,7 @@ grub_virtual_screen_free (void)
 static grub_err_t
 grub_virtual_screen_setup (unsigned int x, unsigned int y,
                            unsigned int width, unsigned int height,
-                           const char *font_name)
+			   grub_font_t font)
 {
   unsigned int i;
 
@@ -209,10 +209,7 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
   grub_virtual_screen_free ();
 
   /* Initialize with default data.  */
-  virtual_screen.font = grub_font_get (font_name);
-  if (!virtual_screen.font)
-    return grub_error (GRUB_ERR_BAD_FONT,
-                       "no font loaded");
+  virtual_screen.font = font;
   virtual_screen.width = width;
   virtual_screen.height = height;
   virtual_screen.offset_x = x;
@@ -282,7 +279,7 @@ grub_err_t
 grub_gfxterm_set_window (struct grub_video_render_target *target,
 			 int x, int y, int width, int height,
 			 int double_repaint,
-			 const char *font_name, int border_width)
+			 grub_font_t font, int border_width)
 {
   /* Clean up any prior instance.  */
   destroy_window ();
@@ -294,7 +291,7 @@ grub_gfxterm_set_window (struct grub_video_render_target *target,
   if (grub_virtual_screen_setup (border_width, border_width, 
                                  width - 2 * border_width, 
                                  height - 2 * border_width, 
-                                 font_name) 
+                                 font) 
       != GRUB_ERR_NONE)
     {
       return grub_errno;
@@ -321,6 +318,7 @@ grub_gfxterm_fullscreen (void)
   grub_video_color_t color;
   grub_err_t err;
   int double_redraw;
+  grub_font_t font;
 
   err = grub_video_get_info (&mode_info);
   /* Figure out what mode we ended up.  */
@@ -346,12 +344,16 @@ grub_gfxterm_fullscreen (void)
   if (! font_name)
     font_name = "";   /* Allow fallback to any font.  */
 
+  font = grub_font_get (font_name);
+  if (!font)
+    return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
+
   grub_gfxterm_decorator_hook = NULL;
 
   return grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY,
 				  0, 0, mode_info.width, mode_info.height,
 				  double_redraw,
-				  font_name, DEFAULT_BORDER_WIDTH);
+				  font, DEFAULT_BORDER_WIDTH);
 }
 
 static grub_err_t
diff --git a/include/grub/gfxterm.h b/include/grub/gfxterm.h
index 3fc8d92..361f73e 100644
--- a/include/grub/gfxterm.h
+++ b/include/grub/gfxterm.h
@@ -23,12 +23,13 @@
 #include <grub/types.h>
 #include <grub/term.h>
 #include <grub/video.h>
+#include <grub/font.h>
 
 grub_err_t
 EXPORT_FUNC (grub_gfxterm_set_window) (struct grub_video_render_target *target,
 				       int x, int y, int width, int height,
 				       int double_repaint,
-				       const char *font_name, int border_width);
+				       grub_font_t font, int border_width);
 
 typedef void (*grub_gfxterm_repaint_callback_t)(int x, int y,
                                                 int width, int height);
-- 
1.8.1.4