55
49
grub_video_get_viewport (&x, &y, &width, &height);
57
grub_video_create_render_target (&text_layer, width, height,
58
GRUB_VIDEO_MODE_TYPE_RGB
59
| GRUB_VIDEO_MODE_TYPE_ALPHA);
61
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
63
color = grub_video_map_rgb (0, 0, 0);
64
grub_video_fill_rect (color, 0, 0, width, height);
66
color = grub_video_map_rgb (255, 0, 0);
67
grub_video_fill_rect (color, 0, 0, 100, 100);
69
color = grub_video_map_rgb (0, 255, 255);
70
grub_video_fill_rect (color, 100, 100, 100, 100);
72
sansbig = grub_font_get ("Unknown Regular 16");
73
sans = grub_font_get ("Unknown Regular 16");
74
sanssmall = grub_font_get ("Unknown Regular 16");
75
fixed = grub_font_get ("Fixed 20");
76
if (! sansbig || ! sans || ! sanssmall || ! fixed)
77
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
79
glyph = grub_font_get_glyph (fixed, '*');
80
grub_font_draw_glyph (glyph, color, 200 ,0);
82
grub_video_set_viewport (x + 150, y + 150,
83
width - 150 * 2, height - 150 * 2);
84
color = grub_video_map_rgb (77, 33, 77);
85
grub_video_fill_rect (color, 0, 0, width, height);
87
grub_video_set_active_render_target (text_layer);
89
color = grub_video_map_rgb (255, 255, 255);
92
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
93
sans, color, 16, texty);
94
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
96
texty += grub_font_get_ascent (fixed);
97
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
98
fixed, color, 16, texty);
99
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
101
/* To convert Unicode characters into UTF-8 for this test, the following
56
grub_font_t sanssmall;
58
struct grub_font_glyph *glyph;
60
grub_video_create_render_target (&text_layer, width, height,
61
GRUB_VIDEO_MODE_TYPE_RGB
62
| GRUB_VIDEO_MODE_TYPE_ALPHA);
64
grub_video_set_active_render_target (text_layer);
66
color = grub_video_map_rgb (0, 255, 255);
67
sansbig = grub_font_get ("Unknown Regular 16");
68
sans = grub_font_get ("Unknown Regular 16");
69
sanssmall = grub_font_get ("Unknown Regular 16");
70
fixed = grub_font_get ("Fixed 20");
71
if (! sansbig || ! sans || ! sanssmall || ! fixed)
72
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
74
glyph = grub_font_get_glyph (fixed, '*');
75
grub_font_draw_glyph (glyph, color, 200 ,0);
77
color = grub_video_map_rgb (255, 255, 255);
80
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
81
sans, color, 16, texty);
82
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
84
texty += grub_font_get_ascent (fixed);
85
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
86
fixed, color, 16, texty);
87
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
89
/* To convert Unicode characters into UTF-8 for this test, the following
103
91
echo -ne '\x00\x00\x26\x3A' | iconv -f UTF-32BE -t UTF-8 | od -t x1
104
This converts the Unicode character U+263A to UTF-8. */
107
Code point Description UTF-8 encoding
108
----------- ------------------------------ --------------
109
U+263A unfilled smiley face E2 98 BA
110
U+00A1 inverted exclamation point C2 A1
111
U+00A3 British pound currency symbol C2 A3
112
U+03C4 Greek tau CF 84
113
U+00E4 lowercase letter a with umlaut C3 A4
114
U+2124 set 'Z' symbol (integers) E2 84 A4
115
U+2287 subset symbol E2 8A 87
116
U+211D set 'R' symbol (real numbers) E2 84 9D */
119
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
120
" \xC2\xA1\xCF\x84\xC3\xA4u! "
121
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
122
color = grub_video_map_rgb (128, 128, 255);
124
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
125
texty += grub_font_get_ascent(fixed);
126
grub_font_draw_string (str, fixed, color, 16, texty);
127
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
129
texty += grub_font_get_ascent(sansbig);
130
grub_font_draw_string (str, sansbig, color, 16, texty);
131
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
133
texty += grub_font_get_ascent(sans);
134
grub_font_draw_string (str, sans, color, 16, texty);
135
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
137
texty += grub_font_get_ascent(sanssmall);
138
grub_font_draw_string (str, sanssmall, color, 16, texty);
139
texty += (grub_font_get_descent (sanssmall)
140
+ grub_font_get_leading (sanssmall));
142
glyph = grub_font_get_glyph (fixed, '*');
144
for (i = 0; i < 16; i++)
92
This converts the Unicode character U+263A to UTF-8. */
95
Code point Description UTF-8 encoding
96
----------- ------------------------------ --------------
97
U+263A unfilled smiley face E2 98 BA
98
U+00A1 inverted exclamation point C2 A1
99
U+00A3 British pound currency symbol C2 A3
100
U+03C4 Greek tau CF 84
101
U+00E4 lowercase letter a with umlaut C3 A4
102
U+2124 set 'Z' symbol (integers) E2 84 A4
103
U+2287 subset symbol E2 8A 87
104
U+211D set 'R' symbol (real numbers) E2 84 9D */
107
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
108
" \xC2\xA1\xCF\x84\xC3\xA4u! "
109
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
110
color = grub_video_map_rgb (128, 128, 255);
112
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
113
texty += grub_font_get_ascent(fixed);
114
grub_font_draw_string (str, fixed, color, 16, texty);
115
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
117
texty += grub_font_get_ascent(sansbig);
118
grub_font_draw_string (str, sansbig, color, 16, texty);
119
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
121
texty += grub_font_get_ascent(sans);
122
grub_font_draw_string (str, sans, color, 16, texty);
123
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
125
texty += grub_font_get_ascent(sanssmall);
126
grub_font_draw_string (str, sanssmall, color, 16, texty);
127
texty += (grub_font_get_descent (sanssmall)
128
+ grub_font_get_leading (sanssmall));
130
glyph = grub_font_get_glyph (fixed, '*');
132
for (i = 0; i < 16; i++)
134
color = grub_video_map_color (i);
136
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
140
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
142
for (i = 0; i < 2; i++)
146
color = grub_video_map_color (i);
148
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
144
color = grub_video_map_rgb (0, 0, 0);
145
grub_video_fill_rect (color, 0, 0, width, height);
147
color = grub_video_map_rgb (255, 0, 0);
148
grub_video_fill_rect (color, 0, 0, 100, 100);
150
color = grub_video_map_rgb (0, 255, 255);
151
grub_video_fill_rect (color, 100, 100, 100, 100);
153
grub_video_set_viewport (x + 150, y + 150,
154
width - 150 * 2, height - 150 * 2);
155
color = grub_video_map_rgb (77, 33, 77);
156
grub_video_fill_rect (color, 0, 0, width, height);
157
grub_video_swap_buffers ();
151
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
153
160
for (i = 0; i < 5; i++)
155
162
color = grub_video_map_rgb (i, 33, 77);