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