/** @file\r
+Implementation for EFI_HII_FONT_PROTOCOL.\r
\r
-Copyright (c) 2007, Intel Corporation\r
+\r
+Copyright (c) 2007 - 2008, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- Font.c\r
-\r
-Abstract:\r
-\r
- Implementation for EFI_HII_FONT_PROTOCOL.\r
-\r
-Revision History\r
-\r
-\r
**/\r
\r
\r
#include "HiiDatabase.h"\r
\r
-static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
+STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
//\r
// B G R\r
//\r
/**\r
Insert a character cell information to the list specified by GlyphInfoList.\r
\r
+ This is a internal function.\r
+\r
@param CharValue Unicode character value, which identifies a glyph\r
block.\r
@param GlyphInfoList HII_GLYPH_INFO list head.\r
task.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
NewCell (\r
IN CHAR16 CharValue,\r
/**\r
Get a character cell information from the list specified by GlyphInfoList.\r
\r
+ This is a internal function.\r
+\r
@param CharValue Unicode character value, which identifies a glyph\r
block.\r
@param GlyphInfoList HII_GLYPH_INFO list head.\r
not exist.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
GetCell (\r
IN CHAR16 CharValue,\r
/**\r
Convert the glyph for a single character into a bitmap.\r
\r
+ This is a internal function.\r
+\r
@param Private HII database driver private data.\r
@param Char Character to retrieve.\r
@param StringInfo Points to the string font and color information\r
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
GetGlyphBuffer (\r
IN HII_DATABASE_PRIVATE_DATA *Private,\r
return EFI_NOT_FOUND;\r
}\r
\r
-STATIC\r
+/**\r
+ Convert bitmap data of the glyph to blt structure.\r
+\r
+ This is a internal function.\r
+\r
+ @param GlyphBuffer Buffer points to bitmap data of glyph.\r
+ @param Foreground The color of the "on" pixels in the glyph in the\r
+ bitmap.\r
+ @param Background The color of the "off" pixels in the glyph in the\r
+ bitmap.\r
+ @param ImageWidth Width of the character or character cell, in\r
+ pixels.\r
+ @param ImageHeight Height of the character or character cell, in\r
+ pixels.\r
+ @param Transparent If TRUE, the Background color is ignored and all\r
+ "off" pixels in the character's drawn wil use the\r
+ pixel value from BltBuffer.\r
+ @param Origin On input, points to the origin of the to be\r
+ displayed character, on output, points to the\r
+ next glyph's origin.\r
+\r
+**/\r
VOID\r
NarrowGlyphToBlt (\r
IN UINT8 *GlyphBuffer,\r
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
)\r
{\r
- UINT8 X;\r
- UINT8 Y;\r
+ UINT8 Xpos;\r
+ UINT8 Ypos;\r
UINT8 Height;\r
UINT8 Width;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;\r
\r
Buffer = *Origin;\r
\r
- for (Y = 0; Y < Height; Y++) {\r
- for (X = 0; X < Width; X++) {\r
- if ((GlyphBuffer[Y] & (1 << X)) != 0) {\r
- Buffer[Y * ImageWidth + (Width - X - 1)] = Foreground;\r
+ for (Ypos = 0; Ypos < Height; Ypos++) {\r
+ for (Xpos = 0; Xpos < Width; Xpos++) {\r
+ if ((GlyphBuffer[Ypos] & (1 << Xpos)) != 0) {\r
+ Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Foreground;\r
} else {\r
if (!Transparent) {\r
- Buffer[Y * ImageWidth + (Width - X - 1)] = Background;\r
+ Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Background;\r
}\r
}\r
}\r
/**\r
Convert bitmap data of the glyph to blt structure.\r
\r
+ This is a internal function.\r
+\r
@param GlyphBuffer Buffer points to bitmap data of glyph.\r
@param Foreground The color of the "on" pixels in the glyph in the\r
bitmap.\r
@param Background The color of the "off" pixels in the glyph in the\r
bitmap.\r
- @param Width Width of the character or character cell, in\r
+ @param ImageWidth Width of the character or character cell, in\r
pixels.\r
- @param Height Height of the character or character cell, in\r
+ @param ImageHeight Height of the character or character cell, in\r
pixels.\r
@param Transparent If TRUE, the Background color is ignored and all\r
"off" pixels in the character's drawn wil use the\r
pixel value from BltBuffer.\r
- @param BltBuffer Points to the blt buffer.\r
+ @param Cell Points to EFI_HII_GLYPH_INFO structure.\r
+ @param Attributes The attribute of incoming glyph in GlyphBuffer.\r
+ @param Origin On input, points to the origin of the to be\r
+ displayed character, on output, points to the\r
+ next glyph's origin.\r
\r
\r
**/\r
-STATIC\r
VOID\r
GlyphToBlt (\r
IN UINT8 *GlyphBuffer,\r
IN UINTN ImageWidth,\r
IN UINTN ImageHeight,\r
IN BOOLEAN Transparent,\r
- IN EFI_HII_GLYPH_INFO Cell,\r
+ IN CONST EFI_HII_GLYPH_INFO *Cell,\r
IN UINT8 Attributes,\r
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
)\r
{\r
- UINT8 X;\r
- UINT8 Y;\r
+ UINT8 Xpos;\r
+ UINT8 Ypos;\r
UINT8 Data;\r
UINT8 Index;\r
UINTN OffsetY;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
\r
ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);\r
- ASSERT (Cell.Width <= ImageWidth && Cell.Height <= ImageHeight);\r
+ ASSERT (Cell->Width <= ImageWidth && Cell->Height <= ImageHeight);\r
\r
BltBuffer = *Origin;\r
\r
// The glyph's upper left hand corner pixel is the most significant bit of the\r
// first bitmap byte.\r
//\r
- for (Y = 0; Y < Cell.Height; Y++) {\r
- OffsetY = BITMAP_LEN_1_BIT (Cell.Width, Y);\r
+ for (Ypos = 0; Ypos < Cell->Height; Ypos++) {\r
+ OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);\r
\r
//\r
// All bits in these bytes are meaningful.\r
//\r
- for (X = 0; X < Cell.Width / 8; X++) {\r
- Data = *(GlyphBuffer + OffsetY + X);\r
+ for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {\r
+ Data = *(GlyphBuffer + OffsetY + Xpos);\r
for (Index = 0; Index < 8; Index++) {\r
if ((Data & (1 << Index)) != 0) {\r
- BltBuffer[Y * ImageWidth + X * 8 + (8 - Index - 1)] = Foreground;\r
+ BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Foreground;\r
} else {\r
if (!Transparent) {\r
- BltBuffer[Y * ImageWidth + X * 8 + (8 - Index - 1)] = Background;\r
+ BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Background;\r
}\r
}\r
}\r
}\r
\r
- if (Cell.Width % 8 != 0) {\r
+ if (Cell->Width % 8 != 0) {\r
//\r
// There are some padding bits in this byte. Ignore them.\r
//\r
- Data = *(GlyphBuffer + OffsetY + X);\r
- for (Index = 0; Index < Cell.Width % 8; Index++) {\r
+ Data = *(GlyphBuffer + OffsetY + Xpos);\r
+ for (Index = 0; Index < Cell->Width % 8; Index++) {\r
if ((Data & (1 << (8 - Index - 1))) != 0) {\r
- BltBuffer[Y * ImageWidth + X * 8 + Index] = Foreground;\r
+ BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
} else {\r
if (!Transparent) {\r
- BltBuffer[Y * ImageWidth + X * 8 + Index] = Background;\r
+ BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Background;\r
}\r
}\r
}\r
} // end of if (Width % 8...)\r
\r
- } // end of for (Y=0...)\r
+ } // end of for (Ypos=0...)\r
\r
- *Origin = BltBuffer + Cell.Width;\r
+ *Origin = BltBuffer + Cell->Width;\r
}\r
\r
\r
/**\r
Convert bitmap data of the glyph to blt structure.\r
\r
+ This is a internal function.\r
+\r
@param GlyphBuffer Buffer points to bitmap data of glyph.\r
@param Foreground The color of the "on" pixels in the glyph in the\r
bitmap.\r
@param Background The color of the "off" pixels in the glyph in the\r
bitmap.\r
- @param Width Width of the character or character cell, in\r
+ @param ImageWidth Width of the character or character cell, in\r
pixels.\r
- @param Height Height of the character or character cell, in\r
+ @param ImageHeight Height of the character or character cell, in\r
pixels.\r
@param Transparent If TRUE, the Background color is ignored and all\r
"off" pixels in the character's drawn wil use the\r
@return Points to the address of next origin node in BltBuffer.\r
\r
**/\r
-STATIC\r
VOID\r
GlyphToImage (\r
IN UINT8 *GlyphBuffer,\r
IN UINTN ImageWidth,\r
IN UINTN ImageHeight,\r
IN BOOLEAN Transparent,\r
- IN EFI_HII_GLYPH_INFO Cell,\r
+ IN CONST EFI_HII_GLYPH_INFO *Cell,\r
IN UINT8 Attributes,\r
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
)\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;\r
\r
ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);\r
- ASSERT (Cell.Width <= ImageWidth && Cell.Height <= ImageHeight);\r
+ ASSERT (Cell->Width <= ImageWidth && Cell->Height <= ImageHeight);\r
\r
Buffer = *Origin;\r
\r
// This character is a non-spacing key, print it OR'd with the previous glyph.\r
// without advancing cursor.\r
//\r
- Buffer -= Cell.Width;\r
+ Buffer -= Cell->Width;\r
GlyphToBlt (\r
GlyphBuffer,\r
Foreground,\r
\r
} else if ((Attributes & PROPORTIONAL_GLYPH) == PROPORTIONAL_GLYPH) {\r
//\r
- // This character is proportional glyph, i.e. Cell.Width * Cell.Height pixels.\r
+ // This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.\r
//\r
GlyphToBlt (\r
GlyphBuffer,\r
/**\r
Write the output parameters of FindGlyphBlock().\r
\r
+ This is a internal function.\r
+\r
@param BufferIn Buffer which stores the bitmap data of the found\r
block.\r
@param BufferLen Length of BufferIn.\r
task.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
WriteOutputParam (\r
IN UINT8 *BufferIn,\r
/**\r
Copy a Font Name to a new created EFI_FONT_INFO structure.\r
\r
+ This is a internal function.\r
+\r
@param FontName NULL-terminated string.\r
@param FontInfo a new EFI_FONT_INFO which stores the FontName.\r
It's caller's responsibility to free this buffer.\r
task.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
SaveFontName (\r
IN EFI_STRING FontName,\r
\r
\r
/**\r
- Check whether EFI_FONT_DISPLAY_INFO points to system default font and color.\r
+ Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or\r
+ returns the system default according to the optional inputs.\r
+\r
+ This is a internal function.\r
\r
@param Private HII database driver private data.\r
@param StringInfo Points to the string output information,\r
including the color and font.\r
- @param SystemInfo If not NULL, points to system default font and\r
- color when incoming StringInfo does not match the\r
- default. Points to NULL if matches. It's\r
- caller's reponsibility to free this buffer.\r
+ @param SystemInfo If not NULL, points to system default font and color.\r
+\r
@param SystemInfoLen If not NULL, output the length of default system\r
info.\r
\r
@retval FALSE No.\r
\r
**/\r
-STATIC\r
BOOLEAN\r
IsSystemFontInfo (\r
IN HII_DATABASE_PRIVATE_DATA *Private,\r
EFI_STATUS Status;\r
EFI_FONT_DISPLAY_INFO *SystemDefault;\r
UINTN DefaultLen;\r
+ BOOLEAN Flag;\r
\r
ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);\r
\r
return TRUE;\r
}\r
\r
- //\r
- // Check whether incoming string font and color matches system default.\r
- //\r
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);\r
ASSERT_EFI_ERROR (Status);\r
\r
+ //\r
+ // Record the system default info.\r
+ //\r
if (SystemInfo != NULL) {\r
*SystemInfo = SystemDefault;\r
- } else {\r
- SafeFreePool (SystemDefault);\r
}\r
\r
if (SystemInfoLen != NULL) {\r
*SystemInfoLen = DefaultLen;\r
}\r
\r
- if (StringInfo == NULL ||\r
- (StringInfo != NULL && CompareMem (SystemDefault, StringInfo, DefaultLen) == 0)) {\r
+ if (StringInfo == NULL) {\r
return TRUE;\r
}\r
\r
- return FALSE;\r
+ Flag = FALSE;\r
+ //\r
+ // Check the FontInfoMask to see whether it is retrieving system info.\r
+ //\r
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) == 0) {\r
+ if (StrCmp (StringInfo->FontInfo.FontName, SystemDefault->FontInfo.FontName) != 0) {\r
+ goto Exit;\r
+ }\r
+ }\r
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) == 0) {\r
+ if (StringInfo->FontInfo.FontSize != SystemDefault->FontInfo.FontSize) {\r
+ goto Exit;\r
+ }\r
+ }\r
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) == 0) {\r
+ if (StringInfo->FontInfo.FontStyle != SystemDefault->FontInfo.FontStyle) {\r
+ goto Exit;\r
+ }\r
+ }\r
+ if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == 0) {\r
+ if (CompareMem (\r
+ &StringInfo->ForegroundColor, \r
+ &SystemDefault->ForegroundColor, \r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ ) != 0) {\r
+ goto Exit;\r
+ }\r
+ }\r
+ if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == 0) {\r
+ if (CompareMem (\r
+ &StringInfo->BackgroundColor, \r
+ &SystemDefault->BackgroundColor, \r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ ) != 0) {\r
+ goto Exit;\r
+ }\r
+ }\r
+\r
+ Flag = TRUE;\r
+\r
+Exit:\r
+ if (SystemInfo == NULL) {\r
+ SafeFreePool (SystemDefault); \r
+ }\r
+ return Flag;\r
}\r
\r
\r
/**\r
Check whether the unicode represents a line break or not.\r
\r
+ This is a internal function.\r
+\r
@param Char Unicode character\r
\r
@retval 0 Yes, it is a line break.\r
@retval -1 No, it is not a link break.\r
\r
**/\r
-STATIC\r
INT8\r
IsLineBreak (\r
IN CHAR16 Char\r
will be allocated to hold the generated image and\r
the pointer updated on exit. It is the caller's\r
responsibility to free this buffer.\r
- @param BltX,BLTY Specifies the offset from the left and top edge\r
+ @param BltX Specifies the offset from the left and top edge\r
+ of the image of the first character cell in the\r
+ image.\r
+ @param BltY Specifies the offset from the left and top edge\r
of the image of the first character cell in the\r
image.\r
@param RowInfoArray If this is non-NULL on entry, then on exit, this\r
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for\r
RowInfoArray or Blt.\r
@retval EFI_INVALID_PARAMETER The String or Blt was NULL.\r
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination..\r
\r
**/\r
EFI_STATUS\r
//\r
// These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.\r
//\r
- if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_X)) == EFI_HII_OUT_FLAG_CLEAN_X) {\r
+ if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLEAN_Y) {\r
+ if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
// This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.\r
//\r
- if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) {\r
+ 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)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
//\r
\r
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);\r
- if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {\r
+ if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {\r
//\r
// Don't draw at all if there is only one row and\r
// the row's bottom-most on pixel cannot fit.\r
//\r
if (!LineBreak) {\r
Flags &= (~ (EFI_HII_OUT_FLAGS) EFI_HII_OUT_FLAG_WRAP);\r
- Flags |= EFI_HII_OUT_FLAG_CLEAN_X;\r
+ Flags |= EFI_HII_OUT_FLAG_CLIP_CLEAN_X;\r
}\r
}\r
\r
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.\r
//\r
if (LineWidth + BltX <= Image->Width ||\r
- (LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLEAN_X) == 0)) {\r
+ (LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_X) == 0)) {\r
//\r
// Record right-most character in RowInfo even if it is partially displayed.\r
//\r
//\r
if (RowIndex == MaxRowNum - 1 && Image->Height < LineHeight) {\r
LineHeight = Image->Height;\r
- if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {\r
+ if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {\r
//\r
// Don't draw at all if the row's bottom-most on pixel cannot fit.\r
//\r
RowInfo[RowIndex].LineWidth,\r
RowInfo[RowIndex].LineHeight,\r
Transparent,\r
- Cell[Index1],\r
+ &Cell[Index1],\r
Attributes[Index1],\r
&BufferPtr\r
);\r
Image->Width,\r
Image->Height,\r
Transparent,\r
- Cell[Index1],\r
+ &Cell[Index1],\r
Attributes[Index1],\r
&BufferPtr\r
);\r
will be allocated to hold the generated image and\r
the pointer updated on exit. It is the caller's\r
responsibility to free this buffer.\r
- @param BltX,BLTY Specifies the offset from the left and top edge\r
+ @param BltX Specifies the offset from the left and top edge\r
+ of the image of the first character cell in the\r
+ image.\r
+ @param BltY Specifies the offset from the left and top edge\r
of the image of the first character cell in the\r
image.\r
@param RowInfoArray If this is non-NULL on entry, then on exit, this\r
@retval EFI_SUCCESS The string was successfully rendered.\r
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for\r
RowInfoArray or Blt.\r
- @retval EFI_INVALID_PARAMETER The PackageList was NULL.\r
+ @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.\r
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination.\r
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the stringid is not \r
+ in the specified PackageList. \r
\r
**/\r
EFI_STATUS\r
HII_DATABASE_PRIVATE_DATA *Private;\r
EFI_STRING String;\r
UINTN StringSize;\r
+ UINTN FontLen;\r
+ EFI_FONT_INFO *StringFontInfo;\r
+ EFI_FONT_DISPLAY_INFO *NewStringInfo;\r
+ CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];\r
\r
if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {\r
return EFI_INVALID_PARAMETER;\r
return EFI_NOT_FOUND;\r
}\r
\r
- Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
+ //\r
+ // When Language points to NULL, current system language is used.\r
+ //\r
+ if (Language != NULL) {\r
+ AsciiStrCpy (CurrentLang, (CHAR8 *) Language);\r
+ } else {\r
+ HiiLibGetCurrentLanguage (CurrentLang);\r
+ }\r
\r
//\r
// Get the string to be displayed.\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
+ Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
+ StringFontInfo = NULL;\r
+ NewStringInfo = NULL;\r
+ \r
Status = Private->HiiString.GetString (\r
&Private->HiiString,\r
- Language,\r
+ CurrentLang,\r
PackageList,\r
StringId,\r
String,\r
&StringSize,\r
- NULL\r
+ &StringFontInfo\r
);\r
if (Status == EFI_BUFFER_TOO_SMALL) {\r
SafeFreePool (String);\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- SafeFreePool (String);\r
- return Status;\r
+ goto Exit;\r
+ }\r
+ \r
+ //\r
+ // When StringInfo specifies that string will be output in the system default font and color,\r
+ // use particular stringfontinfo described in string package instead if exists. \r
+ // StringFontInfo equals NULL means system default font attaches with the string block.\r
+ //\r
+ if (StringFontInfo != NULL && IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, NULL, NULL)) {\r
+ FontLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + StrSize (StringFontInfo->FontName);\r
+ NewStringInfo = AllocateZeroPool (FontLen);\r
+ if (NewStringInfo == NULL) { \r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Exit;\r
+ }\r
+ NewStringInfo->FontInfoMask = EFI_FONT_INFO_SYS_FORE_COLOR | EFI_FONT_INFO_SYS_BACK_COLOR;\r
+ NewStringInfo->FontInfo.FontStyle = StringFontInfo->FontStyle;\r
+ NewStringInfo->FontInfo.FontSize = StringFontInfo->FontSize; \r
+ StrCpy (NewStringInfo->FontInfo.FontName, StringFontInfo->FontName);\r
+ \r
+ Status = HiiStringToImage (\r
+ This, \r
+ Flags, \r
+ String, \r
+ NewStringInfo, \r
+ Blt, \r
+ BltX, \r
+ BltY, \r
+ RowInfoArray,\r
+ RowInfoArraySize,\r
+ ColumnInfoArray\r
+ );\r
+ goto Exit;\r
}\r
\r
- return HiiStringToImage (\r
+ Status = HiiStringToImage (\r
This,\r
Flags,\r
String,\r
ColumnInfoArray\r
);\r
\r
+Exit:\r
+ SafeFreePool (String);\r
+ SafeFreePool (StringFontInfo);\r
+ SafeFreePool (NewStringInfo);\r
+\r
+ return Status;\r
}\r
\r
\r
Image->Width,\r
Image->Height,\r
FALSE,\r
- Cell,\r
+ &Cell,\r
Attributes,\r
&BltBuffer\r
);\r
returned font handle or points to NULL if there\r
are no more matching fonts.\r
@param StringInfoIn Upon entry, points to the font to return\r
- information about.\r
+ information about. \r
+ If NULL, then the information about the system default \r
+ font will be returned.\r
@param StringInfoOut Upon return, contains the matching font's\r
information. If NULL, then no information is\r
returned. It's caller's responsibility to free\r
\r
@retval EFI_SUCCESS Matching font returned successfully.\r
@retval EFI_NOT_FOUND No matching font was found.\r
- @retval EFI_INVALID_PARAMETER StringInfoIn is NULL.\r
+ @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.\r
@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the\r
request.\r
\r
HiiGetFontInfo (\r
IN CONST EFI_HII_FONT_PROTOCOL *This,\r
IN OUT EFI_FONT_HANDLE *FontHandle,\r
- IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn,\r
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL\r
OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,\r
IN CONST EFI_STRING String OPTIONAL\r
)\r
EFI_STRING StringIn;\r
EFI_FONT_HANDLE LocalFontHandle;\r
\r
- if (This == NULL || StringInfoIn == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the font information mask to make sure it is valid.\r
- //\r
- if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==\r
- (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||\r
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==\r
- (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||\r
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==\r
- (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||\r
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==\r
- (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||\r
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==\r
- (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {\r
+ if (This == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
FontInfo = NULL;\r
+ SystemDefault = NULL;\r
LocalFontHandle = NULL;\r
if (FontHandle != NULL) {\r
LocalFontHandle = *FontHandle;\r
}\r
\r
+ Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+ //\r
+ // Already searched to the end of the whole list, return directly.\r
+ //\r
+ if (LocalFontHandle == &Private->FontInfoList) {\r
+ LocalFontHandle = NULL;\r
+ Status = EFI_NOT_FOUND;\r
+ goto Exit;\r
+ }\r
+\r
//\r
// Get default system display info, if StringInfoIn points to\r
// system display info, return it directly.\r
//\r
- Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
-\r
if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, &SystemDefault, &StringInfoOutLen)) {\r
- if (StringInfoOut != NULL) {\r
- *StringInfoOut = AllocateCopyPool (StringInfoOutLen, (EFI_FONT_DISPLAY_INFO *) StringInfoIn);\r
- if (*StringInfoOut == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- LocalFontHandle = NULL;\r
- goto Exit;\r
+ //\r
+ // System font is the first node. When handle is not NULL, system font can not\r
+ // be found any more.\r
+ //\r
+ if (LocalFontHandle == NULL) {\r
+ if (StringInfoOut != NULL) {\r
+ *StringInfoOut = AllocateCopyPool (StringInfoOutLen, SystemDefault);\r
+ if (*StringInfoOut == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ LocalFontHandle = NULL;\r
+ goto Exit;\r
+ }\r
}\r
+\r
+ LocalFontHandle = Private->FontInfoList.ForwardLink;\r
+ Status = EFI_SUCCESS;\r
+ goto Exit;\r
+ } else {\r
+ LocalFontHandle = NULL;\r
+ Status = EFI_NOT_FOUND;\r
+ goto Exit;\r
}\r
+ }\r
\r
- LocalFontHandle = Private->FontInfoList.ForwardLink;\r
- Status = EFI_SUCCESS;\r
- goto Exit;\r
+ //\r
+ // Check the font information mask to make sure it is valid.\r
+ //\r
+ if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) == \r
+ (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||\r
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) == \r
+ (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||\r
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) == \r
+ (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||\r
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) == \r
+ (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) || \r
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) == \r
+ (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
//\r
\r
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_SIZE) == EFI_FONT_INFO_SYS_SIZE) {\r
InfoOut.FontInfo.FontSize = SystemDefault->FontInfo.FontSize;\r
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {\r
+ } \r
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {\r
InfoOut.FontInfo.FontStyle = SystemDefault->FontInfo.FontStyle;\r
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {\r
+ }\r
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {\r
InfoOut.ForegroundColor = SystemDefault->ForegroundColor;\r
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {\r
+ }\r
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {\r
InfoOut.BackgroundColor = SystemDefault->BackgroundColor;\r
}\r
+ \r
\r
FontInfo->FontSize = InfoOut.FontInfo.FontSize;\r
FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;\r
return Status;\r
}\r
\r
+\r