Implementation for EFI_HII_FONT_PROTOCOL.\r
\r
\r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
-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
-http://opensource.org/licenses/bsd-license.php\r
-\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
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
@param RowWidth The width of the text on the line, in pixels.\r
@param RowHeight The height of the line, in 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
+ "off" pixels in the character's drawn will 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
\r
Height = EFI_GLYPH_HEIGHT;\r
Width = EFI_GLYPH_WIDTH;\r
- \r
+\r
//\r
// Move position to the left-top corner of char.\r
//\r
Buffer = *Origin - EFI_GLYPH_HEIGHT * ImageWidth;\r
\r
//\r
- // Char may be partially displayed when CLIP_X or CLIP_Y is not set. \r
+ // Char may be partially displayed when CLIP_X or CLIP_Y is not set.\r
//\r
if (RowHeight < Height) {\r
Height = (UINT8) RowHeight;\r
@param RowWidth The width of the text on the line, in pixels.\r
@param RowHeight The height of the line, in 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
+ "off" pixels in the character's drawn will use the\r
pixel value from BltBuffer.\r
@param Cell Points to EFI_HII_GLYPH_INFO structure.\r
@param Attributes The attribute of incoming glyph in GlyphBuffer.\r
// The glyph's upper left hand corner pixel is the most significant bit of the\r
// first bitmap byte.\r
//\r
- for (Ypos = 0; Ypos < Cell->Height && ((UINTN) (Ypos + YposOffset) < RowHeight); Ypos++) {\r
+ for (Ypos = 0; Ypos < Cell->Height && (((UINT32) Ypos + YposOffset) < RowHeight); Ypos++) {\r
OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);\r
\r
//\r
//\r
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {\r
Data = *(GlyphBuffer + OffsetY + Xpos);\r
- for (Index = 0; Index < 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+ for (Index = 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
if ((Data & (1 << (8 - Index - 1))) != 0) {\r
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
} else {\r
// There are some padding bits in this byte. Ignore them.\r
//\r
Data = *(GlyphBuffer + OffsetY + Xpos);\r
- for (Index = 0; Index < Cell->Width % 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+ for (Index = 0; Index < Cell->Width % 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
if ((Data & (1 << (8 - Index - 1))) != 0) {\r
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
} else {\r
@param RowWidth The width of the text on the line, in pixels.\r
@param RowHeight The height of the line, in 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
+ "off" pixels in the character's drawn will use the\r
pixel value from BltBuffer.\r
@param Cell Points to EFI_HII_GLYPH_INFO structure.\r
@param Attributes The attribute of incoming glyph in GlyphBuffer.\r
@param InputCell Buffer which stores cell information of the\r
encoded bitmap.\r
@param GlyphBuffer Output the corresponding bitmap data of the found\r
- block. It is the caller's responsiblity to free\r
+ block. It is the caller's responsibility to free\r
this buffer.\r
@param Cell Output cell information of the encoded bitmap.\r
@param GlyphBufferLen If not NULL, output the length of GlyphBuffer.\r
@param CharValue Unicode character value, which identifies a glyph\r
block.\r
@param GlyphBuffer Output the corresponding bitmap data of the found\r
- block. It is the caller's responsiblity to free\r
+ block. It is the caller's responsibility to free\r
this buffer.\r
@param Cell Output cell information of the encoded bitmap.\r
@param GlyphBufferLen If not NULL, output the length of GlyphBuffer.\r
ASSERT (FontPackage->Signature == HII_FONT_PACKAGE_SIGNATURE);\r
BaseLine = 0;\r
MinOffsetY = 0;\r
- \r
+\r
if (CharValue == (CHAR16) (-1)) {\r
//\r
// Collect the cell information specified in font package fixed header.\r
(UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32),\r
sizeof (EFI_HII_GLYPH_INFO)\r
);\r
- BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);\r
- if (MinOffsetY > LocalCell.OffsetY) {\r
- MinOffsetY = LocalCell.OffsetY;\r
- }\r
}\r
\r
BlockPtr = FontPackage->GlyphBlock;\r
break;\r
\r
case EFI_HII_GIBT_EXT1:\r
- BlockPtr += *(BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8));\r
+ BlockPtr += *(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8));\r
break;\r
case EFI_HII_GIBT_EXT2:\r
CopyMem (\r
&Length16,\r
- BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8),\r
+ (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
sizeof (UINT16)\r
);\r
BlockPtr += Length16;\r
case EFI_HII_GIBT_EXT4:\r
CopyMem (\r
&Length32,\r
- BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8),\r
+ (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
sizeof (UINT32)\r
);\r
BlockPtr += Length32;\r
BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);\r
if (CharCurrent == CharValue) {\r
return WriteOutputParam (\r
- BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8),\r
+ (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8)),\r
BufferLen,\r
&LocalCell,\r
GlyphBuffer,\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ if (CharValue == (CHAR16) (-1)) {\r
+ if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {\r
+ BaseLine = (UINT16) (DefaultCell.Height + DefaultCell.OffsetY);\r
+ }\r
+ if (MinOffsetY > DefaultCell.OffsetY) {\r
+ MinOffsetY = DefaultCell.OffsetY;\r
+ }\r
+ }\r
BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);\r
\r
if (CharCurrent == CharValue) {\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ if (CharValue == (CHAR16) (-1)) {\r
+ if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {\r
+ BaseLine = (UINT16) (DefaultCell.Height + DefaultCell.OffsetY);\r
+ }\r
+ if (MinOffsetY > DefaultCell.OffsetY) {\r
+ MinOffsetY = DefaultCell.OffsetY;\r
+ }\r
+ }\r
BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);\r
BlockPtr += sizeof (EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK) - sizeof (UINT8);\r
for (Index = 0; Index < Length16; Index++) {\r
)\r
{\r
UINTN FontInfoLen;\r
+ UINTN NameSize;\r
\r
ASSERT (FontName != NULL && FontInfo != NULL);\r
\r
- FontInfoLen = sizeof (EFI_FONT_INFO) - sizeof (CHAR16) + StrSize (FontName);\r
+ NameSize = StrSize (FontName);\r
+ FontInfoLen = sizeof (EFI_FONT_INFO) - sizeof (CHAR16) + NameSize;\r
*FontInfo = (EFI_FONT_INFO *) AllocateZeroPool (FontInfoLen);\r
if (*FontInfo == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- StrCpy ((*FontInfo)->FontName, FontName);\r
+ StrCpyS ((*FontInfo)->FontName, NameSize / sizeof (CHAR16), FontName);\r
return EFI_SUCCESS;\r
}\r
\r
{\r
EFI_FONT_DISPLAY_INFO *Info;\r
UINTN InfoSize;\r
+ UINTN NameSize;\r
\r
if (Private == NULL || Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE) {\r
return EFI_INVALID_PARAMETER;\r
//\r
// The standard font always has the name "sysdefault".\r
//\r
- InfoSize = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + StrSize (L"sysdefault");\r
+ NameSize = StrSize (L"sysdefault");\r
+ InfoSize = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + NameSize;\r
Info = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (InfoSize);\r
if (Info == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
Info->FontInfoMask = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;\r
Info->FontInfo.FontStyle = 0;\r
Info->FontInfo.FontSize = EFI_GLYPH_HEIGHT;\r
- StrCpy (Info->FontInfo.FontName, L"sysdefault");\r
+ StrCpyS (Info->FontInfo.FontName, NameSize / sizeof (CHAR16), L"sysdefault");\r
\r
*FontInfo = Info;\r
if (FontInfoSize != NULL) {\r
return TRUE;\r
}\r
\r
+ SystemDefault = NULL;\r
+ DefaultLen = 0;\r
+\r
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);\r
ASSERT_EFI_ERROR (Status);\r
+ ASSERT ((SystemDefault != NULL) && (DefaultLen != 0));\r
\r
//\r
// Record the system default info.\r
}\r
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == 0) {\r
if (CompareMem (\r
- &StringInfo->ForegroundColor, \r
- &SystemDefault->ForegroundColor, \r
+ &StringInfo->ForegroundColor,\r
+ &SystemDefault->ForegroundColor,\r
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
) != 0) {\r
goto Exit;\r
}\r
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == 0) {\r
if (CompareMem (\r
- &StringInfo->BackgroundColor, \r
- &SystemDefault->BackgroundColor, \r
+ &StringInfo->BackgroundColor,\r
+ &SystemDefault->BackgroundColor,\r
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
) != 0) {\r
goto Exit;\r
@param FontHandle On entry, Points to the font handle returned by a\r
previous call to GetFontInfo() or NULL to start\r
with the first font.\r
- @param GlobalFontInfo If not NULL, output the corresponding globa font\r
+ @param GlobalFontInfo If not NULL, output the corresponding global font\r
info.\r
\r
@retval TRUE Existed\r
ASSERT (FontInfo != NULL);\r
\r
//\r
- // Matched flag represents an exactly match; VagueMatched1 repensents a RESIZE\r
+ // Matched flag represents an exactly match; VagueMatched1 represents a RESIZE\r
// or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.\r
//\r
Matched = FALSE;\r
}\r
break;\r
//\r
- // If EFI_FONT_INFO_RESIZE is specified, then the sytem may attempt to\r
+ // If EFI_FONT_INFO_RESIZE is specified, then the system may attempt to\r
// stretch or shrink a font to meet the size requested.\r
//\r
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESIZE:\r
//\r
// Mandatory line break characters, which force a line-break\r
//\r
+ case 0x000A:\r
case 0x000C:\r
case 0x000D:\r
case 0x2028:\r
UINTN StrLength;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *RowBufferPtr;\r
HII_GLOBAL_FONT_INFO *GlobalFont;\r
+ UINT32 PreInitBkgnd;\r
\r
//\r
// Check incoming parameters.\r
SysFontFlag = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);\r
\r
if (SysFontFlag) {\r
+ ASSERT (SystemDefault != NULL);\r
FontInfo = NULL;\r
Height = SystemDefault->FontInfo.FontSize;\r
BaseLine = SystemDefault->FontInfo.FontSize;\r
goto Exit;\r
}\r
}\r
- \r
+\r
//\r
- // Use the maxinum height of font as the base line.\r
- // And, use the maxinum height as line height.\r
+ // Use the maximum height of font as the base line.\r
+ // And, use the maximum height as line height.\r
//\r
LineHeight = Height;\r
LastLineHeight = Height;\r
BaseLineOffset = Height - BaseLine;\r
- \r
+\r
//\r
// Parse the string to be displayed to drop some ignored characters.\r
//\r
}\r
//\r
// If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs\r
- // are not drawn. Otherwise they are replaced wth Unicode character 0xFFFD.\r
+ // are not drawn. Otherwise they are replaced with Unicode character 0xFFFD.\r
//\r
StringIn2 = AllocateZeroPool (StrSize (StringPtr));\r
if (StringIn2 == NULL) {\r
Index++;\r
continue;\r
}\r
- \r
+\r
Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);\r
if (Status == EFI_NOT_FOUND) {\r
if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {\r
//\r
Image = *Blt;\r
BufferPtr = Image->Image.Bitmap + Image->Width * BltY + BltX;\r
- ASSERT (Image->Height >= BltY);\r
+ if (Image->Height < BltY) {\r
+ //\r
+ // the top edge of the image should be in Image resolution scope.\r
+ //\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Exit;\r
+ }\r
MaxRowNum = (UINT16) ((Image->Height - BltY) / Height);\r
if ((Image->Height - BltY) % Height != 0) {\r
LastLineHeight = (Image->Height - BltY) % Height;\r
// If this character is the last character of a row, we need not\r
// draw its (AdvanceX - Width - OffsetX) for next character.\r
//\r
- LineWidth -= (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);\r
+ LineWidth -= (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);\r
\r
//\r
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.\r
//\r
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).\r
//\r
- LineWidth -= (UINTN) (Cell[Index].Width + Cell[Index].OffsetX);\r
- LineWidth -= (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);\r
+ LineWidth -= (Cell[Index].Width + Cell[Index].OffsetX);\r
+ LineWidth -= (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);\r
RowInfo[RowIndex].EndIndex = Index - 1;\r
RowInfo[RowIndex].LineWidth = LineWidth;\r
RowInfo[RowIndex].LineHeight = LineHeight;\r
// opportunity prior to a character whose right-most extent would exceed Width.\r
// Search the right-most line-break opportunity here.\r
//\r
- if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP && \r
- (RowInfo[RowIndex].LineWidth + BltX > Image->Width || StringPtr[NextIndex] != 0) && \r
+ if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP &&\r
+ (RowInfo[RowIndex].LineWidth + BltX > Image->Width || StringPtr[NextIndex] != 0) &&\r
!LineBreak) {\r
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {\r
LineWidth = RowInfo[RowIndex].LineWidth;\r
if (Index1 == RowInfo[RowIndex].StartIndex) {\r
LineWidth = 0;\r
} else {\r
- LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
+ LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
}\r
RowInfo[RowIndex].LineWidth = LineWidth;\r
}\r
//\r
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).\r
//\r
- LineWidth -= (UINTN) (Cell[Index1].Width + Cell[Index1].OffsetX);\r
- LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
+ LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);\r
+ LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
RowInfo[RowIndex].EndIndex = Index1 - 1;\r
RowInfo[RowIndex].LineWidth = LineWidth;\r
} else {\r
}\r
}\r
}\r
- \r
+\r
//\r
// LineWidth can't exceed Image width.\r
//\r
if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) {\r
BltBuffer = NULL;\r
if (RowInfo[RowIndex].LineWidth != 0) {\r
- BltBuffer = AllocateZeroPool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ BltBuffer = AllocatePool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
if (BltBuffer == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Exit;\r
}\r
//\r
+ // Initialize the background color.\r
+ //\r
+ PreInitBkgnd = Background.Blue | Background.Green << 8 | Background.Red << 16;\r
+ SetMem32 (BltBuffer,RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),PreInitBkgnd);\r
+ //\r
// Set BufferPtr to Origin by adding baseline to the starting position.\r
//\r
BufferPtr = BltBuffer + BaseLine * RowInfo[RowIndex].LineWidth;\r
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {\r
//\r
- // Only BLT these character which have corrsponding glyph in font basebase.\r
+ // Only BLT these character which have corresponding glyph in font database.\r
//\r
GlyphToImage (\r
GlyphBuf[Index1],\r
);\r
}\r
if (ColumnInfoArray != NULL) {\r
- if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0) \r
+ if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)\r
|| RowInfo[RowIndex].LineWidth == 0) {\r
*ColumnInfoArray = (UINTN) ~0;\r
} else {\r
FreePool (BltBuffer);\r
goto Exit;\r
}\r
- \r
+\r
FreePool (BltBuffer);\r
}\r
} else {\r
//\r
- // Save the starting position for calculate the starting postition of next row. \r
+ // Save the starting position for calculate the starting position of next row.\r
//\r
RowBufferPtr = BufferPtr;\r
//\r
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {\r
//\r
- // Only BLT these character which have corrsponding glyph in font basebase.\r
+ // Only BLT these character which have corresponding glyph in font database.\r
//\r
GlyphToImage (\r
GlyphBuf[Index1],\r
);\r
}\r
if (ColumnInfoArray != NULL) {\r
- if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0) \r
+ if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)\r
|| RowInfo[RowIndex].LineWidth == 0) {\r
*ColumnInfoArray = (UINTN) ~0;\r
} else {\r
\r
NextLine:\r
//\r
- // Recalculate the start point of X/Y axis to draw multi-lines with the order of top-to-down\r
+ // Recalculate the start point of Y axis to draw multi-lines with the order of top-to-down\r
//\r
- BltX = 0;\r
BltY += RowInfo[RowIndex].LineHeight;\r
\r
RowIndex++;\r
when character display is normalized that some\r
character cells overlap.\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_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 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
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the string id is not\r
+ in the specified PackageList.\r
\r
**/\r
EFI_STATUS\r
EFI_STRING String;\r
UINTN StringSize;\r
UINTN FontLen;\r
+ UINTN NameSize;\r
EFI_FONT_INFO *StringFontInfo;\r
EFI_FONT_DISPLAY_INFO *NewStringInfo;\r
CHAR8 TempSupportedLanguages;\r
if (EFI_ERROR (Status)) {\r
goto Exit;\r
}\r
- \r
+\r
if (Language == NULL) {\r
Language = "";\r
}\r
- CurrentLanguage = GetEfiGlobalVariable (L"PlatformLang");\r
+ GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLanguage, NULL);\r
BestLanguage = GetBestLanguage (\r
SupportedLanguages,\r
FALSE,\r
Status = EFI_NOT_FOUND;\r
goto Exit;\r
}\r
- \r
+\r
StringSize = MAX_STRING_LENGTH;\r
String = (EFI_STRING) AllocateZeroPool (StringSize);\r
if (String == NULL) {\r
if (EFI_ERROR (Status)) {\r
goto Exit;\r
}\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
+ // 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
+ NameSize = StrSize (StringFontInfo->FontName);\r
+ FontLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + NameSize;\r
NewStringInfo = AllocateZeroPool (FontLen);\r
- if (NewStringInfo == NULL) { \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
+ NewStringInfo->FontInfo.FontSize = StringFontInfo->FontSize;\r
+ StrCpyS (NewStringInfo->FontInfo.FontName, NameSize / sizeof (CHAR16), StringFontInfo->FontName);\r
+\r
Status = HiiStringToImage (\r
- This, \r
- Flags, \r
- String, \r
- NewStringInfo, \r
- Blt, \r
- BltX, \r
- BltY, \r
+ This,\r
+ Flags,\r
+ String,\r
+ NewStringInfo,\r
+ Blt,\r
+ BltX,\r
+ BltY,\r
RowInfoArray,\r
RowInfoArraySize,\r
ColumnInfoArray\r
Foreground = StringInfoOut->ForegroundColor;\r
Background = StringInfoOut->BackgroundColor;\r
} else {\r
+ ASSERT (SystemDefault != NULL);\r
Foreground = SystemDefault->ForegroundColor;\r
Background = SystemDefault->BackgroundColor;\r
}\r
//\r
BaseLine = (UINT16) (Cell.Height + Cell.OffsetY);\r
//\r
- // Set BltBuffer to the position of Origin. \r
+ // Set BltBuffer to the position of Origin.\r
//\r
BltBuffer = Image->Image.Bitmap + (Cell.Height + Cell.OffsetY) * Image->Width - Cell.OffsetX;\r
GlyphToImage (\r
with the first font. On return, points to the\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
- 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
- this buffer.\r
+ @param StringInfoIn Upon entry, points to the font to return information\r
+ about. If NULL, then the information about the system\r
+ default font will be returned.\r
+ @param StringInfoOut Upon return, contains the matching font's information.\r
+ If NULL, then no information is returned. This buffer\r
+ is allocated with a call to the Boot Service AllocatePool().\r
+ It is the caller's responsibility to call the Boot\r
+ Service FreePool() when the caller no longer requires\r
+ the contents of StringInfoOut.\r
@param String Points to the string which will be tested to\r
determine if all characters are available. If\r
NULL, then any font is acceptable.\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ StringInfoOutLen = 0;\r
FontInfo = NULL;\r
SystemDefault = NULL;\r
LocalFontHandle = NULL;\r
goto Exit;\r
}\r
}\r
- \r
+\r
//\r
// StringInfoIn must not be NULL if it is not system default font info.\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
+ 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
+ ((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
+ ((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
+ ((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
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_SIZE) == EFI_FONT_INFO_SYS_SIZE) {\r
InfoOut.FontInfo.FontSize = SystemDefault->FontInfo.FontSize;\r
- } \r
+ }\r
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {\r
InfoOut.FontInfo.FontStyle = SystemDefault->FontInfo.FontStyle;\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
ASSERT (FontInfo != NULL);\r
FontInfo->FontSize = InfoOut.FontInfo.FontSize;\r
FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;\r
if (IsFontInfoExisted (Private, FontInfo, &InfoOut.FontInfoMask, LocalFontHandle, &GlobalFont)) {\r
//\r
// Test to guarantee all characters are available in the found font.\r
- // \r
+ //\r
if (String != NULL) {\r
StringIn = String;\r
while (*StringIn != 0) {\r
//\r
if (StringInfoOut != NULL) {\r
StringInfoOutLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (EFI_FONT_INFO) + GlobalFont->FontInfoSize;\r
- *StringInfoOut = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (StringInfoOutLen); \r
+ *StringInfoOut = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (StringInfoOutLen);\r
if (*StringInfoOut == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
LocalFontHandle = NULL;\r
goto Exit;\r
}\r
- \r
+\r
CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));\r
CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);\r
}\r
- \r
- LocalFontHandle = GlobalFont->Entry.ForwardLink; \r
+\r
+ LocalFontHandle = GlobalFont->Entry.ForwardLink;\r
Status = EFI_SUCCESS;\r
goto Exit;\r
- } \r
+ }\r
\r
Status = EFI_NOT_FOUND;\r
\r