* util/grub-mkfont.c (write_font_ascii_bitmap): Fix handling of glyphs

not filling whole 8x16 space.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-07-11 13:50:18 +02:00
parent a2371e19b3
commit 6f80a7b231
2 changed files with 34 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2013-07-11 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c (write_font_ascii_bitmap): Fix handling of glyphs
not filling whole 8x16 space.
2013-07-11 Vladimir Serbinenko <phcoder@gmail.com> 2013-07-11 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/charset.c (bidi_line_wrap): Fix spurios warning. * grub-core/normal/charset.c (bidi_line_wrap): Fix spurios warning.

View file

@ -784,24 +784,38 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
grub_util_error (_("cannot write to `%s': %s"), output_file, grub_util_error (_("cannot write to `%s': %s"), output_file,
strerror (errno)); strerror (errno));
int correct_size;
for (glyph = font_info->glyphs_sorted, num = 0; num < font_info->num_glyphs; for (glyph = font_info->glyphs_sorted, num = 0; num < font_info->num_glyphs;
glyph++, num++) glyph++, num++)
{ {
correct_size = 1; if (glyph->width == 8 && glyph->height == 16
if (glyph->width != 8 || glyph->height != 16) && glyph->x_ofs == 0 && glyph->y_ofs == 0)
{ fwrite (glyph->bitmap, 16, 1, file);
/* printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); */ else
correct_size = 0; {
} grub_uint8_t glph[16];
int row; int p = 0, mask = 0x80;
for (row = 0; row < glyph->height; row++) int row, col;
{ int dy = 12 - glyph->height - glyph->y_ofs;
if (correct_size) for (row = 0; row < 16; row++)
fwrite (&glyph->bitmap[row], sizeof(glyph->bitmap[row]), 1, file); glph[row] = 0;
else for (row = 0; row < glyph->height; row++)
fwrite (&correct_size, 1, 1, file); for (col = 0; col < glyph->width; col++)
} {
int val = glyph->bitmap[p] & mask;
mask >>= 1;
if (mask == 0)
{
mask = 0x80;
p++;
}
if (val && dy + row >= 0
&& dy + row < 16
&& glyph->x_ofs + col >= 0
&& glyph->x_ofs + col < 8)
glph[dy + row] |= 1 << (7 - (glyph->x_ofs + col));
}
fwrite (glph, 16, 1, file);
}
} }
fclose (file); fclose (file);
} }