2009-01-02 Colin D Bennett <colin@gibibit.com>
New font engine. Additional changes by Vesa Jääskeläinen <chaac@nic.fi> to adapt to build system and fixed gfxterm.c to work with different sized fonts. * configure.ac: Changed UNIFONT_HEX to UNIFONT_BDF. * configure: Re-generated. * DISTLIST: Removed font/manager.c. Added font/font.c. Added font/font_cmd.c. * Makefile.in: Changed UNIFONT_HEX to UNIFONT_BDF. Added Font tool compilation. * include/grub/misc.h (grub_utf8_to_ucs4): Changed prototype. Changed users. * kern/misc.c (grub_utf8_to_ucs4): Changed prototype. * kern/term.c: Changed users of grub_utf8_to_ucs4. * normal/menu.c: Likewise. * conf/common.rmk (font_mod_SOURCES): Removed font/manager.c. (font_mod_SOURCES): Added font/font_cmd.c, font/font.c. * include/grub/font.h: Replaced with new file. * include/grub/video.h (GRUB_VIDEO_MODE_TYPE_ALPHA): Changed value. (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED): Likewise. (GRUB_VIDEO_MODE_TYPE_COLOR_MASK): Likewise. (GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP): Added. (grub_video_blit_format): Added GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED. (grub_video_mode_info): Added bg_red, bg_green, bg_blue, bg_alpha, fg_red, fg_green, fg_blue, fg_alpha. (grub_video_adapter): Removed blit_glyph. (grub_video_blit_glyph): Removed. * font/manager.c: Removed file. * font/font.c: New file. * font/font_cmd.c: Likewise. * video/video.c (grub_video_blit_glyph): Removed. * video/i386/pc/vbe.c (grub_video_vbe_map_rgb): Added 1-bit support. (grub_video_vbe_map_rgba): Likewise. (grub_video_vbe_unmap_color_int): Likewise. (grub_video_vbe_blit_glyph): Removed. (grub_video_vbe_adapter): Removed blit_glyph. * video/i386/pc/vbeutil.c (get_data_ptr): Added 1-bit support. (get_pixel): Likewise. (set_pixel): Likewise. * commands/videotest.c (grub_cmd_videotest): Added more tests for fonts. * term/gfxterm.c: Adapted to new font engine. * term/i386/pc/vesafb.c: Marked as deprecated. Made it compile. * term/i386/pc/vga.c: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/BDFLoader.java: New file. * util/fonttool/src/org/gnu/grub/fonttool/CharDefs.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/CharacterRange.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/CharacterRange.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Converter.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Font.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Glyph.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/PFF2Sections.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/PFF2Writer.java: Likewise. * util/grub.d/00_header.in: Changed to use new loadfont command. * util/grub-mkconfig_lib.in: Changed font extension.
This commit is contained in:
parent
278922e80b
commit
1e901a7573
34 changed files with 2859 additions and 543 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -36,17 +36,21 @@ grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_getkey ();
|
||||
|
||||
grub_video_color_t color;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
int i;
|
||||
struct grub_font_glyph glyph;
|
||||
grub_font_t sansbig;
|
||||
grub_font_t sans;
|
||||
grub_font_t sanssmall;
|
||||
grub_font_t fixed;
|
||||
struct grub_font_glyph *glyph;
|
||||
struct grub_video_render_target *text_layer;
|
||||
grub_video_color_t palette[16];
|
||||
const char *str;
|
||||
int texty;
|
||||
|
||||
grub_video_get_viewport (&x, &y, &width, &height);
|
||||
|
||||
|
@ -65,8 +69,15 @@ grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
color = grub_video_map_rgb (0, 255, 255);
|
||||
grub_video_fill_rect (color, 100, 100, 100, 100);
|
||||
|
||||
grub_font_get_glyph ('*', &glyph);
|
||||
grub_video_blit_glyph (&glyph, color, 200 ,0);
|
||||
sansbig = grub_font_get ("Helvetica Bold 24");
|
||||
sans = grub_font_get ("Helvetica Bold 14");
|
||||
sanssmall = grub_font_get ("Helvetica 8");
|
||||
fixed = grub_font_get ("Fixed 20");
|
||||
if (! sansbig || ! sans || ! sanssmall || ! fixed)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "No font loaded.");
|
||||
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
grub_font_draw_glyph (glyph, color, 200 ,0);
|
||||
|
||||
grub_video_set_viewport (x + 150, y + 150,
|
||||
width - 150 * 2, height - 150 * 2);
|
||||
|
@ -77,18 +88,69 @@ grub_cmd_videotest (struct grub_arg_list *state __attribute__ ((unused)),
|
|||
|
||||
color = grub_video_map_rgb (255, 255, 255);
|
||||
|
||||
grub_font_get_glyph ('A', &glyph);
|
||||
grub_video_blit_glyph (&glyph, color, 16, 16);
|
||||
grub_font_get_glyph ('B', &glyph);
|
||||
grub_video_blit_glyph (&glyph, color, 16 * 2, 16);
|
||||
texty = 32;
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
|
||||
grub_font_get_glyph ('*', &glyph);
|
||||
texty += grub_font_get_ascent (fixed);
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
/* To convert Unicode characters into UTF-8 for this test, the following
|
||||
command is useful:
|
||||
echo -ne '\x00\x00\x26\x3A' | iconv -f UTF-32BE -t UTF-8 | od -t x1
|
||||
This converts the Unicode character U+263A to UTF-8. */
|
||||
|
||||
/* Characters used:
|
||||
Code point Description UTF-8 encoding
|
||||
----------- ------------------------------ --------------
|
||||
U+263A unfilled smiley face E2 98 BA
|
||||
U+00A1 inverted exclamation point C2 A1
|
||||
U+00A3 British pound currency symbol C2 A3
|
||||
U+03C4 Greek tau CF 84
|
||||
U+00E4 lowercase letter a with umlaut C3 A4
|
||||
U+2124 set 'Z' symbol (integers) E2 84 A4
|
||||
U+2287 subset symbol E2 8A 87
|
||||
U+211D set 'R' symbol (real numbers) E2 84 9D */
|
||||
|
||||
str =
|
||||
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
|
||||
" \xC2\xA1\xCF\x84\xC3\xA4u! "
|
||||
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
|
||||
color = grub_video_map_rgb (128, 128, 255);
|
||||
|
||||
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
|
||||
texty += grub_font_get_ascent(fixed);
|
||||
grub_font_draw_string (str, fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
/* Some character don't exist in the Helvetica font, so the font engine
|
||||
will fall back to using glyphs from another font that does contain them.
|
||||
TODO The font engine should be smart about selecting a replacement font
|
||||
and prioritize fonts with similar sizes. */
|
||||
|
||||
texty += grub_font_get_ascent(sansbig);
|
||||
grub_font_draw_string (str, sansbig, color, 16, texty);
|
||||
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
|
||||
|
||||
texty += grub_font_get_ascent(sans);
|
||||
grub_font_draw_string (str, sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
|
||||
texty += grub_font_get_ascent(sanssmall);
|
||||
grub_font_draw_string (str, sanssmall, color, 16, texty);
|
||||
texty += (grub_font_get_descent (sanssmall)
|
||||
+ grub_font_get_leading (sanssmall));
|
||||
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
color = grub_video_map_color (i);
|
||||
palette[i] = color;
|
||||
grub_video_blit_glyph (&glyph, color, 16 + i * 16, 32);
|
||||
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
|
||||
}
|
||||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue