--- font.c 2010-01-22 16:52:54.980914210 +0600 +++ font.bak.c 2010-01-22 00:38:28.000000000 +0600 @@ -51,7 +51,6 @@ struct grub_font { - grub_uint8_t version; char *name; grub_file_t file; char *family; @@ -65,7 +64,6 @@ grub_uint32_t num_chars; struct char_index_entry *char_index; grub_uint16_t *bmp_idx; - grub_uint8_t *glyph_bitmap_buffer; }; /* Definition of font registry. */ @@ -93,7 +91,6 @@ /* Font file format constants. */ static const char pff2_magic[4] = { 'P', 'F', 'F', '2' }; -static const char pff3_magic[4] = { 'P', 'F', 'F', '3' }; static const char section_names_file[4] = { 'F', 'I', 'L', 'E' }; static const char section_names_font_name[4] = { 'N', 'A', 'M', 'E' }; static const char section_names_point_size[4] = { 'P', 'T', 'S', 'Z' }; @@ -216,8 +213,6 @@ static void font_init (grub_font_t font) { - font->version = 2; - font->name = 0; font->file = 0; font->family = 0; @@ -445,7 +440,6 @@ struct font_file_section section; char magic[4]; grub_font_t font = 0; - grub_uint8_t pff3 = 0; #if FONT_DEBUG >= 1 grub_printf("add_font(%s)\n", filename); @@ -495,15 +489,12 @@ grub_printf("read magic ok\n"); #endif - if (grub_memcmp (magic, pff2_magic, 4) != 0 && grub_memcmp (magic, pff3_magic, 4) != 0) + if (grub_memcmp (magic, pff2_magic, 4) != 0) { grub_error (GRUB_ERR_BAD_FONT, "invalid font magic %x %x %x %x", magic[0], magic[1], magic[2], magic[3]); goto fail; } - else - if (grub_memcmp (magic, pff3_magic, 4) == 0) - pff3 = 1; #if FONT_DEBUG >= 3 grub_printf("compare magic ok\n"); @@ -517,9 +508,6 @@ font_init (font); font->file = file; - if (pff3 != 0) - font->version = 3; - #if FONT_DEBUG >= 3 grub_printf("allocate font ok; loading font info\n"); #endif @@ -621,9 +609,6 @@ font->max_char_width, font->max_char_height, font->num_chars); #endif - - /* Font loaded. Create glyph to bitmap conversion buffer */ - font->glyph_bitmap_buffer = grub_malloc (font->max_char_width * font->max_char_height * 4); if (font->max_char_width == 0 || font->max_char_height == 0 @@ -752,10 +737,7 @@ return 0; } - if (font->version == 3) - len = width * height; - else - len = (width * height + 7) / 8; + len = (width * height + 7) / 8; glyph = grub_malloc (sizeof (struct grub_font_glyph) + len); if (! glyph) { @@ -806,7 +788,6 @@ grub_free (font->name); grub_free (font->family); grub_free (font->char_index); - grub_free (font->glyph_bitmap_buffer); grub_free (font); } } @@ -1079,59 +1060,29 @@ glyph_bitmap.mode_info.width = glyph->width; glyph_bitmap.mode_info.height = glyph->height; - - if (glyph->font->version == 3) - { - glyph_bitmap.mode_info.mode_type = - (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) - | GRUB_VIDEO_MODE_TYPE_RGB | GRUB_VIDEO_MODE_TYPE_ALPHA; - glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_RGBA_8888; - glyph_bitmap.mode_info.bpp = 32; - glyph_bitmap.mode_info.bytes_per_pixel = 4; - glyph_bitmap.mode_info.pitch = glyph->width * 4; - } - else - { - glyph_bitmap.mode_info.mode_type = - (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) - | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP; - glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; - glyph_bitmap.mode_info.bpp = 1; - - /* Really 1 bit per pixel. */ - glyph_bitmap.mode_info.bytes_per_pixel = 0; - - /* Packed densely as bits. */ - glyph_bitmap.mode_info.pitch = glyph->width; - - glyph_bitmap.mode_info.number_of_colors = 2; - glyph_bitmap.mode_info.bg_red = 0; - glyph_bitmap.mode_info.bg_green = 0; - glyph_bitmap.mode_info.bg_blue = 0; - glyph_bitmap.mode_info.bg_alpha = 0; - } - + glyph_bitmap.mode_info.mode_type = + (1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) + | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP; + glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED; + glyph_bitmap.mode_info.bpp = 1; + + /* Really 1 bit per pixel. */ + glyph_bitmap.mode_info.bytes_per_pixel = 0; + + /* Packed densely as bits. */ + glyph_bitmap.mode_info.pitch = glyph->width; + + glyph_bitmap.mode_info.number_of_colors = 2; + glyph_bitmap.mode_info.bg_red = 0; + glyph_bitmap.mode_info.bg_green = 0; + glyph_bitmap.mode_info.bg_blue = 0; + glyph_bitmap.mode_info.bg_alpha = 0; grub_video_unmap_color(color, &glyph_bitmap.mode_info.fg_red, &glyph_bitmap.mode_info.fg_green, &glyph_bitmap.mode_info.fg_blue, &glyph_bitmap.mode_info.fg_alpha); - - if (glyph->font->version == 3) - { - int i; - grub_uint8_t *pixel = glyph->font->glyph_bitmap_buffer; - for (i = 0; i < glyph->width * glyph->height; i++) - { - *pixel = glyph_bitmap.mode_info.fg_red; pixel++; - *pixel = glyph_bitmap.mode_info.fg_green; pixel++; - *pixel = glyph_bitmap.mode_info.fg_blue; pixel++; - *pixel = glyph->bitmap[i]; pixel++; - } - glyph_bitmap.data = glyph->font->glyph_bitmap_buffer; - } - else - glyph_bitmap.data = glyph->bitmap; + glyph_bitmap.data = glyph->bitmap; int bitmap_left = left_x + glyph->offset_x; int bitmap_bottom = baseline_y - glyph->offset_y;