/** @file\r
\r
-Copyright (c) 2007, Intel Corporation\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
\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
@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
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
@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
@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
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