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