* font/font.c: Indented.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-04-09 19:38:23 +02:00
parent 7d65244782
commit 1118c32ec7
2 changed files with 233 additions and 233 deletions

View file

@ -1,3 +1,7 @@
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
* font/font.c: Indented.
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com> 2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
Elif support to GRUB script (by Deepak Vankadaru). Elif support to GRUB script (by Deepak Vankadaru).

View file

@ -91,8 +91,7 @@ struct font_file_section
}; };
/* Replace unknown glyphs with a rounded question mark. */ /* Replace unknown glyphs with a rounded question mark. */
static grub_uint8_t unknown_glyph_bitmap[] = static grub_uint8_t unknown_glyph_bitmap[] = {
{
/* 76543210 */ /* 76543210 */
0x7C, /* ooooo */ 0x7C, /* ooooo */
0x82, /* o o */ 0x82, /* o o */
@ -141,8 +140,8 @@ ascii_glyph_lookup (grub_uint32_t code)
int current; int current;
for (current = 0; current < 0x80; current++) for (current = 0; current < 0x80; current++)
{ {
ascii_font_glyph[current] = grub_malloc(sizeof(struct grub_font_glyph) ascii_font_glyph[current] =
+ ASCII_BITMAP_SIZE); grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
ascii_font_glyph[current]->width = 8; ascii_font_glyph[current]->width = 8;
ascii_font_glyph[current]->height = 16; ascii_font_glyph[current]->height = 16;
@ -173,9 +172,9 @@ grub_font_loader_init (void)
return; return;
/* Make glyph for unknown glyph. */ /* Make glyph for unknown glyph. */
unknown_glyph = grub_malloc(sizeof(struct grub_font_glyph) unknown_glyph = grub_malloc (sizeof (struct grub_font_glyph)
+ sizeof(unknown_glyph_bitmap)); + sizeof (unknown_glyph_bitmap));
if (! unknown_glyph) if (!unknown_glyph)
return; return;
unknown_glyph->width = 8; unknown_glyph->width = 8;
@ -183,13 +182,13 @@ grub_font_loader_init (void)
unknown_glyph->offset_x = 0; unknown_glyph->offset_x = 0;
unknown_glyph->offset_y = -3; unknown_glyph->offset_y = -3;
unknown_glyph->device_width = 8; unknown_glyph->device_width = 8;
grub_memcpy(unknown_glyph->bitmap, grub_memcpy (unknown_glyph->bitmap,
unknown_glyph_bitmap, sizeof(unknown_glyph_bitmap)); unknown_glyph_bitmap, sizeof (unknown_glyph_bitmap));
/* Initialize the null font. */ /* Initialize the null font. */
font_init (&null_font); font_init (&null_font);
null_font.name = "<No Font>"; null_font.name = "<No Font>";
null_font.ascent = unknown_glyph->height-3; null_font.ascent = unknown_glyph->height - 3;
null_font.descent = 3; null_font.descent = 3;
null_font.max_char_width = unknown_glyph->width; null_font.max_char_width = unknown_glyph->width;
null_font.max_char_height = unknown_glyph->height; null_font.max_char_height = unknown_glyph->height;
@ -289,7 +288,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
grub_uint32_t last_code; grub_uint32_t last_code;
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("load_font_index(sect_length=%d)\n", sect_length); grub_printf ("load_font_index(sect_length=%d)\n", sect_length);
#endif #endif
/* Sanity check: ensure section length is divisible by the entry size. */ /* Sanity check: ensure section length is divisible by the entry size. */
@ -308,10 +307,10 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
/* Allocate the character index array. */ /* Allocate the character index array. */
font->char_index = grub_malloc (font->num_chars font->char_index = grub_malloc (font->num_chars
* sizeof (struct char_index_entry)); * sizeof (struct char_index_entry));
if (! font->char_index) if (!font->char_index)
return 1; return 1;
font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t)); font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
if (! font->bmp_idx) if (!font->bmp_idx)
{ {
grub_free (font->char_index); grub_free (font->char_index);
return 1; return 1;
@ -320,7 +319,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("num_chars=%d)\n", font->num_chars); grub_printf ("num_chars=%d)\n", font->num_chars);
#endif #endif
last_code = 0; last_code = 0;
@ -364,7 +363,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
#if FONT_DEBUG >= 5 #if FONT_DEBUG >= 5
/* Print the 1st 10 characters. */ /* Print the 1st 10 characters. */
if (i < 10) if (i < 10)
grub_printf("c=%d o=%d\n", entry->code, entry->offset); grub_printf ("c=%d o=%d\n", entry->code, entry->offset);
#endif #endif
} }
@ -380,7 +379,7 @@ read_section_as_string (struct font_file_section *section)
grub_ssize_t ret; grub_ssize_t ret;
str = grub_malloc (section->length + 1); str = grub_malloc (section->length + 1);
if (! str) if (!str)
return 0; return 0;
ret = grub_file_read (section->file, str, section->length); ret = grub_file_read (section->file, str, section->length);
@ -398,7 +397,8 @@ read_section_as_string (struct font_file_section *section)
which is stored into *VALUE. which is stored into *VALUE.
Returns 0 upon success, nonzero upon failure. */ Returns 0 upon success, nonzero upon failure. */
static int static int
read_section_as_short (struct font_file_section *section, grub_int16_t *value) read_section_as_short (struct font_file_section *section,
grub_int16_t * value)
{ {
grub_uint16_t raw_value; grub_uint16_t raw_value;
@ -408,8 +408,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value)
"font file format error: section %c%c%c%c length " "font file format error: section %c%c%c%c length "
"is %d but should be 2", "is %d but should be 2",
section->name[0], section->name[1], section->name[0], section->name[1],
section->name[2], section->name[3], section->name[2], section->name[3], section->length);
section->length);
return 1; return 1;
} }
if (grub_file_read (section->file, &raw_value, 2) != 2) if (grub_file_read (section->file, &raw_value, 2) != 2)
@ -430,7 +429,7 @@ grub_font_load (const char *filename)
grub_font_t font = 0; grub_font_t font = 0;
#if FONT_DEBUG >= 1 #if FONT_DEBUG >= 1
grub_printf("add_font(%s)\n", filename); grub_printf ("add_font(%s)\n", filename);
#endif #endif
file = grub_buffile_open (filename, 1024); file = grub_buffile_open (filename, 1024);
@ -438,7 +437,7 @@ grub_font_load (const char *filename)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("file opened\n"); grub_printf ("file opened\n");
#endif #endif
/* Read the FILE section. It indicates the file format. */ /* Read the FILE section. It indicates the file format. */
@ -446,10 +445,10 @@ grub_font_load (const char *filename)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("opened FILE section\n"); grub_printf ("opened FILE section\n");
#endif #endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE, if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FILE,
sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0) sizeof (FONT_FORMAT_SECTION_NAMES_FILE) - 1) != 0)
{ {
grub_error (GRUB_ERR_BAD_FONT, grub_error (GRUB_ERR_BAD_FONT,
"font file format error: 1st section must be FILE"); "font file format error: 1st section must be FILE");
@ -457,7 +456,7 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("section name ok\n"); grub_printf ("section name ok\n");
#endif #endif
if (section.length != 4) if (section.length != 4)
{ {
@ -468,14 +467,14 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("section length ok\n"); grub_printf ("section length ok\n");
#endif #endif
/* Check the file format type code. */ /* Check the file format type code. */
if (grub_file_read (file, magic, 4) != 4) if (grub_file_read (file, magic, 4) != 4)
goto fail; goto fail;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("read magic ok\n"); grub_printf ("read magic ok\n");
#endif #endif
if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0) if (grub_memcmp (magic, FONT_FORMAT_PFF2_MAGIC, 4) != 0)
@ -486,19 +485,19 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("compare magic ok\n"); grub_printf ("compare magic ok\n");
#endif #endif
/* Allocate the font object. */ /* Allocate the font object. */
font = (grub_font_t) grub_malloc (sizeof (struct grub_font)); font = (grub_font_t) grub_malloc (sizeof (struct grub_font));
if (! font) if (!font)
goto fail; goto fail;
font_init (font); font_init (font);
font->file = file; font->file = file;
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("allocate font ok; loading font info\n"); grub_printf ("allocate font ok; loading font info\n");
#endif #endif
/* Load the font information. */ /* Load the font information. */
@ -513,13 +512,13 @@ grub_font_load (const char *filename)
} }
#if FONT_DEBUG >= 2 #if FONT_DEBUG >= 2
grub_printf("opened section %c%c%c%c ok\n", grub_printf ("opened section %c%c%c%c ok\n",
section.name[0], section.name[1], section.name[0], section.name[1],
section.name[2], section.name[3]); section.name[2], section.name[3]);
#endif #endif
if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME, if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME,
sizeof(FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0)
{ {
font->name = read_section_as_string (&section); font->name = read_section_as_string (&section);
if (!font->name) if (!font->name)
@ -527,13 +526,15 @@ grub_font_load (const char *filename)
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_POINT_SIZE, FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
sizeof(FONT_FORMAT_SECTION_NAMES_POINT_SIZE) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
1) == 0)
{ {
if (read_section_as_short (&section, &font->point_size) != 0) if (read_section_as_short (&section, &font->point_size) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
== 0)
{ {
char *wt; char *wt;
wt = read_section_as_string (&section); wt = read_section_as_string (&section);
@ -548,40 +549,45 @@ grub_font_load (const char *filename)
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH, FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
- 1) == 0)
{ {
if (read_section_as_short (&section, &font->max_char_width) != 0) if (read_section_as_short (&section, &font->max_char_width) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT, FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
- 1) == 0)
{ {
if (read_section_as_short (&section, &font->max_char_height) != 0) if (read_section_as_short (&section, &font->max_char_height) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_ASCENT, FONT_FORMAT_SECTION_NAMES_ASCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_ASCENT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
== 0)
{ {
if (read_section_as_short (&section, &font->ascent) != 0) if (read_section_as_short (&section, &font->ascent) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
sizeof(FONT_FORMAT_SECTION_NAMES_DESCENT) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
== 0)
{ {
if (read_section_as_short (&section, &font->descent) != 0) if (read_section_as_short (&section, &font->descent) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, else if (grub_memcmp (section.name,
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX, FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
1) == 0)
{ {
if (load_font_index (file, section.length, font) != 0) if (load_font_index (file, section.length, font) != 0)
goto fail; goto fail;
} }
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA, else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DATA,
sizeof(FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0) sizeof (FONT_FORMAT_SECTION_NAMES_DATA) - 1) == 0)
{ {
/* When the DATA section marker is reached, we stop reading. */ /* When the DATA section marker is reached, we stop reading. */
break; break;
@ -590,7 +596,7 @@ grub_font_load (const char *filename)
{ {
/* Unhandled section type, simply skip past it. */ /* Unhandled section type, simply skip past it. */
#if FONT_DEBUG >= 3 #if FONT_DEBUG >= 3
grub_printf("Unhandled section type, skipping.\n"); grub_printf ("Unhandled section type, skipping.\n");
#endif #endif
grub_off_t section_end = grub_file_tell (file) + section.length; grub_off_t section_end = grub_file_tell (file) + section.length;
if ((int) grub_file_seek (file, section_end) == -1) if ((int) grub_file_seek (file, section_end) == -1)
@ -598,7 +604,7 @@ grub_font_load (const char *filename)
} }
} }
if (! font->name) if (!font->name)
{ {
grub_printf ("Note: Font has no name.\n"); grub_printf ("Note: Font has no name.\n");
font->name = grub_strdup ("Unknown"); font->name = grub_strdup ("Unknown");
@ -609,16 +615,13 @@ grub_font_load (const char *filename)
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n", "Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
font->name, font->name,
font->ascent, font->descent, font->ascent, font->descent,
font->max_char_width, font->max_char_height, font->max_char_width, font->max_char_height, font->num_chars);
font->num_chars);
#endif #endif
if (font->max_char_width == 0 if (font->max_char_width == 0
|| font->max_char_height == 0 || font->max_char_height == 0
|| font->num_chars == 0 || font->num_chars == 0
|| font->char_index == 0 || font->char_index == 0 || font->ascent == 0 || font->descent == 0)
|| font->ascent == 0
|| font->descent == 0)
{ {
grub_error (GRUB_ERR_BAD_FONT, grub_error (GRUB_ERR_BAD_FONT,
"invalid font file: missing some required data"); "invalid font file: missing some required data");
@ -679,7 +682,7 @@ find_glyph (const grub_font_t font, grub_uint32_t code)
lo = 0; lo = 0;
hi = font->num_chars - 1; hi = font->num_chars - 1;
if (! table) if (!table)
return 0; return 0;
while (lo <= hi) while (lo <= hi)
@ -719,7 +722,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
/* Return cached glyph. */ /* Return cached glyph. */
return index_entry->glyph; return index_entry->glyph;
if (! font->file) if (!font->file)
/* No open file, can't load any glyphs. */ /* No open file, can't load any glyphs. */
return 0; return 0;
@ -730,11 +733,11 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
grub_file_seek (font->file, index_entry->offset); grub_file_seek (font->file, index_entry->offset);
/* Read the glyph width, height, and baseline. */ /* Read the glyph width, height, and baseline. */
if (read_be_uint16(font->file, &width) != 0 if (read_be_uint16 (font->file, &width) != 0
|| read_be_uint16(font->file, &height) != 0 || read_be_uint16 (font->file, &height) != 0
|| read_be_int16(font->file, &xoff) != 0 || read_be_int16 (font->file, &xoff) != 0
|| read_be_int16(font->file, &yoff) != 0 || read_be_int16 (font->file, &yoff) != 0
|| read_be_int16(font->file, &dwidth) != 0) || read_be_int16 (font->file, &dwidth) != 0)
{ {
remove_font (font); remove_font (font);
return 0; return 0;
@ -742,7 +745,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
len = (width * height + 7) / 8; len = (width * height + 7) / 8;
glyph = grub_malloc (sizeof (struct grub_font_glyph) + len); glyph = grub_malloc (sizeof (struct grub_font_glyph) + len);
if (! glyph) if (!glyph)
{ {
remove_font (font); remove_font (font);
return 0; return 0;
@ -804,7 +807,7 @@ register_font (grub_font_t font)
struct grub_font_node *node = 0; struct grub_font_node *node = 0;
node = grub_malloc (sizeof (struct grub_font_node)); node = grub_malloc (sizeof (struct grub_font_node));
if (! node) if (!node)
return 1; return 1;
node->value = font; node->value = font;
@ -822,8 +825,7 @@ remove_font (grub_font_t font)
struct grub_font_node **nextp, *cur; struct grub_font_node **nextp, *cur;
for (nextp = &grub_font_list, cur = *nextp; for (nextp = &grub_font_list, cur = *nextp;
cur; cur; nextp = &cur->next, cur = cur->next)
nextp = &cur->next, cur = cur->next)
{ {
if (cur->value == font) if (cur->value == font)
{ {
@ -927,7 +929,7 @@ grub_font_get_string_width (grub_font_t font, const char *str)
const grub_uint8_t *ptr; const grub_uint8_t *ptr;
for (ptr = (const grub_uint8_t *) str, width = 0; for (ptr = (const grub_uint8_t *) str, width = 0;
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; ) grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
{ {
glyph = grub_font_get_glyph_with_fallback (font, code); glyph = grub_font_get_glyph_with_fallback (font, code);
width += glyph->device_width; width += glyph->device_width;
@ -961,7 +963,7 @@ grub_font_get_glyph (grub_font_t font, grub_uint32_t code)
sizes are used so that tiny 8 point glyphs are not mixed into a string sizes are used so that tiny 8 point glyphs are not mixed into a string
of 24 point text unless there is no other choice. */ of 24 point text unless there is no other choice. */
static int static int
get_font_diversity(grub_font_t a, grub_font_t b) get_font_diversity (grub_font_t a, grub_font_t b)
{ {
int d; int d;
@ -1052,9 +1054,8 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
baseline of the character, while the x coordinate designates the left baseline of the character, while the x coordinate designates the left
side location of the character. */ side location of the character. */
grub_err_t grub_err_t
grub_font_draw_glyph (struct grub_font_glyph *glyph, grub_font_draw_glyph (struct grub_font_glyph * glyph,
grub_video_color_t color, grub_video_color_t color, int left_x, int baseline_y)
int left_x, int baseline_y)
{ {
struct grub_video_bitmap glyph_bitmap; struct grub_video_bitmap glyph_bitmap;
@ -1065,8 +1066,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
glyph_bitmap.mode_info.width = glyph->width; glyph_bitmap.mode_info.width = glyph->width;
glyph_bitmap.mode_info.height = glyph->height; glyph_bitmap.mode_info.height = glyph->height;
glyph_bitmap.mode_info.mode_type = glyph_bitmap.mode_info.mode_type =
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
glyph_bitmap.mode_info.bpp = 1; glyph_bitmap.mode_info.bpp = 1;
@ -1081,7 +1081,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
glyph_bitmap.mode_info.bg_green = 0; glyph_bitmap.mode_info.bg_green = 0;
glyph_bitmap.mode_info.bg_blue = 0; glyph_bitmap.mode_info.bg_blue = 0;
glyph_bitmap.mode_info.bg_alpha = 0; glyph_bitmap.mode_info.bg_alpha = 0;
grub_video_unmap_color(color, grub_video_unmap_color (color,
&glyph_bitmap.mode_info.fg_red, &glyph_bitmap.mode_info.fg_red,
&glyph_bitmap.mode_info.fg_green, &glyph_bitmap.mode_info.fg_green,
&glyph_bitmap.mode_info.fg_blue, &glyph_bitmap.mode_info.fg_blue,
@ -1094,8 +1094,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND, return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
bitmap_left, bitmap_top, bitmap_left, bitmap_top,
0, 0, 0, 0, glyph->width, glyph->height);
glyph->width, glyph->height);
} }
/* Draw a UTF-8 string of text on the current video render target. /* Draw a UTF-8 string of text on the current video render target.
@ -1105,8 +1104,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
a glyph from another loaded font may be used instead. */ a glyph from another loaded font may be used instead. */
grub_err_t grub_err_t
grub_font_draw_string (const char *str, grub_font_t font, grub_font_draw_string (const char *str, grub_font_t font,
grub_video_color_t color, grub_video_color_t color, int left_x, int baseline_y)
int left_x, int baseline_y)
{ {
int x; int x;
struct grub_font_glyph *glyph; struct grub_font_glyph *glyph;
@ -1114,15 +1112,13 @@ grub_font_draw_string (const char *str, grub_font_t font,
const grub_uint8_t *ptr; const grub_uint8_t *ptr;
for (ptr = (const grub_uint8_t *) str, x = left_x; for (ptr = (const grub_uint8_t *) str, x = left_x;
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0; ) grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
{ {
glyph = grub_font_get_glyph_with_fallback (font, code); glyph = grub_font_get_glyph_with_fallback (font, code);
if (grub_font_draw_glyph (glyph, color, x, baseline_y) if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE)
!= GRUB_ERR_NONE)
return grub_errno; return grub_errno;
x += glyph->device_width; x += glyph->device_width;
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }