2 This file contains the Glyph related function.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "HiiDatabase.h"
18 EFI_NARROW_GLYPH mNarrowGlyphBuffer
= {0, 0, {0}};
20 BOOLEAN mSysFontColorCached
= FALSE
;
21 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor
= {0};
25 This function is only called by Graphics Console module and GraphicsLib.
26 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
27 complying to UEFI HII.
29 This function will ASSERT and return EFI_UNSUPPORTED.
34 @param GlyphBuffer N.A.
36 @param InternalStatus N.A.
38 @return EFI_UNSUPPORTED N.A.
44 IN EFI_HII_PROTOCOL
*This
,
47 OUT UINT8
**GlyphBuffer
,
49 IN OUT UINT32
*InternalStatus
53 EFI_IMAGE_OUTPUT
*Blt
;
54 EFI_FONT_DISPLAY_INFO
*FontInfo
;
59 if (!mSysFontColorCached
) {
61 // Cache the system font's foreground color.
63 Status
= mHiiFontProtocol
->GetFontInfo (
71 if (!EFI_ERROR (Status
)) {
72 ASSERT (StrCmp (FontInfo
->FontInfo
.FontName
, L
"sysdefault") == 0);
73 mSysFGColor
= FontInfo
->ForegroundColor
;
76 mSysFontColorCached
= TRUE
;
82 Status
= mHiiFontProtocol
->GetGlyph (
90 if (!EFI_ERROR (Status
)) {
92 // For simplicity, we only handle Narrow Glyph.
94 ASSERT (Blt
->Height
== EFI_GLYPH_HEIGHT
);
95 ASSERT (Blt
->Width
== EFI_GLYPH_WIDTH
);
97 if (Blt
->Height
== EFI_GLYPH_HEIGHT
&& Blt
->Width
== EFI_GLYPH_WIDTH
) {
99 ZeroMem (&mNarrowGlyphBuffer
, sizeof (mNarrowGlyphBuffer
));
100 mNarrowGlyphBuffer
.UnicodeWeight
= *Source
;
101 for (Ypos
= 0; Ypos
< EFI_GLYPH_HEIGHT
; Ypos
++) {
102 for (Xpos
= 0; Xpos
< EFI_GLYPH_WIDTH
; Xpos
++) {
103 if (CompareMem (&Blt
->Image
.Bitmap
[Ypos
* EFI_GLYPH_WIDTH
+ Xpos
], &mSysFGColor
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)) == 0) {
104 mNarrowGlyphBuffer
.GlyphCol1
[Ypos
] |= 1 << (EFI_GLYPH_WIDTH
- 1 - Xpos
);
109 *GlyphBuffer
= (UINT8
*) &mNarrowGlyphBuffer
;
110 *BitWidth
= EFI_GLYPH_WIDTH
;
113 Status
= EFI_NOT_FOUND
;
118 if (EFI_ERROR (Status
)) {
125 This function is only called by Graphics Console module and GraphicsLib.
126 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
127 complying to UEFI HII.
129 This function will ASSERT and return EFI_UNSUPPORTED.
132 @param GlyphBuffer N.A.
133 @param Foreground N.A.
134 @param Background N.A.
138 @param BltBuffer N.A.
140 @return EFI_UNSUPPORTED N.A.
146 IN EFI_HII_PROTOCOL
*This
,
147 IN UINT8
*GlyphBuffer
,
148 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
149 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
153 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
160 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
162 for (Y
= 0; Y
< Height
; Y
++) {
163 for (X
= 0; X
< Width
; X
++) {
164 if ((((EFI_NARROW_GLYPH
*) GlyphBuffer
)->GlyphCol1
[Y
] & (1 << X
)) != 0) {
165 BltBuffer
[Y
* Width
* Count
+ (Width
- X
- 1)] = Foreground
;
167 BltBuffer
[Y
* Width
* Count
+ (Width
- X
- 1)] = Background
;