/**@file\r
-\r
This file contains the Glyph related function.\r
\r
Copyright (c) 2006 - 2008, Intel Corporation\r
\r
#include "HiiDatabase.h"\r
\r
+EFI_NARROW_GLYPH mNarrowGlyphBuffer = {0, 0, {0}};\r
+\r
+BOOLEAN mSysFontColorCached = FALSE;\r
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor = {0};\r
\r
-UINT8 mGlyphBuffer[EFI_GLYPH_WIDTH * 2 * EFI_GLYPH_HEIGHT];\r
\r
/**\r
- This function is only called by Graphics Console module and GraphicsLib. \r
- EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
- complying to UEFI HII.\r
+ Translates a Unicode character into the corresponding font glyph.\r
\r
- This function will ASSERT and return EFI_UNSUPPORTED.\r
-\r
- @param This N.A.\r
- @param Source N.A.\r
- @param Index N.A.\r
- @param GlyphBuffer N.A.\r
- @param BitWidth N.A.\r
- @param InternalStatus N.A.\r
-\r
- @return EFI_UNSUPPORTED N.A.\r
+ Notes:\r
+ This function is only called by Graphics Console module and GraphicsLib. \r
+ Wrap the Framework HII GetGlyph function to UEFI Font Protocol.\r
+ \r
+ EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
+ complying to UEFI HII.\r
+ \r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param Source A pointer to a Unicode string.\r
+ @param Index On input, the offset into the string from which to fetch the character. On successful completion, the \r
+ index is updated to the first character past the character(s) making up the just extracted glyph. \r
+ @param GlyphBuffer Pointer to an array where the glyphs corresponding to the characters in the source may be stored. \r
+ GlyphBuffer is assumed to be wide enough to accept a wide glyph character.\r
+ @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by this value is filled with the length of the glyph in pixels. \r
+ It is unchanged if the call was unsuccessful.\r
+ @param InternalStatus To save the time required to read the string from the beginning on each glyph extraction \r
+ (for example, to ensure that the narrow versus wide glyph mode is correct), this value is \r
+ updated each time the function is called with the status that is local to the call. The cell pointed \r
+ to by this parameter must be initialized to zero prior to invoking the call the first time for any string.\r
+\r
+ @retval EFI_SUCCESS It worked.\r
+ @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+ \r
\r
**/\r
EFI_STATUS\r
IN OUT UINT32 *InternalStatus\r
)\r
{\r
- ASSERT (FALSE);\r
- return EFI_UNSUPPORTED;\r
+ EFI_STATUS Status;\r
+ EFI_IMAGE_OUTPUT *Blt;\r
+ EFI_FONT_DISPLAY_INFO *FontInfo;\r
+ UINTN Xpos;\r
+ UINTN Ypos;\r
+ UINTN BaseLine;\r
+\r
+ if (!mSysFontColorCached) {\r
+ //\r
+ // Cache the system font's foreground color.\r
+ //\r
+ Status = mHiiFontProtocol->GetFontInfo (\r
+ mHiiFontProtocol,\r
+ NULL,\r
+ NULL,\r
+ &FontInfo,\r
+ NULL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (StrCmp (FontInfo->FontInfo.FontName, L"sysdefault") == 0);\r
+ mSysFGColor = FontInfo->ForegroundColor;\r
+ FreePool (FontInfo);\r
+\r
+ mSysFontColorCached = TRUE;\r
+ }\r
+ \r
+ }\r
+\r
+ Blt = NULL;\r
+ Status = mHiiFontProtocol->GetGlyph (\r
+ mHiiFontProtocol,\r
+ Source[*Index],\r
+ NULL,\r
+ &Blt,\r
+ &BaseLine\r
+ );\r
+\r
+ if (!EFI_ERROR (Status) && (Status != EFI_WARN_UNKNOWN_GLYPH)) {\r
+ //\r
+ // For simplicity, we only handle Narrow Glyph.\r
+ //\r
+ if (Blt->Height == EFI_GLYPH_HEIGHT && Blt->Width == EFI_GLYPH_WIDTH) {\r
+\r
+ ZeroMem (&mNarrowGlyphBuffer, sizeof (mNarrowGlyphBuffer));\r
+ mNarrowGlyphBuffer.UnicodeWeight = *Source;\r
+ for (Ypos = 0; Ypos < EFI_GLYPH_HEIGHT; Ypos++) {\r
+ for (Xpos = 0; Xpos < EFI_GLYPH_WIDTH; Xpos++) {\r
+ if (CompareMem (&Blt->Image.Bitmap[Ypos * EFI_GLYPH_WIDTH + Xpos], &mSysFGColor, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) == 0) {\r
+ mNarrowGlyphBuffer.GlyphCol1[Ypos] = (UINT8) (mNarrowGlyphBuffer.GlyphCol1[Ypos] | (1 << (EFI_GLYPH_WIDTH - 1 - Xpos)));\r
+ }\r
+ }\r
+ }\r
+\r
+ *GlyphBuffer = (UINT8 *) &mNarrowGlyphBuffer;\r
+ *BitWidth = EFI_GLYPH_WIDTH;\r
+ *Index += 1;\r
+ } else {\r
+ Status = EFI_NOT_FOUND;\r
+ }\r
+\r
+ }\r
+\r
+ if (EFI_ERROR (Status) || (Status == EFI_WARN_UNKNOWN_GLYPH)) {\r
+ if (Status == EFI_WARN_UNKNOWN_GLYPH) {\r
+ Status = EFI_NOT_FOUND;\r
+ }\r
+ *GlyphBuffer = NULL;\r
+ }\r
+ return Status;\r
}\r
\r
/**\r
+ Translates a glyph into the format required for input to the Universal Graphics Adapter (UGA) Block Transfer (BLT) routines.\r
+ \r
+ Notes:\r
This function is only called by Graphics Console module and GraphicsLib. \r
EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib \r
complying to UEFI HII.\r
\r
- This function will ASSERT and return EFI_UNSUPPORTED.\r
-\r
- @param This N.A.\r
- @param GlyphBuffer N.A.\r
- @param Foreground N.A.\r
- @param Background N.A.\r
- @param Count N.A.\r
- @param Width N.A.\r
- @param Height N.A.\r
- @param BltBuffer N.A.\r
-\r
- @return EFI_UNSUPPORTED N.A.\r
+ @param This A pointer to the EFI_HII_PROTOCOL instance.\r
+ @param GlyphBuffer A pointer to the buffer that contains glyph data. \r
+ @param Foreground The foreground setting requested to be used for the generated BltBuffer data. Type EFI_UGA_PIXEL is defined in "Related Definitions" below.\r
+ @param Background The background setting requested to be used for the generated BltBuffer data. \r
+ @param Count The entry in the BltBuffer upon which to act.\r
+ @param Width The width in bits of the glyph being converted.\r
+ @param Height The height in bits of the glyph being converted\r
+ @param BltBuffer A pointer to the buffer that contains the data that is ready to be used by the UGA BLT routines. \r
+\r
+ @retval EFI_SUCCESS It worked.\r
+ @retval EFI_NOT_FOUND A glyph for a character was not found.\r
+ \r
\r
**/\r
EFI_STATUS\r
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer\r
)\r
{\r
- ASSERT (FALSE);\r
- return EFI_UNSUPPORTED;\r
+ UINTN X;\r
+ UINTN Y;\r
+\r
+ //\r
+ // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r
+ //\r
+ for (Y = 0; Y < Height; Y++) {\r
+ for (X = 0; X < Width; X++) {\r
+ if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Y] & (1 << X)) != 0) {\r
+ BltBuffer[Y * Width * Count + (Width - X - 1)] = Foreground;\r
+ } else {\r
+ BltBuffer[Y * Width * Count + (Width - X - 1)] = Background;\r
+ }\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
}\r