* font/font.c: Indented.
This commit is contained in:
parent
7d65244782
commit
1118c32ec7
2 changed files with 233 additions and 233 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* font/font.c: Indented.
|
||||||
|
|
||||||
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
|
2010-04-09 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
Elif support to GRUB script (by Deepak Vankadaru).
|
Elif support to GRUB script (by Deepak Vankadaru).
|
||||||
|
|
60
font/font.c
60
font/font.c
|
@ -91,8 +91,7 @@ struct font_file_section
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Replace unknown glyphs with a rounded question mark. */
|
/* Replace unknown glyphs with a rounded question mark. */
|
||||||
static grub_uint8_t unknown_glyph_bitmap[] =
|
static grub_uint8_t unknown_glyph_bitmap[] = {
|
||||||
{
|
|
||||||
/* 76543210 */
|
/* 76543210 */
|
||||||
0x7C, /* ooooo */
|
0x7C, /* ooooo */
|
||||||
0x82, /* o o */
|
0x82, /* o o */
|
||||||
|
@ -141,8 +140,8 @@ ascii_glyph_lookup (grub_uint32_t code)
|
||||||
int current;
|
int current;
|
||||||
for (current = 0; current < 0x80; current++)
|
for (current = 0; current < 0x80; current++)
|
||||||
{
|
{
|
||||||
ascii_font_glyph[current] = grub_malloc(sizeof(struct grub_font_glyph)
|
ascii_font_glyph[current] =
|
||||||
+ ASCII_BITMAP_SIZE);
|
grub_malloc (sizeof (struct grub_font_glyph) + ASCII_BITMAP_SIZE);
|
||||||
|
|
||||||
ascii_font_glyph[current]->width = 8;
|
ascii_font_glyph[current]->width = 8;
|
||||||
ascii_font_glyph[current]->height = 16;
|
ascii_font_glyph[current]->height = 16;
|
||||||
|
@ -398,7 +397,8 @@ read_section_as_string (struct font_file_section *section)
|
||||||
which is stored into *VALUE.
|
which is stored into *VALUE.
|
||||||
Returns 0 upon success, nonzero upon failure. */
|
Returns 0 upon success, nonzero upon failure. */
|
||||||
static int
|
static int
|
||||||
read_section_as_short (struct font_file_section *section, grub_int16_t *value)
|
read_section_as_short (struct font_file_section *section,
|
||||||
|
grub_int16_t * value)
|
||||||
{
|
{
|
||||||
grub_uint16_t raw_value;
|
grub_uint16_t raw_value;
|
||||||
|
|
||||||
|
@ -408,8 +408,7 @@ read_section_as_short (struct font_file_section *section, grub_int16_t *value)
|
||||||
"font file format error: section %c%c%c%c length "
|
"font file format error: section %c%c%c%c length "
|
||||||
"is %d but should be 2",
|
"is %d but should be 2",
|
||||||
section->name[0], section->name[1],
|
section->name[0], section->name[1],
|
||||||
section->name[2], section->name[3],
|
section->name[2], section->name[3], section->length);
|
||||||
section->length);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (grub_file_read (section->file, &raw_value, 2) != 2)
|
if (grub_file_read (section->file, &raw_value, 2) != 2)
|
||||||
|
@ -527,13 +526,15 @@ grub_font_load (const char *filename)
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name,
|
else if (grub_memcmp (section.name,
|
||||||
FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
|
FONT_FORMAT_SECTION_NAMES_POINT_SIZE,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_POINT_SIZE) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_POINT_SIZE) -
|
||||||
|
1) == 0)
|
||||||
{
|
{
|
||||||
if (read_section_as_short (§ion, &font->point_size) != 0)
|
if (read_section_as_short (§ion, &font->point_size) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
|
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_WEIGHT,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_WEIGHT) - 1)
|
||||||
|
== 0)
|
||||||
{
|
{
|
||||||
char *wt;
|
char *wt;
|
||||||
wt = read_section_as_string (§ion);
|
wt = read_section_as_string (§ion);
|
||||||
|
@ -548,34 +549,39 @@ grub_font_load (const char *filename)
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name,
|
else if (grub_memcmp (section.name,
|
||||||
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
|
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH)
|
||||||
|
- 1) == 0)
|
||||||
{
|
{
|
||||||
if (read_section_as_short (§ion, &font->max_char_width) != 0)
|
if (read_section_as_short (§ion, &font->max_char_width) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name,
|
else if (grub_memcmp (section.name,
|
||||||
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
|
FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT)
|
||||||
|
- 1) == 0)
|
||||||
{
|
{
|
||||||
if (read_section_as_short (§ion, &font->max_char_height) != 0)
|
if (read_section_as_short (§ion, &font->max_char_height) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name,
|
else if (grub_memcmp (section.name,
|
||||||
FONT_FORMAT_SECTION_NAMES_ASCENT,
|
FONT_FORMAT_SECTION_NAMES_ASCENT,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_ASCENT) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_ASCENT) - 1)
|
||||||
|
== 0)
|
||||||
{
|
{
|
||||||
if (read_section_as_short (§ion, &font->ascent) != 0)
|
if (read_section_as_short (§ion, &font->ascent) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
|
else if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_DESCENT,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_DESCENT) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_DESCENT) - 1)
|
||||||
|
== 0)
|
||||||
{
|
{
|
||||||
if (read_section_as_short (§ion, &font->descent) != 0)
|
if (read_section_as_short (§ion, &font->descent) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (grub_memcmp (section.name,
|
else if (grub_memcmp (section.name,
|
||||||
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
|
FONT_FORMAT_SECTION_NAMES_CHAR_INDEX,
|
||||||
sizeof(FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) - 1) == 0)
|
sizeof (FONT_FORMAT_SECTION_NAMES_CHAR_INDEX) -
|
||||||
|
1) == 0)
|
||||||
{
|
{
|
||||||
if (load_font_index (file, section.length, font) != 0)
|
if (load_font_index (file, section.length, font) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -609,16 +615,13 @@ grub_font_load (const char *filename)
|
||||||
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
|
"Ascent=%d Descent=%d MaxW=%d MaxH=%d Number of characters=%d.\n",
|
||||||
font->name,
|
font->name,
|
||||||
font->ascent, font->descent,
|
font->ascent, font->descent,
|
||||||
font->max_char_width, font->max_char_height,
|
font->max_char_width, font->max_char_height, font->num_chars);
|
||||||
font->num_chars);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (font->max_char_width == 0
|
if (font->max_char_width == 0
|
||||||
|| font->max_char_height == 0
|
|| font->max_char_height == 0
|
||||||
|| font->num_chars == 0
|
|| font->num_chars == 0
|
||||||
|| font->char_index == 0
|
|| font->char_index == 0 || font->ascent == 0 || font->descent == 0)
|
||||||
|| font->ascent == 0
|
|
||||||
|| font->descent == 0)
|
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FONT,
|
grub_error (GRUB_ERR_BAD_FONT,
|
||||||
"invalid font file: missing some required data");
|
"invalid font file: missing some required data");
|
||||||
|
@ -822,8 +825,7 @@ remove_font (grub_font_t font)
|
||||||
struct grub_font_node **nextp, *cur;
|
struct grub_font_node **nextp, *cur;
|
||||||
|
|
||||||
for (nextp = &grub_font_list, cur = *nextp;
|
for (nextp = &grub_font_list, cur = *nextp;
|
||||||
cur;
|
cur; nextp = &cur->next, cur = cur->next)
|
||||||
nextp = &cur->next, cur = cur->next)
|
|
||||||
{
|
{
|
||||||
if (cur->value == font)
|
if (cur->value == font)
|
||||||
{
|
{
|
||||||
|
@ -1053,8 +1055,7 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code)
|
||||||
side location of the character. */
|
side location of the character. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_font_draw_glyph (struct grub_font_glyph * glyph,
|
grub_font_draw_glyph (struct grub_font_glyph * glyph,
|
||||||
grub_video_color_t color,
|
grub_video_color_t color, int left_x, int baseline_y)
|
||||||
int left_x, int baseline_y)
|
|
||||||
{
|
{
|
||||||
struct grub_video_bitmap glyph_bitmap;
|
struct grub_video_bitmap glyph_bitmap;
|
||||||
|
|
||||||
|
@ -1065,8 +1066,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
||||||
glyph_bitmap.mode_info.width = glyph->width;
|
glyph_bitmap.mode_info.width = glyph->width;
|
||||||
glyph_bitmap.mode_info.height = glyph->height;
|
glyph_bitmap.mode_info.height = glyph->height;
|
||||||
glyph_bitmap.mode_info.mode_type =
|
glyph_bitmap.mode_info.mode_type =
|
||||||
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
|
(1 << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) | GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
|
||||||
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
|
|
||||||
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
|
glyph_bitmap.mode_info.blit_format = GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED;
|
||||||
glyph_bitmap.mode_info.bpp = 1;
|
glyph_bitmap.mode_info.bpp = 1;
|
||||||
|
|
||||||
|
@ -1094,8 +1094,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
||||||
|
|
||||||
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
return grub_video_blit_bitmap (&glyph_bitmap, GRUB_VIDEO_BLIT_BLEND,
|
||||||
bitmap_left, bitmap_top,
|
bitmap_left, bitmap_top,
|
||||||
0, 0,
|
0, 0, glyph->width, glyph->height);
|
||||||
glyph->width, glyph->height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a UTF-8 string of text on the current video render target.
|
/* Draw a UTF-8 string of text on the current video render target.
|
||||||
|
@ -1105,8 +1104,7 @@ grub_font_draw_glyph (struct grub_font_glyph *glyph,
|
||||||
a glyph from another loaded font may be used instead. */
|
a glyph from another loaded font may be used instead. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_font_draw_string (const char *str, grub_font_t font,
|
grub_font_draw_string (const char *str, grub_font_t font,
|
||||||
grub_video_color_t color,
|
grub_video_color_t color, int left_x, int baseline_y)
|
||||||
int left_x, int baseline_y)
|
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
struct grub_font_glyph *glyph;
|
struct grub_font_glyph *glyph;
|
||||||
|
@ -1117,12 +1115,10 @@ grub_font_draw_string (const char *str, grub_font_t font,
|
||||||
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
|
grub_utf8_to_ucs4 (&code, 1, ptr, -1, &ptr) > 0;)
|
||||||
{
|
{
|
||||||
glyph = grub_font_get_glyph_with_fallback (font, code);
|
glyph = grub_font_get_glyph_with_fallback (font, code);
|
||||||
if (grub_font_draw_glyph (glyph, color, x, baseline_y)
|
if (grub_font_draw_glyph (glyph, color, x, baseline_y) != GRUB_ERR_NONE)
|
||||||
!= GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
x += glyph->device_width;
|
x += glyph->device_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue