* util/grub-mkfont.c (write_font_ascii_bitmap): Fix handling of glyphs
not filling whole 8x16 space.
This commit is contained in:
parent
a2371e19b3
commit
6f80a7b231
2 changed files with 34 additions and 15 deletions
|
@ -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>
|
||||
|
||||
* grub-core/normal/charset.c (bidi_line_wrap): Fix spurios warning.
|
||||
|
|
|
@ -784,23 +784,37 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file)
|
|||
grub_util_error (_("cannot write to `%s': %s"), output_file,
|
||||
strerror (errno));
|
||||
|
||||
int correct_size;
|
||||
for (glyph = font_info->glyphs_sorted, num = 0; num < font_info->num_glyphs;
|
||||
glyph++, num++)
|
||||
{
|
||||
correct_size = 1;
|
||||
if (glyph->width != 8 || glyph->height != 16)
|
||||
{
|
||||
/* printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); */
|
||||
correct_size = 0;
|
||||
}
|
||||
int row;
|
||||
for (row = 0; row < glyph->height; row++)
|
||||
{
|
||||
if (correct_size)
|
||||
fwrite (&glyph->bitmap[row], sizeof(glyph->bitmap[row]), 1, file);
|
||||
if (glyph->width == 8 && glyph->height == 16
|
||||
&& glyph->x_ofs == 0 && glyph->y_ofs == 0)
|
||||
fwrite (glyph->bitmap, 16, 1, file);
|
||||
else
|
||||
fwrite (&correct_size, 1, 1, file);
|
||||
{
|
||||
grub_uint8_t glph[16];
|
||||
int p = 0, mask = 0x80;
|
||||
int row, col;
|
||||
int dy = 12 - glyph->height - glyph->y_ofs;
|
||||
for (row = 0; row < 16; row++)
|
||||
glph[row] = 0;
|
||||
for (row = 0; row < glyph->height; row++)
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue