2 Implementation for EFI_HII_FONT_PROTOCOL.
5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "HiiDatabase.h"
19 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mHiiEfiColors
[16] = {
23 {0x00, 0x00, 0x00, 0x00}, // BLACK
24 {0x98, 0x00, 0x00, 0x00}, // BLUE
25 {0x00, 0x98, 0x00, 0x00}, // GREEN
26 {0x98, 0x98, 0x00, 0x00}, // CYAN
27 {0x00, 0x00, 0x98, 0x00}, // RED
28 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
29 {0x00, 0x98, 0x98, 0x00}, // BROWN
30 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
31 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
32 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE
33 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN
34 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
35 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
36 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
37 {0x00, 0xff, 0xff, 0x00}, // YELLOW
38 {0xff, 0xff, 0xff, 0x00}, // WHITE
43 Insert a character cell information to the list specified by GlyphInfoList.
45 This is a internal function.
47 @param CharValue Unicode character value, which identifies a glyph
49 @param GlyphInfoList HII_GLYPH_INFO list head.
50 @param Cell Incoming character cell information.
52 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
53 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
60 IN LIST_ENTRY
*GlyphInfoList
,
61 IN EFI_HII_GLYPH_INFO
*Cell
64 HII_GLYPH_INFO
*GlyphInfo
;
66 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
68 GlyphInfo
= (HII_GLYPH_INFO
*) AllocateZeroPool (sizeof (HII_GLYPH_INFO
));
69 if (GlyphInfo
== NULL
) {
70 return EFI_OUT_OF_RESOURCES
;
74 // GlyphInfoList stores a list of default character cell information, each is
75 // identified by "CharId".
77 GlyphInfo
->Signature
= HII_GLYPH_INFO_SIGNATURE
;
78 GlyphInfo
->CharId
= CharValue
;
79 if (Cell
->AdvanceX
== 0) {
80 Cell
->AdvanceX
= Cell
->Width
;
82 CopyMem (&GlyphInfo
->Cell
, Cell
, sizeof (EFI_HII_GLYPH_INFO
));
83 InsertTailList (GlyphInfoList
, &GlyphInfo
->Entry
);
90 Get a character cell information from the list specified by GlyphInfoList.
92 This is a internal function.
94 @param CharValue Unicode character value, which identifies a glyph
96 @param GlyphInfoList HII_GLYPH_INFO list head.
97 @param Cell Buffer which stores output character cell
100 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
101 @retval EFI_NOT_FOUND The character info specified by CharValue does
108 IN LIST_ENTRY
*GlyphInfoList
,
109 OUT EFI_HII_GLYPH_INFO
*Cell
112 HII_GLYPH_INFO
*GlyphInfo
;
115 ASSERT (Cell
!= NULL
&& GlyphInfoList
!= NULL
);
118 // Since the EFI_HII_GIBT_DEFAULTS block won't increment CharValueCurrent,
119 // the value of "CharId" of a default character cell which is used for a
120 // EFI_HII_GIBT_GLYPH_DEFAULT or EFI_HII_GIBT_GLYPHS_DEFAULT should be
121 // less or equal to the value of "CharValueCurrent" of this default block.
123 // For instance, if the CharId of a GlyphInfoList is {1, 3, 7}, a default glyph
124 // with CharValue equals "7" uses the GlyphInfo with CharId = 7;
125 // a default glyph with CharValue equals "6" uses the GlyphInfo with CharId = 3.
127 for (Link
= GlyphInfoList
->BackLink
; Link
!= GlyphInfoList
; Link
= Link
->BackLink
) {
128 GlyphInfo
= CR (Link
, HII_GLYPH_INFO
, Entry
, HII_GLYPH_INFO_SIGNATURE
);
129 if (GlyphInfo
->CharId
<= CharValue
) {
130 CopyMem (Cell
, &GlyphInfo
->Cell
, sizeof (EFI_HII_GLYPH_INFO
));
135 return EFI_NOT_FOUND
;
140 Convert the glyph for a single character into a bitmap.
142 This is a internal function.
144 @param Private HII database driver private data.
145 @param Char Character to retrieve.
146 @param StringInfo Points to the string font and color information
147 or NULL if the string should use the default
148 system font and color.
149 @param GlyphBuffer Buffer to store the retrieved bitmap data.
150 @param Cell Points to EFI_HII_GLYPH_INFO structure.
151 @param Attributes If not NULL, output the glyph attributes if any.
153 @retval EFI_SUCCESS Glyph bitmap outputted.
154 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer GlyphBuffer.
155 @retval EFI_NOT_FOUND The glyph was unknown can not be found.
156 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
161 IN HII_DATABASE_PRIVATE_DATA
*Private
,
163 IN EFI_FONT_INFO
*StringInfo
,
164 OUT UINT8
**GlyphBuffer
,
165 OUT EFI_HII_GLYPH_INFO
*Cell
,
166 OUT UINT8
*Attributes OPTIONAL
169 HII_DATABASE_RECORD
*Node
;
171 HII_SIMPLE_FONT_PACKAGE_INSTANCE
*SimpleFont
;
174 EFI_NARROW_GLYPH Narrow
;
176 HII_GLOBAL_FONT_INFO
*GlobalFont
;
178 EFI_NARROW_GLYPH
*NarrowPtr
;
179 EFI_WIDE_GLYPH
*WidePtr
;
181 if (GlyphBuffer
== NULL
|| Cell
== NULL
) {
182 return EFI_INVALID_PARAMETER
;
184 if (Private
== NULL
|| Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
) {
185 return EFI_INVALID_PARAMETER
;
188 ZeroMem (Cell
, sizeof (EFI_HII_GLYPH_INFO
));
191 // If StringInfo is not NULL, it must point to an existing EFI_FONT_INFO rather
192 // than system default font and color.
193 // If NULL, try to find the character in simplified font packages since
194 // default system font is the fixed font (narrow or wide glyph).
196 if (StringInfo
!= NULL
) {
197 if(!IsFontInfoExisted (Private
, StringInfo
, NULL
, NULL
, &GlobalFont
)) {
198 return EFI_INVALID_PARAMETER
;
200 if (Attributes
!= NULL
) {
201 *Attributes
= PROPORTIONAL_GLYPH
;
203 return FindGlyphBlock (GlobalFont
->FontPackage
, Char
, GlyphBuffer
, Cell
, NULL
);
205 HeaderSize
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
);
207 for (Link
= Private
->DatabaseList
.ForwardLink
; Link
!= &Private
->DatabaseList
; Link
= Link
->ForwardLink
) {
208 Node
= CR (Link
, HII_DATABASE_RECORD
, DatabaseEntry
, HII_DATABASE_RECORD_SIGNATURE
);
209 for (Link1
= Node
->PackageList
->SimpleFontPkgHdr
.ForwardLink
;
210 Link1
!= &Node
->PackageList
->SimpleFontPkgHdr
;
211 Link1
= Link1
->ForwardLink
213 SimpleFont
= CR (Link1
, HII_SIMPLE_FONT_PACKAGE_INSTANCE
, SimpleFontEntry
, HII_S_FONT_PACKAGE_SIGNATURE
);
215 // Search the narrow glyph array
217 NarrowPtr
= (EFI_NARROW_GLYPH
*) ((UINT8
*) (SimpleFont
->SimpleFontPkgHdr
) + HeaderSize
);
218 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
; Index
++) {
219 CopyMem (&Narrow
, NarrowPtr
+ Index
,sizeof (EFI_NARROW_GLYPH
));
220 if (Narrow
.UnicodeWeight
== Char
) {
221 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (EFI_GLYPH_HEIGHT
);
222 if (*GlyphBuffer
== NULL
) {
223 return EFI_OUT_OF_RESOURCES
;
225 Cell
->Width
= EFI_GLYPH_WIDTH
;
226 Cell
->Height
= EFI_GLYPH_HEIGHT
;
227 Cell
->AdvanceX
= Cell
->Width
;
228 CopyMem (*GlyphBuffer
, Narrow
.GlyphCol1
, Cell
->Height
);
229 if (Attributes
!= NULL
) {
230 *Attributes
= (UINT8
) (Narrow
.Attributes
| NARROW_GLYPH
);
236 // Search the wide glyph array
238 WidePtr
= (EFI_WIDE_GLYPH
*) (NarrowPtr
+ SimpleFont
->SimpleFontPkgHdr
->NumberOfNarrowGlyphs
);
239 for (Index
= 0; Index
< SimpleFont
->SimpleFontPkgHdr
->NumberOfWideGlyphs
; Index
++) {
240 CopyMem (&Wide
, WidePtr
+ Index
, sizeof (EFI_WIDE_GLYPH
));
241 if (Wide
.UnicodeWeight
== Char
) {
242 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (EFI_GLYPH_HEIGHT
* 2);
243 if (*GlyphBuffer
== NULL
) {
244 return EFI_OUT_OF_RESOURCES
;
246 Cell
->Width
= EFI_GLYPH_WIDTH
* 2;
247 Cell
->Height
= EFI_GLYPH_HEIGHT
;
248 Cell
->AdvanceX
= Cell
->Width
;
249 CopyMem (*GlyphBuffer
, Wide
.GlyphCol1
, EFI_GLYPH_HEIGHT
);
250 CopyMem (*GlyphBuffer
+ EFI_GLYPH_HEIGHT
, Wide
.GlyphCol2
, EFI_GLYPH_HEIGHT
);
251 if (Attributes
!= NULL
) {
252 *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 wil 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
;
319 if (RowWidth
< Width
) {
320 Width
= (UINT8
) RowWidth
;
323 for (Ypos
= 0; Ypos
< Height
; Ypos
++) {
324 for (Xpos
= 0; Xpos
< Width
; Xpos
++) {
325 if ((GlyphBuffer
[Ypos
] & (1 << (EFI_GLYPH_WIDTH
- Xpos
- 1))) != 0) {
326 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Foreground
;
329 Buffer
[Ypos
* ImageWidth
+ Xpos
] = Background
;
335 *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 wil 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
;
397 // Move position to the left-top corner of char.
399 BltBuffer
= *Origin
+ Cell
->OffsetX
- (Cell
->OffsetY
+ Cell
->Height
) * ImageWidth
;
400 YposOffset
= (UINT16
) (BaseLine
- (Cell
->OffsetY
+ Cell
->Height
));
403 // Since non-spacing key will be printed OR'd with the previous glyph, don't
406 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
411 // The glyph's upper left hand corner pixel is the most significant bit of the
412 // first bitmap byte.
414 for (Ypos
= 0; Ypos
< Cell
->Height
&& ((UINTN
) (Ypos
+ YposOffset
) < RowHeight
); Ypos
++) {
415 OffsetY
= BITMAP_LEN_1_BIT (Cell
->Width
, Ypos
);
418 // All bits in these bytes are meaningful.
420 for (Xpos
= 0; Xpos
< Cell
->Width
/ 8; Xpos
++) {
421 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
422 for (Index
= 0; Index
< 8 && ((UINTN
) (Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
423 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
424 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
427 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
433 if (Cell
->Width
% 8 != 0) {
435 // There are some padding bits in this byte. Ignore them.
437 Data
= *(GlyphBuffer
+ OffsetY
+ Xpos
);
438 for (Index
= 0; Index
< Cell
->Width
% 8 && ((UINTN
) (Xpos
* 8 + Index
+ Cell
->OffsetX
) < RowWidth
); Index
++) {
439 if ((Data
& (1 << (8 - Index
- 1))) != 0) {
440 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Foreground
;
443 BltBuffer
[Ypos
* ImageWidth
+ Xpos
* 8 + Index
] = Background
;
447 } // end of if (Width % 8...)
449 } // end of for (Ypos=0...)
451 *Origin
= *Origin
+ Cell
->AdvanceX
;
456 Convert bitmap data of the glyph to blt structure.
458 This is a internal function.
460 @param GlyphBuffer Buffer points to bitmap data of glyph.
461 @param Foreground The color of the "on" pixels in the glyph in the
463 @param Background The color of the "off" pixels in the glyph in the
465 @param ImageWidth Width of the whole image in pixels.
466 @param BaseLine BaseLine in the line.
467 @param RowWidth The width of the text on the line, in pixels.
468 @param RowHeight The height of the line, in pixels.
469 @param Transparent If TRUE, the Background color is ignored and all
470 "off" pixels in the character's drawn wil use the
471 pixel value from BltBuffer.
472 @param Cell Points to EFI_HII_GLYPH_INFO structure.
473 @param Attributes The attribute of incoming glyph in GlyphBuffer.
474 @param Origin On input, points to the origin of the to be
475 displayed character, on output, points to the
478 @return Points to the address of next origin node in BltBuffer.
483 IN UINT8
*GlyphBuffer
,
484 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
485 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
486 IN UINT16 ImageWidth
,
490 IN BOOLEAN Transparent
,
491 IN CONST EFI_HII_GLYPH_INFO
*Cell
,
493 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**Origin
496 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Buffer
;
498 ASSERT (Origin
!= NULL
&& *Origin
!= NULL
&& Cell
!= NULL
);
502 if ((Attributes
& EFI_GLYPH_NON_SPACING
) == EFI_GLYPH_NON_SPACING
) {
504 // This character is a non-spacing key, print it OR'd with the previous glyph.
505 // without advancing cursor.
507 Buffer
-= Cell
->AdvanceX
;
522 } else if ((Attributes
& EFI_GLYPH_WIDE
) == EFI_GLYPH_WIDE
) {
524 // This character is wide glyph, i.e. 16 pixels * 19 pixels.
525 // Draw it as two narrow glyphs.
539 GlyphBuffer
+ EFI_GLYPH_HEIGHT
,
549 } else if ((Attributes
& NARROW_GLYPH
) == NARROW_GLYPH
) {
551 // This character is narrow glyph, i.e. 8 pixels * 19 pixels.
564 } else if ((Attributes
& PROPORTIONAL_GLYPH
) == PROPORTIONAL_GLYPH
) {
566 // This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.
586 Write the output parameters of FindGlyphBlock().
588 This is a internal function.
590 @param BufferIn Buffer which stores the bitmap data of the found
592 @param BufferLen Length of BufferIn.
593 @param InputCell Buffer which stores cell information of the
595 @param GlyphBuffer Output the corresponding bitmap data of the found
596 block. It is the caller's responsiblity to free
598 @param Cell Output cell information of the encoded bitmap.
599 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
601 @retval EFI_SUCCESS The operation is performed successfully.
602 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
603 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
611 IN EFI_HII_GLYPH_INFO
*InputCell
,
612 OUT UINT8
**GlyphBuffer
, OPTIONAL
613 OUT EFI_HII_GLYPH_INFO
*Cell
, OPTIONAL
614 OUT UINTN
*GlyphBufferLen OPTIONAL
617 if (BufferIn
== NULL
|| InputCell
== NULL
) {
618 return EFI_INVALID_PARAMETER
;
622 CopyMem (Cell
, InputCell
, sizeof (EFI_HII_GLYPH_INFO
));
625 if (GlyphBuffer
!= NULL
&& BufferLen
> 0) {
626 *GlyphBuffer
= (UINT8
*) AllocateZeroPool (BufferLen
);
627 if (*GlyphBuffer
== NULL
) {
628 return EFI_OUT_OF_RESOURCES
;
630 CopyMem (*GlyphBuffer
, BufferIn
, BufferLen
);
633 if (GlyphBufferLen
!= NULL
) {
634 *GlyphBufferLen
= BufferLen
;
642 Parse all glyph blocks to find a glyph block specified by CharValue.
643 If CharValue = (CHAR16) (-1), collect all default character cell information
644 within this font package and backup its information.
646 @param FontPackage Hii string package instance.
647 @param CharValue Unicode character value, which identifies a glyph
649 @param GlyphBuffer Output the corresponding bitmap data of the found
650 block. It is the caller's responsiblity to free
652 @param Cell Output cell information of the encoded bitmap.
653 @param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
655 @retval EFI_SUCCESS The bitmap data is retrieved successfully.
656 @retval EFI_NOT_FOUND The specified CharValue does not exist in current
658 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
664 IN HII_FONT_PACKAGE_INSTANCE
*FontPackage
,
666 OUT UINT8
**GlyphBuffer
, OPTIONAL
667 OUT EFI_HII_GLYPH_INFO
*Cell
, OPTIONAL
668 OUT UINTN
*GlyphBufferLen OPTIONAL
676 EFI_HII_GIBT_GLYPHS_BLOCK Glyphs
;
679 EFI_HII_GLYPH_INFO DefaultCell
;
680 EFI_HII_GLYPH_INFO LocalCell
;
684 ASSERT (FontPackage
!= NULL
);
685 ASSERT (FontPackage
->Signature
== HII_FONT_PACKAGE_SIGNATURE
);
689 if (CharValue
== (CHAR16
) (-1)) {
691 // Collect the cell information specified in font package fixed header.
692 // Use CharValue =0 to represent this particular cell.
696 &FontPackage
->GlyphInfoList
,
697 (EFI_HII_GLYPH_INFO
*) ((UINT8
*) FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
))
699 if (EFI_ERROR (Status
)) {
704 (UINT8
*) FontPackage
->FontPkgHdr
+ 3 * sizeof (UINT32
),
705 sizeof (EFI_HII_GLYPH_INFO
)
707 BaseLine
= (UINT16
) (LocalCell
.Height
+ LocalCell
.OffsetY
);
708 if (MinOffsetY
> LocalCell
.OffsetY
) {
709 MinOffsetY
= LocalCell
.OffsetY
;
713 BlockPtr
= FontPackage
->GlyphBlock
;
717 while (*BlockPtr
!= EFI_HII_GIBT_END
) {
719 case EFI_HII_GIBT_DEFAULTS
:
721 // Collect all default character cell information specified by
722 // EFI_HII_GIBT_DEFAULTS.
724 if (CharValue
== (CHAR16
) (-1)) {
727 &FontPackage
->GlyphInfoList
,
728 (EFI_HII_GLYPH_INFO
*) (BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))
730 if (EFI_ERROR (Status
)) {
735 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
736 sizeof (EFI_HII_GLYPH_INFO
)
738 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
739 BaseLine
= (UINT16
) (LocalCell
.Height
+ LocalCell
.OffsetY
);
741 if (MinOffsetY
> LocalCell
.OffsetY
) {
742 MinOffsetY
= LocalCell
.OffsetY
;
745 BlockPtr
+= sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK
);
748 case EFI_HII_GIBT_DUPLICATE
:
749 if (CharCurrent
== CharValue
) {
750 CopyMem (&CharValue
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (CHAR16
));
752 BlockPtr
= FontPackage
->GlyphBlock
;
756 BlockPtr
+= sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK
);
759 case EFI_HII_GIBT_EXT1
:
760 BlockPtr
+= *(UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
));
762 case EFI_HII_GIBT_EXT2
:
765 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
768 BlockPtr
+= Length16
;
770 case EFI_HII_GIBT_EXT4
:
773 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
) + sizeof (UINT8
)),
776 BlockPtr
+= Length32
;
779 case EFI_HII_GIBT_GLYPH
:
782 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
783 sizeof (EFI_HII_GLYPH_INFO
)
785 if (CharValue
== (CHAR16
) (-1)) {
786 if (BaseLine
< LocalCell
.Height
+ LocalCell
.OffsetY
) {
787 BaseLine
= (UINT16
) (LocalCell
.Height
+ LocalCell
.OffsetY
);
789 if (MinOffsetY
> LocalCell
.OffsetY
) {
790 MinOffsetY
= LocalCell
.OffsetY
;
793 BufferLen
= BITMAP_LEN_1_BIT (LocalCell
.Width
, LocalCell
.Height
);
794 if (CharCurrent
== CharValue
) {
795 return WriteOutputParam (
796 (UINT8
*)((UINTN
)BlockPtr
+ sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
)),
805 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPH_BLOCK
) - sizeof (UINT8
) + BufferLen
;
808 case EFI_HII_GIBT_GLYPHS
:
809 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
);
810 CopyMem (&Glyphs
.Cell
, BlockPtr
, sizeof (EFI_HII_GLYPH_INFO
));
811 BlockPtr
+= sizeof (EFI_HII_GLYPH_INFO
);
812 CopyMem (&Glyphs
.Count
, BlockPtr
, sizeof (UINT16
));
813 BlockPtr
+= sizeof (UINT16
);
815 if (CharValue
== (CHAR16
) (-1)) {
816 if (BaseLine
< Glyphs
.Cell
.Height
+ Glyphs
.Cell
.OffsetY
) {
817 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 (
836 BlockPtr
+= BufferLen
;
838 CharCurrent
= (UINT16
) (CharCurrent
+ Glyphs
.Count
);
841 case EFI_HII_GIBT_GLYPH_DEFAULT
:
842 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
843 if (EFI_ERROR (Status
)) {
846 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
848 if (CharCurrent
== CharValue
) {
849 return WriteOutputParam (
850 BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
),
859 BlockPtr
+= sizeof (EFI_HII_GLYPH_BLOCK
) + BufferLen
;
862 case EFI_HII_GIBT_GLYPHS_DEFAULT
:
863 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
864 Status
= GetCell (CharCurrent
, &FontPackage
->GlyphInfoList
, &DefaultCell
);
865 if (EFI_ERROR (Status
)) {
868 BufferLen
= BITMAP_LEN_1_BIT (DefaultCell
.Width
, DefaultCell
.Height
);
869 BlockPtr
+= sizeof (EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK
) - sizeof (UINT8
);
870 for (Index
= 0; Index
< Length16
; Index
++) {
871 if (CharCurrent
+ Index
== CharValue
) {
872 return WriteOutputParam (
881 BlockPtr
+= BufferLen
;
883 CharCurrent
= (UINT16
) (CharCurrent
+ Length16
);
886 case EFI_HII_GIBT_SKIP1
:
887 CharCurrent
= (UINT16
) (CharCurrent
+ (UINT16
) (*(BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
))));
888 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP1_BLOCK
);
890 case EFI_HII_GIBT_SKIP2
:
891 CopyMem (&Length16
, BlockPtr
+ sizeof (EFI_HII_GLYPH_BLOCK
), sizeof (UINT16
));
892 CharCurrent
= (UINT16
) (CharCurrent
+ Length16
);
893 BlockPtr
+= sizeof (EFI_HII_GIBT_SKIP2_BLOCK
);
900 if (CharValue
< CharCurrent
) {
901 return EFI_NOT_FOUND
;
905 if (CharValue
== (CHAR16
) (-1)) {
906 FontPackage
->BaseLine
= BaseLine
;
907 FontPackage
->Height
= (UINT16
) (BaseLine
- MinOffsetY
);
911 return EFI_NOT_FOUND
;
916 Copy a Font Name to a new created EFI_FONT_INFO structure.
918 This is a internal function.
920 @param FontName NULL-terminated string.
921 @param FontInfo a new EFI_FONT_INFO which stores the FontName.
922 It's caller's responsibility to free this buffer.
924 @retval EFI_SUCCESS FontInfo is allocated and copied with FontName.
925 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
931 IN EFI_STRING FontName
,
932 OUT EFI_FONT_INFO
**FontInfo
937 ASSERT (FontName
!= NULL
&& FontInfo
!= NULL
);
939 FontInfoLen
= sizeof (EFI_FONT_INFO
) - sizeof (CHAR16
) + StrSize (FontName
);
940 *FontInfo
= (EFI_FONT_INFO
*) AllocateZeroPool (FontInfoLen
);
941 if (*FontInfo
== NULL
) {
942 return EFI_OUT_OF_RESOURCES
;
945 StrCpy ((*FontInfo
)->FontName
, FontName
);
951 Retrieve system default font and color.
953 @param Private HII database driver private data.
954 @param FontInfo Points to system default font output-related
955 information. It's caller's responsibility to free
957 @param FontInfoSize If not NULL, output the size of buffer FontInfo.
959 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
960 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
962 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
967 IN HII_DATABASE_PRIVATE_DATA
*Private
,
968 OUT EFI_FONT_DISPLAY_INFO
**FontInfo
,
969 OUT UINTN
*FontInfoSize OPTIONAL
972 EFI_FONT_DISPLAY_INFO
*Info
;
975 if (Private
== NULL
|| Private
->Signature
!= HII_DATABASE_PRIVATE_DATA_SIGNATURE
) {
976 return EFI_INVALID_PARAMETER
;
978 if (FontInfo
== NULL
) {
979 return EFI_INVALID_PARAMETER
;
983 // The standard font always has the name "sysdefault".
985 InfoSize
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + StrSize (L
"sysdefault");
986 Info
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (InfoSize
);
988 return EFI_OUT_OF_RESOURCES
;
991 Info
->ForegroundColor
= mHiiEfiColors
[Private
->Attribute
& 0x0f];
992 Info
->BackgroundColor
= mHiiEfiColors
[Private
->Attribute
>> 4];
993 Info
->FontInfoMask
= EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_SYS_STYLE
;
994 Info
->FontInfo
.FontStyle
= 0;
995 Info
->FontInfo
.FontSize
= EFI_GLYPH_HEIGHT
;
996 StrCpy (Info
->FontInfo
.FontName
, L
"sysdefault");
999 if (FontInfoSize
!= NULL
) {
1000 *FontInfoSize
= InfoSize
;
1007 Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
1008 returns the system default according to the optional inputs.
1010 This is a internal function.
1012 @param Private HII database driver private data.
1013 @param StringInfo Points to the string output information,
1014 including the color and font.
1015 @param SystemInfo If not NULL, points to system default font and color.
1017 @param SystemInfoLen If not NULL, output the length of default system
1020 @retval TRUE Yes, it points to system default.
1026 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1027 IN EFI_FONT_DISPLAY_INFO
*StringInfo
,
1028 OUT EFI_FONT_DISPLAY_INFO
**SystemInfo
, OPTIONAL
1029 OUT UINTN
*SystemInfoLen OPTIONAL
1033 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1037 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1039 if (StringInfo
== NULL
&& SystemInfo
== NULL
) {
1043 SystemDefault
= NULL
;
1046 Status
= GetSystemFont (Private
, &SystemDefault
, &DefaultLen
);
1047 ASSERT_EFI_ERROR (Status
);
1048 ASSERT ((SystemDefault
!= NULL
) && (DefaultLen
!= 0));
1051 // Record the system default info.
1053 if (SystemInfo
!= NULL
) {
1054 *SystemInfo
= SystemDefault
;
1057 if (SystemInfoLen
!= NULL
) {
1058 *SystemInfoLen
= DefaultLen
;
1061 if (StringInfo
== NULL
) {
1067 // Check the FontInfoMask to see whether it is retrieving system info.
1069 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) == 0) {
1070 if (StrCmp (StringInfo
->FontInfo
.FontName
, SystemDefault
->FontInfo
.FontName
) != 0) {
1074 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) == 0) {
1075 if (StringInfo
->FontInfo
.FontSize
!= SystemDefault
->FontInfo
.FontSize
) {
1079 if ((StringInfo
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) == 0) {
1080 if (StringInfo
->FontInfo
.FontStyle
!= SystemDefault
->FontInfo
.FontStyle
) {
1084 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == 0) {
1086 &StringInfo
->ForegroundColor
,
1087 &SystemDefault
->ForegroundColor
,
1088 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1093 if ((StringInfo
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == 0) {
1095 &StringInfo
->BackgroundColor
,
1096 &SystemDefault
->BackgroundColor
,
1097 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1106 if (SystemInfo
== NULL
) {
1107 if (SystemDefault
!= NULL
) {
1108 FreePool (SystemDefault
);
1116 This function checks whether EFI_FONT_INFO exists in current database. If
1117 FontInfoMask is specified, check what options can be used to make a match.
1118 Note that the masks relate to where the system default should be supplied
1119 are ignored by this function.
1121 @param Private Hii database private structure.
1122 @param FontInfo Points to EFI_FONT_INFO structure.
1123 @param FontInfoMask If not NULL, describes what options can be used
1124 to make a match between the font requested and
1125 the font available. The caller must guarantee
1127 @param FontHandle On entry, Points to the font handle returned by a
1128 previous call to GetFontInfo() or NULL to start
1129 with the first font.
1130 @param GlobalFontInfo If not NULL, output the corresponding globa font
1133 @retval TRUE Existed
1134 @retval FALSE Not existed
1139 IN HII_DATABASE_PRIVATE_DATA
*Private
,
1140 IN EFI_FONT_INFO
*FontInfo
,
1141 IN EFI_FONT_INFO_MASK
*FontInfoMask
, OPTIONAL
1142 IN EFI_FONT_HANDLE FontHandle
, OPTIONAL
1143 OUT HII_GLOBAL_FONT_INFO
**GlobalFontInfo OPTIONAL
1146 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1147 HII_GLOBAL_FONT_INFO
*GlobalFontBackup1
;
1148 HII_GLOBAL_FONT_INFO
*GlobalFontBackup2
;
1150 EFI_FONT_INFO_MASK Mask
;
1152 BOOLEAN VagueMatched1
;
1153 BOOLEAN VagueMatched2
;
1155 ASSERT (Private
!= NULL
&& Private
->Signature
== HII_DATABASE_PRIVATE_DATA_SIGNATURE
);
1156 ASSERT (FontInfo
!= NULL
);
1159 // Matched flag represents an exactly match; VagueMatched1 repensents a RESIZE
1160 // or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.
1163 VagueMatched1
= FALSE
;
1164 VagueMatched2
= FALSE
;
1167 GlobalFontBackup1
= NULL
;
1168 GlobalFontBackup2
= NULL
;
1170 // The process of where the system default should be supplied instead of
1171 // the specified font info beyonds this function's scope.
1173 if (FontInfoMask
!= NULL
) {
1174 Mask
= *FontInfoMask
& (~SYS_FONT_INFO_MASK
);
1178 // If not NULL, FontHandle points to the next node of the last searched font
1179 // node by previous call.
1181 if (FontHandle
== NULL
) {
1182 Link
= Private
->FontInfoList
.ForwardLink
;
1184 Link
= (LIST_ENTRY
*) FontHandle
;
1187 for (; Link
!= &Private
->FontInfoList
; Link
= Link
->ForwardLink
) {
1188 GlobalFont
= CR (Link
, HII_GLOBAL_FONT_INFO
, Entry
, HII_GLOBAL_FONT_INFO_SIGNATURE
);
1189 if (FontInfoMask
== NULL
) {
1190 if (CompareMem (GlobalFont
->FontInfo
, FontInfo
, GlobalFont
->FontInfoSize
) == 0) {
1191 if (GlobalFontInfo
!= NULL
) {
1192 *GlobalFontInfo
= GlobalFont
;
1198 // Check which options could be used to make a match.
1201 case EFI_FONT_INFO_ANY_FONT
:
1202 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
&&
1203 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1207 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
:
1208 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1212 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
:
1213 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1217 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_ANY_STYLE
:
1221 // If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to
1222 // remove some of the specified styles to meet the style requested.
1224 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
:
1225 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1226 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1228 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1229 VagueMatched1
= TRUE
;
1230 GlobalFontBackup1
= GlobalFont
;
1235 // If EFI_FONT_INFO_RESIZE is specified, then the sytem may attempt to
1236 // stretch or shrink a font to meet the size requested.
1238 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESIZE
:
1239 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1240 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1243 VagueMatched1
= TRUE
;
1244 GlobalFontBackup1
= GlobalFont
;
1248 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_RESIZE
:
1249 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1250 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1253 VagueMatched1
= TRUE
;
1254 GlobalFontBackup1
= GlobalFont
;
1256 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1257 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1258 VagueMatched1
= TRUE
;
1259 GlobalFontBackup1
= GlobalFont
;
1261 VagueMatched2
= TRUE
;
1262 GlobalFontBackup2
= GlobalFont
;
1266 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1267 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1270 VagueMatched1
= TRUE
;
1271 GlobalFontBackup1
= GlobalFont
;
1274 case EFI_FONT_INFO_ANY_FONT
| EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1275 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1277 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1278 VagueMatched1
= TRUE
;
1279 GlobalFontBackup1
= GlobalFont
;
1282 case EFI_FONT_INFO_ANY_STYLE
:
1284 GlobalFont
->FontInfo
->FontName
,
1286 StrSize (FontInfo
->FontName
)
1288 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1292 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_ANY_SIZE
:
1294 GlobalFont
->FontInfo
->FontName
,
1296 StrSize (FontInfo
->FontName
)
1301 case EFI_FONT_INFO_ANY_STYLE
| EFI_FONT_INFO_RESIZE
:
1303 GlobalFont
->FontInfo
->FontName
,
1305 StrSize (FontInfo
->FontName
)
1307 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1310 VagueMatched1
= TRUE
;
1311 GlobalFontBackup1
= GlobalFont
;
1315 case EFI_FONT_INFO_ANY_SIZE
:
1317 GlobalFont
->FontInfo
->FontName
,
1319 StrSize (FontInfo
->FontName
)
1321 GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1325 case EFI_FONT_INFO_ANY_SIZE
| EFI_FONT_INFO_RESTYLE
:
1327 GlobalFont
->FontInfo
->FontName
,
1329 StrSize (FontInfo
->FontName
)
1331 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1333 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1334 VagueMatched1
= TRUE
;
1335 GlobalFontBackup1
= GlobalFont
;
1339 case EFI_FONT_INFO_RESTYLE
:
1341 GlobalFont
->FontInfo
->FontName
,
1343 StrSize (FontInfo
->FontName
)
1345 GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1347 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1349 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1350 VagueMatched1
= TRUE
;
1351 GlobalFontBackup1
= GlobalFont
;
1355 case EFI_FONT_INFO_RESIZE
:
1357 GlobalFont
->FontInfo
->FontName
,
1359 StrSize (FontInfo
->FontName
)
1361 GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1363 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1366 VagueMatched1
= TRUE
;
1367 GlobalFontBackup1
= GlobalFont
;
1371 case EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_RESTYLE
:
1373 GlobalFont
->FontInfo
->FontName
,
1375 StrSize (FontInfo
->FontName
)
1377 if (GlobalFont
->FontInfo
->FontStyle
== FontInfo
->FontStyle
) {
1378 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1381 VagueMatched1
= TRUE
;
1382 GlobalFontBackup1
= GlobalFont
;
1384 } else if ((GlobalFont
->FontInfo
->FontStyle
& FontInfo
->FontStyle
) == FontInfo
->FontStyle
) {
1385 if (GlobalFont
->FontInfo
->FontSize
== FontInfo
->FontSize
) {
1386 VagueMatched1
= TRUE
;
1387 GlobalFontBackup1
= GlobalFont
;
1389 VagueMatched2
= TRUE
;
1390 GlobalFontBackup2
= GlobalFont
;
1400 if (GlobalFontInfo
!= NULL
) {
1401 *GlobalFontInfo
= GlobalFont
;
1408 if (VagueMatched1
) {
1409 if (GlobalFontInfo
!= NULL
) {
1410 *GlobalFontInfo
= GlobalFontBackup1
;
1413 } else if (VagueMatched2
) {
1414 if (GlobalFontInfo
!= NULL
) {
1415 *GlobalFontInfo
= GlobalFontBackup2
;
1425 Check whether the unicode represents a line break or not.
1427 This is a internal function. Please see Section 27.2.6 of the UEFI Specification
1428 for a description of the supported string format.
1430 @param Char Unicode character
1432 @retval 0 Yes, it forces a line break.
1433 @retval 1 Yes, it presents a line break opportunity
1434 @retval 2 Yes, it requires a line break happen before and after it.
1435 @retval -1 No, it is not a link break.
1445 // Mandatory line break characters, which force a line-break
1453 // Space characters, which is taken as a line-break opportunity
1469 // In-Word Break Opportunities
1474 // A space which is not a line-break opportunity
1479 // A hyphen which is not a line-break opportunity
1484 // Hyphen characters which describe line break opportunities after the character
1495 // A hyphen which describes line break opportunities before and after them, but not between a pair of them
1505 Renders a string to a bitmap or to the display.
1507 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
1508 @param Flags Describes how the string is to be drawn.
1509 @param String Points to the null-terminated string to be
1511 @param StringInfo Points to the string output information,
1512 including the color and font. If NULL, then the
1513 string will be output in the default system font
1515 @param Blt If this points to a non-NULL on entry, this
1516 points to the image, which is Width pixels wide
1517 and Height pixels high. The string will be drawn
1519 EFI_HII_OUT_FLAG_CLIP is implied. If this points
1520 to a NULL on entry, then a buffer
1521 will be allocated to hold the generated image and
1522 the pointer updated on exit. It is the caller's
1523 responsibility to free this buffer.
1524 @param BltX Specifies the offset from the left and top edge
1525 of the image of the first character cell in the
1527 @param BltY Specifies the offset from the left and top edge
1528 of the image of the first character cell in the
1530 @param RowInfoArray If this is non-NULL on entry, then on exit, this
1531 will point to an allocated buffer containing
1532 row information and RowInfoArraySize will be
1533 updated to contain the number of elements.
1534 This array describes the characters which were at
1535 least partially drawn and the heights of the
1536 rows. It is the caller's responsibility to free
1538 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
1539 contains the number of elements in RowInfoArray.
1540 @param ColumnInfoArray If this is non-NULL, then on return it will be
1541 filled with the horizontal offset for each
1542 character in the string on the row where it is
1543 displayed. Non-printing characters will have
1544 the offset ~0. The caller is responsible to
1545 allocate a buffer large enough so that there
1546 is one entry for each character in the string,
1547 not including the null-terminator. It is possible
1548 when character display is normalized that some
1549 character cells overlap.
1551 @retval EFI_SUCCESS The string was successfully rendered.
1552 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
1553 RowInfoArray or Blt.
1554 @retval EFI_INVALID_PARAMETER The String or Blt was NULL.
1555 @retval EFI_INVALID_PARAMETER Flags were invalid combination..
1561 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
1562 IN EFI_HII_OUT_FLAGS Flags
,
1563 IN CONST EFI_STRING String
,
1564 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
1565 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
1568 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
1569 OUT UINTN
*RowInfoArraySize OPTIONAL
,
1570 OUT UINTN
*ColumnInfoArray OPTIONAL
1574 HII_DATABASE_PRIVATE_DATA
*Private
;
1576 EFI_HII_GLYPH_INFO
*Cell
;
1578 EFI_IMAGE_OUTPUT
*Image
;
1579 EFI_STRING StringPtr
;
1580 EFI_STRING StringTmp
;
1581 EFI_HII_ROW_INFO
*RowInfo
;
1585 UINTN LastLineHeight
;
1586 UINTN BaseLineOffset
;
1592 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
1593 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
1594 EFI_FONT_HANDLE FontHandle
;
1595 EFI_STRING StringIn
;
1596 EFI_STRING StringIn2
;
1599 EFI_FONT_INFO
*FontInfo
;
1600 BOOLEAN SysFontFlag
;
1601 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1602 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1603 BOOLEAN Transparent
;
1604 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
1605 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BufferPtr
;
1609 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*RowBufferPtr
;
1610 HII_GLOBAL_FONT_INFO
*GlobalFont
;
1613 // Check incoming parameters.
1616 if (This
== NULL
|| String
== NULL
|| Blt
== NULL
) {
1617 return EFI_INVALID_PARAMETER
;
1621 // These two flag cannot be used if Blt is NULL upon entry.
1623 if ((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
) {
1624 return EFI_INVALID_PARAMETER
;
1626 if ((Flags
& EFI_HII_OUT_FLAG_CLIP
) == EFI_HII_OUT_FLAG_CLIP
) {
1627 return EFI_INVALID_PARAMETER
;
1631 // These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
1633 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_X
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) {
1634 return EFI_INVALID_PARAMETER
;
1636 if ((Flags
& (EFI_HII_OUT_FLAG_CLIP
| EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) {
1637 return EFI_INVALID_PARAMETER
;
1640 // This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
1642 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
)) {
1643 return EFI_INVALID_PARAMETER
;
1648 // Create a new bitmap and draw the string onto this image.
1650 Image
= AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1651 if (Image
== NULL
) {
1652 return EFI_OUT_OF_RESOURCES
;
1655 Image
->Height
= 600;
1656 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
*sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1657 if (Image
->Image
.Bitmap
== NULL
) {
1659 return EFI_OUT_OF_RESOURCES
;
1663 // Other flags are not permitted when Blt is NULL.
1665 Flags
&= EFI_HII_OUT_FLAG_WRAP
| EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_IGNORE_LINE_BREAK
;
1669 StrLength
= StrLen(String
);
1670 GlyphBuf
= (UINT8
**) AllocateZeroPool (StrLength
* sizeof (UINT8
*));
1671 ASSERT (GlyphBuf
!= NULL
);
1672 Cell
= (EFI_HII_GLYPH_INFO
*) AllocateZeroPool (StrLength
* sizeof (EFI_HII_GLYPH_INFO
));
1673 ASSERT (Cell
!= NULL
);
1674 Attributes
= (UINT8
*) AllocateZeroPool (StrLength
* sizeof (UINT8
));
1675 ASSERT (Attributes
!= NULL
);
1678 Status
= EFI_SUCCESS
;
1680 SystemDefault
= NULL
;
1684 // Calculate the string output information, including specified color and font .
1685 // If StringInfo does not points to system font info, it must indicate an existing
1688 StringInfoOut
= NULL
;
1690 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
1691 SysFontFlag
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &SystemDefault
, NULL
);
1694 ASSERT (SystemDefault
!= NULL
);
1696 Height
= SystemDefault
->FontInfo
.FontSize
;
1697 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1698 Foreground
= SystemDefault
->ForegroundColor
;
1699 Background
= SystemDefault
->BackgroundColor
;
1703 // StringInfo must not be NULL if it is not system info.
1705 ASSERT (StringInfo
!= NULL
);
1706 Status
= HiiGetFontInfo (This
, &FontHandle
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &StringInfoOut
, NULL
);
1707 if (Status
== EFI_NOT_FOUND
) {
1709 // The specified EFI_FONT_DISPLAY_INFO does not exist in current database.
1710 // Use the system font instead. Still use the color specified by StringInfo.
1714 Height
= SystemDefault
->FontInfo
.FontSize
;
1715 BaseLine
= SystemDefault
->FontInfo
.FontSize
;
1716 Foreground
= ((EFI_FONT_DISPLAY_INFO
*) StringInfo
)->ForegroundColor
;
1717 Background
= ((EFI_FONT_DISPLAY_INFO
*) StringInfo
)->BackgroundColor
;
1719 } else if (Status
== EFI_SUCCESS
) {
1720 FontInfo
= &StringInfoOut
->FontInfo
;
1721 IsFontInfoExisted (Private
, FontInfo
, NULL
, NULL
, &GlobalFont
);
1722 Height
= GlobalFont
->FontPackage
->Height
;
1723 BaseLine
= GlobalFont
->FontPackage
->BaseLine
;
1724 Foreground
= StringInfoOut
->ForegroundColor
;
1725 Background
= StringInfoOut
->BackgroundColor
;
1732 // Use the maxinum height of font as the base line.
1733 // And, use the maxinum height as line height.
1735 LineHeight
= Height
;
1736 LastLineHeight
= Height
;
1737 BaseLineOffset
= Height
- BaseLine
;
1740 // Parse the string to be displayed to drop some ignored characters.
1746 // Ignore line-break characters only. Hyphens or dash character will be displayed
1747 // without line-break opportunity.
1749 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == EFI_HII_IGNORE_LINE_BREAK
) {
1750 StringIn
= AllocateZeroPool (StrSize (StringPtr
));
1751 if (StringIn
== NULL
) {
1752 Status
= EFI_OUT_OF_RESOURCES
;
1755 StringTmp
= StringIn
;
1756 while (*StringPtr
!= 0) {
1757 if (IsLineBreak (*StringPtr
) == 0) {
1760 *StringTmp
++ = *StringPtr
++;
1764 StringPtr
= StringIn
;
1767 // If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs
1768 // are not drawn. Otherwise they are replaced wth Unicode character 0xFFFD.
1770 StringIn2
= AllocateZeroPool (StrSize (StringPtr
));
1771 if (StringIn2
== NULL
) {
1772 Status
= EFI_OUT_OF_RESOURCES
;
1776 StringTmp
= StringIn2
;
1777 StrLength
= StrLen(StringPtr
);
1778 while (*StringPtr
!= 0 && Index
< StrLength
) {
1779 if (IsLineBreak (*StringPtr
) == 0) {
1780 *StringTmp
++ = *StringPtr
++;
1785 Status
= GetGlyphBuffer (Private
, *StringPtr
, FontInfo
, &GlyphBuf
[Index
], &Cell
[Index
], &Attributes
[Index
]);
1786 if (Status
== EFI_NOT_FOUND
) {
1787 if ((Flags
& EFI_HII_IGNORE_IF_NO_GLYPH
) == EFI_HII_IGNORE_IF_NO_GLYPH
) {
1788 GlyphBuf
[Index
] = NULL
;
1789 ZeroMem (&Cell
[Index
], sizeof (Cell
[Index
]));
1790 Status
= EFI_SUCCESS
;
1793 // Unicode 0xFFFD must exist in current hii database if this flag is not set.
1795 Status
= GetGlyphBuffer (
1797 REPLACE_UNKNOWN_GLYPH
,
1803 if (EFI_ERROR (Status
)) {
1804 Status
= EFI_INVALID_PARAMETER
;
1809 if (EFI_ERROR (Status
)) {
1813 *StringTmp
++ = *StringPtr
++;
1817 StringPtr
= StringIn2
;
1820 // Draw the string according to the specified EFI_HII_OUT_FLAGS and Blt.
1821 // If Blt is not NULL, then EFI_HII_OUT_FLAG_CLIP is implied, render this string
1822 // to an existing image (bitmap or screen depending on flags) pointed by "*Blt".
1823 // Otherwise render this string to a new allocated image and output it.
1826 BufferPtr
= Image
->Image
.Bitmap
+ Image
->Width
* BltY
+ BltX
;
1827 if (Image
->Height
< BltY
) {
1829 // the top edge of the image should be in Image resolution scope.
1831 Status
= EFI_INVALID_PARAMETER
;
1834 MaxRowNum
= (UINT16
) ((Image
->Height
- BltY
) / Height
);
1835 if ((Image
->Height
- BltY
) % Height
!= 0) {
1836 LastLineHeight
= (Image
->Height
- BltY
) % Height
;
1840 RowInfo
= (EFI_HII_ROW_INFO
*) AllocateZeroPool (MaxRowNum
* sizeof (EFI_HII_ROW_INFO
));
1841 if (RowInfo
== NULL
) {
1842 Status
= EFI_OUT_OF_RESOURCES
;
1847 // Format the glyph buffer according to flags.
1849 Transparent
= (BOOLEAN
) ((Flags
& EFI_HII_OUT_FLAG_TRANSPARENT
) == EFI_HII_OUT_FLAG_TRANSPARENT
? TRUE
: FALSE
);
1851 for (RowIndex
= 0, Index
= 0; RowIndex
< MaxRowNum
&& StringPtr
[Index
] != 0; ) {
1856 // Clip the final row if the row's bottom-most on pixel cannot fit when
1857 // EFI_HII_OUT_FLAG_CLEAN_Y is set.
1859 if (RowIndex
== MaxRowNum
- 1) {
1860 if ((Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y
&& LastLineHeight
< LineHeight
) {
1862 // Don't draw at all if the row's bottom-most on pixel cannot fit.
1866 LineHeight
= LastLineHeight
;
1870 // Calculate how many characters there are in a row.
1872 RowInfo
[RowIndex
].StartIndex
= Index
;
1874 while (LineWidth
+ BltX
< Image
->Width
&& StringPtr
[Index
] != 0) {
1875 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0 &&
1876 IsLineBreak (StringPtr
[Index
]) == 0) {
1878 // It forces a line break that ends this row.
1886 // If the glyph of the character is existing, then accumulate the actual printed width
1888 LineWidth
+= (UINTN
) Cell
[Index
].AdvanceX
;
1894 // Record index of next char.
1898 // Return to the previous char.
1901 if (LineBreak
&& Index
> 0 ) {
1903 // Return the previous non line break char.
1909 // If this character is the last character of a row, we need not
1910 // draw its (AdvanceX - Width - OffsetX) for next character.
1912 LineWidth
-= (UINTN
) (Cell
[Index
].AdvanceX
- Cell
[Index
].Width
- Cell
[Index
].OffsetX
);
1915 // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
1917 if (LineWidth
+ BltX
<= Image
->Width
||
1918 (LineWidth
+ BltX
> Image
->Width
&& (Flags
& EFI_HII_OUT_FLAG_CLIP_CLEAN_X
) == 0)) {
1920 // Record right-most character in RowInfo even if it is partially displayed.
1922 RowInfo
[RowIndex
].EndIndex
= Index
;
1923 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
1924 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
1925 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
1928 // When EFI_HII_OUT_FLAG_CLEAN_X is set, it will not draw a character
1929 // if its right-most on pixel cannot fit.
1931 if (Index
> RowInfo
[RowIndex
].StartIndex
) {
1933 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
1935 LineWidth
-= (UINTN
) (Cell
[Index
].Width
+ Cell
[Index
].OffsetX
);
1936 LineWidth
-= (UINTN
) (Cell
[Index
- 1].AdvanceX
- Cell
[Index
- 1].Width
- Cell
[Index
- 1].OffsetX
);
1937 RowInfo
[RowIndex
].EndIndex
= Index
- 1;
1938 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
1939 RowInfo
[RowIndex
].LineHeight
= LineHeight
;
1940 RowInfo
[RowIndex
].BaselineOffset
= BaseLineOffset
;
1943 // There is no enough column to draw any character, so set current line width to zero.
1944 // And go to draw Next line if LineBreak is set.
1946 RowInfo
[RowIndex
].LineWidth
= 0;
1952 // EFI_HII_OUT_FLAG_WRAP will wrap the text at the right-most line-break
1953 // opportunity prior to a character whose right-most extent would exceed Width.
1954 // Search the right-most line-break opportunity here.
1956 if ((Flags
& EFI_HII_OUT_FLAG_WRAP
) == EFI_HII_OUT_FLAG_WRAP
&&
1957 (RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
|| StringPtr
[NextIndex
] != 0) &&
1959 if ((Flags
& EFI_HII_IGNORE_LINE_BREAK
) == 0) {
1960 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
1961 for (Index1
= RowInfo
[RowIndex
].EndIndex
; Index1
>= RowInfo
[RowIndex
].StartIndex
; Index1
--) {
1962 if (Index1
== RowInfo
[RowIndex
].EndIndex
) {
1963 LineWidth
-= (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
1965 LineWidth
-= Cell
[Index1
].AdvanceX
;
1967 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
1969 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
1970 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
1973 // relocate to the character after the right-most line break opportunity of this line
1975 NextIndex
= Index1
+ 1;
1979 // If don't find a line break opportunity from EndIndex to StartIndex,
1982 if (Index1
== RowInfo
[RowIndex
].StartIndex
)
1987 // Update LineWidth to the real width
1989 if (IsLineBreak (StringPtr
[Index1
]) > 0) {
1990 if (Index1
== RowInfo
[RowIndex
].StartIndex
) {
1993 LineWidth
-= (UINTN
) (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
1995 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
1999 // If no line-break opportunity can be found, then the text will
2000 // behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.
2003 LineWidth
= RowInfo
[RowIndex
].LineWidth
;
2004 Index1
= RowInfo
[RowIndex
].EndIndex
;
2005 if (LineWidth
+ BltX
> Image
->Width
) {
2006 if (Index1
> RowInfo
[RowIndex
].StartIndex
) {
2008 // Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
2010 LineWidth
-= (UINTN
) (Cell
[Index1
].Width
+ Cell
[Index1
].OffsetX
);
2011 LineWidth
-= (UINTN
) (Cell
[Index1
- 1].AdvanceX
- Cell
[Index1
- 1].Width
- Cell
[Index1
- 1].OffsetX
);
2012 RowInfo
[RowIndex
].EndIndex
= Index1
- 1;
2013 RowInfo
[RowIndex
].LineWidth
= LineWidth
;
2016 // There is no enough column to draw any character, so set current line width to zero.
2017 // And go to draw Next line if LineBreak is set.
2019 RowInfo
[RowIndex
].LineWidth
= 0;
2027 // LineWidth can't exceed Image width.
2029 if (RowInfo
[RowIndex
].LineWidth
+ BltX
> Image
->Width
) {
2030 RowInfo
[RowIndex
].LineWidth
= Image
->Width
- BltX
;
2034 // Draw it to screen or existing bitmap depending on whether
2035 // EFI_HII_DIRECT_TO_SCREEN is set.
2038 if ((Flags
& EFI_HII_DIRECT_TO_SCREEN
) == EFI_HII_DIRECT_TO_SCREEN
) {
2040 if (RowInfo
[RowIndex
].LineWidth
!= 0) {
2041 BltBuffer
= AllocateZeroPool (RowInfo
[RowIndex
].LineWidth
* RowInfo
[RowIndex
].LineHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2042 if (BltBuffer
== NULL
) {
2043 Status
= EFI_OUT_OF_RESOURCES
;
2047 // Set BufferPtr to Origin by adding baseline to the starting position.
2049 BufferPtr
= BltBuffer
+ BaseLine
* RowInfo
[RowIndex
].LineWidth
;
2051 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2052 if (RowInfo
[RowIndex
].LineWidth
> 0 && RowInfo
[RowIndex
].LineWidth
> LineOffset
) {
2054 // Only BLT these character which have corrsponding glyph in font basebase.
2060 (UINT16
) RowInfo
[RowIndex
].LineWidth
,
2062 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2063 RowInfo
[RowIndex
].LineHeight
,
2070 if (ColumnInfoArray
!= NULL
) {
2071 if ((GlyphBuf
[Index1
] == NULL
&& Cell
[Index1
].AdvanceX
== 0)
2072 || RowInfo
[RowIndex
].LineWidth
== 0) {
2073 *ColumnInfoArray
= (UINTN
) ~0;
2075 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2079 LineOffset
+= Cell
[Index1
].AdvanceX
;
2082 if (BltBuffer
!= NULL
) {
2083 Status
= Image
->Image
.Screen
->Blt (
2084 Image
->Image
.Screen
,
2086 EfiBltBufferToVideo
,
2091 RowInfo
[RowIndex
].LineWidth
,
2092 RowInfo
[RowIndex
].LineHeight
,
2095 if (EFI_ERROR (Status
)) {
2096 FreePool (BltBuffer
);
2100 FreePool (BltBuffer
);
2104 // Save the starting position for calculate the starting postition of next row.
2106 RowBufferPtr
= BufferPtr
;
2108 // Set BufferPtr to Origin by adding baseline to the starting position.
2110 BufferPtr
= BufferPtr
+ BaseLine
* Image
->Width
;
2111 for (Index1
= RowInfo
[RowIndex
].StartIndex
; Index1
<= RowInfo
[RowIndex
].EndIndex
; Index1
++) {
2112 if (RowInfo
[RowIndex
].LineWidth
> 0 && RowInfo
[RowIndex
].LineWidth
> LineOffset
) {
2114 // Only BLT these character which have corrsponding glyph in font basebase.
2122 RowInfo
[RowIndex
].LineWidth
- LineOffset
,
2123 RowInfo
[RowIndex
].LineHeight
,
2130 if (ColumnInfoArray
!= NULL
) {
2131 if ((GlyphBuf
[Index1
] == NULL
&& Cell
[Index1
].AdvanceX
== 0)
2132 || RowInfo
[RowIndex
].LineWidth
== 0) {
2133 *ColumnInfoArray
= (UINTN
) ~0;
2135 *ColumnInfoArray
= LineOffset
+ Cell
[Index1
].OffsetX
+ BltX
;
2139 LineOffset
+= Cell
[Index1
].AdvanceX
;
2143 // Jump to starting position of next row.
2145 if (RowIndex
== 0) {
2146 BufferPtr
= RowBufferPtr
- BltX
+ LineHeight
* Image
->Width
;
2148 BufferPtr
= RowBufferPtr
+ LineHeight
* Image
->Width
;
2154 // Recalculate the start point of X/Y axis to draw multi-lines with the order of top-to-down
2157 BltY
+= RowInfo
[RowIndex
].LineHeight
;
2164 // If there is not a mandatory line break or line break opportunity, only render one line to image
2171 // Write output parameters.
2173 RowInfoSize
= RowIndex
* sizeof (EFI_HII_ROW_INFO
);
2174 if (RowInfoArray
!= NULL
) {
2175 if (RowInfoSize
> 0) {
2176 *RowInfoArray
= AllocateZeroPool (RowInfoSize
);
2177 if (*RowInfoArray
== NULL
) {
2178 Status
= EFI_OUT_OF_RESOURCES
;
2181 CopyMem (*RowInfoArray
, RowInfo
, RowInfoSize
);
2183 *RowInfoArray
= NULL
;
2186 if (RowInfoArraySize
!= NULL
) {
2187 *RowInfoArraySize
= RowIndex
;
2190 Status
= EFI_SUCCESS
;
2194 for (Index
= 0; Index
< StrLength
; Index
++) {
2195 if (GlyphBuf
[Index
] != NULL
) {
2196 FreePool (GlyphBuf
[Index
]);
2199 if (StringIn
!= NULL
) {
2200 FreePool (StringIn
);
2202 if (StringIn2
!= NULL
) {
2203 FreePool (StringIn2
);
2205 if (StringInfoOut
!= NULL
) {
2206 FreePool (StringInfoOut
);
2208 if (RowInfo
!= NULL
) {
2211 if (SystemDefault
!= NULL
) {
2212 FreePool (SystemDefault
);
2214 if (GlyphBuf
!= NULL
) {
2215 FreePool (GlyphBuf
);
2220 if (Attributes
!= NULL
) {
2221 FreePool (Attributes
);
2229 Render a string to a bitmap or the screen containing the contents of the specified string.
2231 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2232 @param Flags Describes how the string is to be drawn.
2233 @param PackageList The package list in the HII database to search
2234 for the specified string.
2235 @param StringId The string's id, which is unique within
2237 @param Language Points to the language for the retrieved string.
2238 If NULL, then the current system language is
2240 @param StringInfo Points to the string output information,
2241 including the color and font. If NULL, then the
2242 string will be output in the default system font
2244 @param Blt If this points to a non-NULL on entry, this
2245 points to the image, which is Width pixels wide
2246 and Height pixels high. The string will be drawn
2248 EFI_HII_OUT_FLAG_CLIP is implied. If this points
2249 to a NULL on entry, then a buffer
2250 will be allocated to hold the generated image and
2251 the pointer updated on exit. It is the caller's
2252 responsibility to free this buffer.
2253 @param BltX Specifies the offset from the left and top edge
2254 of the image of the first character cell in the
2256 @param BltY Specifies the offset from the left and top edge
2257 of the image of the first character cell in the
2259 @param RowInfoArray If this is non-NULL on entry, then on exit, this
2260 will point to an allocated buffer containing
2261 row information and RowInfoArraySize will be
2262 updated to contain the number of elements.
2263 This array describes the characters which were at
2264 least partially drawn and the heights of the
2265 rows. It is the caller's responsibility to free
2267 @param RowInfoArraySize If this is non-NULL on entry, then on exit it
2268 contains the number of elements in RowInfoArray.
2269 @param ColumnInfoArray If this is non-NULL, then on return it will be
2270 filled with the horizontal offset for each
2271 character in the string on the row where it is
2272 displayed. Non-printing characters will have
2273 the offset ~0. The caller is responsible to
2274 allocate a buffer large enough so that there
2275 is one entry for each character in the string,
2276 not including the null-terminator. It is possible
2277 when character display is normalized that some
2278 character cells overlap.
2280 @retval EFI_SUCCESS The string was successfully rendered.
2281 @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
2282 RowInfoArray or Blt.
2283 @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
2284 @retval EFI_INVALID_PARAMETER Flags were invalid combination.
2285 @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the stringid is not
2286 in the specified PackageList.
2291 HiiStringIdToImage (
2292 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2293 IN EFI_HII_OUT_FLAGS Flags
,
2294 IN EFI_HII_HANDLE PackageList
,
2295 IN EFI_STRING_ID StringId
,
2296 IN CONST CHAR8
* Language
,
2297 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo OPTIONAL
,
2298 IN OUT EFI_IMAGE_OUTPUT
**Blt
,
2301 OUT EFI_HII_ROW_INFO
**RowInfoArray OPTIONAL
,
2302 OUT UINTN
*RowInfoArraySize OPTIONAL
,
2303 OUT UINTN
*ColumnInfoArray OPTIONAL
2307 HII_DATABASE_PRIVATE_DATA
*Private
;
2308 EFI_HII_STRING_PROTOCOL
*HiiString
;
2312 EFI_FONT_INFO
*StringFontInfo
;
2313 EFI_FONT_DISPLAY_INFO
*NewStringInfo
;
2314 CHAR8 TempSupportedLanguages
;
2315 CHAR8
*SupportedLanguages
;
2316 UINTN SupportedLanguagesSize
;
2317 CHAR8
*CurrentLanguage
;
2318 CHAR8
*BestLanguage
;
2320 if (This
== NULL
|| PackageList
== NULL
|| Blt
== NULL
|| PackageList
== NULL
) {
2321 return EFI_INVALID_PARAMETER
;
2324 if (!IsHiiHandleValid (PackageList
)) {
2325 return EFI_NOT_FOUND
;
2329 // Initialize string pointers to be NULL
2331 SupportedLanguages
= NULL
;
2332 CurrentLanguage
= NULL
;
2333 BestLanguage
= NULL
;
2335 StringFontInfo
= NULL
;
2336 NewStringInfo
= NULL
;
2339 // Get the string to be displayed.
2341 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2342 HiiString
= &Private
->HiiString
;
2345 // Get the size of supported language.
2347 SupportedLanguagesSize
= 0;
2348 Status
= HiiString
->GetLanguages (
2351 &TempSupportedLanguages
,
2352 &SupportedLanguagesSize
2354 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
2358 SupportedLanguages
= AllocatePool (SupportedLanguagesSize
);
2359 if (SupportedLanguages
== NULL
) {
2360 return EFI_OUT_OF_RESOURCES
;
2363 Status
= HiiString
->GetLanguages (
2367 &SupportedLanguagesSize
2369 if (EFI_ERROR (Status
)) {
2373 if (Language
== NULL
) {
2376 GetEfiGlobalVariable2 (L
"PlatformLang", (VOID
**)&CurrentLanguage
, NULL
);
2377 BestLanguage
= GetBestLanguage (
2381 (CurrentLanguage
== NULL
) ? CurrentLanguage
: "",
2382 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
2385 if (BestLanguage
== NULL
) {
2386 Status
= EFI_NOT_FOUND
;
2390 StringSize
= MAX_STRING_LENGTH
;
2391 String
= (EFI_STRING
) AllocateZeroPool (StringSize
);
2392 if (String
== NULL
) {
2393 Status
= EFI_OUT_OF_RESOURCES
;
2397 Status
= HiiString
->GetString (
2406 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2408 String
= (EFI_STRING
) AllocateZeroPool (StringSize
);
2409 if (String
== NULL
) {
2410 Status
= EFI_OUT_OF_RESOURCES
;
2413 Status
= HiiString
->GetString (
2424 if (EFI_ERROR (Status
)) {
2429 // When StringInfo specifies that string will be output in the system default font and color,
2430 // use particular stringfontinfo described in string package instead if exists.
2431 // StringFontInfo equals NULL means system default font attaches with the string block.
2433 if (StringFontInfo
!= NULL
&& IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, NULL
, NULL
)) {
2434 FontLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (CHAR16
) + StrSize (StringFontInfo
->FontName
);
2435 NewStringInfo
= AllocateZeroPool (FontLen
);
2436 if (NewStringInfo
== NULL
) {
2437 Status
= EFI_OUT_OF_RESOURCES
;
2440 NewStringInfo
->FontInfoMask
= EFI_FONT_INFO_SYS_FORE_COLOR
| EFI_FONT_INFO_SYS_BACK_COLOR
;
2441 NewStringInfo
->FontInfo
.FontStyle
= StringFontInfo
->FontStyle
;
2442 NewStringInfo
->FontInfo
.FontSize
= StringFontInfo
->FontSize
;
2443 StrCpy (NewStringInfo
->FontInfo
.FontName
, StringFontInfo
->FontName
);
2445 Status
= HiiStringToImage (
2460 Status
= HiiStringToImage (
2474 if (SupportedLanguages
!= NULL
) {
2475 FreePool (SupportedLanguages
);
2477 if (CurrentLanguage
!= NULL
) {
2478 FreePool (CurrentLanguage
);
2480 if (BestLanguage
!= NULL
) {
2481 FreePool (BestLanguage
);
2483 if (String
!= NULL
) {
2486 if (StringFontInfo
!= NULL
) {
2487 FreePool (StringFontInfo
);
2489 if (NewStringInfo
!= NULL
) {
2490 FreePool (NewStringInfo
);
2498 Convert the glyph for a single character into a bitmap.
2500 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2501 @param Char Character to retrieve.
2502 @param StringInfo Points to the string font and color information
2503 or NULL if the string should use the default
2504 system font and color.
2505 @param Blt Thus must point to a NULL on entry. A buffer will
2506 be allocated to hold the output and the pointer
2507 updated on exit. It is the caller's
2508 responsibility to free this buffer.
2509 @param Baseline Number of pixels from the bottom of the bitmap to
2512 @retval EFI_SUCCESS Glyph bitmap created.
2513 @retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.
2514 @retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was replaced with the
2515 glyph for Unicode character 0xFFFD.
2516 @retval EFI_INVALID_PARAMETER Blt is NULL or *Blt is not NULL.
2522 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2524 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfo
,
2525 OUT EFI_IMAGE_OUTPUT
**Blt
,
2526 OUT UINTN
*Baseline OPTIONAL
2530 HII_DATABASE_PRIVATE_DATA
*Private
;
2531 EFI_IMAGE_OUTPUT
*Image
;
2533 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2534 EFI_FONT_DISPLAY_INFO
*StringInfoOut
;
2536 EFI_FONT_HANDLE FontHandle
;
2538 EFI_HII_GLYPH_INFO Cell
;
2539 EFI_FONT_INFO
*FontInfo
;
2541 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
2542 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
2543 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
2546 if (This
== NULL
|| Blt
== NULL
|| *Blt
!= NULL
) {
2547 return EFI_INVALID_PARAMETER
;
2550 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2554 SystemDefault
= NULL
;
2558 StringInfoOut
= NULL
;
2561 ZeroMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2562 ZeroMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2564 Default
= IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfo
, &SystemDefault
, NULL
);
2568 // Find out a EFI_FONT_DISPLAY_INFO which could display the character in
2569 // the specified color and font.
2571 String
= (EFI_STRING
) AllocateZeroPool (sizeof (CHAR16
) * 2);
2572 if (String
== NULL
) {
2573 Status
= EFI_OUT_OF_RESOURCES
;
2579 Status
= HiiGetFontInfo (This
, &FontHandle
, StringInfo
, &StringInfoOut
, String
);
2580 if (EFI_ERROR (Status
)) {
2583 ASSERT (StringInfoOut
!= NULL
);
2584 FontInfo
= &StringInfoOut
->FontInfo
;
2585 Foreground
= StringInfoOut
->ForegroundColor
;
2586 Background
= StringInfoOut
->BackgroundColor
;
2588 ASSERT (SystemDefault
!= NULL
);
2589 Foreground
= SystemDefault
->ForegroundColor
;
2590 Background
= SystemDefault
->BackgroundColor
;
2593 Status
= GetGlyphBuffer (Private
, Char
, FontInfo
, &GlyphBuffer
, &Cell
, &Attributes
);
2594 if (EFI_ERROR (Status
)) {
2598 Image
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
2599 if (Image
== NULL
) {
2600 Status
= EFI_OUT_OF_RESOURCES
;
2603 Image
->Width
= Cell
.Width
;
2604 Image
->Height
= Cell
.Height
;
2606 if (Image
->Width
* Image
->Height
> 0) {
2607 Image
->Image
.Bitmap
= AllocateZeroPool (Image
->Width
* Image
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
2608 if (Image
->Image
.Bitmap
== NULL
) {
2610 Status
= EFI_OUT_OF_RESOURCES
;
2615 // Set BaseLine to the char height.
2617 BaseLine
= (UINT16
) (Cell
.Height
+ Cell
.OffsetY
);
2619 // Set BltBuffer to the position of Origin.
2621 BltBuffer
= Image
->Image
.Bitmap
+ (Cell
.Height
+ Cell
.OffsetY
) * Image
->Width
- Cell
.OffsetX
;
2628 Cell
.Width
+ Cell
.OffsetX
,
2629 BaseLine
- Cell
.OffsetY
,
2638 if (Baseline
!= NULL
) {
2639 *Baseline
= Cell
.OffsetY
;
2642 Status
= EFI_SUCCESS
;
2646 if (Status
== EFI_NOT_FOUND
) {
2648 // Glyph is unknown and replaced with the glyph for unicode character 0xFFFD
2650 if (Char
!= REPLACE_UNKNOWN_GLYPH
) {
2651 Status
= HiiGetGlyph (This
, REPLACE_UNKNOWN_GLYPH
, StringInfo
, Blt
, Baseline
);
2652 if (!EFI_ERROR (Status
)) {
2653 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2656 Status
= EFI_WARN_UNKNOWN_GLYPH
;
2660 if (SystemDefault
!= NULL
) {
2661 FreePool (SystemDefault
);
2663 if (StringInfoOut
!= NULL
) {
2664 FreePool (StringInfoOut
);
2666 if (String
!= NULL
) {
2669 if (GlyphBuffer
!= NULL
) {
2670 FreePool (GlyphBuffer
);
2678 This function iterates through fonts which match the specified font, using
2679 the specified criteria. If String is non-NULL, then all of the characters in
2680 the string must exist in order for a candidate font to be returned.
2682 @param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
2683 @param FontHandle On entry, points to the font handle returned by a
2684 previous call to GetFontInfo() or NULL to start
2685 with the first font. On return, points to the
2686 returned font handle or points to NULL if there
2687 are no more matching fonts.
2688 @param StringInfoIn Upon entry, points to the font to return information
2689 about. If NULL, then the information about the system
2690 default font will be returned.
2691 @param StringInfoOut Upon return, contains the matching font's information.
2692 If NULL, then no information is returned. This buffer
2693 is allocated with a call to the Boot Service AllocatePool().
2694 It is the caller's responsibility to call the Boot
2695 Service FreePool() when the caller no longer requires
2696 the contents of StringInfoOut.
2697 @param String Points to the string which will be tested to
2698 determine if all characters are available. If
2699 NULL, then any font is acceptable.
2701 @retval EFI_SUCCESS Matching font returned successfully.
2702 @retval EFI_NOT_FOUND No matching font was found.
2703 @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
2704 @retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
2711 IN CONST EFI_HII_FONT_PROTOCOL
*This
,
2712 IN OUT EFI_FONT_HANDLE
*FontHandle
,
2713 IN CONST EFI_FONT_DISPLAY_INFO
*StringInfoIn
, OPTIONAL
2714 OUT EFI_FONT_DISPLAY_INFO
**StringInfoOut
,
2715 IN CONST EFI_STRING String OPTIONAL
2718 HII_DATABASE_PRIVATE_DATA
*Private
;
2720 EFI_FONT_DISPLAY_INFO
*SystemDefault
;
2721 EFI_FONT_DISPLAY_INFO InfoOut
;
2722 UINTN StringInfoOutLen
;
2723 EFI_FONT_INFO
*FontInfo
;
2724 HII_GLOBAL_FONT_INFO
*GlobalFont
;
2725 EFI_STRING StringIn
;
2726 EFI_FONT_HANDLE LocalFontHandle
;
2729 return EFI_INVALID_PARAMETER
;
2732 StringInfoOutLen
= 0;
2734 SystemDefault
= NULL
;
2735 LocalFontHandle
= NULL
;
2736 if (FontHandle
!= NULL
) {
2737 LocalFontHandle
= *FontHandle
;
2740 Private
= HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This
);
2743 // Already searched to the end of the whole list, return directly.
2745 if (LocalFontHandle
== &Private
->FontInfoList
) {
2746 LocalFontHandle
= NULL
;
2747 Status
= EFI_NOT_FOUND
;
2752 // Get default system display info, if StringInfoIn points to
2753 // system display info, return it directly.
2755 if (IsSystemFontInfo (Private
, (EFI_FONT_DISPLAY_INFO
*) StringInfoIn
, &SystemDefault
, &StringInfoOutLen
)) {
2757 // System font is the first node. When handle is not NULL, system font can not
2758 // be found any more.
2760 if (LocalFontHandle
== NULL
) {
2761 if (StringInfoOut
!= NULL
) {
2762 *StringInfoOut
= AllocateCopyPool (StringInfoOutLen
, SystemDefault
);
2763 if (*StringInfoOut
== NULL
) {
2764 Status
= EFI_OUT_OF_RESOURCES
;
2765 LocalFontHandle
= NULL
;
2770 LocalFontHandle
= Private
->FontInfoList
.ForwardLink
;
2771 Status
= EFI_SUCCESS
;
2774 LocalFontHandle
= NULL
;
2775 Status
= EFI_NOT_FOUND
;
2781 // StringInfoIn must not be NULL if it is not system default font info.
2783 ASSERT (StringInfoIn
!= NULL
);
2785 // Check the font information mask to make sure it is valid.
2787 if (((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ==
2788 (EFI_FONT_INFO_SYS_FONT
| EFI_FONT_INFO_ANY_FONT
)) ||
2789 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2790 (EFI_FONT_INFO_SYS_SIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2791 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2792 (EFI_FONT_INFO_SYS_STYLE
| EFI_FONT_INFO_ANY_STYLE
)) ||
2793 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ==
2794 (EFI_FONT_INFO_RESIZE
| EFI_FONT_INFO_ANY_SIZE
)) ||
2795 ((StringInfoIn
->FontInfoMask
& (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
)) ==
2796 (EFI_FONT_INFO_RESTYLE
| EFI_FONT_INFO_ANY_STYLE
))) {
2797 return EFI_INVALID_PARAMETER
;
2801 // Parse the font information mask to find a matching font.
2804 CopyMem (&InfoOut
, (EFI_FONT_DISPLAY_INFO
*) StringInfoIn
, sizeof (EFI_FONT_DISPLAY_INFO
));
2806 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FONT
) == EFI_FONT_INFO_SYS_FONT
) {
2807 Status
= SaveFontName (SystemDefault
->FontInfo
.FontName
, &FontInfo
);
2809 Status
= SaveFontName (((EFI_FONT_DISPLAY_INFO
*) StringInfoIn
)->FontInfo
.FontName
, &FontInfo
);
2811 if (EFI_ERROR (Status
)) {
2815 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_SIZE
) == EFI_FONT_INFO_SYS_SIZE
) {
2816 InfoOut
.FontInfo
.FontSize
= SystemDefault
->FontInfo
.FontSize
;
2818 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_STYLE
) == EFI_FONT_INFO_SYS_STYLE
) {
2819 InfoOut
.FontInfo
.FontStyle
= SystemDefault
->FontInfo
.FontStyle
;
2821 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_FORE_COLOR
) == EFI_FONT_INFO_SYS_FORE_COLOR
) {
2822 InfoOut
.ForegroundColor
= SystemDefault
->ForegroundColor
;
2824 if ((StringInfoIn
->FontInfoMask
& EFI_FONT_INFO_SYS_BACK_COLOR
) == EFI_FONT_INFO_SYS_BACK_COLOR
) {
2825 InfoOut
.BackgroundColor
= SystemDefault
->BackgroundColor
;
2828 ASSERT (FontInfo
!= NULL
);
2829 FontInfo
->FontSize
= InfoOut
.FontInfo
.FontSize
;
2830 FontInfo
->FontStyle
= InfoOut
.FontInfo
.FontStyle
;
2832 if (IsFontInfoExisted (Private
, FontInfo
, &InfoOut
.FontInfoMask
, LocalFontHandle
, &GlobalFont
)) {
2834 // Test to guarantee all characters are available in the found font.
2836 if (String
!= NULL
) {
2838 while (*StringIn
!= 0) {
2839 Status
= FindGlyphBlock (GlobalFont
->FontPackage
, *StringIn
, NULL
, NULL
, NULL
);
2840 if (EFI_ERROR (Status
)) {
2841 LocalFontHandle
= NULL
;
2848 // Write to output parameter
2850 if (StringInfoOut
!= NULL
) {
2851 StringInfoOutLen
= sizeof (EFI_FONT_DISPLAY_INFO
) - sizeof (EFI_FONT_INFO
) + GlobalFont
->FontInfoSize
;
2852 *StringInfoOut
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (StringInfoOutLen
);
2853 if (*StringInfoOut
== NULL
) {
2854 Status
= EFI_OUT_OF_RESOURCES
;
2855 LocalFontHandle
= NULL
;
2859 CopyMem (*StringInfoOut
, &InfoOut
, sizeof (EFI_FONT_DISPLAY_INFO
));
2860 CopyMem (&(*StringInfoOut
)->FontInfo
, GlobalFont
->FontInfo
, GlobalFont
->FontInfoSize
);
2863 LocalFontHandle
= GlobalFont
->Entry
.ForwardLink
;
2864 Status
= EFI_SUCCESS
;
2868 Status
= EFI_NOT_FOUND
;
2872 if (FontHandle
!= NULL
) {
2873 *FontHandle
= LocalFontHandle
;
2876 if (SystemDefault
!= NULL
) {
2877 FreePool (SystemDefault
);
2879 if (FontInfo
!= NULL
) {
2880 FreePool (FontInfo
);