]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Protocol/HiiFont.h
Grammatical and disclaimer changes (does not follow internal C coding stds.)
[mirror_edk2.git] / MdePkg / Include / Protocol / HiiFont.h
... / ...
CommitLineData
1/** @file\r
2 The file provides services to retrieve font information.\r
3 \r
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved<BR>\r
5This program and the accompanying materials are licensed and made available under \r
6the terms and conditions of the BSD License that accompanies this distribution. \r
7The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php. \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#ifndef __HII_FONT_H__\r
16#define __HII_FONT_H__\r
17\r
18#include <Protocol/GraphicsOutput.h>\r
19#include <Protocol/HiiImage.h>\r
20\r
21#define EFI_HII_FONT_PROTOCOL_GUID \\r
22{ 0xe9ca4775, 0x8657, 0x47fc, { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } }\r
23\r
24typedef struct _EFI_HII_FONT_PROTOCOL EFI_HII_FONT_PROTOCOL;\r
25\r
26typedef VOID *EFI_FONT_HANDLE;\r
27\r
28///\r
29/// EFI_HII_OUT_FLAGS.\r
30/// \r
31typedef UINT32 EFI_HII_OUT_FLAGS;\r
32\r
33#define EFI_HII_OUT_FLAG_CLIP 0x00000001\r
34#define EFI_HII_OUT_FLAG_WRAP 0x00000002\r
35#define EFI_HII_OUT_FLAG_CLIP_CLEAN_Y 0x00000004\r
36#define EFI_HII_OUT_FLAG_CLIP_CLEAN_X 0x00000008\r
37#define EFI_HII_OUT_FLAG_TRANSPARENT 0x00000010\r
38#define EFI_HII_IGNORE_IF_NO_GLYPH 0x00000020\r
39#define EFI_HII_IGNORE_LINE_BREAK 0x00000040\r
40#define EFI_HII_DIRECT_TO_SCREEN 0x00000080\r
41\r
42/**\r
43 Definition of EFI_HII_ROW_INFO.\r
44**/\r
45typedef struct _EFI_HII_ROW_INFO {\r
46 ///\r
47 /// The index of the first character in the string which is displayed on the line.\r
48 ///\r
49 UINTN StartIndex;\r
50 ///\r
51 /// The index of the last character in the string which is displayed on the line.\r
52 /// If this is the same as StartIndex, then no characters are displayed. \r
53 ///\r
54 UINTN EndIndex;\r
55 UINTN LineHeight; ///< The height of the line, in pixels.\r
56 UINTN LineWidth; ///< The width of the text on the line, in pixels.\r
57 \r
58 ///\r
59 /// The number of pixels above the bottom of the row of the font baseline or 0 if none. \r
60 ///\r
61 UINTN BaselineOffset;\r
62} EFI_HII_ROW_INFO;\r
63\r
64///\r
65/// Font info flag. All flags (FONT, SIZE, STYLE, and COLOR) are defined.\r
66/// They are defined as EFI_FONT_INFO_***\r
67///\r
68typedef UINT32 EFI_FONT_INFO_MASK;\r
69\r
70#define EFI_FONT_INFO_SYS_FONT 0x00000001\r
71#define EFI_FONT_INFO_SYS_SIZE 0x00000002\r
72#define EFI_FONT_INFO_SYS_STYLE 0x00000004\r
73#define EFI_FONT_INFO_SYS_FORE_COLOR 0x00000010\r
74#define EFI_FONT_INFO_SYS_BACK_COLOR 0x00000020\r
75#define EFI_FONT_INFO_RESIZE 0x00001000\r
76#define EFI_FONT_INFO_RESTYLE 0x00002000\r
77#define EFI_FONT_INFO_ANY_FONT 0x00010000\r
78#define EFI_FONT_INFO_ANY_SIZE 0x00020000\r
79#define EFI_FONT_INFO_ANY_STYLE 0x00040000\r
80\r
81//\r
82// EFI_FONT_INFO\r
83// \r
84typedef struct {\r
85 EFI_HII_FONT_STYLE FontStyle;\r
86 UINT16 FontSize; ///< character cell height in pixels\r
87 CHAR16 FontName[1];\r
88} EFI_FONT_INFO;\r
89\r
90/**\r
91 Describes font output-related information.\r
92\r
93 This structure is used for describing the way in which a string\r
94 should be rendered in a particular font. FontInfo specifies the\r
95 basic font information and ForegroundColor and BackgroundColor\r
96 specify the color in which they should be displayed. The flags\r
97 in FontInfoMask describe where the system default should be\r
98 supplied instead of the specified information. The flags also\r
99 describe what options can be used to make a match between the\r
100 font requested and the font available.\r
101**/\r
102typedef struct _EFI_FONT_DISPLAY_INFO {\r
103 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ForegroundColor;\r
104 EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundColor;\r
105 EFI_FONT_INFO_MASK FontInfoMask;\r
106 EFI_FONT_INFO FontInfo; \r
107} EFI_FONT_DISPLAY_INFO;\r
108\r
109/**\r
110\r
111 This function renders a string to a bitmap or the screen using\r
112 the specified font, color and options. It either draws the\r
113 string and glyphs on an existing bitmap, allocates a new bitmap,\r
114 or uses the screen. The strings can be clipped or wrapped.\r
115 Optionally, the function also returns the information about each\r
116 row and the character position on that row. If\r
117 EFI_HII_OUT_FLAG_CLIP is set, then text will be formatted only\r
118 based on explicit line breaks and all pixels which would lie\r
119 outside the bounding box specified by Width and Height are\r
120 ignored. The information in the RowInfoArray only describes\r
121 characters which are at least partially displayed. For the final\r
122 row, the LineHeight and BaseLine may describe pixels that are\r
123 outside the limit specified by Height (unless\r
124 EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is specified) even though those\r
125 pixels were not drawn. The LineWidth may describe pixels which\r
126 are outside the limit specified by Width (unless\r
127 EFI_HII_OUT_FLAG_CLIP_CLEAN_X is specified) even though those\r
128 pixels were not drawn. If EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set,\r
129 then it modifies the behavior of EFI_HII_OUT_FLAG_CLIP so that\r
130 if a character's right-most on pixel cannot fit, then it will\r
131 not be drawn at all. This flag requires that\r
132 EFI_HII_OUT_FLAG_CLIP be set. If EFI_HII_OUT_FLAG_CLIP_CLEAN_Y\r
133 is set, then it modifies the behavior of EFI_HII_OUT_FLAG_CLIP\r
134 so that if a row's bottom-most pixel cannot fit, then it will\r
135 not be drawn at all. This flag requires that\r
136 EFI_HII_OUT_FLAG_CLIP be set. If EFI_HII_OUT_FLAG_WRAP is set,\r
137 then text will be wrapped at the right-most line-break\r
138 opportunity prior to a character whose right-most extent would\r
139 exceed Width. If no line-break opportunity can be found, then\r
140 the text will behave as if EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set.\r
141 This flag cannot be used with EFI_HII_OUT_FLAG_CLIP_CLEAN_X. If\r
142 EFI_HII_OUT_FLAG_TRANSPARENT is set, then BackgroundColor is\r
143 ignored and all 'off' pixels in the character's drawn\r
144 will use the pixel value from Blt. This flag cannot be used if\r
145 Blt is NULL upon entry. If EFI_HII_IGNORE_IF_NO_GLYPH is set,\r
146 then characters which have no glyphs are not drawn. Otherwise,\r
147 they are replaced with Unicode character code 0xFFFD (REPLACEMENT\r
148 CHARACTER). If EFI_HII_IGNORE_LINE_BREAK is set, then explicit\r
149 line break characters will be ignored. If\r
150 EFI_HII_DIRECT_TO_SCREEN is set, then the string will be written\r
151 directly to the output device specified by Screen. Otherwise the\r
152 string will be rendered to the bitmap specified by Bitmap.\r
153\r
154 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.\r
155\r
156 @param Flags Describes how the string is to be drawn.\r
157\r
158 @param String Points to the null-terminated string to be \r
159\r
160 @param StringInfo Points to the string output information,\r
161 including the color and font. If NULL, then\r
162 the string will be output in the default\r
163 system font and color.\r
164\r
165 @param Blt If this points to a non-NULL on entry, this points\r
166 to the image, which is Width pixels wide and\r
167 Height pixels high. The string will be drawn onto\r
168 this image and EFI_HII_OUT_FLAG_CLIP is implied.\r
169 If this points to a NULL on entry, then a buffer\r
170 will be allocated to hold the generated image and\r
171 the pointer updated on exit. It is the caller's\r
172 responsibility to free this buffer.\r
173\r
174 @param BltX, BltY Specifies the offset from the left and top\r
175 edge of the image of the first character\r
176 cell in the image.\r
177\r
178 @param RowInfoArray If this is non-NULL on entry, then on\r
179 exit, this will point to an allocated buffer\r
180 containing row information and\r
181 RowInfoArraySize will be updated to contain\r
182 the number of elements. This array describes\r
183 the characters that were at least partially\r
184 drawn and the heights of the rows. It is the\r
185 caller's responsibility to free this buffer.\r
186\r
187 @param RowInfoArraySize If this is non-NULL on entry, then on\r
188 exit it contains the number of\r
189 elements in RowInfoArray.\r
190\r
191 @param ColumnInfoArray If this is non-NULL, then on return it\r
192 will be filled with the horizontal\r
193 offset for each character in the\r
194 string on the row where it is\r
195 displayed. Non-printing characters\r
196 will have the offset ~0. The caller is\r
197 responsible for allocating a buffer large\r
198 enough so that there is one entry for\r
199 each character in the string, not\r
200 including the null-terminator. It is\r
201 possible when character display is\r
202 normalized that some character cells\r
203 overlap.\r
204\r
205 @retval EFI_SUCCESS The string was successfully updated.\r
206 \r
207 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for RowInfoArray or Blt.\r
208 \r
209 @retval EFI_INVALID_PARAMETER The String or Blt was NULL.\r
210\r
211 @retval EFI_INVALID_PARAMETER Flags were invalid combination.\r
212**/\r
213typedef\r
214EFI_STATUS\r
215(EFIAPI *EFI_HII_STRING_TO_IMAGE)(\r
216 IN CONST EFI_HII_FONT_PROTOCOL *This,\r
217 IN EFI_HII_OUT_FLAGS Flags,\r
218 IN CONST EFI_STRING String,\r
219 IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,\r
220 IN OUT EFI_IMAGE_OUTPUT **Blt,\r
221 IN UINTN BltX,\r
222 IN UINTN BltY,\r
223 OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,\r
224 OUT UINTN *RowInfoArraySize OPTIONAL,\r
225 OUT UINTN *ColumnInfoArray OPTIONAL\r
226);\r
227\r
228\r
229\r
230/**\r
231\r
232 This function renders a string as a bitmap or to the screen\r
233 and can clip or wrap the string. The bitmap is either supplied\r
234 by the caller or allocated by the function. The\r
235 strings are drawn with the font, size and style specified and\r
236 can be drawn transparently or opaquely. The function can also\r
237 return information about each row and each character's\r
238 position on the row. If EFI_HII_OUT_FLAG_CLIP is set, then\r
239 text will be formatted based only on explicit line breaks, and\r
240 all pixels that would lie outside the bounding box specified\r
241 by Width and Height are ignored. The information in the\r
242 RowInfoArray only describes characters which are at least\r
243 partially displayed. For the final row, the LineHeight and\r
244 BaseLine may describe pixels which are outside the limit\r
245 specified by Height (unless EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is\r
246 specified) even though those pixels were not drawn. If\r
247 EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set, then it modifies the\r
248 behavior of EFI_HII_OUT_FLAG_CLIP so that if a character's\r
249 right-most on pixel cannot fit, then it will not be drawn at\r
250 all. This flag requires that EFI_HII_OUT_FLAG_CLIP be set. If\r
251 EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is set, then it modifies the\r
252 behavior of EFI_HII_OUT_FLAG_CLIP so that if a row's bottom\r
253 most pixel cannot fit, then it will not be drawn at all. This\r
254 flag requires that EFI_HII_OUT_FLAG_CLIP be set. If\r
255 EFI_HII_OUT_FLAG_WRAP is set, then text will be wrapped at the\r
256 right-most line-break opportunity prior to a character whose\r
257 right-most extent would exceed Width. If no line-break\r
258 opportunity can be found, then the text will behave as if\r
259 EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set. This flag cannot be used\r
260 with EFI_HII_OUT_FLAG_CLIP_CLEAN_X. If\r
261 EFI_HII_OUT_FLAG_TRANSPARENT is set, then BackgroundColor is\r
262 ignored and all off" pixels in the character's glyph will\r
263 use the pixel value from Blt. This flag cannot be used if Blt\r
264 is NULL upon entry. If EFI_HII_IGNORE_IF_NO_GLYPH is set, then\r
265 characters which have no glyphs are not drawn. Otherwise, they\r
266 are replaced with Unicode character code 0xFFFD (REPLACEMENT\r
267 CHARACTER). If EFI_HII_IGNORE_LINE_BREAK is set, then explicit\r
268 line break characters will be ignored. If\r
269 EFI_HII_DIRECT_TO_SCREEN is set, then the string will be\r
270 written directly to the output device specified by Screen.\r
271 Otherwise the string will be rendered to the bitmap specified\r
272 by Bitmap.\r
273\r
274\r
275 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.\r
276\r
277 @param Flags Describes how the string is to be drawn.\r
278\r
279 @param PackageList \r
280 The package list in the HII database to\r
281 search for the specified string.\r
282\r
283 @param StringId The string's id, which is unique within\r
284 PackageList.\r
285\r
286 @param Language Points to the language for the retrieved\r
287 string. If NULL, then the current system\r
288 language is used.\r
289\r
290 @param StringInfo Points to the string output information,\r
291 including the color and font. If NULL, then\r
292 the string will be output in the default\r
293 system font and color.\r
294\r
295 @param Blt If this points to a non-NULL on entry, this points\r
296 to the image, which is Width pixels wide and\r
297 Height pixels high. The string will be drawn onto\r
298 this image and EFI_HII_OUT_FLAG_CLIP is implied.\r
299 If this points to a NULL on entry, then a buffer\r
300 will be allocated to hold the generated image and\r
301 the pointer updated on exit. It is the caller's\r
302 responsibility to free this buffer.\r
303\r
304 @param BltX, BltY Specifies the offset from the left and top\r
305 edge of the output image of the first\r
306 character cell in the image.\r
307\r
308 @param RowInfoArray If this is non-NULL on entry, then on\r
309 exit, this will point to an allocated\r
310 buffer containing row information and\r
311 RowInfoArraySize will be updated to\r
312 contain the number of elements. This array\r
313 describes the characters which were at\r
314 least partially drawn and the heights of\r
315 the rows. It is the caller's\r
316 responsibility to free this buffer.\r
317\r
318 @param RowInfoArraySize If this is non-NULL on entry, then on\r
319 exit it contains the number of\r
320 elements in RowInfoArray.\r
321\r
322 @param ColumnInfoArray If non-NULL, on return it is filled\r
323 with the horizontal offset for each\r
324 character in the string on the row\r
325 where it is displayed. Non-printing\r
326 characters will have the offset ~0.\r
327 The caller is responsible to allocate\r
328 a buffer large enough so that there is\r
329 one entry for each character in the\r
330 string, not including the\r
331 null-terminator. It is possible when\r
332 character display is normalized that\r
333 some character cells overlap.\r
334\r
335\r
336 @retval EFI_SUCCESS The string was successfully updated.\r
337\r
338 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output\r
339 buffer for RowInfoArray or Blt.\r
340\r
341 @retval EFI_INVALID_PARAMETER The String, or Blt, or Height, or\r
342 Width was NULL.\r
343 @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.\r
344 @retval EFI_INVALID_PARAMETER Flags were invalid combination.\r
345 @retval EFI_NOT_FOUND The specified PackageList is not in the Database, \r
346 or the stringid is not in the specified PackageList. \r
347\r
348**/\r
349typedef\r
350EFI_STATUS\r
351(EFIAPI *EFI_HII_STRING_ID_TO_IMAGE)(\r
352 IN CONST EFI_HII_FONT_PROTOCOL *This,\r
353 IN EFI_HII_OUT_FLAGS Flags,\r
354 IN EFI_HII_HANDLE PackageList,\r
355 IN EFI_STRING_ID StringId,\r
356 IN CONST CHAR8 *Language,\r
357 IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,\r
358 IN OUT EFI_IMAGE_OUTPUT **Blt,\r
359 IN UINTN BltX,\r
360 IN UINTN BltY,\r
361 OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,\r
362 OUT UINTN *RowInfoArraySize OPTIONAL,\r
363 OUT UINTN *ColumnInfoArray OPTIONAL\r
364);\r
365\r
366\r
367/**\r
368\r
369 Convert the glyph for a single character into a bitmap.\r
370\r
371 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.\r
372\r
373 @param Char The character to retrieve.\r
374\r
375 @param StringInfo Points to the string font and color\r
376 information or NULL if the string should use\r
377 the default system font and color.\r
378\r
379 @param Blt This must point to a NULL on entry. A buffer will\r
380 be allocated to hold the output and the pointer\r
381 updated on exit. It is the caller's responsibility\r
382 to free this buffer.\r
383\r
384 @param Baseline The number of pixels from the bottom of the bitmap\r
385 to the baseline.\r
386\r
387\r
388 @retval EFI_SUCCESS The glyph bitmap created.\r
389\r
390 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.\r
391\r
392 @retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was\r
393 replaced with the glyph for\r
394 Unicode character code 0xFFFD.\r
395\r
396 @retval EFI_INVALID_PARAMETER Blt is NULL, or Width is NULL, or\r
397 Height is NULL\r
398\r
399\r
400**/\r
401typedef\r
402EFI_STATUS\r
403(EFIAPI *EFI_HII_GET_GLYPH)(\r
404 IN CONST EFI_HII_FONT_PROTOCOL *This,\r
405 IN CONST CHAR16 Char,\r
406 IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,\r
407 OUT EFI_IMAGE_OUTPUT **Blt,\r
408 OUT UINTN *Baseline OPTIONAL\r
409);\r
410\r
411/**\r
412\r
413 This function iterates through fonts which match the specified\r
414 font, using the specified criteria. If String is non-NULL, then\r
415 all of the characters in the string must exist in order for a\r
416 candidate font to be returned.\r
417\r
418 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.\r
419\r
420 @param FontHandle On entry, points to the font handle returned\r
421 by a previous call to GetFontInfo() or NULL\r
422 to start with the first font. On return,\r
423 points to the returned font handle or points\r
424 to NULL if there are no more matching fonts.\r
425\r
426 @param StringInfoIn Upon entry, points to the font to return\r
427 information about. If NULL, then the information \r
428 about the system default font will be returned.\r
429\r
430 @param StringInfoOut Upon return, contains the matching\r
431 font's information. If NULL, then no\r
432 information is returned.\r
433\r
434 @param String Points to the string which will be tested to\r
435 determine if all characters are available. If\r
436 NULL, then any font is acceptable.\r
437 \r
438 @retval EFI_SUCCESS Matching font returned successfully.\r
439 \r
440 @retval EFI_NOT_FOUND No matching font was found.\r
441\r
442 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the request.\r
443 \r
444**/\r
445typedef\r
446EFI_STATUS\r
447(EFIAPI *EFI_HII_GET_FONT_INFO)(\r
448 IN CONST EFI_HII_FONT_PROTOCOL *This,\r
449 IN OUT EFI_FONT_HANDLE *FontHandle,\r
450 IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL\r
451 OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,\r
452 IN CONST EFI_STRING String OPTIONAL\r
453);\r
454\r
455///\r
456/// The protocol provides the service to retrieve the font informations.\r
457///\r
458struct _EFI_HII_FONT_PROTOCOL {\r
459 EFI_HII_STRING_TO_IMAGE StringToImage;\r
460 EFI_HII_STRING_ID_TO_IMAGE StringIdToImage;\r
461 EFI_HII_GET_GLYPH GetGlyph;\r
462 EFI_HII_GET_FONT_INFO GetFontInfo;\r
463};\r
464\r
465extern EFI_GUID gEfiHiiFontProtocolGuid;\r
466\r
467\r
468#endif\r
469\r