3 This file contains the Glyph related function.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. 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_NARROW_GLYPH mNarrowGlyphBuffer
= {0, 0, {0}};
21 BOOLEAN mSysFontColorCached
= FALSE
;
22 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor
= {0};
26 This function is only called by Graphics Console module and GraphicsLib.
27 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
28 complying to UEFI HII.
30 This function will ASSERT and return EFI_UNSUPPORTED.
35 @param GlyphBuffer N.A.
37 @param InternalStatus N.A.
39 @return EFI_UNSUPPORTED N.A.
45 IN EFI_HII_PROTOCOL
*This
,
48 OUT UINT8
**GlyphBuffer
,
50 IN OUT UINT32
*InternalStatus
54 EFI_IMAGE_OUTPUT
*Blt
;
55 EFI_FONT_DISPLAY_INFO
*FontInfo
;
60 if (!mSysFontColorCached
) {
62 // Cache the system font's foreground color.
64 Status
= mHiiFontProtocol
->GetFontInfo (
72 if (!EFI_ERROR (Status
)) {
73 ASSERT (StrCmp (FontInfo
->FontInfo
.FontName
, L
"sysdefault") == 0);
74 mSysFGColor
= FontInfo
->ForegroundColor
;
77 mSysFontColorCached
= TRUE
;
83 Status
= mHiiFontProtocol
->GetGlyph (
91 if (!EFI_ERROR (Status
)) {
93 // For simplicity, we only handle Narrow Glyph.
95 ASSERT (Blt
->Height
== EFI_GLYPH_HEIGHT
);
96 ASSERT (Blt
->Width
== EFI_GLYPH_WIDTH
);
98 if (Blt
->Height
== EFI_GLYPH_HEIGHT
&& Blt
->Width
== EFI_GLYPH_WIDTH
) {
100 ZeroMem (&mNarrowGlyphBuffer
, sizeof (mNarrowGlyphBuffer
));
101 mNarrowGlyphBuffer
.UnicodeWeight
= *Source
;
102 for (Ypos
= 0; Ypos
< EFI_GLYPH_HEIGHT
; Ypos
++) {
103 for (Xpos
= 0; Xpos
< EFI_GLYPH_WIDTH
; Xpos
++) {
104 if (CompareMem (&Blt
->Image
.Bitmap
[Ypos
* EFI_GLYPH_WIDTH
+ Xpos
], &mSysFGColor
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)) == 0) {
105 mNarrowGlyphBuffer
.GlyphCol1
[Ypos
] |= 1 << (EFI_GLYPH_WIDTH
- 1 - Xpos
);
110 *GlyphBuffer
= (UINT8
*) &mNarrowGlyphBuffer
;
111 *BitWidth
= EFI_GLYPH_WIDTH
;
114 Status
= EFI_NOT_FOUND
;
119 if (EFI_ERROR (Status
)) {
126 This function is only called by Graphics Console module and GraphicsLib.
127 EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
128 complying to UEFI HII.
130 This function will ASSERT and return EFI_UNSUPPORTED.
133 @param GlyphBuffer N.A.
134 @param Foreground N.A.
135 @param Background N.A.
139 @param BltBuffer N.A.
141 @return EFI_UNSUPPORTED N.A.
147 IN EFI_HII_PROTOCOL
*This
,
148 IN UINT8
*GlyphBuffer
,
149 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
,
150 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
,
154 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
161 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
163 for (Y
= 0; Y
< Height
; Y
++) {
164 for (X
= 0; X
< Width
; X
++) {
165 if ((((EFI_NARROW_GLYPH
*) GlyphBuffer
)->GlyphCol1
[Y
] & (1 << X
)) != 0) {
166 BltBuffer
[Y
* Width
* Count
+ (Width
- X
- 1)] = Foreground
;
168 BltBuffer
[Y
* Width
* Count
+ (Width
- X
- 1)] = Background
;