--- grub-mkfont.c 2010-01-22 15:01:47.664910782 +0600 +++ grub-mkfont.bak.c 2010-01-22 00:38:28.000000000 +0600 @@ -51,7 +51,7 @@ enum file_formats { - PFN, + PF2, ASCII_BITMAPS }; @@ -59,7 +59,6 @@ #define GRUB_FONT_FLAG_NOBITMAP 2 #define GRUB_FONT_FLAG_NOHINTING 4 #define GRUB_FONT_FLAG_FORCEHINT 8 -#define GRUB_FONT_FLAG_8BIT_AA 4096 struct grub_font_info { @@ -95,7 +94,6 @@ {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, {"ascii-bitmaps", no_argument, 0, 0x102}, - {"pff3", no_argument, 0, '3'}, {0, 0, 0, 0} }; @@ -111,7 +109,6 @@ Usage: %s [OPTIONS] FONT_FILES\n\ \nOptions:\n\ -o, --output=FILE_NAME set output file name\n\ - -3, --pff3 save in pff3 format (antialiased)\n\ --ascii-bitmaps save only the ASCII bitmaps\n\ -i, --index=N set face index\n\ -r, --range=A-B[,C-D] set font range\n\ @@ -157,12 +154,7 @@ grub_uint8_t *data; int mask, i, j, bitmap_size; FT_GlyphSlot glyph; - int flag = FT_LOAD_RENDER; - - if (font_info->flags & GRUB_FONT_FLAG_8BIT_AA) - flag |= FT_LOAD_TARGET_NORMAL; - else - flag |= FT_LOAD_MONOCHROME; + int flag = FT_LOAD_RENDER | FT_LOAD_MONOCHROME; if (font_info->flags & GRUB_FONT_FLAG_NOBITMAP) flag |= FT_LOAD_NO_BITMAP; @@ -193,11 +185,7 @@ width = glyph->bitmap.width; height = glyph->bitmap.rows; - if (font_info->flags & GRUB_FONT_FLAG_8BIT_AA) - bitmap_size = width * height; - else - bitmap_size = ((width * height + 7) / 8); - + bitmap_size = ((width * height + 7) / 8); glyph_info = xmalloc (sizeof (struct grub_glyph_info) + bitmap_size); glyph_info->bitmap_size = bitmap_size; @@ -223,18 +211,13 @@ if (glyph_info->y_ofs + height > font_info->max_y) font_info->max_y = glyph_info->y_ofs + height; - if (font_info->flags & GRUB_FONT_FLAG_8BIT_AA) - memcpy (glyph_info->bitmap, glyph->bitmap.buffer, bitmap_size); - else - { - mask = 0; - data = &glyph_info->bitmap[0] - 1; - for (j = 0; j < height; j++) - for (i = 0; i < width; i++) - add_pixel (&data, &mask, - glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] & - (1 << (7 - (i & 7)))); - } + mask = 0; + data = &glyph_info->bitmap[0] - 1; + for (j = 0; j < height; j++) + for (i = 0; i < width; i++) + add_pixel (&data, &mask, + glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] & + (1 << (7 - (i & 7)))); } void @@ -246,17 +229,18 @@ grub_uint32_t j; for (i = 0; i < font_info->num_range; i++) - for (j = font_info->ranges[i * 2]; j <= font_info->ranges[i * 2 + 1]; j++) - add_char (font_info, face, j); + for (j = font_info->ranges[i * 2]; j <= font_info->ranges[i * 2 + 1]; + j++) + add_char (font_info, face, j); } else { grub_uint32_t char_code, glyph_index; for (char_code = FT_Get_First_Char (face, &glyph_index); - glyph_index; - char_code = FT_Get_Next_Char (face, char_code, &glyph_index)) - add_char (font_info, face, char_code); + glyph_index; + char_code = FT_Get_Next_Char (face, char_code, &glyph_index)) + add_char (font_info, face, char_code); } } @@ -308,74 +292,56 @@ xmax = glyph->x_ofs + glyph->width; if (xmax < glyph->device_width) - xmax = glyph->device_width; + xmax = glyph->device_width; xmin = glyph->x_ofs; if (xmin > 0) - xmin = 0; + xmin = 0; ymax = glyph->y_ofs + glyph->height; if (ymax < font_info->asce) - ymax = font_info->asce; + ymax = font_info->asce; ymin = glyph->y_ofs; if (ymin > - font_info->desc) - ymin = - font_info->desc; + ymin = - font_info->desc; bitmap = glyph->bitmap; mask = 0x80; for (y = ymax - 1; y >= ymin; y--) - { - int line_pos; + { + int line_pos; - line_pos = 0; - for (x = xmin; x < xmax; x++) - { - if ((x >= glyph->x_ofs) && - (x < glyph->x_ofs + glyph->width) && - (y >= glyph->y_ofs) && - (y < glyph->y_ofs + glyph->height)) - { - if (font_info->flags & GRUB_FONT_FLAG_8BIT_AA) - { - if (*bitmap > 127) - line[line_pos++] = '#'; - else if (*bitmap > 64) - line[line_pos++] = '8'; - else if (*bitmap > 8) - line[line_pos++] = 'o'; - else if (*bitmap > 1) - line[line_pos++] = '-'; - else - line[line_pos++] = '_'; - - bitmap++; - } - else - { - line[line_pos++] = (*bitmap & mask) ? '#' : '_'; - mask >>= 1; - if (mask == 0) - { - mask = 0x80; - bitmap++; - } - } - } - else if ((x >= 0) && - (x < glyph->device_width) && - (y >= - font_info->desc) && - (y < font_info->asce)) - { - line[line_pos++] = ((x == 0) || (y == 0)) ? '+' : '.'; - } - else - line[line_pos++] = '*'; - } - line[line_pos] = 0; - printf ("%s\n", line); - } - } + line_pos = 0; + for (x = xmin; x < xmax; x++) + { + if ((x >= glyph->x_ofs) && + (x < glyph->x_ofs + glyph->width) && + (y >= glyph->y_ofs) && + (y < glyph->y_ofs + glyph->height)) + { + line[line_pos++] = (*bitmap & mask) ? '#' : '_'; + mask >>= 1; + if (mask == 0) + { + mask = 0x80; + bitmap++; + } + } + else if ((x >= 0) && + (x < glyph->device_width) && + (y >= - font_info->desc) && + (y < font_info->asce)) + { + line[line_pos++] = ((x == 0) || (y == 0)) ? '+' : '.'; + } + else + line[line_pos++] = '*'; + } + line[line_pos] = 0; + printf ("%s\n", line); + } + } } void @@ -396,22 +362,22 @@ 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; + 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 (correct_size) + fwrite (&glyph->bitmap[row], sizeof(glyph->bitmap[row]), 1, file); + else + fwrite (&correct_size, 1, 1, file); } } - fclose (file); + fclose (file); } void -write_font_pfN (struct grub_font_info *font_info, char *output_file) +write_font_pf2 (struct grub_font_info *font_info, char *output_file) { FILE *file; grub_uint32_t leng, data; @@ -428,11 +394,7 @@ leng = grub_cpu_to_be32 (4); grub_util_write_image ("FILE", 4, file); grub_util_write_image ((char *) &leng, 4, file); - if (font_info->flags & GRUB_FONT_FLAG_8BIT_AA) - grub_util_write_image ("PFF3", 4, file); - else - grub_util_write_image ("PFF2", 4, file); - + grub_util_write_image ("PFF2", 4, file); offset += 12; if (! font_info->name) @@ -562,7 +524,7 @@ int font_index = 0; int font_size = 0; char *output_file = NULL; - enum file_formats file_format = PFN; + enum file_formats file_format = PF2; memset (&font_info, 0, sizeof (font_info)); @@ -573,7 +535,7 @@ /* Check for options. */ while (1) { - int c = getopt_long (argc, argv, "bao:n:i:s:d:r:hVv3", options, 0); + int c = getopt_long (argc, argv, "bao:n:i:s:d:r:hVv", options, 0); if (c == -1) break; @@ -670,10 +632,6 @@ case 0x102: file_format = ASCII_BITMAPS; break; - - case '3': - font_info.flags |= GRUB_FONT_FLAG_8BIT_AA; - break; default: usage (1); @@ -739,8 +697,8 @@ FT_Done_FreeType (ft_lib); - if (file_format == PFN) - write_font_pfN (&font_info, output_file); + if (file_format == PF2) + write_font_pf2 (&font_info, output_file); else if (file_format == ASCII_BITMAPS) write_font_ascii_bitmap (&font_info, output_file);