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
10 #include "HiiDatabase.h"
12 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mHiiEfiColors
[16] = {
16 { 0x00, 0x00, 0x00, 0x00 }, // BLACK
17 { 0x98, 0x00, 0x00, 0x00 }, // BLUE
18 { 0x00, 0x98, 0x00, 0x00 }, // GREEN
19 { 0x98, 0x98, 0x00, 0x00 }, // CYAN
20 { 0x00, 0x00, 0x98, 0x00 }, // RED
21 { 0x98, 0x00, 0x98, 0x00 }, // MAGENTA
22 { 0x00, 0x98, 0x98, 0x00 }, // BROWN
23 { 0x98, 0x98, 0x98, 0x00 }, // LIGHTGRAY
24 { 0x30, 0x30, 0x30, 0x00 }, // DARKGRAY - BRIGHT BLACK
25 { 0xff, 0x00, 0x00, 0x00 }, // LIGHTBLUE
26 { 0x00, 0xff, 0x00, 0x00 }, // LIGHTGREEN
27 { 0xff, 0xff, 0x00, 0x00 }, // LIGHTCYAN
28 { 0x00, 0x00, 0xff, 0x00 }, // LIGHTRED
29 { 0xff, 0x00, 0xff, 0x00 }, // LIGHTMAGENTA
30 { 0x00, 0xff, 0xff, 0x00 }, // YELLOW
31 { 0xff, 0xff, 0xff, 0x00 }, // WHITE
35 Insert a character cell information to the list specified by GlyphInfoList.
37 This is a internal function.
39 @param CharValue Unicode character value, which identifies a glyph
41 @param GlyphInfoList HII_GLYPH_INFO list head.
42 @param Cell Incoming character cell information.
44 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
45 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
52 IN LIST_ENTRY
*GlyphInfoList
,
53 IN EFI_HII_GLYPH_INFO
*Cell
56 HII_GLYPH_INFO
*GlyphInfo
;
58 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
60 GlyphInfo
= (HII_GLYPH_INFO
*)AllocateZeroPool (sizeof (HII_GLYPH_INFO
));
61 if (GlyphInfo
== NULL
) {
62 return EFI_OUT_OF_RESOURCES
;
66 // GlyphInfoList stores a list of default character cell information, each is
67 // identified by "CharId".
69 GlyphInfo
->Signature
= HII_GLYPH_INFO_SIGNATURE
;
70 GlyphInfo
->CharId
= CharValue
;
71 if (Cell
->AdvanceX
== 0) {
72 Cell
->AdvanceX
= Cell
->Width
;
75 CopyMem (&GlyphInfo
->Cell
, Cell
, sizeof (EFI_HII_GLYPH_INFO
));
76 InsertTailList (GlyphInfoList
, &GlyphInfo
->Entry
);
82 Get a character cell information from the list specified by GlyphInfoList.
84 This is a internal function.
86 @param CharValue Unicode character value, which identifies a glyph
88 @param GlyphInfoList HII_GLYPH_INFO list head.
89 @param Cell Buffer which stores output character cell
92 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
93 @retval EFI_NOT_FOUND The character info specified by CharValue does
100 IN LIST_ENTRY
*GlyphInfoList
,
101 OUT EFI_HII_GLYPH_INFO
*Cell
104 HII_GLYPH_INFO
*GlyphInfo
;
107 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
110 // Since the EFI_HII_GIBT_DEFAULTS block won't increment CharValueCurrent,
111 // the value of "CharId" of a default character cell which is used for a
112 // EFI_HII_GIBT_GLYPH_DEFAULT or EFI_HII_GIBT_GLYPHS_DEFAULT should be
113 // less or equal to the value of "CharValueCurrent" of this default block.
115 // For instance, if the CharId of a GlyphInfoList is {1, 3, 7}, a default glyph
116 // with CharValue equals "7" uses the GlyphInfo with CharId = 7;
117 // a default glyph with CharValue equals "6" uses the GlyphInfo with CharId = 3.
119 for (Link
= GlyphInfoList
->BackLink
; Link
!= GlyphInfoList
; Link
= Link
->BackLink
) {
120 GlyphInfo
= CR (Link
, HII_GLYPH_INFO
, Entry
, HII_GLYPH_INFO_SIGNATURE
);
121 if (GlyphInfo
->CharId
<= CharValue
) {
122 CopyMem (Cell
, &GlyphInfo
->Cell
, sizeof (EFI_HII_GLYPH_INFO
));
127 return EFI_NOT_FOUND
;
131 Convert the glyph for a single character into a bitmap.
133 This is a internal function.
135 @param Private HII database driver private data.
136 @param Char Character to retrieve.
137 @param StringInfo Points to the string font and color information
138 or NULL if the string should use the default
139 system font and color.
140 @param GlyphBuffer Buffer to store the retrieved bitmap data.
141 @param Cell Points to EFI_HII_GLYPH_INFO structure.
142 @param Attributes If not NULL, output the glyph attributes if any.
144 @retval EFI_SUCCESS Glyph bitmap outputted.
145 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer GlyphBuffer.
146 @retval EFI_NOT_FOUND The glyph was unknown can not be found.
147 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
152 IN HII_DATABASE_PRIVATE_DATA
*Private
,
154 IN EFI_FONT_INFO
*StringInfo
,
155 OUT UINT8
**GlyphBuffer
,
156 OUT EFI_HII_GLYPH_INFO
*Cell
,
157 OUT UINT8
*Attributes OPTIONAL
160 HII_DATABASE_RECORD
*Node
;
162 HII_SIMPLE_FONT_PACKAGE_INSTANCE
*SimpleFont
;
165 EFI_NARROW_GLYPH Narrow
;
167 HII_GLOBAL_FONT_INFO
*GlobalFont
;
169 EFI_NARROW_GLYPH
*NarrowPtr
;
170 EFI_WIDE_GLYPH
*WidePtr
;
172 if ((GlyphBuffer
== NULL
) || (Cell
== NULL
)) {
173 return EFI_INVALID_PARAMETER
;
176 if ((Private
== NULL
) || (Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
)) {
177 return EFI_INVALID_PARAMETER
;
180 ZeroMem (Cell
, sizeof (EFI_HII_GLYPH_INFO
));
183 // If StringInfo is not NULL, it must point to an existing EFI_FONT_INFO rather
184 // than system default font and color.
185 // If NULL, try to find the character in simplified font packages since
186 // default system font is the fixed font (narrow or wide glyph).
188 if (StringInfo
!= NULL
) {
189 if (!IsFontInfoExisted (Private
, StringInfo
, NULL
, NULL
, &GlobalFont
)) {
190 return EFI_INVALID_PARAMETER
;
193 if (Attributes
!= NULL
) {
194 *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
208 SimpleFont
= CR (Link1
, HII_SIMPLE_FONT_PACKAGE_INSTANCE
, SimpleFontEntry
, HII_S_FONT_PACKAGE_SIGNATURE
);
210 // Search the narrow glyph array
212 NarrowPtr
= (EFI_NARROW_GLYPH
*)((UINT8
*)(SimpleFont
->SimpleFontPkgHdr
) + HeaderSize
);
213 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
; Index
++) {
214 CopyMem (&Narrow
, NarrowPtr
+ Index
, sizeof (EFI_NARROW_GLYPH
));
215 if (Narrow
.UnicodeWeight
== Char
) {
216 *GlyphBuffer
= (UINT8
*)AllocateZeroPool (EFI_GLYPH_HEIGHT
);
217 if (*GlyphBuffer
== NULL
) {
218 return EFI_OUT_OF_RESOURCES
;
221 Cell
->Width
= EFI_GLYPH_WIDTH
;
222 Cell
->Height
= EFI_GLYPH_HEIGHT
;
223 Cell
->AdvanceX
= Cell
->Width
;
224 CopyMem (*GlyphBuffer
, Narrow
.GlyphCol1
, Cell
->Height
);
225 if (Attributes
!= NULL
) {
226 *Attributes
= (UINT8
)(Narrow
.Attributes
| NARROW_GLYPH
);
234 // Search the wide glyph array
236 WidePtr
= (EFI_WIDE_GLYPH
*)(NarrowPtr
+ SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
);
237 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfWideGlyphs
; Index
++) {
238 CopyMem (&Wide
, WidePtr
+ Index
, sizeof (EFI_WIDE_GLYPH
));
239 if (Wide
.UnicodeWeight
== Char
) {
240 *GlyphBuffer
= (UINT8
*)AllocateZeroPool (EFI_GLYPH_HEIGHT
* 2);
241 if (*GlyphBuffer
== NULL
) {
242 return EFI_OUT_OF_RESOURCES
;
245 Cell
->Width
= EFI_GLYPH_WIDTH
* 2;
246 Cell
->Height
= EFI_GLYPH_HEIGHT
;
247 Cell
->AdvanceX
= Cell
->Width
;
248 CopyMem (*GlyphBuffer
, Wide
.GlyphCol1
, EFI_GLYPH_HEIGHT
);
249 CopyMem (*GlyphBuffer
+ EFI_GLYPH_HEIGHT
, Wide
.GlyphCol2
, EFI_GLYPH_HEIGHT
);
250 if (Attributes
!= NULL
) {
251 *Attributes
= (UINT8
)(Wide
.Attributes
| EFI_GLYPH_WIDE
);
261 return EFI_NOT_FOUND
;
265 Convert bitmap data of the glyph to blt structure.
267 This is a internal function.
269 @param GlyphBuffer Buffer points to bitmap data of glyph.
270 @param Foreground The color of the "on" pixels in the glyph in the
272 @param Background The color of the "off" pixels in the glyph in the
274 @param ImageWidth Width of the whole image in pixels.
275 @param RowWidth The width of the text on the line, in pixels.
276 @param RowHeight The height of the line, in pixels.
277 @param Transparent If TRUE, the Background color is ignored and all
278 "off" pixels in the character's drawn will use the
279 pixel value from BltBuffer.
280 @param Origin On input, points to the origin of the to be
281 displayed character, on output, points to the
287 IN UINT8
*GlyphBuffer
,
288 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
289 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
290 IN UINT16 ImageWidth
,
293 IN BOOLEAN Transparent
,
294 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
301 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Buffer
;
303 ASSERT (GlyphBuffer
!= NULL
&& Origin
!= NULL
&& *Origin
!= NULL
);
305 Height
= EFI_GLYPH_HEIGHT
;
306 Width
= EFI_GLYPH_WIDTH
;
309 // Move position to the left-top corner of char.
311 Buffer
= *Origin
- EFI_GLYPH_HEIGHT
* ImageWidth
;
314 // Char may be partially displayed when CLIP_X or CLIP_Y is not set.
316 if (RowHeight
< Height
) {
317 Height
= (UINT8
)RowHeight
;
320 if (RowWidth
< Width
) {
321 Width
= (UINT8
)RowWidth
;
324 for (Ypos
= 0; Ypos
< Height
; Ypos
++) {
325 for (Xpos
= 0; Xpos
< Width
; Xpos
++) {
326 if ((GlyphBuffer
[Ypos
] & (1 << (EFI_GLYPH_WIDTH
- Xpos
- 1))) != 0) {
327 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Foreground
;
330 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Background
;
336 *Origin
= *Origin
+ EFI_GLYPH_WIDTH
;
340 Convert bitmap data of the glyph to blt structure.
342 This is a internal function.
344 @param GlyphBuffer Buffer points to bitmap data of glyph.
345 @param Foreground The color of the "on" pixels in the glyph in the
347 @param Background The color of the "off" pixels in the glyph in the
349 @param ImageWidth Width of the whole image in pixels.
350 @param BaseLine BaseLine in the line.
351 @param RowWidth The width of the text on the line, in pixels.
352 @param RowHeight The height of the line, in pixels.
353 @param Transparent If TRUE, the Background color is ignored and all
354 "off" pixels in the character's drawn will use the
355 pixel value from BltBuffer.
356 @param Cell Points to EFI_HII_GLYPH_INFO structure.
357 @param Attributes The attribute of incoming glyph in GlyphBuffer.
358 @param Origin On input, points to the origin of the to be
359 displayed character, on output, points to the
366 IN UINT8
*GlyphBuffer
,
367 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
368 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
369 IN UINT16 ImageWidth
,
373 IN BOOLEAN Transparent
,
374 IN CONST EFI_HII_GLYPH_INFO
*Cell
,
376 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
385 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
387 ASSERT (Origin
!= NULL
&& *Origin
!= NULL
&& Cell
!= NULL
);
390 // Only adjust origin position if char has no bitmap.
392 if (GlyphBuffer
== NULL
) {
393 *Origin
= *Origin
+ Cell
->AdvanceX
;
398 // Move position to the left-top corner of char.
400 BltBuffer
= *Origin
+ Cell
->OffsetX
- (Cell
->OffsetY
+ Cell
->Height
) * ImageWidth
;
401 YposOffset
= (UINT16
)(BaseLine
- (Cell
->OffsetY
+ Cell
->Height
));
404 // Since non-spacing key will be printed OR'd with the previous glyph, don't
407 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
412 // The glyph's upper left hand corner pixel is the most significant bit of the
413 // first bitmap byte.
415 for (Ypos
= 0; Ypos
< Cell
->Height
&& (((UINT32
)Ypos
+ YposOffset
) < RowHeight
); Ypos
++) {
416 OffsetY
= BITMAP_LEN_1_BIT (Cell
->Width
, Ypos
);
419 // All bits in these bytes are meaningful.
421 for (Xpos
= 0; Xpos
< Cell
->Width
/ 8; Xpos
++) {
422 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
423 for (Index
= 0; Index
< 8 && (((UINT32
)Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
424 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
425 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
428 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
434 if (Cell
->Width
% 8 != 0) {
436 // There are some padding bits in this byte. Ignore them.
438 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
439 for (Index
= 0; Index
< Cell
->Width
% 8 && (((UINT32
)Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
440 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
441 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
444 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
448 } // end of if (Width % 8...)
449 } // end of for (Ypos=0...)
451 *Origin
= *Origin
+ Cell
->AdvanceX
;
455 Convert bitmap data of the glyph to blt structure.
457 This is a internal function.
459 @param GlyphBuffer Buffer points to bitmap data of glyph.
460 @param Foreground The color of the "on" pixels in the glyph in the
462 @param Background The color of the "off" pixels in the glyph in the
464 @param ImageWidth Width of the whole image in pixels.
465 @param BaseLine BaseLine in the line.
466 @param RowWidth The width of the text on the line, in pixels.
467 @param RowHeight The height of the line, in pixels.
468 @param Transparent If TRUE, the Background color is ignored and all
469 "off" pixels in the character's drawn will use the
470 pixel value from BltBuffer.
471 @param Cell Points to EFI_HII_GLYPH_INFO structure.
472 @param Attributes The attribute of incoming glyph in GlyphBuffer.
473 @param Origin On input, points to the origin of the to be
474 displayed character, on output, points to the
477 @return Points to the address of next origin node in BltBuffer.
482 IN UINT8
*GlyphBuffer
,
483 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
484 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
485 IN UINT16 ImageWidth
,
489 IN BOOLEAN Transparent
,
490 IN CONST EFI_HII_GLYPH_INFO
*Cell
,
492 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
495 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Buffer
;
497 ASSERT (Origin
!= NULL
&& *Origin
!= NULL
&& Cell
!= NULL
);
501 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
503 // This character is a non-spacing key, print it OR'd with the previous glyph.
504 // without advancing cursor.
506 Buffer
-= Cell
->AdvanceX
;
520 } else if ((Attributes
& EFI_GLYPH_WIDE
) == EFI_GLYPH_WIDE
) {
522 // This character is wide glyph, i.e. 16 pixels * 19 pixels.
523 // Draw it as two narrow glyphs.
537 GlyphBuffer
+ EFI_GLYPH_HEIGHT
,
546 } else if ((Attributes
& NARROW_GLYPH
) == NARROW_GLYPH
) {
548 // This character is narrow glyph, i.e. 8 pixels * 19 pixels.
560 } else if ((Attributes
& PROPORTIONAL_GLYPH
) == PROPORTIONAL_GLYPH
) {
562 // This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.
581 Write the output parameters of FindGlyphBlock().
583 This is a internal function.
585 @param BufferIn Buffer which stores the bitmap data of the found
587 @param BufferLen Length of BufferIn.
588 @param InputCell Buffer which stores cell information of the
590 @param GlyphBuffer Output the corresponding bitmap data of the found
591 block. It is the caller's responsibility to free
593 @param Cell Output cell information of the encoded bitmap.
594 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
596 @retval EFI_SUCCESS The operation is performed successfully.
597 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
598 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
606 IN EFI_HII_GLYPH_INFO
*InputCell
,
607 OUT UINT8
**GlyphBuffer OPTIONAL
,
608 OUT EFI_HII_GLYPH_INFO
*Cell OPTIONAL
,
609 OUT UINTN
*GlyphBufferLen OPTIONAL
612 if ((BufferIn
== NULL
) || (InputCell
== NULL
)) {
613 return EFI_INVALID_PARAMETER
;
617 CopyMem (Cell
, InputCell
, sizeof (EFI_HII_GLYPH_INFO
));
620 if ((GlyphBuffer
!= NULL
) && (BufferLen
> 0)) {
621 *GlyphBuffer
= (UINT8
*)AllocateZeroPool (BufferLen
);
622 if (*GlyphBuffer
== NULL
) {
623 return EFI_OUT_OF_RESOURCES
;
626 CopyMem (*GlyphBuffer
, BufferIn
, BufferLen
);
629 if (GlyphBufferLen
!= NULL
) {
630 *GlyphBufferLen
= BufferLen
;
637 Parse all glyph blocks to find a glyph block specified by CharValue.
638 If CharValue = (CHAR16) (-1), collect all default character cell information
639 within this font package and backup its information.
641 @param FontPackage Hii string package instance.
642 @param CharValue Unicode character value, which identifies a glyph
644 @param GlyphBuffer Output the corresponding bitmap data of the found
645 block. It is the caller's responsibility to free
647 @param Cell Output cell information of the encoded bitmap.
648 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
650 @retval EFI_SUCCESS The bitmap data is retrieved successfully.
651 @retval EFI_NOT_FOUND The specified CharValue does not exist in current
653 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
659 IN HII_FONT_PACKAGE_INSTANCE
*FontPackage
,
661 OUT UINT8
**GlyphBuffer OPTIONAL
,
662 OUT EFI_HII_GLYPH_INFO
*Cell OPTIONAL
,
663 OUT UINTN
*GlyphBufferLen OPTIONAL
671 EFI_HII_GIBT_GLYPHS_BLOCK Glyphs
;
674 EFI_HII_GLYPH_INFO DefaultCell
;
675 EFI_HII_GLYPH_INFO LocalCell
;
679 ASSERT (FontPackage
!= NULL
);
680 ASSERT (FontPackage
->Signature
== HII_FONT_PACKAGE_SIGNATURE
);
684 if (CharValue
== (CHAR16
)(-1)) {
686 // Collect the cell information specified in font package fixed header.
687 // Use CharValue =0 to represent this particular cell.
691 &FontPackage
->GlyphInfoList
,
692 (EFI_HII_GLYPH_INFO
*)((UINT8
*)FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
))
694 if (EFI_ERROR (Status
)) {
700 (UINT8
*)FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
),
701 sizeof (EFI_HII_GLYPH_INFO
)
705 BlockPtr
= FontPackage
->GlyphBlock
;
709 while (*BlockPtr
!= EFI_HII_GIBT_END
) {
711 case EFI_HII_GIBT_DEFAULTS
:
713 // Collect all default character cell information specified by
714 // EFI_HII_GIBT_DEFAULTS.
716 if (CharValue
== (CHAR16
)(-1)) {
719 &FontPackage
->GlyphInfoList
,
720 (EFI_HII_GLYPH_INFO
*)(BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))
722 if (EFI_ERROR (Status
)) {
728 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
729 sizeof (EFI_HII_GLYPH_INFO
)
731 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
732 BaseLine
= (UINT16
)(LocalCell
.Height
+ LocalCell
.OffsetY
);
735 if (MinOffsetY
> LocalCell
.OffsetY
) {
736 MinOffsetY
= LocalCell
.OffsetY
;
740 BlockPtr
+= sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK
);
743 case EFI_HII_GIBT_DUPLICATE
:
744 if (CharCurrent
== CharValue
) {
745 CopyMem (&CharValue
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (CHAR16
));
747 BlockPtr
= FontPackage
->GlyphBlock
;
752 BlockPtr
+= sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK
);
755 case EFI_HII_GIBT_EXT1
:
756 BlockPtr
+= *(UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
));
758 case EFI_HII_GIBT_EXT2
:
761 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
764 BlockPtr
+= Length16
;
766 case EFI_HII_GIBT_EXT4
:
769 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
772 BlockPtr
+= Length32
;
775 case EFI_HII_GIBT_GLYPH
:
778 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
779 sizeof (EFI_HII_GLYPH_INFO
)
781 if (CharValue
== (CHAR16
)(-1)) {
782 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
783 BaseLine
= (UINT16
)(LocalCell
.Height
+ LocalCell
.OffsetY
);
786 if (MinOffsetY
> LocalCell
.OffsetY
) {
787 MinOffsetY
= LocalCell
.OffsetY
;
791 BufferLen
= BITMAP_LEN_1_BIT (LocalCell
.Width
, LocalCell
.Height
);
792 if (CharCurrent
== CharValue
) {
793 return WriteOutputParam (
794 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
)),
804 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
) + BufferLen
;
807 case EFI_HII_GIBT_GLYPHS
:
808 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
);
809 CopyMem (&Glyphs
.Cell
, BlockPtr
, sizeof (EFI_HII_GLYPH_INFO
));
810 BlockPtr
+= sizeof (EFI_HII_GLYPH_INFO
);
811 CopyMem (&Glyphs
.Count
, BlockPtr
, sizeof (UINT16
));
812 BlockPtr
+= sizeof (UINT16
);
814 if (CharValue
== (CHAR16
)(-1)) {
815 if (BaseLine
< Glyphs
.Cell
.Height
+ Glyphs
.Cell
.OffsetY
) {
816 BaseLine
= (UINT16
)(Glyphs
.Cell
.Height
+ Glyphs
.Cell
.OffsetY
);
819 if (MinOffsetY
> Glyphs
.Cell
.OffsetY
) {
820 MinOffsetY
= Glyphs
.Cell
.OffsetY
;
824 BufferLen
= BITMAP_LEN_1_BIT (Glyphs
.Cell
.Width
, Glyphs
.Cell
.Height
);
825 for (Index
= 0; Index
< Glyphs
.Count
; Index
++) {
826 if (CharCurrent
+ Index
== CharValue
) {
827 return WriteOutputParam (
837 BlockPtr
+= BufferLen
;
840 CharCurrent
= (UINT16
)(CharCurrent
+ Glyphs
.Count
);
843 case EFI_HII_GIBT_GLYPH_DEFAULT
:
844 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
845 if (EFI_ERROR (Status
)) {
849 if (CharValue
== (CHAR16
)(-1)) {
850 if (BaseLine
< DefaultCell
.Height
+ DefaultCell
.OffsetY
) {
851 BaseLine
= (UINT16
)(DefaultCell
.Height
+ DefaultCell
.OffsetY
);
854 if (MinOffsetY
> DefaultCell
.OffsetY
) {
855 MinOffsetY
= DefaultCell
.OffsetY
;
859 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
861 if (CharCurrent
== CharValue
) {
862 return WriteOutputParam (
863 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
873 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
) + BufferLen
;
876 case EFI_HII_GIBT_GLYPHS_DEFAULT
:
877 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
878 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
879 if (EFI_ERROR (Status
)) {
883 if (CharValue
== (CHAR16
)(-1)) {
884 if (BaseLine
< DefaultCell
.Height
+ DefaultCell
.OffsetY
) {
885 BaseLine
= (UINT16
)(DefaultCell
.Height
+ DefaultCell
.OffsetY
);
888 if (MinOffsetY
> DefaultCell
.OffsetY
) {
889 MinOffsetY
= DefaultCell
.OffsetY
;
893 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
894 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK
) - sizeof (UINT8
);
895 for (Index
= 0; Index
< Length16
; Index
++) {
896 if (CharCurrent
+ Index
== CharValue
) {
897 return WriteOutputParam (
907 BlockPtr
+= BufferLen
;
910 CharCurrent
= (UINT16
)(CharCurrent
+ Length16
);
913 case EFI_HII_GIBT_SKIP1
:
914 CharCurrent
= (UINT16
)(CharCurrent
+ (UINT16
)(*(BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))));
915 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP1_BLOCK
);
917 case EFI_HII_GIBT_SKIP2
:
918 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
919 CharCurrent
= (UINT16
)(CharCurrent
+ Length16
);
920 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP2_BLOCK
);
927 if (CharValue
< CharCurrent
) {
928 return EFI_NOT_FOUND
;
932 if (CharValue
== (CHAR16
)(-1)) {
933 FontPackage
->BaseLine
= BaseLine
;
934 FontPackage
->Height
= (UINT16
)(BaseLine
- MinOffsetY
);
938 return EFI_NOT_FOUND
;
942 Copy a Font Name to a new created EFI_FONT_INFO structure.
944 This is a internal function.
946 @param FontName NULL-terminated string.
947 @param FontInfo a new EFI_FONT_INFO which stores the FontName.
948 It's caller's responsibility to free this buffer.
950 @retval EFI_SUCCESS FontInfo is allocated and copied with FontName.
951 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
957 IN EFI_STRING FontName
,
958 OUT EFI_FONT_INFO
**FontInfo
964 ASSERT (FontName
!= NULL
&& FontInfo
!= NULL
);
966 NameSize
= StrSize (FontName
);
967 FontInfoLen
= sizeof (EFI_FONT_INFO
) - sizeof (CHAR16
) + NameSize
;
968 *FontInfo
= (EFI_FONT_INFO
*)AllocateZeroPool (FontInfoLen
);
969 if (*FontInfo
== NULL
) {
970 return EFI_OUT_OF_RESOURCES
;
973 StrCpyS ((*FontInfo
)->FontName
, NameSize
/ sizeof (CHAR16
), FontName
);
978 Retrieve system default font and color.
980 @param Private HII database driver private data.
981 @param FontInfo Points to system default font output-related
982 information. It's caller's responsibility to free
984 @param FontInfoSize If not NULL, output the size of buffer FontInfo.
986 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
987 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
989 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
994 IN HII_DATABASE_PRIVATE_DATA
*Private
,
995 OUT EFI_FONT_DISPLAY_INFO
**FontInfo
,
996 OUT UINTN
*FontInfoSize OPTIONAL
999 EFI_FONT_DISPLAY_INFO
*Info
;
1003 if ((Private
== NULL
) || (Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
)) {
1004 return EFI_INVALID_PARAMETER
;
1007 if (FontInfo
== NULL
) {
1008 return EFI_INVALID_PARAMETER
;
1012 // The standard font always has the name "sysdefault".
1014 NameSize
= StrSize (L
"sysdefault");
1015 InfoSize
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + NameSize
;
1016 Info
= (EFI_FONT_DISPLAY_INFO
*)AllocateZeroPool (InfoSize
);
1018 return EFI_OUT_OF_RESOURCES
;
1021 Info
->ForegroundColor
= mHiiEfiColors
[Private
->Attribute
& 0x0f];
1022 ASSERT ((Private
->Attribute
>> 4) < 8);
1023 Info
->BackgroundColor
= mHiiEfiColors
[Private
->Attribute
>> 4];
1024 Info
->FontInfoMask
= EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_SYS_STYLE
;
1025 Info
->FontInfo
.FontStyle
= 0;
1026 Info
->FontInfo
.FontSize
= EFI_GLYPH_HEIGHT
;
1027 StrCpyS (Info
->FontInfo
.FontName
, NameSize
/ sizeof (CHAR16
), L
"sysdefault");
1030 if (FontInfoSize
!= NULL
) {
1031 *FontInfoSize
= InfoSize
;
1038 Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
1039 returns the system default according to the optional inputs.
1041 This is a internal function.
1043 @param Private HII database driver private data.
1044 @param StringInfo Points to the string output information,
1045 including the color and font.
1046 @param SystemInfo If not NULL, points to system default font and color.
1048 @param SystemInfoLen If not NULL, output the length of default system
1051 @retval TRUE Yes, it points to system default.
1057 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1058 IN EFI_FONT_DISPLAY_INFO
*StringInfo
,
1059 OUT EFI_FONT_DISPLAY_INFO
**SystemInfo OPTIONAL
,
1060 OUT UINTN
*SystemInfoLen OPTIONAL
1064 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1068 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1070 if ((StringInfo
== NULL
) && (SystemInfo
== NULL
)) {
1074 SystemDefault
= NULL
;
1077 Status
= GetSystemFont (Private
, &SystemDefault
, &DefaultLen
);
1078 ASSERT_EFI_ERROR (Status
);
1079 ASSERT ((SystemDefault
!= NULL
) && (DefaultLen
!= 0));
1082 // Record the system default info.
1084 if (SystemInfo
!= NULL
) {
1085 *SystemInfo
= SystemDefault
;
1088 if (SystemInfoLen
!= NULL
) {
1089 *SystemInfoLen
= DefaultLen
;
1092 if (StringInfo
== NULL
) {
1098 // Check the FontInfoMask to see whether it is retrieving system info.
1100 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) == 0) {
1101 if (StrCmp (StringInfo
->FontInfo
.FontName
, SystemDefault
->FontInfo
.FontName
) != 0) {
1106 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) == 0) {
1107 if (StringInfo
->FontInfo
.FontSize
!= SystemDefault
->FontInfo
.FontSize
) {
1112 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) == 0) {
1113 if (StringInfo
->FontInfo
.FontStyle
!= SystemDefault
->FontInfo
.FontStyle
) {
1118 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == 0) {
1120 &StringInfo
->ForegroundColor
,
1121 &SystemDefault
->ForegroundColor
,
1122 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1129 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == 0) {
1131 &StringInfo
->BackgroundColor
,
1132 &SystemDefault
->BackgroundColor
,
1133 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1143 if (SystemInfo
== NULL
) {
1144 if (SystemDefault
!= NULL
) {
1145 FreePool (SystemDefault
);
1153 This function checks whether EFI_FONT_INFO exists in current database. If
1154 FontInfoMask is specified, check what options can be used to make a match.
1155 Note that the masks relate to where the system default should be supplied
1156 are ignored by this function.
1158 @param Private Hii database private structure.
1159 @param FontInfo Points to EFI_FONT_INFO structure.
1160 @param FontInfoMask If not NULL, describes what options can be used
1161 to make a match between the font requested and
1162 the font available. The caller must guarantee
1164 @param FontHandle On entry, Points to the font handle returned by a
1165 previous call to GetFontInfo() or NULL to start
1166 with the first font.
1167 @param GlobalFontInfo If not NULL, output the corresponding global font
1170 @retval TRUE Existed
1171 @retval FALSE Not existed
1176 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1177 IN EFI_FONT_INFO
*FontInfo
,
1178 IN EFI_FONT_INFO_MASK
*FontInfoMask OPTIONAL
,
1179 IN EFI_FONT_HANDLE FontHandle OPTIONAL
,
1180 OUT HII_GLOBAL_FONT_INFO
**GlobalFontInfo OPTIONAL
1183 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1184 HII_GLOBAL_FONT_INFO
*GlobalFontBackup1
;
1185 HII_GLOBAL_FONT_INFO
*GlobalFontBackup2
;
1187 EFI_FONT_INFO_MASK Mask
;
1189 BOOLEAN VagueMatched1
;
1190 BOOLEAN VagueMatched2
;
1192 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1193 ASSERT (FontInfo
!= NULL
);
1196 // Matched flag represents an exactly match; VagueMatched1 represents a RESIZE
1197 // or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.
1200 VagueMatched1
= FALSE
;
1201 VagueMatched2
= FALSE
;
1204 GlobalFontBackup1
= NULL
;
1205 GlobalFontBackup2
= NULL
;
1207 // The process of where the system default should be supplied instead of
1208 // the specified font info beyonds this function's scope.
1210 if (FontInfoMask
!= NULL
) {
1211 Mask
= *FontInfoMask
& (~SYS_FONT_INFO_MASK
);
1215 // If not NULL, FontHandle points to the next node of the last searched font
1216 // node by previous call.
1218 if (FontHandle
== NULL
) {
1219 Link
= Private
->FontInfoList
.ForwardLink
;
1221 Link
= (LIST_ENTRY
*)FontHandle
;
1224 for ( ; Link
!= &Private
->FontInfoList
; Link
= Link
->ForwardLink
) {
1225 GlobalFont
= CR (Link
, HII_GLOBAL_FONT_INFO
, Entry
, HII_GLOBAL_FONT_INFO_SIGNATURE
);
1226 if (FontInfoMask
== NULL
) {
1227 if (CompareMem (GlobalFont
->FontInfo
, FontInfo
, GlobalFont
->FontInfoSize
) == 0) {
1228 if (GlobalFontInfo
!= NULL
) {
1229 *GlobalFontInfo
= GlobalFont
;
1236 // Check which options could be used to make a match.
1239 case EFI_FONT_INFO_ANY_FONT
:
1240 if ((GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) &&
1241 (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
))
1247 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
:
1248 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1253 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
:
1254 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1259 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_ANY_STYLE
:
1263 // If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to
1264 // remove some of the specified styles to meet the style requested.
1266 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
:
1267 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1268 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1270 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1271 VagueMatched1
= TRUE
;
1272 GlobalFontBackup1
= GlobalFont
;
1278 // If EFI_FONT_INFO_RESIZE is specified, then the system may attempt to
1279 // stretch or shrink a font to meet the size requested.
1281 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESIZE
:
1282 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1283 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1286 VagueMatched1
= TRUE
;
1287 GlobalFontBackup1
= GlobalFont
;
1292 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_RESIZE
:
1293 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1294 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1297 VagueMatched1
= TRUE
;
1298 GlobalFontBackup1
= GlobalFont
;
1300 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1301 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1302 VagueMatched1
= TRUE
;
1303 GlobalFontBackup1
= GlobalFont
;
1305 VagueMatched2
= TRUE
;
1306 GlobalFontBackup2
= GlobalFont
;
1311 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1312 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1315 VagueMatched1
= TRUE
;
1316 GlobalFontBackup1
= GlobalFont
;
1320 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1321 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1323 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1324 VagueMatched1
= TRUE
;
1325 GlobalFontBackup1
= GlobalFont
;
1329 case EFI_FONT_INFO_ANY_STYLE
:
1331 GlobalFont
->FontInfo
->FontName
,
1333 StrSize (FontInfo
->FontName
)
1335 (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
))
1341 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_ANY_SIZE
:
1343 GlobalFont
->FontInfo
->FontName
,
1345 StrSize (FontInfo
->FontName
)
1352 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1354 GlobalFont
->FontInfo
->FontName
,
1356 StrSize (FontInfo
->FontName
)
1359 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1362 VagueMatched1
= TRUE
;
1363 GlobalFontBackup1
= GlobalFont
;
1368 case EFI_FONT_INFO_ANY_SIZE
:
1370 GlobalFont
->FontInfo
->FontName
,
1372 StrSize (FontInfo
->FontName
)
1374 (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
))
1380 case EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1382 GlobalFont
->FontInfo
->FontName
,
1384 StrSize (FontInfo
->FontName
)
1387 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1389 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1390 VagueMatched1
= TRUE
;
1391 GlobalFontBackup1
= GlobalFont
;
1396 case EFI_FONT_INFO_RESTYLE
:
1398 GlobalFont
->FontInfo
->FontName
,
1400 StrSize (FontInfo
->FontName
)
1402 (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
))
1404 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1406 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1407 VagueMatched1
= TRUE
;
1408 GlobalFontBackup1
= GlobalFont
;
1413 case EFI_FONT_INFO_RESIZE
:
1415 GlobalFont
->FontInfo
->FontName
,
1417 StrSize (FontInfo
->FontName
)
1419 (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
))
1421 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1424 VagueMatched1
= TRUE
;
1425 GlobalFontBackup1
= GlobalFont
;
1430 case EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_RESTYLE
:
1432 GlobalFont
->FontInfo
->FontName
,
1434 StrSize (FontInfo
->FontName
)
1437 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1438 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1441 VagueMatched1
= TRUE
;
1442 GlobalFontBackup1
= GlobalFont
;
1444 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1445 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1446 VagueMatched1
= TRUE
;
1447 GlobalFontBackup1
= GlobalFont
;
1449 VagueMatched2
= TRUE
;
1450 GlobalFontBackup2
= GlobalFont
;
1461 if (GlobalFontInfo
!= NULL
) {
1462 *GlobalFontInfo
= GlobalFont
;
1470 if (VagueMatched1
) {
1471 if (GlobalFontInfo
!= NULL
) {
1472 *GlobalFontInfo
= GlobalFontBackup1
;
1476 } else if (VagueMatched2
) {
1477 if (GlobalFontInfo
!= NULL
) {
1478 *GlobalFontInfo
= GlobalFontBackup2
;
1488 Check whether the unicode represents a line break or not.
1490 This is a internal function. Please see Section 27.2.6 of the UEFI Specification
1491 for a description of the supported string format.
1493 @param Char Unicode character
1495 @retval 0 Yes, it forces a line break.
1496 @retval 1 Yes, it presents a line break opportunity
1497 @retval 2 Yes, it requires a line break happen before and after it.
1498 @retval -1 No, it is not a link break.
1508 // Mandatory line break characters, which force a line-break
1517 // Space characters, which is taken as a line-break opportunity
1533 // In-Word Break Opportunities
1538 // A space which is not a line-break opportunity
1543 // A hyphen which is not a line-break opportunity
1548 // Hyphen characters which describe line break opportunities after the character
1559 // A hyphen which describes line break opportunities before and after them, but not between a pair of them
1569 Renders a string to a bitmap or to the display.
1571 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
1572 @param Flags Describes how the string is to be drawn.
1573 @param String Points to the null-terminated string to be
1575 @param StringInfo Points to the string output information,
1576 including the color and font. If NULL, then the
1577 string will be output in the default system font
1579 @param Blt If this points to a non-NULL on entry, this
1580 points to the image, which is Width pixels wide
1581 and Height pixels high. The string will be drawn
1583 EFI_HII_OUT_FLAG_CLIP is implied. If this points
1584 to a NULL on entry, then a buffer
1585 will be allocated to hold the generated image and
1586 the pointer updated on exit. It is the caller's
1587 responsibility to free this buffer.
1588 @param BltX Specifies the offset from the left and top edge
1589 of the image of the first character cell in the
1591 @param BltY Specifies the offset from the left and top edge
1592 of the image of the first character cell in the
1594 @param RowInfoArray If this is non-NULL on entry, then on exit, this
1595 will point to an allocated buffer containing
1596 row information and RowInfoArraySize will be
1597 updated to contain the number of elements.
1598 This array describes the characters which were at
1599 least partially drawn and the heights of the
1600 rows. It is the caller's responsibility to free
1602 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
1603 contains the number of elements in RowInfoArray.
1604 @param ColumnInfoArray If this is non-NULL, then on return it will be
1605 filled with the horizontal offset for each
1606 character in the string on the row where it is
1607 displayed. Non-printing characters will have
1608 the offset ~0. The caller is responsible to
1609 allocate a buffer large enough so that there
1610 is one entry for each character in the string,
1611 not including the null-terminator. It is possible
1612 when character display is normalized that some
1613 character cells overlap.
1615 @retval EFI_SUCCESS The string was successfully rendered.
1616 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
1617 RowInfoArray or Blt.
1618 @retval EFI_INVALID_PARAMETER The String or Blt was NULL.
1619 @retval EFI_INVALID_PARAMETER Flags were invalid combination..
1625 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
1626 IN EFI_HII_OUT_FLAGS Flags
,
1627 IN CONST EFI_STRING String
,
1628 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
1629 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
1632 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
1633 OUT UINTN
*RowInfoArraySize OPTIONAL
,
1634 OUT UINTN
*ColumnInfoArray OPTIONAL
1638 HII_DATABASE_PRIVATE_DATA
*Private
;
1640 EFI_HII_GLYPH_INFO
*Cell
;
1642 EFI_IMAGE_OUTPUT
*Image
;
1643 EFI_STRING StringPtr
;
1644 EFI_STRING StringTmp
;
1645 EFI_HII_ROW_INFO
*RowInfo
;
1649 UINTN LastLineHeight
;
1650 UINTN BaseLineOffset
;
1656 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
1657 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1658 EFI_FONT_HANDLE FontHandle
;
1659 EFI_STRING StringIn
;
1660 EFI_STRING StringIn2
;
1663 EFI_FONT_INFO
*FontInfo
;
1664 BOOLEAN SysFontFlag
;
1665 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1666 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1667 BOOLEAN Transparent
;
1668 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
1669 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BufferPtr
;
1673 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*RowBufferPtr
;
1674 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1675 UINT32 PreInitBkgnd
;
1678 // Check incoming parameters.
1681 if ((This
== NULL
) || (String
== NULL
) || (Blt
== NULL
)) {
1682 return EFI_INVALID_PARAMETER
;
1687 // These two flag cannot be used if Blt is NULL upon entry.
1689 if ((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
) {
1690 return EFI_INVALID_PARAMETER
;
1693 if ((Flags
& EFI_HII_OUT_FLAG_CLIP
) == EFI_HII_OUT_FLAG_CLIP
) {
1694 return EFI_INVALID_PARAMETER
;
1699 // These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
1701 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_X
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) {
1702 return EFI_INVALID_PARAMETER
;
1705 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) {
1706 return EFI_INVALID_PARAMETER
;
1710 // This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
1712 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
)) {
1713 return EFI_INVALID_PARAMETER
;
1718 // Create a new bitmap and draw the string onto this image.
1720 Image
= AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1721 if (Image
== NULL
) {
1722 return EFI_OUT_OF_RESOURCES
;
1726 Image
->Height
= 600;
1727 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
*sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1728 if (Image
->Image
.Bitmap
== NULL
) {
1730 return EFI_OUT_OF_RESOURCES
;
1734 // Other flags are not permitted when Blt is NULL.
1736 Flags
&= EFI_HII_OUT_FLAG_WRAP
| EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_IGNORE_LINE_BREAK
;
1740 StrLength
= StrLen (String
);
1741 GlyphBuf
= (UINT8
**)AllocateZeroPool (StrLength
* sizeof (UINT8
*));
1742 ASSERT (GlyphBuf
!= NULL
);
1743 Cell
= (EFI_HII_GLYPH_INFO
*)AllocateZeroPool (StrLength
* sizeof (EFI_HII_GLYPH_INFO
));
1744 ASSERT (Cell
!= NULL
);
1745 Attributes
= (UINT8
*)AllocateZeroPool (StrLength
* sizeof (UINT8
));
1746 ASSERT (Attributes
!= NULL
);
1749 Status
= EFI_SUCCESS
;
1751 SystemDefault
= NULL
;
1755 // Calculate the string output information, including specified color and font .
1756 // If StringInfo does not points to system font info, it must indicate an existing
1759 StringInfoOut
= NULL
;
1761 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
1762 SysFontFlag
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*)StringInfo
, &SystemDefault
, NULL
);
1765 ASSERT (SystemDefault
!= NULL
);
1767 Height
= SystemDefault
->FontInfo
.FontSize
;
1768 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1769 Foreground
= SystemDefault
->ForegroundColor
;
1770 Background
= SystemDefault
->BackgroundColor
;
1773 // StringInfo must not be NULL if it is not system info.
1775 ASSERT (StringInfo
!= NULL
);
1776 Status
= HiiGetFontInfo (This
, &FontHandle
, (EFI_FONT_DISPLAY_INFO
*)StringInfo
, &StringInfoOut
, NULL
);
1777 if (Status
== EFI_NOT_FOUND
) {
1779 // The specified EFI_FONT_DISPLAY_INFO does not exist in current database.
1780 // Use the system font instead. Still use the color specified by StringInfo.
1784 Height
= SystemDefault
->FontInfo
.FontSize
;
1785 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1786 Foreground
= ((EFI_FONT_DISPLAY_INFO
*)StringInfo
)->ForegroundColor
;
1787 Background
= ((EFI_FONT_DISPLAY_INFO
*)StringInfo
)->BackgroundColor
;
1788 } else if (Status
== EFI_SUCCESS
) {
1789 FontInfo
= &StringInfoOut
->FontInfo
;
1790 IsFontInfoExisted (Private
, FontInfo
, NULL
, NULL
, &GlobalFont
);
1791 Height
= GlobalFont
->FontPackage
->Height
;
1792 BaseLine
= GlobalFont
->FontPackage
->BaseLine
;
1793 Foreground
= StringInfoOut
->ForegroundColor
;
1794 Background
= StringInfoOut
->BackgroundColor
;
1801 // Use the maximum height of font as the base line.
1802 // And, use the maximum height as line height.
1804 LineHeight
= Height
;
1805 LastLineHeight
= Height
;
1806 BaseLineOffset
= Height
- BaseLine
;
1809 // Parse the string to be displayed to drop some ignored characters.
1815 // Ignore line-break characters only. Hyphens or dash character will be displayed
1816 // without line-break opportunity.
1818 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == EFI_HII_IGNORE_LINE_BREAK
) {
1819 StringIn
= AllocateZeroPool (StrSize (StringPtr
));
1820 if (StringIn
== NULL
) {
1821 Status
= EFI_OUT_OF_RESOURCES
;
1825 StringTmp
= StringIn
;
1826 while (*StringPtr
!= 0) {
1827 if (IsLineBreak (*StringPtr
) == 0) {
1830 *StringTmp
++ = *StringPtr
++;
1835 StringPtr
= StringIn
;
1839 // If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs
1840 // are not drawn. Otherwise they are replaced with Unicode character 0xFFFD.
1842 StringIn2
= AllocateZeroPool (StrSize (StringPtr
));
1843 if (StringIn2
== NULL
) {
1844 Status
= EFI_OUT_OF_RESOURCES
;
1849 StringTmp
= StringIn2
;
1850 StrLength
= StrLen (StringPtr
);
1851 while (*StringPtr
!= 0 && Index
< StrLength
) {
1852 if (IsLineBreak (*StringPtr
) == 0) {
1853 *StringTmp
++ = *StringPtr
++;
1858 Status
= GetGlyphBuffer (Private
, *StringPtr
, FontInfo
, &GlyphBuf
[Index
], &Cell
[Index
], &Attributes
[Index
]);
1859 if (Status
== EFI_NOT_FOUND
) {
1860 if ((Flags
& EFI_HII_IGNORE_IF_NO_GLYPH
) == EFI_HII_IGNORE_IF_NO_GLYPH
) {
1861 GlyphBuf
[Index
] = NULL
;
1862 ZeroMem (&Cell
[Index
], sizeof (Cell
[Index
]));
1863 Status
= EFI_SUCCESS
;
1866 // Unicode 0xFFFD must exist in current hii database if this flag is not set.
1868 Status
= GetGlyphBuffer (
1870 REPLACE_UNKNOWN_GLYPH
,
1876 if (EFI_ERROR (Status
)) {
1877 Status
= EFI_INVALID_PARAMETER
;
1882 if (EFI_ERROR (Status
)) {
1886 *StringTmp
++ = *StringPtr
++;
1891 StringPtr
= StringIn2
;
1894 // Draw the string according to the specified EFI_HII_OUT_FLAGS and Blt.
1895 // If Blt is not NULL, then EFI_HII_OUT_FLAG_CLIP is implied, render this string
1896 // to an existing image (bitmap or screen depending on flags) pointed by "*Blt".
1897 // Otherwise render this string to a new allocated image and output it.
1900 BufferPtr
= Image
->Image
.Bitmap
+ Image
->Width
* BltY
+ BltX
;
1901 if (Image
->Height
< BltY
) {
1903 // the top edge of the image should be in Image resolution scope.
1905 Status
= EFI_INVALID_PARAMETER
;
1909 MaxRowNum
= (UINT16
)((Image
->Height
- BltY
) / Height
);
1910 if ((Image
->Height
- BltY
) % Height
!= 0) {
1911 LastLineHeight
= (Image
->Height
- BltY
) % Height
;
1915 RowInfo
= (EFI_HII_ROW_INFO
*)AllocateZeroPool (MaxRowNum
* sizeof (EFI_HII_ROW_INFO
));
1916 if (RowInfo
== NULL
) {
1917 Status
= EFI_OUT_OF_RESOURCES
;
1922 // Format the glyph buffer according to flags.
1924 Transparent
= (BOOLEAN
)((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
? TRUE
: FALSE
);
1926 for (RowIndex
= 0, Index
= 0; RowIndex
< MaxRowNum
&& StringPtr
[Index
] != 0; ) {
1931 // Clip the final row if the row's bottom-most on pixel cannot fit when
1932 // EFI_HII_OUT_FLAG_CLEAN_Y is set.
1934 if (RowIndex
== MaxRowNum
- 1) {
1935 if (((Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) && (LastLineHeight
< LineHeight
)) {
1937 // Don't draw at all if the row's bottom-most on pixel cannot fit.
1942 LineHeight
= LastLineHeight
;
1946 // Calculate how many characters there are in a row.
1948 RowInfo
[RowIndex
].StartIndex
= Index
;
1950 while (LineWidth
+ BltX
< Image
->Width
&& StringPtr
[Index
] != 0) {
1951 if (((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0) &&
1952 (IsLineBreak (StringPtr
[Index
]) == 0))
1955 // It forces a line break that ends this row.
1963 // If the glyph of the character is existing, then accumulate the actual printed width
1965 LineWidth
+= (UINTN
)Cell
[Index
].AdvanceX
;
1971 // Record index of next char.
1975 // Return to the previous char.
1978 if (LineBreak
&& (Index
> 0)) {
1980 // Return the previous non line break char.
1986 // If this character is the last character of a row, we need not
1987 // draw its (AdvanceX - Width - OffsetX) for next character.
1989 LineWidth
-= (Cell
[Index
].AdvanceX
- Cell
[Index
].Width
- Cell
[Index
].OffsetX
);
1992 // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
1994 if ((LineWidth
+ BltX
<= Image
->Width
) ||
1995 ((LineWidth
+ BltX
> Image
->Width
) && ((Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) == 0)))
1998 // Record right-most character in RowInfo even if it is partially displayed.
2000 RowInfo
[RowIndex
].EndIndex
= Index
;
2001 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2002 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
2003 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
2006 // When EFI_HII_OUT_FLAG_CLEAN_X is set, it will not draw a character
2007 // if its right-most on pixel cannot fit.
2009 if (Index
> RowInfo
[RowIndex
].StartIndex
) {
2011 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
2013 LineWidth
-= (Cell
[Index
].Width
+ Cell
[Index
].OffsetX
);
2014 LineWidth
-= (Cell
[Index
- 1].AdvanceX
- Cell
[Index
- 1].Width
- Cell
[Index
- 1].OffsetX
);
2015 RowInfo
[RowIndex
].EndIndex
= Index
- 1;
2016 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2017 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
2018 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
2021 // There is no enough column to draw any character, so set current line width to zero.
2022 // And go to draw Next line if LineBreak is set.
2024 RowInfo
[RowIndex
].LineWidth
= 0;
2030 // EFI_HII_OUT_FLAG_WRAP will wrap the text at the right-most line-break
2031 // opportunity prior to a character whose right-most extent would exceed Width.
2032 // Search the right-most line-break opportunity here.
2034 if (((Flags
& EFI_HII_OUT_FLAG_WRAP
) == EFI_HII_OUT_FLAG_WRAP
) &&
2035 ((RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
) || (StringPtr
[NextIndex
] != 0)) &&
2038 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0) {
2039 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
2040 for (Index1
= RowInfo
[RowIndex
].EndIndex
; Index1
>= RowInfo
[RowIndex
].StartIndex
; Index1
--) {
2041 if (Index1
== RowInfo
[RowIndex
].EndIndex
) {
2042 LineWidth
-= (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
2044 LineWidth
-= Cell
[Index1
].AdvanceX
;
2047 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
2049 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
2050 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
2054 // relocate to the character after the right-most line break opportunity of this line
2056 NextIndex
= Index1
+ 1;
2061 // If don't find a line break opportunity from EndIndex to StartIndex,
2064 if (Index1
== RowInfo
[RowIndex
].StartIndex
) {
2070 // Update LineWidth to the real width
2072 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
2073 if (Index1
== RowInfo
[RowIndex
].StartIndex
) {
2076 LineWidth
-= (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
2079 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2084 // If no line-break opportunity can be found, then the text will
2085 // behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.
2088 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
2089 Index1
= RowInfo
[RowIndex
].EndIndex
;
2090 if (LineWidth
+ BltX
> Image
->Width
) {
2091 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
2093 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
2095 LineWidth
-= (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
2096 LineWidth
-= (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
2097 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
2098 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2101 // There is no enough column to draw any character, so set current line width to zero.
2102 // And go to draw Next line if LineBreak is set.
2104 RowInfo
[RowIndex
].LineWidth
= 0;
2112 // LineWidth can't exceed Image width.
2114 if (RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
) {
2115 RowInfo
[RowIndex
].LineWidth
= Image
->Width
- BltX
;
2119 // Draw it to screen or existing bitmap depending on whether
2120 // EFI_HII_DIRECT_TO_SCREEN is set.
2123 if ((Flags
& EFI_HII_DIRECT_TO_SCREEN
) == EFI_HII_DIRECT_TO_SCREEN
) {
2125 if (RowInfo
[RowIndex
].LineWidth
!= 0) {
2126 BltBuffer
= AllocatePool (RowInfo
[RowIndex
].LineWidth
* RowInfo
[RowIndex
].LineHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2127 if (BltBuffer
== NULL
) {
2128 Status
= EFI_OUT_OF_RESOURCES
;
2133 // Initialize the background color.
2135 PreInitBkgnd
= Background
.Blue
| Background
.Green
<< 8 | Background
.Red
<< 16;
2136 SetMem32 (BltBuffer
, RowInfo
[RowIndex
].LineWidth
* RowInfo
[RowIndex
].LineHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), PreInitBkgnd
);
2138 // Set BufferPtr to Origin by adding baseline to the starting position.
2140 BufferPtr
= BltBuffer
+ BaseLine
* RowInfo
[RowIndex
].LineWidth
;
2143 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2144 if ((RowInfo
[RowIndex
].LineWidth
> 0) && (RowInfo
[RowIndex
].LineWidth
> LineOffset
)) {
2146 // Only BLT these character which have corresponding glyph in font database.
2152 (UINT16
)RowInfo
[RowIndex
].LineWidth
,
2154 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2155 RowInfo
[RowIndex
].LineHeight
,
2163 if (ColumnInfoArray
!= NULL
) {
2164 if ( ((GlyphBuf
[Index1
] == NULL
) && (Cell
[Index1
].AdvanceX
== 0))
2165 || (RowInfo
[RowIndex
].LineWidth
== 0))
2167 *ColumnInfoArray
= (UINTN
) ~0;
2169 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2175 LineOffset
+= Cell
[Index1
].AdvanceX
;
2178 if (BltBuffer
!= NULL
) {
2179 Status
= Image
->Image
.Screen
->Blt (
2180 Image
->Image
.Screen
,
2182 EfiBltBufferToVideo
,
2187 RowInfo
[RowIndex
].LineWidth
,
2188 RowInfo
[RowIndex
].LineHeight
,
2191 if (EFI_ERROR (Status
)) {
2192 FreePool (BltBuffer
);
2196 FreePool (BltBuffer
);
2200 // Save the starting position for calculate the starting position of next row.
2202 RowBufferPtr
= BufferPtr
;
2204 // Set BufferPtr to Origin by adding baseline to the starting position.
2206 BufferPtr
= BufferPtr
+ BaseLine
* Image
->Width
;
2207 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2208 if ((RowInfo
[RowIndex
].LineWidth
> 0) && (RowInfo
[RowIndex
].LineWidth
> LineOffset
)) {
2210 // Only BLT these character which have corresponding glyph in font database.
2218 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2219 RowInfo
[RowIndex
].LineHeight
,
2227 if (ColumnInfoArray
!= NULL
) {
2228 if ( ((GlyphBuf
[Index1
] == NULL
) && (Cell
[Index1
].AdvanceX
== 0))
2229 || (RowInfo
[RowIndex
].LineWidth
== 0))
2231 *ColumnInfoArray
= (UINTN
) ~0;
2233 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2239 LineOffset
+= Cell
[Index1
].AdvanceX
;
2243 // Jump to starting position of next row.
2245 if (RowIndex
== 0) {
2246 BufferPtr
= RowBufferPtr
- BltX
+ LineHeight
* Image
->Width
;
2248 BufferPtr
= RowBufferPtr
+ LineHeight
* Image
->Width
;
2254 // Recalculate the start point of Y axis to draw multi-lines with the order of top-to-down
2256 BltY
+= RowInfo
[RowIndex
].LineHeight
;
2263 // If there is not a mandatory line break or line break opportunity, only render one line to image
2270 // Write output parameters.
2272 RowInfoSize
= RowIndex
* sizeof (EFI_HII_ROW_INFO
);
2273 if (RowInfoArray
!= NULL
) {
2274 if (RowInfoSize
> 0) {
2275 *RowInfoArray
= AllocateZeroPool (RowInfoSize
);
2276 if (*RowInfoArray
== NULL
) {
2277 Status
= EFI_OUT_OF_RESOURCES
;
2281 CopyMem (*RowInfoArray
, RowInfo
, RowInfoSize
);
2283 *RowInfoArray
= NULL
;
2287 if (RowInfoArraySize
!= NULL
) {
2288 *RowInfoArraySize
= RowIndex
;
2291 Status
= EFI_SUCCESS
;
2295 for (Index
= 0; Index
< StrLength
; Index
++) {
2296 if (GlyphBuf
[Index
] != NULL
) {
2297 FreePool (GlyphBuf
[Index
]);
2301 if (StringIn
!= NULL
) {
2302 FreePool (StringIn
);
2305 if (StringIn2
!= NULL
) {
2306 FreePool (StringIn2
);
2309 if (StringInfoOut
!= NULL
) {
2310 FreePool (StringInfoOut
);
2313 if (RowInfo
!= NULL
) {
2317 if (SystemDefault
!= NULL
) {
2318 FreePool (SystemDefault
);
2321 if (GlyphBuf
!= NULL
) {
2322 FreePool (GlyphBuf
);
2329 if (Attributes
!= NULL
) {
2330 FreePool (Attributes
);
2337 Render a string to a bitmap or the screen containing the contents of the specified string.
2339 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2340 @param Flags Describes how the string is to be drawn.
2341 @param PackageList The package list in the HII database to search
2342 for the specified string.
2343 @param StringId The string's id, which is unique within
2345 @param Language Points to the language for the retrieved string.
2346 If NULL, then the current system language is
2348 @param StringInfo Points to the string output information,
2349 including the color and font. If NULL, then the
2350 string will be output in the default system font
2352 @param Blt If this points to a non-NULL on entry, this
2353 points to the image, which is Width pixels wide
2354 and Height pixels high. The string will be drawn
2356 EFI_HII_OUT_FLAG_CLIP is implied. If this points
2357 to a NULL on entry, then a buffer
2358 will be allocated to hold the generated image and
2359 the pointer updated on exit. It is the caller's
2360 responsibility to free this buffer.
2361 @param BltX Specifies the offset from the left and top edge
2362 of the image of the first character cell in the
2364 @param BltY Specifies the offset from the left and top edge
2365 of the image of the first character cell in the
2367 @param RowInfoArray If this is non-NULL on entry, then on exit, this
2368 will point to an allocated buffer containing
2369 row information and RowInfoArraySize will be
2370 updated to contain the number of elements.
2371 This array describes the characters which were at
2372 least partially drawn and the heights of the
2373 rows. It is the caller's responsibility to free
2375 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
2376 contains the number of elements in RowInfoArray.
2377 @param ColumnInfoArray If this is non-NULL, then on return it will be
2378 filled with the horizontal offset for each
2379 character in the string on the row where it is
2380 displayed. Non-printing characters will have
2381 the offset ~0. The caller is responsible to
2382 allocate a buffer large enough so that there
2383 is one entry for each character in the string,
2384 not including the null-terminator. It is possible
2385 when character display is normalized that some
2386 character cells overlap.
2388 @retval EFI_SUCCESS The string was successfully rendered.
2389 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
2390 RowInfoArray or Blt.
2391 @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
2392 @retval EFI_INVALID_PARAMETER Flags were invalid combination.
2393 @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the string id is not
2394 in the specified PackageList.
2399 HiiStringIdToImage (
2400 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2401 IN EFI_HII_OUT_FLAGS Flags
,
2402 IN EFI_HII_HANDLE PackageList
,
2403 IN EFI_STRING_ID StringId
,
2404 IN CONST CHAR8
*Language
,
2405 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
2406 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
2409 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
2410 OUT UINTN
*RowInfoArraySize OPTIONAL
,
2411 OUT UINTN
*ColumnInfoArray OPTIONAL
2415 HII_DATABASE_PRIVATE_DATA
*Private
;
2416 EFI_HII_STRING_PROTOCOL
*HiiString
;
2421 EFI_FONT_INFO
*StringFontInfo
;
2422 EFI_FONT_DISPLAY_INFO
*NewStringInfo
;
2423 CHAR8 TempSupportedLanguages
;
2424 CHAR8
*SupportedLanguages
;
2425 UINTN SupportedLanguagesSize
;
2426 CHAR8
*CurrentLanguage
;
2427 CHAR8
*BestLanguage
;
2429 if ((This
== NULL
) || (PackageList
== NULL
) || (Blt
== NULL
) || (PackageList
== NULL
)) {
2430 return EFI_INVALID_PARAMETER
;
2433 if (!IsHiiHandleValid (PackageList
)) {
2434 return EFI_NOT_FOUND
;
2438 // Initialize string pointers to be NULL
2440 SupportedLanguages
= NULL
;
2441 CurrentLanguage
= NULL
;
2442 BestLanguage
= NULL
;
2444 StringFontInfo
= NULL
;
2445 NewStringInfo
= NULL
;
2448 // Get the string to be displayed.
2450 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2451 HiiString
= &Private
->HiiString
;
2454 // Get the size of supported language.
2456 SupportedLanguagesSize
= 0;
2457 Status
= HiiString
->GetLanguages (
2460 &TempSupportedLanguages
,
2461 &SupportedLanguagesSize
2463 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2467 SupportedLanguages
= AllocatePool (SupportedLanguagesSize
);
2468 if (SupportedLanguages
== NULL
) {
2469 return EFI_OUT_OF_RESOURCES
;
2472 Status
= HiiString
->GetLanguages (
2476 &SupportedLanguagesSize
2478 if (EFI_ERROR (Status
)) {
2482 if (Language
== NULL
) {
2486 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**)&CurrentLanguage
, NULL
);
2487 BestLanguage
= GetBestLanguage (
2491 (CurrentLanguage
== NULL
) ? CurrentLanguage
: "",
2492 (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
2495 if (BestLanguage
== NULL
) {
2496 Status
= EFI_NOT_FOUND
;
2500 StringSize
= MAX_STRING_LENGTH
;
2501 String
= (EFI_STRING
)AllocateZeroPool (StringSize
);
2502 if (String
== NULL
) {
2503 Status
= EFI_OUT_OF_RESOURCES
;
2507 Status
= HiiString
->GetString (
2516 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2518 String
= (EFI_STRING
)AllocateZeroPool (StringSize
);
2519 if (String
== NULL
) {
2520 Status
= EFI_OUT_OF_RESOURCES
;
2524 Status
= HiiString
->GetString (
2535 if (EFI_ERROR (Status
)) {
2540 // When StringInfo specifies that string will be output in the system default font and color,
2541 // use particular stringfontinfo described in string package instead if exists.
2542 // StringFontInfo equals NULL means system default font attaches with the string block.
2544 if ((StringFontInfo
!= NULL
) && IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*)StringInfo
, NULL
, NULL
)) {
2545 NameSize
= StrSize (StringFontInfo
->FontName
);
2546 FontLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + NameSize
;
2547 NewStringInfo
= AllocateZeroPool (FontLen
);
2548 if (NewStringInfo
== NULL
) {
2549 Status
= EFI_OUT_OF_RESOURCES
;
2553 NewStringInfo
->FontInfoMask
= EFI_FONT_INFO_SYS_FORE_COLOR
| EFI_FONT_INFO_SYS_BACK_COLOR
;
2554 NewStringInfo
->FontInfo
.FontStyle
= StringFontInfo
->FontStyle
;
2555 NewStringInfo
->FontInfo
.FontSize
= StringFontInfo
->FontSize
;
2556 StrCpyS (NewStringInfo
->FontInfo
.FontName
, NameSize
/ sizeof (CHAR16
), StringFontInfo
->FontName
);
2558 Status
= HiiStringToImage (
2573 Status
= HiiStringToImage (
2587 if (SupportedLanguages
!= NULL
) {
2588 FreePool (SupportedLanguages
);
2591 if (CurrentLanguage
!= NULL
) {
2592 FreePool (CurrentLanguage
);
2595 if (BestLanguage
!= NULL
) {
2596 FreePool (BestLanguage
);
2599 if (String
!= NULL
) {
2603 if (StringFontInfo
!= NULL
) {
2604 FreePool (StringFontInfo
);
2607 if (NewStringInfo
!= NULL
) {
2608 FreePool (NewStringInfo
);
2615 Convert the glyph for a single character into a bitmap.
2617 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2618 @param Char Character to retrieve.
2619 @param StringInfo Points to the string font and color information
2620 or NULL if the string should use the default
2621 system font and color.
2622 @param Blt Thus must point to a NULL on entry. A buffer will
2623 be allocated to hold the output and the pointer
2624 updated on exit. It is the caller's
2625 responsibility to free this buffer.
2626 @param Baseline Number of pixels from the bottom of the bitmap to
2629 @retval EFI_SUCCESS Glyph bitmap created.
2630 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.
2631 @retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was replaced with the
2632 glyph for Unicode character 0xFFFD.
2633 @retval EFI_INVALID_PARAMETER Blt is NULL or *Blt is not NULL.
2639 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2641 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo
,
2642 OUT EFI_IMAGE_OUTPUT
**Blt
,
2643 OUT UINTN
*Baseline OPTIONAL
2647 HII_DATABASE_PRIVATE_DATA
*Private
;
2648 EFI_IMAGE_OUTPUT
*Image
;
2650 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2651 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
2653 EFI_FONT_HANDLE FontHandle
;
2655 EFI_HII_GLYPH_INFO Cell
;
2656 EFI_FONT_INFO
*FontInfo
;
2658 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
2659 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
2660 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
2663 if ((This
== NULL
) || (Blt
== NULL
) || (*Blt
!= NULL
)) {
2664 return EFI_INVALID_PARAMETER
;
2667 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2671 SystemDefault
= NULL
;
2675 StringInfoOut
= NULL
;
2678 ZeroMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2679 ZeroMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2681 Default
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*)StringInfo
, &SystemDefault
, NULL
);
2685 // Find out a EFI_FONT_DISPLAY_INFO which could display the character in
2686 // the specified color and font.
2688 String
= (EFI_STRING
)AllocateZeroPool (sizeof (CHAR16
) * 2);
2689 if (String
== NULL
) {
2690 Status
= EFI_OUT_OF_RESOURCES
;
2697 Status
= HiiGetFontInfo (This
, &FontHandle
, StringInfo
, &StringInfoOut
, String
);
2698 if (EFI_ERROR (Status
)) {
2702 ASSERT (StringInfoOut
!= NULL
);
2703 FontInfo
= &StringInfoOut
->FontInfo
;
2704 Foreground
= StringInfoOut
->ForegroundColor
;
2705 Background
= StringInfoOut
->BackgroundColor
;
2707 ASSERT (SystemDefault
!= NULL
);
2708 Foreground
= SystemDefault
->ForegroundColor
;
2709 Background
= SystemDefault
->BackgroundColor
;
2712 Status
= GetGlyphBuffer (Private
, Char
, FontInfo
, &GlyphBuffer
, &Cell
, &Attributes
);
2713 if (EFI_ERROR (Status
)) {
2717 Image
= (EFI_IMAGE_OUTPUT
*)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
2718 if (Image
== NULL
) {
2719 Status
= EFI_OUT_OF_RESOURCES
;
2723 Image
->Width
= Cell
.Width
;
2724 Image
->Height
= Cell
.Height
;
2726 if (Image
->Width
* Image
->Height
> 0) {
2727 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2728 if (Image
->Image
.Bitmap
== NULL
) {
2730 Status
= EFI_OUT_OF_RESOURCES
;
2735 // Set BaseLine to the char height.
2737 BaseLine
= (UINT16
)(Cell
.Height
+ Cell
.OffsetY
);
2739 // Set BltBuffer to the position of Origin.
2741 BltBuffer
= Image
->Image
.Bitmap
+ (Cell
.Height
+ Cell
.OffsetY
) * Image
->Width
- Cell
.OffsetX
;
2748 Cell
.Width
+ Cell
.OffsetX
,
2749 BaseLine
- Cell
.OffsetY
,
2758 if (Baseline
!= NULL
) {
2759 *Baseline
= Cell
.OffsetY
;
2762 Status
= EFI_SUCCESS
;
2766 if (Status
== EFI_NOT_FOUND
) {
2768 // Glyph is unknown and replaced with the glyph for unicode character 0xFFFD
2770 if (Char
!= REPLACE_UNKNOWN_GLYPH
) {
2771 Status
= HiiGetGlyph (This
, REPLACE_UNKNOWN_GLYPH
, StringInfo
, Blt
, Baseline
);
2772 if (!EFI_ERROR (Status
)) {
2773 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2776 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2780 if (SystemDefault
!= NULL
) {
2781 FreePool (SystemDefault
);
2784 if (StringInfoOut
!= NULL
) {
2785 FreePool (StringInfoOut
);
2788 if (String
!= NULL
) {
2792 if (GlyphBuffer
!= NULL
) {
2793 FreePool (GlyphBuffer
);
2800 This function iterates through fonts which match the specified font, using
2801 the specified criteria. If String is non-NULL, then all of the characters in
2802 the string must exist in order for a candidate font to be returned.
2804 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2805 @param FontHandle On entry, points to the font handle returned by a
2806 previous call to GetFontInfo() or NULL to start
2807 with the first font. On return, points to the
2808 returned font handle or points to NULL if there
2809 are no more matching fonts.
2810 @param StringInfoIn Upon entry, points to the font to return information
2811 about. If NULL, then the information about the system
2812 default font will be returned.
2813 @param StringInfoOut Upon return, contains the matching font's information.
2814 If NULL, then no information is returned. This buffer
2815 is allocated with a call to the Boot Service AllocatePool().
2816 It is the caller's responsibility to call the Boot
2817 Service FreePool() when the caller no longer requires
2818 the contents of StringInfoOut.
2819 @param String Points to the string which will be tested to
2820 determine if all characters are available. If
2821 NULL, then any font is acceptable.
2823 @retval EFI_SUCCESS Matching font returned successfully.
2824 @retval EFI_NOT_FOUND No matching font was found.
2825 @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
2826 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
2833 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2834 IN OUT EFI_FONT_HANDLE
*FontHandle
,
2835 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfoIn OPTIONAL
,
2836 OUT EFI_FONT_DISPLAY_INFO
**StringInfoOut
,
2837 IN CONST EFI_STRING String OPTIONAL
2840 HII_DATABASE_PRIVATE_DATA
*Private
;
2842 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2843 EFI_FONT_DISPLAY_INFO InfoOut
;
2844 UINTN StringInfoOutLen
;
2845 EFI_FONT_INFO
*FontInfo
;
2846 HII_GLOBAL_FONT_INFO
*GlobalFont
;
2847 EFI_STRING StringIn
;
2848 EFI_FONT_HANDLE LocalFontHandle
;
2851 return EFI_INVALID_PARAMETER
;
2854 StringInfoOutLen
= 0;
2856 SystemDefault
= NULL
;
2857 LocalFontHandle
= NULL
;
2858 if (FontHandle
!= NULL
) {
2859 LocalFontHandle
= *FontHandle
;
2862 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2865 // Already searched to the end of the whole list, return directly.
2867 if (LocalFontHandle
== &Private
->FontInfoList
) {
2868 LocalFontHandle
= NULL
;
2869 Status
= EFI_NOT_FOUND
;
2874 // Get default system display info, if StringInfoIn points to
2875 // system display info, return it directly.
2877 if (IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*)StringInfoIn
, &SystemDefault
, &StringInfoOutLen
)) {
2879 // System font is the first node. When handle is not NULL, system font can not
2880 // be found any more.
2882 if (LocalFontHandle
== NULL
) {
2883 if (StringInfoOut
!= NULL
) {
2884 *StringInfoOut
= AllocateCopyPool (StringInfoOutLen
, SystemDefault
);
2885 if (*StringInfoOut
== NULL
) {
2886 Status
= EFI_OUT_OF_RESOURCES
;
2887 LocalFontHandle
= NULL
;
2892 LocalFontHandle
= Private
->FontInfoList
.ForwardLink
;
2893 Status
= EFI_SUCCESS
;
2896 LocalFontHandle
= NULL
;
2897 Status
= EFI_NOT_FOUND
;
2903 // StringInfoIn must not be NULL if it is not system default font info.
2905 ASSERT (StringInfoIn
!= NULL
);
2907 // Check the font information mask to make sure it is valid.
2909 if (((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ==
2910 (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ||
2911 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2912 (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2913 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2914 (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ||
2915 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2916 (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2917 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2918 (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
)))
2920 return EFI_INVALID_PARAMETER
;
2924 // Parse the font information mask to find a matching font.
2927 CopyMem (&InfoOut
, (EFI_FONT_DISPLAY_INFO
*)StringInfoIn
, sizeof (EFI_FONT_DISPLAY_INFO
));
2929 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FONT
) == EFI_FONT_INFO_SYS_FONT
) {
2930 Status
= SaveFontName (SystemDefault
->FontInfo
.FontName
, &FontInfo
);
2932 Status
= SaveFontName (((EFI_FONT_DISPLAY_INFO
*)StringInfoIn
)->FontInfo
.FontName
, &FontInfo
);
2935 if (EFI_ERROR (Status
)) {
2939 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_SIZE
) == EFI_FONT_INFO_SYS_SIZE
) {
2940 InfoOut
.FontInfo
.FontSize
= SystemDefault
->FontInfo
.FontSize
;
2943 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_STYLE
) == EFI_FONT_INFO_SYS_STYLE
) {
2944 InfoOut
.FontInfo
.FontStyle
= SystemDefault
->FontInfo
.FontStyle
;
2947 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == EFI_FONT_INFO_SYS_FORE_COLOR
) {
2948 InfoOut
.ForegroundColor
= SystemDefault
->ForegroundColor
;
2951 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == EFI_FONT_INFO_SYS_BACK_COLOR
) {
2952 InfoOut
.BackgroundColor
= SystemDefault
->BackgroundColor
;
2955 ASSERT (FontInfo
!= NULL
);
2956 FontInfo
->FontSize
= InfoOut
.FontInfo
.FontSize
;
2957 FontInfo
->FontStyle
= InfoOut
.FontInfo
.FontStyle
;
2959 if (IsFontInfoExisted (Private
, FontInfo
, &InfoOut
.FontInfoMask
, LocalFontHandle
, &GlobalFont
)) {
2961 // Test to guarantee all characters are available in the found font.
2963 if (String
!= NULL
) {
2965 while (*StringIn
!= 0) {
2966 Status
= FindGlyphBlock (GlobalFont
->FontPackage
, *StringIn
, NULL
, NULL
, NULL
);
2967 if (EFI_ERROR (Status
)) {
2968 LocalFontHandle
= NULL
;
2977 // Write to output parameter
2979 if (StringInfoOut
!= NULL
) {
2980 StringInfoOutLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (EFI_FONT_INFO
) + GlobalFont
->FontInfoSize
;
2981 *StringInfoOut
= (EFI_FONT_DISPLAY_INFO
*)AllocateZeroPool (StringInfoOutLen
);
2982 if (*StringInfoOut
== NULL
) {
2983 Status
= EFI_OUT_OF_RESOURCES
;
2984 LocalFontHandle
= NULL
;
2988 CopyMem (*StringInfoOut
, &InfoOut
, sizeof (EFI_FONT_DISPLAY_INFO
));
2989 CopyMem (&(*StringInfoOut
)->FontInfo
, GlobalFont
->FontInfo
, GlobalFont
->FontInfoSize
);
2992 LocalFontHandle
= GlobalFont
->Entry
.ForwardLink
;
2993 Status
= EFI_SUCCESS
;
2997 Status
= EFI_NOT_FOUND
;
3001 if (FontHandle
!= NULL
) {
3002 *FontHandle
= LocalFontHandle
;
3005 if (SystemDefault
!= NULL
) {
3006 FreePool (SystemDefault
);
3009 if (FontInfo
!= NULL
) {
3010 FreePool (FontInfo
);