2 Implementation for EFI_HII_FONT_PROTOCOL.
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "HiiDatabase.h"
13 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mHiiEfiColors
[16] = {
17 {0x00, 0x00, 0x00, 0x00}, // BLACK
18 {0x98, 0x00, 0x00, 0x00}, // BLUE
19 {0x00, 0x98, 0x00, 0x00}, // GREEN
20 {0x98, 0x98, 0x00, 0x00}, // CYAN
21 {0x00, 0x00, 0x98, 0x00}, // RED
22 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
23 {0x00, 0x98, 0x98, 0x00}, // BROWN
24 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
25 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
26 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE
27 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN
28 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
29 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
30 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
31 {0x00, 0xff, 0xff, 0x00}, // YELLOW
32 {0xff, 0xff, 0xff, 0x00}, // WHITE
37 Insert a character cell information to the list specified by GlyphInfoList.
39 This is a internal function.
41 @param CharValue Unicode character value, which identifies a glyph
43 @param GlyphInfoList HII_GLYPH_INFO list head.
44 @param Cell Incoming character cell information.
46 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
47 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
54 IN LIST_ENTRY
*GlyphInfoList
,
55 IN EFI_HII_GLYPH_INFO
*Cell
58 HII_GLYPH_INFO
*GlyphInfo
;
60 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
62 GlyphInfo
= (HII_GLYPH_INFO
*) AllocateZeroPool (sizeof (HII_GLYPH_INFO
));
63 if (GlyphInfo
== NULL
) {
64 return EFI_OUT_OF_RESOURCES
;
68 // GlyphInfoList stores a list of default character cell information, each is
69 // identified by "CharId".
71 GlyphInfo
->Signature
= HII_GLYPH_INFO_SIGNATURE
;
72 GlyphInfo
->CharId
= CharValue
;
73 if (Cell
->AdvanceX
== 0) {
74 Cell
->AdvanceX
= Cell
->Width
;
76 CopyMem (&GlyphInfo
->Cell
, Cell
, sizeof (EFI_HII_GLYPH_INFO
));
77 InsertTailList (GlyphInfoList
, &GlyphInfo
->Entry
);
84 Get a character cell information from the list specified by GlyphInfoList.
86 This is a internal function.
88 @param CharValue Unicode character value, which identifies a glyph
90 @param GlyphInfoList HII_GLYPH_INFO list head.
91 @param Cell Buffer which stores output character cell
94 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
95 @retval EFI_NOT_FOUND The character info specified by CharValue does
102 IN LIST_ENTRY
*GlyphInfoList
,
103 OUT EFI_HII_GLYPH_INFO
*Cell
106 HII_GLYPH_INFO
*GlyphInfo
;
109 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
112 // Since the EFI_HII_GIBT_DEFAULTS block won't increment CharValueCurrent,
113 // the value of "CharId" of a default character cell which is used for a
114 // EFI_HII_GIBT_GLYPH_DEFAULT or EFI_HII_GIBT_GLYPHS_DEFAULT should be
115 // less or equal to the value of "CharValueCurrent" of this default block.
117 // For instance, if the CharId of a GlyphInfoList is {1, 3, 7}, a default glyph
118 // with CharValue equals "7" uses the GlyphInfo with CharId = 7;
119 // a default glyph with CharValue equals "6" uses the GlyphInfo with CharId = 3.
121 for (Link
= GlyphInfoList
->BackLink
; Link
!= GlyphInfoList
; Link
= Link
->BackLink
) {
122 GlyphInfo
= CR (Link
, HII_GLYPH_INFO
, Entry
, HII_GLYPH_INFO_SIGNATURE
);
123 if (GlyphInfo
->CharId
<= CharValue
) {
124 CopyMem (Cell
, &GlyphInfo
->Cell
, sizeof (EFI_HII_GLYPH_INFO
));
129 return EFI_NOT_FOUND
;
134 Convert the glyph for a single character into a bitmap.
136 This is a internal function.
138 @param Private HII database driver private data.
139 @param Char Character to retrieve.
140 @param StringInfo Points to the string font and color information
141 or NULL if the string should use the default
142 system font and color.
143 @param GlyphBuffer Buffer to store the retrieved bitmap data.
144 @param Cell Points to EFI_HII_GLYPH_INFO structure.
145 @param Attributes If not NULL, output the glyph attributes if any.
147 @retval EFI_SUCCESS Glyph bitmap outputted.
148 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer GlyphBuffer.
149 @retval EFI_NOT_FOUND The glyph was unknown can not be found.
150 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
155 IN HII_DATABASE_PRIVATE_DATA
*Private
,
157 IN EFI_FONT_INFO
*StringInfo
,
158 OUT UINT8
**GlyphBuffer
,
159 OUT EFI_HII_GLYPH_INFO
*Cell
,
160 OUT UINT8
*Attributes OPTIONAL
163 HII_DATABASE_RECORD
*Node
;
165 HII_SIMPLE_FONT_PACKAGE_INSTANCE
*SimpleFont
;
168 EFI_NARROW_GLYPH Narrow
;
170 HII_GLOBAL_FONT_INFO
*GlobalFont
;
172 EFI_NARROW_GLYPH
*NarrowPtr
;
173 EFI_WIDE_GLYPH
*WidePtr
;
175 if (GlyphBuffer
== NULL
|| Cell
== NULL
) {
176 return EFI_INVALID_PARAMETER
;
178 if (Private
== NULL
|| Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
) {
179 return EFI_INVALID_PARAMETER
;
182 ZeroMem (Cell
, sizeof (EFI_HII_GLYPH_INFO
));
185 // If StringInfo is not NULL, it must point to an existing EFI_FONT_INFO rather
186 // than system default font and color.
187 // If NULL, try to find the character in simplified font packages since
188 // default system font is the fixed font (narrow or wide glyph).
190 if (StringInfo
!= NULL
) {
191 if(!IsFontInfoExisted (Private
, StringInfo
, NULL
, NULL
, &GlobalFont
)) {
192 return EFI_INVALID_PARAMETER
;
194 if (Attributes
!= NULL
) {
195 *Attributes
= PROPORTIONAL_GLYPH
;
197 return FindGlyphBlock (GlobalFont
->FontPackage
, Char
, GlyphBuffer
, Cell
, NULL
);
199 HeaderSize
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
);
201 for (Link
= Private
->DatabaseList
.ForwardLink
; Link
!= &Private
->DatabaseList
; Link
= Link
->ForwardLink
) {
202 Node
= CR (Link
, HII_DATABASE_RECORD
, DatabaseEntry
, HII_DATABASE_RECORD_SIGNATURE
);
203 for (Link1
= Node
->PackageList
->SimpleFontPkgHdr
.ForwardLink
;
204 Link1
!= &Node
->PackageList
->SimpleFontPkgHdr
;
205 Link1
= Link1
->ForwardLink
207 SimpleFont
= CR (Link1
, HII_SIMPLE_FONT_PACKAGE_INSTANCE
, SimpleFontEntry
, HII_S_FONT_PACKAGE_SIGNATURE
);
209 // Search the narrow glyph array
211 NarrowPtr
= (EFI_NARROW_GLYPH
*) ((UINT8
*) (SimpleFont
->SimpleFontPkgHdr
) + HeaderSize
);
212 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
; Index
++) {
213 CopyMem (&Narrow
, NarrowPtr
+ Index
,sizeof (EFI_NARROW_GLYPH
));
214 if (Narrow
.UnicodeWeight
== Char
) {
215 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (EFI_GLYPH_HEIGHT
);
216 if (*GlyphBuffer
== NULL
) {
217 return EFI_OUT_OF_RESOURCES
;
219 Cell
->Width
= EFI_GLYPH_WIDTH
;
220 Cell
->Height
= EFI_GLYPH_HEIGHT
;
221 Cell
->AdvanceX
= Cell
->Width
;
222 CopyMem (*GlyphBuffer
, Narrow
.GlyphCol1
, Cell
->Height
);
223 if (Attributes
!= NULL
) {
224 *Attributes
= (UINT8
) (Narrow
.Attributes
| NARROW_GLYPH
);
230 // Search the wide glyph array
232 WidePtr
= (EFI_WIDE_GLYPH
*) (NarrowPtr
+ SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
);
233 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfWideGlyphs
; Index
++) {
234 CopyMem (&Wide
, WidePtr
+ Index
, sizeof (EFI_WIDE_GLYPH
));
235 if (Wide
.UnicodeWeight
== Char
) {
236 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (EFI_GLYPH_HEIGHT
* 2);
237 if (*GlyphBuffer
== NULL
) {
238 return EFI_OUT_OF_RESOURCES
;
240 Cell
->Width
= EFI_GLYPH_WIDTH
* 2;
241 Cell
->Height
= EFI_GLYPH_HEIGHT
;
242 Cell
->AdvanceX
= Cell
->Width
;
243 CopyMem (*GlyphBuffer
, Wide
.GlyphCol1
, EFI_GLYPH_HEIGHT
);
244 CopyMem (*GlyphBuffer
+ EFI_GLYPH_HEIGHT
, Wide
.GlyphCol2
, EFI_GLYPH_HEIGHT
);
245 if (Attributes
!= NULL
) {
246 *Attributes
= (UINT8
) (Wide
.Attributes
| EFI_GLYPH_WIDE
);
255 return EFI_NOT_FOUND
;
259 Convert bitmap data of the glyph to blt structure.
261 This is a internal function.
263 @param GlyphBuffer Buffer points to bitmap data of glyph.
264 @param Foreground The color of the "on" pixels in the glyph in the
266 @param Background The color of the "off" pixels in the glyph in the
268 @param ImageWidth Width of the whole image in pixels.
269 @param RowWidth The width of the text on the line, in pixels.
270 @param RowHeight The height of the line, in pixels.
271 @param Transparent If TRUE, the Background color is ignored and all
272 "off" pixels in the character's drawn will use the
273 pixel value from BltBuffer.
274 @param Origin On input, points to the origin of the to be
275 displayed character, on output, points to the
281 IN UINT8
*GlyphBuffer
,
282 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
283 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
284 IN UINT16 ImageWidth
,
287 IN BOOLEAN Transparent
,
288 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
295 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Buffer
;
297 ASSERT (GlyphBuffer
!= NULL
&& Origin
!= NULL
&& *Origin
!= NULL
);
299 Height
= EFI_GLYPH_HEIGHT
;
300 Width
= EFI_GLYPH_WIDTH
;
303 // Move position to the left-top corner of char.
305 Buffer
= *Origin
- EFI_GLYPH_HEIGHT
* ImageWidth
;
308 // Char may be partially displayed when CLIP_X or CLIP_Y is not set.
310 if (RowHeight
< Height
) {
311 Height
= (UINT8
) RowHeight
;
313 if (RowWidth
< Width
) {
314 Width
= (UINT8
) RowWidth
;
317 for (Ypos
= 0; Ypos
< Height
; Ypos
++) {
318 for (Xpos
= 0; Xpos
< Width
; Xpos
++) {
319 if ((GlyphBuffer
[Ypos
] & (1 << (EFI_GLYPH_WIDTH
- Xpos
- 1))) != 0) {
320 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Foreground
;
323 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Background
;
329 *Origin
= *Origin
+ EFI_GLYPH_WIDTH
;
334 Convert bitmap data of the glyph to blt structure.
336 This is a internal function.
338 @param GlyphBuffer Buffer points to bitmap data of glyph.
339 @param Foreground The color of the "on" pixels in the glyph in the
341 @param Background The color of the "off" pixels in the glyph in the
343 @param ImageWidth Width of the whole image in pixels.
344 @param BaseLine BaseLine in the line.
345 @param RowWidth The width of the text on the line, in pixels.
346 @param RowHeight The height of the line, in pixels.
347 @param Transparent If TRUE, the Background color is ignored and all
348 "off" pixels in the character's drawn will use the
349 pixel value from BltBuffer.
350 @param Cell Points to EFI_HII_GLYPH_INFO structure.
351 @param Attributes The attribute of incoming glyph in GlyphBuffer.
352 @param Origin On input, points to the origin of the to be
353 displayed character, on output, points to the
360 IN UINT8
*GlyphBuffer
,
361 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
362 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
363 IN UINT16 ImageWidth
,
367 IN BOOLEAN Transparent
,
368 IN CONST EFI_HII_GLYPH_INFO
*Cell
,
370 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
379 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
381 ASSERT (Origin
!= NULL
&& *Origin
!= NULL
&& Cell
!= NULL
);
384 // Only adjust origin position if char has no bitmap.
386 if (GlyphBuffer
== NULL
) {
387 *Origin
= *Origin
+ Cell
->AdvanceX
;
391 // Move position to the left-top corner of char.
393 BltBuffer
= *Origin
+ Cell
->OffsetX
- (Cell
->OffsetY
+ Cell
->Height
) * ImageWidth
;
394 YposOffset
= (UINT16
) (BaseLine
- (Cell
->OffsetY
+ Cell
->Height
));
397 // Since non-spacing key will be printed OR'd with the previous glyph, don't
400 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
405 // The glyph's upper left hand corner pixel is the most significant bit of the
406 // first bitmap byte.
408 for (Ypos
= 0; Ypos
< Cell
->Height
&& (((UINT32
) Ypos
+ YposOffset
) < RowHeight
); Ypos
++) {
409 OffsetY
= BITMAP_LEN_1_BIT (Cell
->Width
, Ypos
);
412 // All bits in these bytes are meaningful.
414 for (Xpos
= 0; Xpos
< Cell
->Width
/ 8; Xpos
++) {
415 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
416 for (Index
= 0; Index
< 8 && (((UINT32
) Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
417 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
418 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
421 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
427 if (Cell
->Width
% 8 != 0) {
429 // There are some padding bits in this byte. Ignore them.
431 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
432 for (Index
= 0; Index
< Cell
->Width
% 8 && (((UINT32
) Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
433 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
434 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
437 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
441 } // end of if (Width % 8...)
443 } // end of for (Ypos=0...)
445 *Origin
= *Origin
+ Cell
->AdvanceX
;
450 Convert bitmap data of the glyph to blt structure.
452 This is a internal function.
454 @param GlyphBuffer Buffer points to bitmap data of glyph.
455 @param Foreground The color of the "on" pixels in the glyph in the
457 @param Background The color of the "off" pixels in the glyph in the
459 @param ImageWidth Width of the whole image in pixels.
460 @param BaseLine BaseLine in the line.
461 @param RowWidth The width of the text on the line, in pixels.
462 @param RowHeight The height of the line, in pixels.
463 @param Transparent If TRUE, the Background color is ignored and all
464 "off" pixels in the character's drawn will use the
465 pixel value from BltBuffer.
466 @param Cell Points to EFI_HII_GLYPH_INFO structure.
467 @param Attributes The attribute of incoming glyph in GlyphBuffer.
468 @param Origin On input, points to the origin of the to be
469 displayed character, on output, points to the
472 @return Points to the address of next origin node in BltBuffer.
477 IN UINT8
*GlyphBuffer
,
478 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
479 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
480 IN UINT16 ImageWidth
,
484 IN BOOLEAN Transparent
,
485 IN CONST EFI_HII_GLYPH_INFO
*Cell
,
487 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
490 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Buffer
;
492 ASSERT (Origin
!= NULL
&& *Origin
!= NULL
&& Cell
!= NULL
);
496 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
498 // This character is a non-spacing key, print it OR'd with the previous glyph.
499 // without advancing cursor.
501 Buffer
-= Cell
->AdvanceX
;
516 } else if ((Attributes
& EFI_GLYPH_WIDE
) == EFI_GLYPH_WIDE
) {
518 // This character is wide glyph, i.e. 16 pixels * 19 pixels.
519 // Draw it as two narrow glyphs.
533 GlyphBuffer
+ EFI_GLYPH_HEIGHT
,
543 } else if ((Attributes
& NARROW_GLYPH
) == NARROW_GLYPH
) {
545 // This character is narrow glyph, i.e. 8 pixels * 19 pixels.
558 } else if ((Attributes
& PROPORTIONAL_GLYPH
) == PROPORTIONAL_GLYPH
) {
560 // This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.
580 Write the output parameters of FindGlyphBlock().
582 This is a internal function.
584 @param BufferIn Buffer which stores the bitmap data of the found
586 @param BufferLen Length of BufferIn.
587 @param InputCell Buffer which stores cell information of the
589 @param GlyphBuffer Output the corresponding bitmap data of the found
590 block. It is the caller's responsibility to free
592 @param Cell Output cell information of the encoded bitmap.
593 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
595 @retval EFI_SUCCESS The operation is performed successfully.
596 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
597 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
605 IN EFI_HII_GLYPH_INFO
*InputCell
,
606 OUT UINT8
**GlyphBuffer OPTIONAL
,
607 OUT EFI_HII_GLYPH_INFO
*Cell OPTIONAL
,
608 OUT UINTN
*GlyphBufferLen OPTIONAL
611 if (BufferIn
== NULL
|| InputCell
== NULL
) {
612 return EFI_INVALID_PARAMETER
;
616 CopyMem (Cell
, InputCell
, sizeof (EFI_HII_GLYPH_INFO
));
619 if (GlyphBuffer
!= NULL
&& BufferLen
> 0) {
620 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (BufferLen
);
621 if (*GlyphBuffer
== NULL
) {
622 return EFI_OUT_OF_RESOURCES
;
624 CopyMem (*GlyphBuffer
, BufferIn
, BufferLen
);
627 if (GlyphBufferLen
!= NULL
) {
628 *GlyphBufferLen
= BufferLen
;
636 Parse all glyph blocks to find a glyph block specified by CharValue.
637 If CharValue = (CHAR16) (-1), collect all default character cell information
638 within this font package and backup its information.
640 @param FontPackage Hii string package instance.
641 @param CharValue Unicode character value, which identifies a glyph
643 @param GlyphBuffer Output the corresponding bitmap data of the found
644 block. It is the caller's responsibility to free
646 @param Cell Output cell information of the encoded bitmap.
647 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
649 @retval EFI_SUCCESS The bitmap data is retrieved successfully.
650 @retval EFI_NOT_FOUND The specified CharValue does not exist in current
652 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
658 IN HII_FONT_PACKAGE_INSTANCE
*FontPackage
,
660 OUT UINT8
**GlyphBuffer OPTIONAL
,
661 OUT EFI_HII_GLYPH_INFO
*Cell OPTIONAL
,
662 OUT UINTN
*GlyphBufferLen OPTIONAL
670 EFI_HII_GIBT_GLYPHS_BLOCK Glyphs
;
673 EFI_HII_GLYPH_INFO DefaultCell
;
674 EFI_HII_GLYPH_INFO LocalCell
;
678 ASSERT (FontPackage
!= NULL
);
679 ASSERT (FontPackage
->Signature
== HII_FONT_PACKAGE_SIGNATURE
);
683 if (CharValue
== (CHAR16
) (-1)) {
685 // Collect the cell information specified in font package fixed header.
686 // Use CharValue =0 to represent this particular cell.
690 &FontPackage
->GlyphInfoList
,
691 (EFI_HII_GLYPH_INFO
*) ((UINT8
*) FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
))
693 if (EFI_ERROR (Status
)) {
698 (UINT8
*) FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
),
699 sizeof (EFI_HII_GLYPH_INFO
)
703 BlockPtr
= FontPackage
->GlyphBlock
;
707 while (*BlockPtr
!= EFI_HII_GIBT_END
) {
709 case EFI_HII_GIBT_DEFAULTS
:
711 // Collect all default character cell information specified by
712 // EFI_HII_GIBT_DEFAULTS.
714 if (CharValue
== (CHAR16
) (-1)) {
717 &FontPackage
->GlyphInfoList
,
718 (EFI_HII_GLYPH_INFO
*) (BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))
720 if (EFI_ERROR (Status
)) {
725 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
726 sizeof (EFI_HII_GLYPH_INFO
)
728 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
729 BaseLine
= (UINT16
) (LocalCell
.Height
+ LocalCell
.OffsetY
);
731 if (MinOffsetY
> LocalCell
.OffsetY
) {
732 MinOffsetY
= LocalCell
.OffsetY
;
735 BlockPtr
+= sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK
);
738 case EFI_HII_GIBT_DUPLICATE
:
739 if (CharCurrent
== CharValue
) {
740 CopyMem (&CharValue
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (CHAR16
));
742 BlockPtr
= FontPackage
->GlyphBlock
;
746 BlockPtr
+= sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK
);
749 case EFI_HII_GIBT_EXT1
:
750 BlockPtr
+= *(UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
));
752 case EFI_HII_GIBT_EXT2
:
755 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
758 BlockPtr
+= Length16
;
760 case EFI_HII_GIBT_EXT4
:
763 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
766 BlockPtr
+= Length32
;
769 case EFI_HII_GIBT_GLYPH
:
772 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
773 sizeof (EFI_HII_GLYPH_INFO
)
775 if (CharValue
== (CHAR16
) (-1)) {
776 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
777 BaseLine
= (UINT16
) (LocalCell
.Height
+ LocalCell
.OffsetY
);
779 if (MinOffsetY
> LocalCell
.OffsetY
) {
780 MinOffsetY
= LocalCell
.OffsetY
;
783 BufferLen
= BITMAP_LEN_1_BIT (LocalCell
.Width
, LocalCell
.Height
);
784 if (CharCurrent
== CharValue
) {
785 return WriteOutputParam (
786 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
)),
795 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
) + BufferLen
;
798 case EFI_HII_GIBT_GLYPHS
:
799 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
);
800 CopyMem (&Glyphs
.Cell
, BlockPtr
, sizeof (EFI_HII_GLYPH_INFO
));
801 BlockPtr
+= sizeof (EFI_HII_GLYPH_INFO
);
802 CopyMem (&Glyphs
.Count
, BlockPtr
, sizeof (UINT16
));
803 BlockPtr
+= sizeof (UINT16
);
805 if (CharValue
== (CHAR16
) (-1)) {
806 if (BaseLine
< Glyphs
.Cell
.Height
+ Glyphs
.Cell
.OffsetY
) {
807 BaseLine
= (UINT16
) (Glyphs
.Cell
.Height
+ Glyphs
.Cell
.OffsetY
);
809 if (MinOffsetY
> Glyphs
.Cell
.OffsetY
) {
810 MinOffsetY
= Glyphs
.Cell
.OffsetY
;
814 BufferLen
= BITMAP_LEN_1_BIT (Glyphs
.Cell
.Width
, Glyphs
.Cell
.Height
);
815 for (Index
= 0; Index
< Glyphs
.Count
; Index
++) {
816 if (CharCurrent
+ Index
== CharValue
) {
817 return WriteOutputParam (
826 BlockPtr
+= BufferLen
;
828 CharCurrent
= (UINT16
) (CharCurrent
+ Glyphs
.Count
);
831 case EFI_HII_GIBT_GLYPH_DEFAULT
:
832 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
833 if (EFI_ERROR (Status
)) {
836 if (CharValue
== (CHAR16
) (-1)) {
837 if (BaseLine
< DefaultCell
.Height
+ DefaultCell
.OffsetY
) {
838 BaseLine
= (UINT16
) (DefaultCell
.Height
+ DefaultCell
.OffsetY
);
840 if (MinOffsetY
> DefaultCell
.OffsetY
) {
841 MinOffsetY
= DefaultCell
.OffsetY
;
844 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
846 if (CharCurrent
== CharValue
) {
847 return WriteOutputParam (
848 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
857 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
) + BufferLen
;
860 case EFI_HII_GIBT_GLYPHS_DEFAULT
:
861 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
862 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
863 if (EFI_ERROR (Status
)) {
866 if (CharValue
== (CHAR16
) (-1)) {
867 if (BaseLine
< DefaultCell
.Height
+ DefaultCell
.OffsetY
) {
868 BaseLine
= (UINT16
) (DefaultCell
.Height
+ DefaultCell
.OffsetY
);
870 if (MinOffsetY
> DefaultCell
.OffsetY
) {
871 MinOffsetY
= DefaultCell
.OffsetY
;
874 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
875 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK
) - sizeof (UINT8
);
876 for (Index
= 0; Index
< Length16
; Index
++) {
877 if (CharCurrent
+ Index
== CharValue
) {
878 return WriteOutputParam (
887 BlockPtr
+= BufferLen
;
889 CharCurrent
= (UINT16
) (CharCurrent
+ Length16
);
892 case EFI_HII_GIBT_SKIP1
:
893 CharCurrent
= (UINT16
) (CharCurrent
+ (UINT16
) (*(BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))));
894 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP1_BLOCK
);
896 case EFI_HII_GIBT_SKIP2
:
897 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
898 CharCurrent
= (UINT16
) (CharCurrent
+ Length16
);
899 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP2_BLOCK
);
906 if (CharValue
< CharCurrent
) {
907 return EFI_NOT_FOUND
;
911 if (CharValue
== (CHAR16
) (-1)) {
912 FontPackage
->BaseLine
= BaseLine
;
913 FontPackage
->Height
= (UINT16
) (BaseLine
- MinOffsetY
);
917 return EFI_NOT_FOUND
;
922 Copy a Font Name to a new created EFI_FONT_INFO structure.
924 This is a internal function.
926 @param FontName NULL-terminated string.
927 @param FontInfo a new EFI_FONT_INFO which stores the FontName.
928 It's caller's responsibility to free this buffer.
930 @retval EFI_SUCCESS FontInfo is allocated and copied with FontName.
931 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
937 IN EFI_STRING FontName
,
938 OUT EFI_FONT_INFO
**FontInfo
944 ASSERT (FontName
!= NULL
&& FontInfo
!= NULL
);
946 NameSize
= StrSize (FontName
);
947 FontInfoLen
= sizeof (EFI_FONT_INFO
) - sizeof (CHAR16
) + NameSize
;
948 *FontInfo
= (EFI_FONT_INFO
*) AllocateZeroPool (FontInfoLen
);
949 if (*FontInfo
== NULL
) {
950 return EFI_OUT_OF_RESOURCES
;
953 StrCpyS ((*FontInfo
)->FontName
, NameSize
/ sizeof (CHAR16
), FontName
);
959 Retrieve system default font and color.
961 @param Private HII database driver private data.
962 @param FontInfo Points to system default font output-related
963 information. It's caller's responsibility to free
965 @param FontInfoSize If not NULL, output the size of buffer FontInfo.
967 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
968 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
970 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
975 IN HII_DATABASE_PRIVATE_DATA
*Private
,
976 OUT EFI_FONT_DISPLAY_INFO
**FontInfo
,
977 OUT UINTN
*FontInfoSize OPTIONAL
980 EFI_FONT_DISPLAY_INFO
*Info
;
984 if (Private
== NULL
|| Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
) {
985 return EFI_INVALID_PARAMETER
;
987 if (FontInfo
== NULL
) {
988 return EFI_INVALID_PARAMETER
;
992 // The standard font always has the name "sysdefault".
994 NameSize
= StrSize (L
"sysdefault");
995 InfoSize
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + NameSize
;
996 Info
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (InfoSize
);
998 return EFI_OUT_OF_RESOURCES
;
1001 Info
->ForegroundColor
= mHiiEfiColors
[Private
->Attribute
& 0x0f];
1002 ASSERT ((Private
->Attribute
>> 4) < 8);
1003 Info
->BackgroundColor
= mHiiEfiColors
[Private
->Attribute
>> 4];
1004 Info
->FontInfoMask
= EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_SYS_STYLE
;
1005 Info
->FontInfo
.FontStyle
= 0;
1006 Info
->FontInfo
.FontSize
= EFI_GLYPH_HEIGHT
;
1007 StrCpyS (Info
->FontInfo
.FontName
, NameSize
/ sizeof (CHAR16
), L
"sysdefault");
1010 if (FontInfoSize
!= NULL
) {
1011 *FontInfoSize
= InfoSize
;
1018 Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
1019 returns the system default according to the optional inputs.
1021 This is a internal function.
1023 @param Private HII database driver private data.
1024 @param StringInfo Points to the string output information,
1025 including the color and font.
1026 @param SystemInfo If not NULL, points to system default font and color.
1028 @param SystemInfoLen If not NULL, output the length of default system
1031 @retval TRUE Yes, it points to system default.
1037 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1038 IN EFI_FONT_DISPLAY_INFO
*StringInfo
,
1039 OUT EFI_FONT_DISPLAY_INFO
**SystemInfo OPTIONAL
,
1040 OUT UINTN
*SystemInfoLen OPTIONAL
1044 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1048 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1050 if (StringInfo
== NULL
&& SystemInfo
== NULL
) {
1054 SystemDefault
= NULL
;
1057 Status
= GetSystemFont (Private
, &SystemDefault
, &DefaultLen
);
1058 ASSERT_EFI_ERROR (Status
);
1059 ASSERT ((SystemDefault
!= NULL
) && (DefaultLen
!= 0));
1062 // Record the system default info.
1064 if (SystemInfo
!= NULL
) {
1065 *SystemInfo
= SystemDefault
;
1068 if (SystemInfoLen
!= NULL
) {
1069 *SystemInfoLen
= DefaultLen
;
1072 if (StringInfo
== NULL
) {
1078 // Check the FontInfoMask to see whether it is retrieving system info.
1080 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) == 0) {
1081 if (StrCmp (StringInfo
->FontInfo
.FontName
, SystemDefault
->FontInfo
.FontName
) != 0) {
1085 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) == 0) {
1086 if (StringInfo
->FontInfo
.FontSize
!= SystemDefault
->FontInfo
.FontSize
) {
1090 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) == 0) {
1091 if (StringInfo
->FontInfo
.FontStyle
!= SystemDefault
->FontInfo
.FontStyle
) {
1095 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == 0) {
1097 &StringInfo
->ForegroundColor
,
1098 &SystemDefault
->ForegroundColor
,
1099 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1104 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == 0) {
1106 &StringInfo
->BackgroundColor
,
1107 &SystemDefault
->BackgroundColor
,
1108 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1117 if (SystemInfo
== NULL
) {
1118 if (SystemDefault
!= NULL
) {
1119 FreePool (SystemDefault
);
1127 This function checks whether EFI_FONT_INFO exists in current database. If
1128 FontInfoMask is specified, check what options can be used to make a match.
1129 Note that the masks relate to where the system default should be supplied
1130 are ignored by this function.
1132 @param Private Hii database private structure.
1133 @param FontInfo Points to EFI_FONT_INFO structure.
1134 @param FontInfoMask If not NULL, describes what options can be used
1135 to make a match between the font requested and
1136 the font available. The caller must guarantee
1138 @param FontHandle On entry, Points to the font handle returned by a
1139 previous call to GetFontInfo() or NULL to start
1140 with the first font.
1141 @param GlobalFontInfo If not NULL, output the corresponding global font
1144 @retval TRUE Existed
1145 @retval FALSE Not existed
1150 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1151 IN EFI_FONT_INFO
*FontInfo
,
1152 IN EFI_FONT_INFO_MASK
*FontInfoMask OPTIONAL
,
1153 IN EFI_FONT_HANDLE FontHandle OPTIONAL
,
1154 OUT HII_GLOBAL_FONT_INFO
**GlobalFontInfo OPTIONAL
1157 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1158 HII_GLOBAL_FONT_INFO
*GlobalFontBackup1
;
1159 HII_GLOBAL_FONT_INFO
*GlobalFontBackup2
;
1161 EFI_FONT_INFO_MASK Mask
;
1163 BOOLEAN VagueMatched1
;
1164 BOOLEAN VagueMatched2
;
1166 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1167 ASSERT (FontInfo
!= NULL
);
1170 // Matched flag represents an exactly match; VagueMatched1 represents a RESIZE
1171 // or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.
1174 VagueMatched1
= FALSE
;
1175 VagueMatched2
= FALSE
;
1178 GlobalFontBackup1
= NULL
;
1179 GlobalFontBackup2
= NULL
;
1181 // The process of where the system default should be supplied instead of
1182 // the specified font info beyonds this function's scope.
1184 if (FontInfoMask
!= NULL
) {
1185 Mask
= *FontInfoMask
& (~SYS_FONT_INFO_MASK
);
1189 // If not NULL, FontHandle points to the next node of the last searched font
1190 // node by previous call.
1192 if (FontHandle
== NULL
) {
1193 Link
= Private
->FontInfoList
.ForwardLink
;
1195 Link
= (LIST_ENTRY
*) FontHandle
;
1198 for (; Link
!= &Private
->FontInfoList
; Link
= Link
->ForwardLink
) {
1199 GlobalFont
= CR (Link
, HII_GLOBAL_FONT_INFO
, Entry
, HII_GLOBAL_FONT_INFO_SIGNATURE
);
1200 if (FontInfoMask
== NULL
) {
1201 if (CompareMem (GlobalFont
->FontInfo
, FontInfo
, GlobalFont
->FontInfoSize
) == 0) {
1202 if (GlobalFontInfo
!= NULL
) {
1203 *GlobalFontInfo
= GlobalFont
;
1209 // Check which options could be used to make a match.
1212 case EFI_FONT_INFO_ANY_FONT
:
1213 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
&&
1214 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1218 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
:
1219 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1223 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
:
1224 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1228 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_ANY_STYLE
:
1232 // If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to
1233 // remove some of the specified styles to meet the style requested.
1235 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
:
1236 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1237 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1239 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1240 VagueMatched1
= TRUE
;
1241 GlobalFontBackup1
= GlobalFont
;
1246 // If EFI_FONT_INFO_RESIZE is specified, then the system may attempt to
1247 // stretch or shrink a font to meet the size requested.
1249 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESIZE
:
1250 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1251 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1254 VagueMatched1
= TRUE
;
1255 GlobalFontBackup1
= GlobalFont
;
1259 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_RESIZE
:
1260 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1261 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1264 VagueMatched1
= TRUE
;
1265 GlobalFontBackup1
= GlobalFont
;
1267 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1268 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1269 VagueMatched1
= TRUE
;
1270 GlobalFontBackup1
= GlobalFont
;
1272 VagueMatched2
= TRUE
;
1273 GlobalFontBackup2
= GlobalFont
;
1277 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1278 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1281 VagueMatched1
= TRUE
;
1282 GlobalFontBackup1
= GlobalFont
;
1285 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1286 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1288 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1289 VagueMatched1
= TRUE
;
1290 GlobalFontBackup1
= GlobalFont
;
1293 case EFI_FONT_INFO_ANY_STYLE
:
1295 GlobalFont
->FontInfo
->FontName
,
1297 StrSize (FontInfo
->FontName
)
1299 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1303 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_ANY_SIZE
:
1305 GlobalFont
->FontInfo
->FontName
,
1307 StrSize (FontInfo
->FontName
)
1312 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1314 GlobalFont
->FontInfo
->FontName
,
1316 StrSize (FontInfo
->FontName
)
1318 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1321 VagueMatched1
= TRUE
;
1322 GlobalFontBackup1
= GlobalFont
;
1326 case EFI_FONT_INFO_ANY_SIZE
:
1328 GlobalFont
->FontInfo
->FontName
,
1330 StrSize (FontInfo
->FontName
)
1332 GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1336 case EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1338 GlobalFont
->FontInfo
->FontName
,
1340 StrSize (FontInfo
->FontName
)
1342 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1344 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1345 VagueMatched1
= TRUE
;
1346 GlobalFontBackup1
= GlobalFont
;
1350 case EFI_FONT_INFO_RESTYLE
:
1352 GlobalFont
->FontInfo
->FontName
,
1354 StrSize (FontInfo
->FontName
)
1356 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1358 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1360 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1361 VagueMatched1
= TRUE
;
1362 GlobalFontBackup1
= GlobalFont
;
1366 case EFI_FONT_INFO_RESIZE
:
1368 GlobalFont
->FontInfo
->FontName
,
1370 StrSize (FontInfo
->FontName
)
1372 GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1374 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1377 VagueMatched1
= TRUE
;
1378 GlobalFontBackup1
= GlobalFont
;
1382 case EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_RESTYLE
:
1384 GlobalFont
->FontInfo
->FontName
,
1386 StrSize (FontInfo
->FontName
)
1388 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1389 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1392 VagueMatched1
= TRUE
;
1393 GlobalFontBackup1
= GlobalFont
;
1395 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1396 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1397 VagueMatched1
= TRUE
;
1398 GlobalFontBackup1
= GlobalFont
;
1400 VagueMatched2
= TRUE
;
1401 GlobalFontBackup2
= GlobalFont
;
1411 if (GlobalFontInfo
!= NULL
) {
1412 *GlobalFontInfo
= GlobalFont
;
1419 if (VagueMatched1
) {
1420 if (GlobalFontInfo
!= NULL
) {
1421 *GlobalFontInfo
= GlobalFontBackup1
;
1424 } else if (VagueMatched2
) {
1425 if (GlobalFontInfo
!= NULL
) {
1426 *GlobalFontInfo
= GlobalFontBackup2
;
1436 Check whether the unicode represents a line break or not.
1438 This is a internal function. Please see Section 27.2.6 of the UEFI Specification
1439 for a description of the supported string format.
1441 @param Char Unicode character
1443 @retval 0 Yes, it forces a line break.
1444 @retval 1 Yes, it presents a line break opportunity
1445 @retval 2 Yes, it requires a line break happen before and after it.
1446 @retval -1 No, it is not a link break.
1456 // Mandatory line break characters, which force a line-break
1465 // Space characters, which is taken as a line-break opportunity
1481 // In-Word Break Opportunities
1486 // A space which is not a line-break opportunity
1491 // A hyphen which is not a line-break opportunity
1496 // Hyphen characters which describe line break opportunities after the character
1507 // A hyphen which describes line break opportunities before and after them, but not between a pair of them
1517 Renders a string to a bitmap or to the display.
1519 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
1520 @param Flags Describes how the string is to be drawn.
1521 @param String Points to the null-terminated string to be
1523 @param StringInfo Points to the string output information,
1524 including the color and font. If NULL, then the
1525 string will be output in the default system font
1527 @param Blt If this points to a non-NULL on entry, this
1528 points to the image, which is Width pixels wide
1529 and Height pixels high. The string will be drawn
1531 EFI_HII_OUT_FLAG_CLIP is implied. If this points
1532 to a NULL on entry, then a buffer
1533 will be allocated to hold the generated image and
1534 the pointer updated on exit. It is the caller's
1535 responsibility to free this buffer.
1536 @param BltX Specifies the offset from the left and top edge
1537 of the image of the first character cell in the
1539 @param BltY Specifies the offset from the left and top edge
1540 of the image of the first character cell in the
1542 @param RowInfoArray If this is non-NULL on entry, then on exit, this
1543 will point to an allocated buffer containing
1544 row information and RowInfoArraySize will be
1545 updated to contain the number of elements.
1546 This array describes the characters which were at
1547 least partially drawn and the heights of the
1548 rows. It is the caller's responsibility to free
1550 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
1551 contains the number of elements in RowInfoArray.
1552 @param ColumnInfoArray If this is non-NULL, then on return it will be
1553 filled with the horizontal offset for each
1554 character in the string on the row where it is
1555 displayed. Non-printing characters will have
1556 the offset ~0. The caller is responsible to
1557 allocate a buffer large enough so that there
1558 is one entry for each character in the string,
1559 not including the null-terminator. It is possible
1560 when character display is normalized that some
1561 character cells overlap.
1563 @retval EFI_SUCCESS The string was successfully rendered.
1564 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
1565 RowInfoArray or Blt.
1566 @retval EFI_INVALID_PARAMETER The String or Blt was NULL.
1567 @retval EFI_INVALID_PARAMETER Flags were invalid combination..
1573 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
1574 IN EFI_HII_OUT_FLAGS Flags
,
1575 IN CONST EFI_STRING String
,
1576 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
1577 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
1580 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
1581 OUT UINTN
*RowInfoArraySize OPTIONAL
,
1582 OUT UINTN
*ColumnInfoArray OPTIONAL
1586 HII_DATABASE_PRIVATE_DATA
*Private
;
1588 EFI_HII_GLYPH_INFO
*Cell
;
1590 EFI_IMAGE_OUTPUT
*Image
;
1591 EFI_STRING StringPtr
;
1592 EFI_STRING StringTmp
;
1593 EFI_HII_ROW_INFO
*RowInfo
;
1597 UINTN LastLineHeight
;
1598 UINTN BaseLineOffset
;
1604 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
1605 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1606 EFI_FONT_HANDLE FontHandle
;
1607 EFI_STRING StringIn
;
1608 EFI_STRING StringIn2
;
1611 EFI_FONT_INFO
*FontInfo
;
1612 BOOLEAN SysFontFlag
;
1613 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1614 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1615 BOOLEAN Transparent
;
1616 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
1617 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BufferPtr
;
1621 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*RowBufferPtr
;
1622 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1623 UINT32 PreInitBkgnd
;
1626 // Check incoming parameters.
1629 if (This
== NULL
|| String
== NULL
|| Blt
== NULL
) {
1630 return EFI_INVALID_PARAMETER
;
1634 // These two flag cannot be used if Blt is NULL upon entry.
1636 if ((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
) {
1637 return EFI_INVALID_PARAMETER
;
1639 if ((Flags
& EFI_HII_OUT_FLAG_CLIP
) == EFI_HII_OUT_FLAG_CLIP
) {
1640 return EFI_INVALID_PARAMETER
;
1644 // These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
1646 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_X
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) {
1647 return EFI_INVALID_PARAMETER
;
1649 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) {
1650 return EFI_INVALID_PARAMETER
;
1653 // This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
1655 if ((Flags
& (EFI_HII_OUT_FLAG_WRAP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_X
)) == (EFI_HII_OUT_FLAG_WRAP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_X
)) {
1656 return EFI_INVALID_PARAMETER
;
1661 // Create a new bitmap and draw the string onto this image.
1663 Image
= AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1664 if (Image
== NULL
) {
1665 return EFI_OUT_OF_RESOURCES
;
1668 Image
->Height
= 600;
1669 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
*sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1670 if (Image
->Image
.Bitmap
== NULL
) {
1672 return EFI_OUT_OF_RESOURCES
;
1676 // Other flags are not permitted when Blt is NULL.
1678 Flags
&= EFI_HII_OUT_FLAG_WRAP
| EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_IGNORE_LINE_BREAK
;
1682 StrLength
= StrLen(String
);
1683 GlyphBuf
= (UINT8
**) AllocateZeroPool (StrLength
* sizeof (UINT8
*));
1684 ASSERT (GlyphBuf
!= NULL
);
1685 Cell
= (EFI_HII_GLYPH_INFO
*) AllocateZeroPool (StrLength
* sizeof (EFI_HII_GLYPH_INFO
));
1686 ASSERT (Cell
!= NULL
);
1687 Attributes
= (UINT8
*) AllocateZeroPool (StrLength
* sizeof (UINT8
));
1688 ASSERT (Attributes
!= NULL
);
1691 Status
= EFI_SUCCESS
;
1693 SystemDefault
= NULL
;
1697 // Calculate the string output information, including specified color and font .
1698 // If StringInfo does not points to system font info, it must indicate an existing
1701 StringInfoOut
= NULL
;
1703 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
1704 SysFontFlag
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &SystemDefault
, NULL
);
1707 ASSERT (SystemDefault
!= NULL
);
1709 Height
= SystemDefault
->FontInfo
.FontSize
;
1710 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1711 Foreground
= SystemDefault
->ForegroundColor
;
1712 Background
= SystemDefault
->BackgroundColor
;
1716 // StringInfo must not be NULL if it is not system info.
1718 ASSERT (StringInfo
!= NULL
);
1719 Status
= HiiGetFontInfo (This
, &FontHandle
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &StringInfoOut
, NULL
);
1720 if (Status
== EFI_NOT_FOUND
) {
1722 // The specified EFI_FONT_DISPLAY_INFO does not exist in current database.
1723 // Use the system font instead. Still use the color specified by StringInfo.
1727 Height
= SystemDefault
->FontInfo
.FontSize
;
1728 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1729 Foreground
= ((EFI_FONT_DISPLAY_INFO
*) StringInfo
)->ForegroundColor
;
1730 Background
= ((EFI_FONT_DISPLAY_INFO
*) StringInfo
)->BackgroundColor
;
1732 } else if (Status
== EFI_SUCCESS
) {
1733 FontInfo
= &StringInfoOut
->FontInfo
;
1734 IsFontInfoExisted (Private
, FontInfo
, NULL
, NULL
, &GlobalFont
);
1735 Height
= GlobalFont
->FontPackage
->Height
;
1736 BaseLine
= GlobalFont
->FontPackage
->BaseLine
;
1737 Foreground
= StringInfoOut
->ForegroundColor
;
1738 Background
= StringInfoOut
->BackgroundColor
;
1745 // Use the maximum height of font as the base line.
1746 // And, use the maximum height as line height.
1748 LineHeight
= Height
;
1749 LastLineHeight
= Height
;
1750 BaseLineOffset
= Height
- BaseLine
;
1753 // Parse the string to be displayed to drop some ignored characters.
1759 // Ignore line-break characters only. Hyphens or dash character will be displayed
1760 // without line-break opportunity.
1762 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == EFI_HII_IGNORE_LINE_BREAK
) {
1763 StringIn
= AllocateZeroPool (StrSize (StringPtr
));
1764 if (StringIn
== NULL
) {
1765 Status
= EFI_OUT_OF_RESOURCES
;
1768 StringTmp
= StringIn
;
1769 while (*StringPtr
!= 0) {
1770 if (IsLineBreak (*StringPtr
) == 0) {
1773 *StringTmp
++ = *StringPtr
++;
1777 StringPtr
= StringIn
;
1780 // If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs
1781 // are not drawn. Otherwise they are replaced with Unicode character 0xFFFD.
1783 StringIn2
= AllocateZeroPool (StrSize (StringPtr
));
1784 if (StringIn2
== NULL
) {
1785 Status
= EFI_OUT_OF_RESOURCES
;
1789 StringTmp
= StringIn2
;
1790 StrLength
= StrLen(StringPtr
);
1791 while (*StringPtr
!= 0 && Index
< StrLength
) {
1792 if (IsLineBreak (*StringPtr
) == 0) {
1793 *StringTmp
++ = *StringPtr
++;
1798 Status
= GetGlyphBuffer (Private
, *StringPtr
, FontInfo
, &GlyphBuf
[Index
], &Cell
[Index
], &Attributes
[Index
]);
1799 if (Status
== EFI_NOT_FOUND
) {
1800 if ((Flags
& EFI_HII_IGNORE_IF_NO_GLYPH
) == EFI_HII_IGNORE_IF_NO_GLYPH
) {
1801 GlyphBuf
[Index
] = NULL
;
1802 ZeroMem (&Cell
[Index
], sizeof (Cell
[Index
]));
1803 Status
= EFI_SUCCESS
;
1806 // Unicode 0xFFFD must exist in current hii database if this flag is not set.
1808 Status
= GetGlyphBuffer (
1810 REPLACE_UNKNOWN_GLYPH
,
1816 if (EFI_ERROR (Status
)) {
1817 Status
= EFI_INVALID_PARAMETER
;
1822 if (EFI_ERROR (Status
)) {
1826 *StringTmp
++ = *StringPtr
++;
1830 StringPtr
= StringIn2
;
1833 // Draw the string according to the specified EFI_HII_OUT_FLAGS and Blt.
1834 // If Blt is not NULL, then EFI_HII_OUT_FLAG_CLIP is implied, render this string
1835 // to an existing image (bitmap or screen depending on flags) pointed by "*Blt".
1836 // Otherwise render this string to a new allocated image and output it.
1839 BufferPtr
= Image
->Image
.Bitmap
+ Image
->Width
* BltY
+ BltX
;
1840 if (Image
->Height
< BltY
) {
1842 // the top edge of the image should be in Image resolution scope.
1844 Status
= EFI_INVALID_PARAMETER
;
1847 MaxRowNum
= (UINT16
) ((Image
->Height
- BltY
) / Height
);
1848 if ((Image
->Height
- BltY
) % Height
!= 0) {
1849 LastLineHeight
= (Image
->Height
- BltY
) % Height
;
1853 RowInfo
= (EFI_HII_ROW_INFO
*) AllocateZeroPool (MaxRowNum
* sizeof (EFI_HII_ROW_INFO
));
1854 if (RowInfo
== NULL
) {
1855 Status
= EFI_OUT_OF_RESOURCES
;
1860 // Format the glyph buffer according to flags.
1862 Transparent
= (BOOLEAN
) ((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
? TRUE
: FALSE
);
1864 for (RowIndex
= 0, Index
= 0; RowIndex
< MaxRowNum
&& StringPtr
[Index
] != 0; ) {
1869 // Clip the final row if the row's bottom-most on pixel cannot fit when
1870 // EFI_HII_OUT_FLAG_CLEAN_Y is set.
1872 if (RowIndex
== MaxRowNum
- 1) {
1873 if ((Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
&& LastLineHeight
< LineHeight
) {
1875 // Don't draw at all if the row's bottom-most on pixel cannot fit.
1879 LineHeight
= LastLineHeight
;
1883 // Calculate how many characters there are in a row.
1885 RowInfo
[RowIndex
].StartIndex
= Index
;
1887 while (LineWidth
+ BltX
< Image
->Width
&& StringPtr
[Index
] != 0) {
1888 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0 &&
1889 IsLineBreak (StringPtr
[Index
]) == 0) {
1891 // It forces a line break that ends this row.
1899 // If the glyph of the character is existing, then accumulate the actual printed width
1901 LineWidth
+= (UINTN
) Cell
[Index
].AdvanceX
;
1907 // Record index of next char.
1911 // Return to the previous char.
1914 if (LineBreak
&& Index
> 0 ) {
1916 // Return the previous non line break char.
1922 // If this character is the last character of a row, we need not
1923 // draw its (AdvanceX - Width - OffsetX) for next character.
1925 LineWidth
-= (Cell
[Index
].AdvanceX
- Cell
[Index
].Width
- Cell
[Index
].OffsetX
);
1928 // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
1930 if (LineWidth
+ BltX
<= Image
->Width
||
1931 (LineWidth
+ BltX
> Image
->Width
&& (Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) == 0)) {
1933 // Record right-most character in RowInfo even if it is partially displayed.
1935 RowInfo
[RowIndex
].EndIndex
= Index
;
1936 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
1937 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
1938 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
1941 // When EFI_HII_OUT_FLAG_CLEAN_X is set, it will not draw a character
1942 // if its right-most on pixel cannot fit.
1944 if (Index
> RowInfo
[RowIndex
].StartIndex
) {
1946 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
1948 LineWidth
-= (Cell
[Index
].Width
+ Cell
[Index
].OffsetX
);
1949 LineWidth
-= (Cell
[Index
- 1].AdvanceX
- Cell
[Index
- 1].Width
- Cell
[Index
- 1].OffsetX
);
1950 RowInfo
[RowIndex
].EndIndex
= Index
- 1;
1951 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
1952 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
1953 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
1956 // There is no enough column to draw any character, so set current line width to zero.
1957 // And go to draw Next line if LineBreak is set.
1959 RowInfo
[RowIndex
].LineWidth
= 0;
1965 // EFI_HII_OUT_FLAG_WRAP will wrap the text at the right-most line-break
1966 // opportunity prior to a character whose right-most extent would exceed Width.
1967 // Search the right-most line-break opportunity here.
1969 if ((Flags
& EFI_HII_OUT_FLAG_WRAP
) == EFI_HII_OUT_FLAG_WRAP
&&
1970 (RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
|| StringPtr
[NextIndex
] != 0) &&
1972 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0) {
1973 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
1974 for (Index1
= RowInfo
[RowIndex
].EndIndex
; Index1
>= RowInfo
[RowIndex
].StartIndex
; Index1
--) {
1975 if (Index1
== RowInfo
[RowIndex
].EndIndex
) {
1976 LineWidth
-= (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
1978 LineWidth
-= Cell
[Index1
].AdvanceX
;
1980 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
1982 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
1983 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
1986 // relocate to the character after the right-most line break opportunity of this line
1988 NextIndex
= Index1
+ 1;
1992 // If don't find a line break opportunity from EndIndex to StartIndex,
1995 if (Index1
== RowInfo
[RowIndex
].StartIndex
)
2000 // Update LineWidth to the real width
2002 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
2003 if (Index1
== RowInfo
[RowIndex
].StartIndex
) {
2006 LineWidth
-= (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
2008 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2012 // If no line-break opportunity can be found, then the text will
2013 // behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.
2016 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
2017 Index1
= RowInfo
[RowIndex
].EndIndex
;
2018 if (LineWidth
+ BltX
> Image
->Width
) {
2019 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
2021 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
2023 LineWidth
-= (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
2024 LineWidth
-= (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
2025 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
2026 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2029 // There is no enough column to draw any character, so set current line width to zero.
2030 // And go to draw Next line if LineBreak is set.
2032 RowInfo
[RowIndex
].LineWidth
= 0;
2040 // LineWidth can't exceed Image width.
2042 if (RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
) {
2043 RowInfo
[RowIndex
].LineWidth
= Image
->Width
- BltX
;
2047 // Draw it to screen or existing bitmap depending on whether
2048 // EFI_HII_DIRECT_TO_SCREEN is set.
2051 if ((Flags
& EFI_HII_DIRECT_TO_SCREEN
) == EFI_HII_DIRECT_TO_SCREEN
) {
2053 if (RowInfo
[RowIndex
].LineWidth
!= 0) {
2054 BltBuffer
= AllocatePool (RowInfo
[RowIndex
].LineWidth
* RowInfo
[RowIndex
].LineHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2055 if (BltBuffer
== NULL
) {
2056 Status
= EFI_OUT_OF_RESOURCES
;
2060 // Initialize the background color.
2062 PreInitBkgnd
= Background
.Blue
| Background
.Green
<< 8 | Background
.Red
<< 16;
2063 SetMem32 (BltBuffer
,RowInfo
[RowIndex
].LineWidth
* RowInfo
[RowIndex
].LineHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
),PreInitBkgnd
);
2065 // Set BufferPtr to Origin by adding baseline to the starting position.
2067 BufferPtr
= BltBuffer
+ BaseLine
* RowInfo
[RowIndex
].LineWidth
;
2069 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2070 if (RowInfo
[RowIndex
].LineWidth
> 0 && RowInfo
[RowIndex
].LineWidth
> LineOffset
) {
2072 // Only BLT these character which have corresponding glyph in font database.
2078 (UINT16
) RowInfo
[RowIndex
].LineWidth
,
2080 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2081 RowInfo
[RowIndex
].LineHeight
,
2088 if (ColumnInfoArray
!= NULL
) {
2089 if ((GlyphBuf
[Index1
] == NULL
&& Cell
[Index1
].AdvanceX
== 0)
2090 || RowInfo
[RowIndex
].LineWidth
== 0) {
2091 *ColumnInfoArray
= (UINTN
) ~0;
2093 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2097 LineOffset
+= Cell
[Index1
].AdvanceX
;
2100 if (BltBuffer
!= NULL
) {
2101 Status
= Image
->Image
.Screen
->Blt (
2102 Image
->Image
.Screen
,
2104 EfiBltBufferToVideo
,
2109 RowInfo
[RowIndex
].LineWidth
,
2110 RowInfo
[RowIndex
].LineHeight
,
2113 if (EFI_ERROR (Status
)) {
2114 FreePool (BltBuffer
);
2118 FreePool (BltBuffer
);
2122 // Save the starting position for calculate the starting position of next row.
2124 RowBufferPtr
= BufferPtr
;
2126 // Set BufferPtr to Origin by adding baseline to the starting position.
2128 BufferPtr
= BufferPtr
+ BaseLine
* Image
->Width
;
2129 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2130 if (RowInfo
[RowIndex
].LineWidth
> 0 && RowInfo
[RowIndex
].LineWidth
> LineOffset
) {
2132 // Only BLT these character which have corresponding glyph in font database.
2140 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2141 RowInfo
[RowIndex
].LineHeight
,
2148 if (ColumnInfoArray
!= NULL
) {
2149 if ((GlyphBuf
[Index1
] == NULL
&& Cell
[Index1
].AdvanceX
== 0)
2150 || RowInfo
[RowIndex
].LineWidth
== 0) {
2151 *ColumnInfoArray
= (UINTN
) ~0;
2153 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2157 LineOffset
+= Cell
[Index1
].AdvanceX
;
2161 // Jump to starting position of next row.
2163 if (RowIndex
== 0) {
2164 BufferPtr
= RowBufferPtr
- BltX
+ LineHeight
* Image
->Width
;
2166 BufferPtr
= RowBufferPtr
+ LineHeight
* Image
->Width
;
2172 // Recalculate the start point of Y axis to draw multi-lines with the order of top-to-down
2174 BltY
+= RowInfo
[RowIndex
].LineHeight
;
2181 // If there is not a mandatory line break or line break opportunity, only render one line to image
2188 // Write output parameters.
2190 RowInfoSize
= RowIndex
* sizeof (EFI_HII_ROW_INFO
);
2191 if (RowInfoArray
!= NULL
) {
2192 if (RowInfoSize
> 0) {
2193 *RowInfoArray
= AllocateZeroPool (RowInfoSize
);
2194 if (*RowInfoArray
== NULL
) {
2195 Status
= EFI_OUT_OF_RESOURCES
;
2198 CopyMem (*RowInfoArray
, RowInfo
, RowInfoSize
);
2200 *RowInfoArray
= NULL
;
2203 if (RowInfoArraySize
!= NULL
) {
2204 *RowInfoArraySize
= RowIndex
;
2207 Status
= EFI_SUCCESS
;
2211 for (Index
= 0; Index
< StrLength
; Index
++) {
2212 if (GlyphBuf
[Index
] != NULL
) {
2213 FreePool (GlyphBuf
[Index
]);
2216 if (StringIn
!= NULL
) {
2217 FreePool (StringIn
);
2219 if (StringIn2
!= NULL
) {
2220 FreePool (StringIn2
);
2222 if (StringInfoOut
!= NULL
) {
2223 FreePool (StringInfoOut
);
2225 if (RowInfo
!= NULL
) {
2228 if (SystemDefault
!= NULL
) {
2229 FreePool (SystemDefault
);
2231 if (GlyphBuf
!= NULL
) {
2232 FreePool (GlyphBuf
);
2237 if (Attributes
!= NULL
) {
2238 FreePool (Attributes
);
2246 Render a string to a bitmap or the screen containing the contents of the specified string.
2248 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2249 @param Flags Describes how the string is to be drawn.
2250 @param PackageList The package list in the HII database to search
2251 for the specified string.
2252 @param StringId The string's id, which is unique within
2254 @param Language Points to the language for the retrieved string.
2255 If NULL, then the current system language is
2257 @param StringInfo Points to the string output information,
2258 including the color and font. If NULL, then the
2259 string will be output in the default system font
2261 @param Blt If this points to a non-NULL on entry, this
2262 points to the image, which is Width pixels wide
2263 and Height pixels high. The string will be drawn
2265 EFI_HII_OUT_FLAG_CLIP is implied. If this points
2266 to a NULL on entry, then a buffer
2267 will be allocated to hold the generated image and
2268 the pointer updated on exit. It is the caller's
2269 responsibility to free this buffer.
2270 @param BltX Specifies the offset from the left and top edge
2271 of the image of the first character cell in the
2273 @param BltY Specifies the offset from the left and top edge
2274 of the image of the first character cell in the
2276 @param RowInfoArray If this is non-NULL on entry, then on exit, this
2277 will point to an allocated buffer containing
2278 row information and RowInfoArraySize will be
2279 updated to contain the number of elements.
2280 This array describes the characters which were at
2281 least partially drawn and the heights of the
2282 rows. It is the caller's responsibility to free
2284 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
2285 contains the number of elements in RowInfoArray.
2286 @param ColumnInfoArray If this is non-NULL, then on return it will be
2287 filled with the horizontal offset for each
2288 character in the string on the row where it is
2289 displayed. Non-printing characters will have
2290 the offset ~0. The caller is responsible to
2291 allocate a buffer large enough so that there
2292 is one entry for each character in the string,
2293 not including the null-terminator. It is possible
2294 when character display is normalized that some
2295 character cells overlap.
2297 @retval EFI_SUCCESS The string was successfully rendered.
2298 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
2299 RowInfoArray or Blt.
2300 @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
2301 @retval EFI_INVALID_PARAMETER Flags were invalid combination.
2302 @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the string id is not
2303 in the specified PackageList.
2308 HiiStringIdToImage (
2309 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2310 IN EFI_HII_OUT_FLAGS Flags
,
2311 IN EFI_HII_HANDLE PackageList
,
2312 IN EFI_STRING_ID StringId
,
2313 IN CONST CHAR8
* Language
,
2314 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
2315 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
2318 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
2319 OUT UINTN
*RowInfoArraySize OPTIONAL
,
2320 OUT UINTN
*ColumnInfoArray OPTIONAL
2324 HII_DATABASE_PRIVATE_DATA
*Private
;
2325 EFI_HII_STRING_PROTOCOL
*HiiString
;
2330 EFI_FONT_INFO
*StringFontInfo
;
2331 EFI_FONT_DISPLAY_INFO
*NewStringInfo
;
2332 CHAR8 TempSupportedLanguages
;
2333 CHAR8
*SupportedLanguages
;
2334 UINTN SupportedLanguagesSize
;
2335 CHAR8
*CurrentLanguage
;
2336 CHAR8
*BestLanguage
;
2338 if (This
== NULL
|| PackageList
== NULL
|| Blt
== NULL
|| PackageList
== NULL
) {
2339 return EFI_INVALID_PARAMETER
;
2342 if (!IsHiiHandleValid (PackageList
)) {
2343 return EFI_NOT_FOUND
;
2347 // Initialize string pointers to be NULL
2349 SupportedLanguages
= NULL
;
2350 CurrentLanguage
= NULL
;
2351 BestLanguage
= NULL
;
2353 StringFontInfo
= NULL
;
2354 NewStringInfo
= NULL
;
2357 // Get the string to be displayed.
2359 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2360 HiiString
= &Private
->HiiString
;
2363 // Get the size of supported language.
2365 SupportedLanguagesSize
= 0;
2366 Status
= HiiString
->GetLanguages (
2369 &TempSupportedLanguages
,
2370 &SupportedLanguagesSize
2372 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2376 SupportedLanguages
= AllocatePool (SupportedLanguagesSize
);
2377 if (SupportedLanguages
== NULL
) {
2378 return EFI_OUT_OF_RESOURCES
;
2381 Status
= HiiString
->GetLanguages (
2385 &SupportedLanguagesSize
2387 if (EFI_ERROR (Status
)) {
2391 if (Language
== NULL
) {
2394 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**)&CurrentLanguage
, NULL
);
2395 BestLanguage
= GetBestLanguage (
2399 (CurrentLanguage
== NULL
) ? CurrentLanguage
: "",
2400 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
2403 if (BestLanguage
== NULL
) {
2404 Status
= EFI_NOT_FOUND
;
2408 StringSize
= MAX_STRING_LENGTH
;
2409 String
= (EFI_STRING
) AllocateZeroPool (StringSize
);
2410 if (String
== NULL
) {
2411 Status
= EFI_OUT_OF_RESOURCES
;
2415 Status
= HiiString
->GetString (
2424 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2426 String
= (EFI_STRING
) AllocateZeroPool (StringSize
);
2427 if (String
== NULL
) {
2428 Status
= EFI_OUT_OF_RESOURCES
;
2431 Status
= HiiString
->GetString (
2442 if (EFI_ERROR (Status
)) {
2447 // When StringInfo specifies that string will be output in the system default font and color,
2448 // use particular stringfontinfo described in string package instead if exists.
2449 // StringFontInfo equals NULL means system default font attaches with the string block.
2451 if (StringFontInfo
!= NULL
&& IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, NULL
, NULL
)) {
2452 NameSize
= StrSize (StringFontInfo
->FontName
);
2453 FontLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + NameSize
;
2454 NewStringInfo
= AllocateZeroPool (FontLen
);
2455 if (NewStringInfo
== NULL
) {
2456 Status
= EFI_OUT_OF_RESOURCES
;
2459 NewStringInfo
->FontInfoMask
= EFI_FONT_INFO_SYS_FORE_COLOR
| EFI_FONT_INFO_SYS_BACK_COLOR
;
2460 NewStringInfo
->FontInfo
.FontStyle
= StringFontInfo
->FontStyle
;
2461 NewStringInfo
->FontInfo
.FontSize
= StringFontInfo
->FontSize
;
2462 StrCpyS (NewStringInfo
->FontInfo
.FontName
, NameSize
/ sizeof (CHAR16
), StringFontInfo
->FontName
);
2464 Status
= HiiStringToImage (
2479 Status
= HiiStringToImage (
2493 if (SupportedLanguages
!= NULL
) {
2494 FreePool (SupportedLanguages
);
2496 if (CurrentLanguage
!= NULL
) {
2497 FreePool (CurrentLanguage
);
2499 if (BestLanguage
!= NULL
) {
2500 FreePool (BestLanguage
);
2502 if (String
!= NULL
) {
2505 if (StringFontInfo
!= NULL
) {
2506 FreePool (StringFontInfo
);
2508 if (NewStringInfo
!= NULL
) {
2509 FreePool (NewStringInfo
);
2517 Convert the glyph for a single character into a bitmap.
2519 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2520 @param Char Character to retrieve.
2521 @param StringInfo Points to the string font and color information
2522 or NULL if the string should use the default
2523 system font and color.
2524 @param Blt Thus must point to a NULL on entry. A buffer will
2525 be allocated to hold the output and the pointer
2526 updated on exit. It is the caller's
2527 responsibility to free this buffer.
2528 @param Baseline Number of pixels from the bottom of the bitmap to
2531 @retval EFI_SUCCESS Glyph bitmap created.
2532 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.
2533 @retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was replaced with the
2534 glyph for Unicode character 0xFFFD.
2535 @retval EFI_INVALID_PARAMETER Blt is NULL or *Blt is not NULL.
2541 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2543 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo
,
2544 OUT EFI_IMAGE_OUTPUT
**Blt
,
2545 OUT UINTN
*Baseline OPTIONAL
2549 HII_DATABASE_PRIVATE_DATA
*Private
;
2550 EFI_IMAGE_OUTPUT
*Image
;
2552 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2553 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
2555 EFI_FONT_HANDLE FontHandle
;
2557 EFI_HII_GLYPH_INFO Cell
;
2558 EFI_FONT_INFO
*FontInfo
;
2560 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
2561 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
2562 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
2565 if (This
== NULL
|| Blt
== NULL
|| *Blt
!= NULL
) {
2566 return EFI_INVALID_PARAMETER
;
2569 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2573 SystemDefault
= NULL
;
2577 StringInfoOut
= NULL
;
2580 ZeroMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2581 ZeroMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2583 Default
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &SystemDefault
, NULL
);
2587 // Find out a EFI_FONT_DISPLAY_INFO which could display the character in
2588 // the specified color and font.
2590 String
= (EFI_STRING
) AllocateZeroPool (sizeof (CHAR16
) * 2);
2591 if (String
== NULL
) {
2592 Status
= EFI_OUT_OF_RESOURCES
;
2598 Status
= HiiGetFontInfo (This
, &FontHandle
, StringInfo
, &StringInfoOut
, String
);
2599 if (EFI_ERROR (Status
)) {
2602 ASSERT (StringInfoOut
!= NULL
);
2603 FontInfo
= &StringInfoOut
->FontInfo
;
2604 Foreground
= StringInfoOut
->ForegroundColor
;
2605 Background
= StringInfoOut
->BackgroundColor
;
2607 ASSERT (SystemDefault
!= NULL
);
2608 Foreground
= SystemDefault
->ForegroundColor
;
2609 Background
= SystemDefault
->BackgroundColor
;
2612 Status
= GetGlyphBuffer (Private
, Char
, FontInfo
, &GlyphBuffer
, &Cell
, &Attributes
);
2613 if (EFI_ERROR (Status
)) {
2617 Image
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
2618 if (Image
== NULL
) {
2619 Status
= EFI_OUT_OF_RESOURCES
;
2622 Image
->Width
= Cell
.Width
;
2623 Image
->Height
= Cell
.Height
;
2625 if (Image
->Width
* Image
->Height
> 0) {
2626 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2627 if (Image
->Image
.Bitmap
== NULL
) {
2629 Status
= EFI_OUT_OF_RESOURCES
;
2634 // Set BaseLine to the char height.
2636 BaseLine
= (UINT16
) (Cell
.Height
+ Cell
.OffsetY
);
2638 // Set BltBuffer to the position of Origin.
2640 BltBuffer
= Image
->Image
.Bitmap
+ (Cell
.Height
+ Cell
.OffsetY
) * Image
->Width
- Cell
.OffsetX
;
2647 Cell
.Width
+ Cell
.OffsetX
,
2648 BaseLine
- Cell
.OffsetY
,
2657 if (Baseline
!= NULL
) {
2658 *Baseline
= Cell
.OffsetY
;
2661 Status
= EFI_SUCCESS
;
2665 if (Status
== EFI_NOT_FOUND
) {
2667 // Glyph is unknown and replaced with the glyph for unicode character 0xFFFD
2669 if (Char
!= REPLACE_UNKNOWN_GLYPH
) {
2670 Status
= HiiGetGlyph (This
, REPLACE_UNKNOWN_GLYPH
, StringInfo
, Blt
, Baseline
);
2671 if (!EFI_ERROR (Status
)) {
2672 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2675 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2679 if (SystemDefault
!= NULL
) {
2680 FreePool (SystemDefault
);
2682 if (StringInfoOut
!= NULL
) {
2683 FreePool (StringInfoOut
);
2685 if (String
!= NULL
) {
2688 if (GlyphBuffer
!= NULL
) {
2689 FreePool (GlyphBuffer
);
2697 This function iterates through fonts which match the specified font, using
2698 the specified criteria. If String is non-NULL, then all of the characters in
2699 the string must exist in order for a candidate font to be returned.
2701 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2702 @param FontHandle On entry, points to the font handle returned by a
2703 previous call to GetFontInfo() or NULL to start
2704 with the first font. On return, points to the
2705 returned font handle or points to NULL if there
2706 are no more matching fonts.
2707 @param StringInfoIn Upon entry, points to the font to return information
2708 about. If NULL, then the information about the system
2709 default font will be returned.
2710 @param StringInfoOut Upon return, contains the matching font's information.
2711 If NULL, then no information is returned. This buffer
2712 is allocated with a call to the Boot Service AllocatePool().
2713 It is the caller's responsibility to call the Boot
2714 Service FreePool() when the caller no longer requires
2715 the contents of StringInfoOut.
2716 @param String Points to the string which will be tested to
2717 determine if all characters are available. If
2718 NULL, then any font is acceptable.
2720 @retval EFI_SUCCESS Matching font returned successfully.
2721 @retval EFI_NOT_FOUND No matching font was found.
2722 @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
2723 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
2730 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2731 IN OUT EFI_FONT_HANDLE
*FontHandle
,
2732 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfoIn OPTIONAL
,
2733 OUT EFI_FONT_DISPLAY_INFO
**StringInfoOut
,
2734 IN CONST EFI_STRING String OPTIONAL
2737 HII_DATABASE_PRIVATE_DATA
*Private
;
2739 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2740 EFI_FONT_DISPLAY_INFO InfoOut
;
2741 UINTN StringInfoOutLen
;
2742 EFI_FONT_INFO
*FontInfo
;
2743 HII_GLOBAL_FONT_INFO
*GlobalFont
;
2744 EFI_STRING StringIn
;
2745 EFI_FONT_HANDLE LocalFontHandle
;
2748 return EFI_INVALID_PARAMETER
;
2751 StringInfoOutLen
= 0;
2753 SystemDefault
= NULL
;
2754 LocalFontHandle
= NULL
;
2755 if (FontHandle
!= NULL
) {
2756 LocalFontHandle
= *FontHandle
;
2759 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2762 // Already searched to the end of the whole list, return directly.
2764 if (LocalFontHandle
== &Private
->FontInfoList
) {
2765 LocalFontHandle
= NULL
;
2766 Status
= EFI_NOT_FOUND
;
2771 // Get default system display info, if StringInfoIn points to
2772 // system display info, return it directly.
2774 if (IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfoIn
, &SystemDefault
, &StringInfoOutLen
)) {
2776 // System font is the first node. When handle is not NULL, system font can not
2777 // be found any more.
2779 if (LocalFontHandle
== NULL
) {
2780 if (StringInfoOut
!= NULL
) {
2781 *StringInfoOut
= AllocateCopyPool (StringInfoOutLen
, SystemDefault
);
2782 if (*StringInfoOut
== NULL
) {
2783 Status
= EFI_OUT_OF_RESOURCES
;
2784 LocalFontHandle
= NULL
;
2789 LocalFontHandle
= Private
->FontInfoList
.ForwardLink
;
2790 Status
= EFI_SUCCESS
;
2793 LocalFontHandle
= NULL
;
2794 Status
= EFI_NOT_FOUND
;
2800 // StringInfoIn must not be NULL if it is not system default font info.
2802 ASSERT (StringInfoIn
!= NULL
);
2804 // Check the font information mask to make sure it is valid.
2806 if (((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ==
2807 (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ||
2808 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2809 (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2810 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2811 (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ||
2812 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2813 (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2814 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2815 (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
))) {
2816 return EFI_INVALID_PARAMETER
;
2820 // Parse the font information mask to find a matching font.
2823 CopyMem (&InfoOut
, (EFI_FONT_DISPLAY_INFO
*) StringInfoIn
, sizeof (EFI_FONT_DISPLAY_INFO
));
2825 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FONT
) == EFI_FONT_INFO_SYS_FONT
) {
2826 Status
= SaveFontName (SystemDefault
->FontInfo
.FontName
, &FontInfo
);
2828 Status
= SaveFontName (((EFI_FONT_DISPLAY_INFO
*) StringInfoIn
)->FontInfo
.FontName
, &FontInfo
);
2830 if (EFI_ERROR (Status
)) {
2834 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_SIZE
) == EFI_FONT_INFO_SYS_SIZE
) {
2835 InfoOut
.FontInfo
.FontSize
= SystemDefault
->FontInfo
.FontSize
;
2837 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_STYLE
) == EFI_FONT_INFO_SYS_STYLE
) {
2838 InfoOut
.FontInfo
.FontStyle
= SystemDefault
->FontInfo
.FontStyle
;
2840 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == EFI_FONT_INFO_SYS_FORE_COLOR
) {
2841 InfoOut
.ForegroundColor
= SystemDefault
->ForegroundColor
;
2843 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == EFI_FONT_INFO_SYS_BACK_COLOR
) {
2844 InfoOut
.BackgroundColor
= SystemDefault
->BackgroundColor
;
2847 ASSERT (FontInfo
!= NULL
);
2848 FontInfo
->FontSize
= InfoOut
.FontInfo
.FontSize
;
2849 FontInfo
->FontStyle
= InfoOut
.FontInfo
.FontStyle
;
2851 if (IsFontInfoExisted (Private
, FontInfo
, &InfoOut
.FontInfoMask
, LocalFontHandle
, &GlobalFont
)) {
2853 // Test to guarantee all characters are available in the found font.
2855 if (String
!= NULL
) {
2857 while (*StringIn
!= 0) {
2858 Status
= FindGlyphBlock (GlobalFont
->FontPackage
, *StringIn
, NULL
, NULL
, NULL
);
2859 if (EFI_ERROR (Status
)) {
2860 LocalFontHandle
= NULL
;
2867 // Write to output parameter
2869 if (StringInfoOut
!= NULL
) {
2870 StringInfoOutLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (EFI_FONT_INFO
) + GlobalFont
->FontInfoSize
;
2871 *StringInfoOut
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (StringInfoOutLen
);
2872 if (*StringInfoOut
== NULL
) {
2873 Status
= EFI_OUT_OF_RESOURCES
;
2874 LocalFontHandle
= NULL
;
2878 CopyMem (*StringInfoOut
, &InfoOut
, sizeof (EFI_FONT_DISPLAY_INFO
));
2879 CopyMem (&(*StringInfoOut
)->FontInfo
, GlobalFont
->FontInfo
, GlobalFont
->FontInfoSize
);
2882 LocalFontHandle
= GlobalFont
->Entry
.ForwardLink
;
2883 Status
= EFI_SUCCESS
;
2887 Status
= EFI_NOT_FOUND
;
2891 if (FontHandle
!= NULL
) {
2892 *FontHandle
= LocalFontHandle
;
2895 if (SystemDefault
!= NULL
) {
2896 FreePool (SystemDefault
);
2898 if (FontInfo
!= NULL
) {
2899 FreePool (FontInfo
);