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