diff --git a/ChangeLog b/ChangeLog index 66eb729ee..f404fd7d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-07-11 Vladimir Serbinenko + + * util/grub-mkfont.c (write_font_ascii_bitmap): Fix handling of glyphs + not filling whole 8x16 space. + 2013-07-11 Vladimir Serbinenko * grub-core/normal/charset.c (bidi_line_wrap): Fix spurios warning. diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 0343fd293..985e09897 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -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, 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); - else - fwrite (&correct_size, 1, 1, file); - } + if (glyph->width == 8 && glyph->height == 16 + && glyph->x_ofs == 0 && glyph->y_ofs == 0) + fwrite (glyph->bitmap, 16, 1, file); + else + { + 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); }