]> git.proxmox.com Git - grub2.git/commitdiff
* grub-core/gfxmenu/gui_label.c (label_paint): Handle the case
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Dec 2011 18:35:54 +0000 (19:35 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Dec 2011 18:35:54 +0000 (19:35 +0100)
text_width > available width a bit more gracefully.

ChangeLog
grub-core/gfxmenu/gui_label.c

index 2bd1aa287394306589af6e03be3fe59c88666bce..ff54cfe78d7eb33e81fdfaf9826c30b2f8961c95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/gfxmenu/gui_label.c (label_paint): Handle the case
+       text_width > available width a bit more gracefully.
+
 2011-12-15  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/loader/i386/bsdXX.c (grub_freebsd_load_elfmodule): Fix
index a7dc95afc03bc87b4f573abcd328592bd7300e81..688bea077c0c6a1442f759d48170872d3a823dce 100644 (file)
@@ -94,15 +94,17 @@ label_paint (void *vself, const grub_video_rect_t *region)
   if (self->align == align_left)
     left_x = 0;
   else if (self->align == align_center)
-    left_x = ((self->bounds.width
-               - grub_font_get_string_width (self->font, self->text))
-             ) / 2;
+    left_x = (self->bounds.width
+             - grub_font_get_string_width (self->font, self->text)) / 2;
   else if (self->align == align_right)
     left_x = (self->bounds.width
               - grub_font_get_string_width (self->font, self->text));
   else
     return;   /* Invalid alignment.  */
 
+  if (left_x < 0 || left_x > (int) self->bounds.width)
+    left_x = 0;
+
   grub_video_rect_t vpsave;
   grub_gui_set_viewport (&self->bounds, &vpsave);
   grub_font_draw_string (self->text,