]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
MdeModulePkg: Change OPTIONAL keyword usage style
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Font.c
index 56b30ff6ffe3416c74fc02c2919162be649d8146..3629b249caebb213db0e064d90b6c54de8b84f42 100644 (file)
@@ -2,14 +2,8 @@
 Implementation for EFI_HII_FONT_PROTOCOL.\r
 \r
 \r
-Copyright (c) 2007 - 2016, 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
@@ -275,7 +269,7 @@ GetGlyphBuffer (
   @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
@@ -304,14 +298,14 @@ NarrowGlyphToBlt (
 \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
@@ -351,7 +345,7 @@ NarrowGlyphToBlt (
   @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
@@ -411,7 +405,7 @@ GlyphToBlt (
   // 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
@@ -419,7 +413,7 @@ GlyphToBlt (
     //\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
@@ -435,7 +429,7 @@ GlyphToBlt (
       // 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
@@ -467,7 +461,7 @@ GlyphToBlt (
   @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
@@ -593,7 +587,7 @@ GlyphToImage (
   @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
@@ -609,8 +603,8 @@ WriteOutputParam (
   IN  UINT8                          *BufferIn,\r
   IN  UINTN                          BufferLen,\r
   IN  EFI_HII_GLYPH_INFO             *InputCell,\r
-  OUT UINT8                          **GlyphBuffer, OPTIONAL\r
-  OUT EFI_HII_GLYPH_INFO             *Cell, OPTIONAL\r
+  OUT UINT8                          **GlyphBuffer  OPTIONAL,\r
+  OUT EFI_HII_GLYPH_INFO             *Cell  OPTIONAL,\r
   OUT UINTN                          *GlyphBufferLen OPTIONAL\r
   )\r
 {\r
@@ -647,7 +641,7 @@ WriteOutputParam (
   @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
@@ -663,8 +657,8 @@ EFI_STATUS
 FindGlyphBlock (\r
   IN  HII_FONT_PACKAGE_INSTANCE      *FontPackage,\r
   IN  CHAR16                         CharValue,\r
-  OUT UINT8                          **GlyphBuffer, OPTIONAL\r
-  OUT EFI_HII_GLYPH_INFO             *Cell, OPTIONAL\r
+  OUT UINT8                          **GlyphBuffer  OPTIONAL,\r
+  OUT EFI_HII_GLYPH_INFO             *Cell  OPTIONAL,\r
   OUT UINTN                          *GlyphBufferLen OPTIONAL\r
   )\r
 {\r
@@ -685,7 +679,7 @@ FindGlyphBlock (
   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
@@ -704,10 +698,6 @@ FindGlyphBlock (
       (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
@@ -843,6 +833,14 @@ FindGlyphBlock (
       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
@@ -865,6 +863,14 @@ FindGlyphBlock (
       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
@@ -993,6 +999,7 @@ GetSystemFont (
   }\r
 \r
   Info->ForegroundColor    = mHiiEfiColors[Private->Attribute & 0x0f];\r
+  ASSERT ((Private->Attribute >> 4) < 8);\r
   Info->BackgroundColor    = mHiiEfiColors[Private->Attribute >> 4];\r
   Info->FontInfoMask       = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;\r
   Info->FontInfo.FontStyle = 0;\r
@@ -1029,7 +1036,7 @@ BOOLEAN
 IsSystemFontInfo (\r
   IN  HII_DATABASE_PRIVATE_DATA      *Private,\r
   IN  EFI_FONT_DISPLAY_INFO          *StringInfo,\r
-  OUT EFI_FONT_DISPLAY_INFO          **SystemInfo, OPTIONAL\r
+  OUT EFI_FONT_DISPLAY_INFO          **SystemInfo  OPTIONAL,\r
   OUT UINTN                          *SystemInfoLen OPTIONAL\r
   )\r
 {\r
@@ -1087,8 +1094,8 @@ IsSystemFontInfo (
   }\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
@@ -1096,8 +1103,8 @@ IsSystemFontInfo (
   }\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
@@ -1131,7 +1138,7 @@ Exit:
   @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
@@ -1142,8 +1149,8 @@ BOOLEAN
 IsFontInfoExisted (\r
   IN  HII_DATABASE_PRIVATE_DATA *Private,\r
   IN  EFI_FONT_INFO             *FontInfo,\r
-  IN  EFI_FONT_INFO_MASK        *FontInfoMask,   OPTIONAL\r
-  IN  EFI_FONT_HANDLE           FontHandle,      OPTIONAL\r
+  IN  EFI_FONT_INFO_MASK        *FontInfoMask    OPTIONAL,\r
+  IN  EFI_FONT_HANDLE           FontHandle       OPTIONAL,\r
   OUT HII_GLOBAL_FONT_INFO      **GlobalFontInfo OPTIONAL\r
   )\r
 {\r
@@ -1160,7 +1167,7 @@ IsFontInfoExisted (
   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
@@ -1236,7 +1243,7 @@ IsFontInfoExisted (
         }\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
@@ -1613,6 +1620,7 @@ HiiStringToImage (
   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
@@ -1732,15 +1740,15 @@ HiiStringToImage (
       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
@@ -1770,7 +1778,7 @@ HiiStringToImage (
   }\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
@@ -1786,7 +1794,7 @@ HiiStringToImage (
       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
@@ -1914,7 +1922,7 @@ HiiStringToImage (
     // 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
@@ -1937,8 +1945,8 @@ HiiStringToImage (
         //\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
@@ -1958,8 +1966,8 @@ HiiStringToImage (
     // 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
@@ -1995,7 +2003,7 @@ HiiStringToImage (
           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
@@ -2012,8 +2020,8 @@ HiiStringToImage (
             //\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
@@ -2027,7 +2035,7 @@ HiiStringToImage (
         }\r
       }\r
     }\r
-    \r
+\r
     //\r
     // LineWidth can't exceed Image width.\r
     //\r
@@ -2043,12 +2051,17 @@ HiiStringToImage (
     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
@@ -2056,7 +2069,7 @@ HiiStringToImage (
       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
@@ -2073,7 +2086,7 @@ HiiStringToImage (
           );\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
@@ -2101,12 +2114,12 @@ HiiStringToImage (
           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
@@ -2116,7 +2129,7 @@ HiiStringToImage (
       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
@@ -2133,7 +2146,7 @@ HiiStringToImage (
           );\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
@@ -2281,13 +2294,13 @@ Exit:
                                   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
@@ -2374,7 +2387,7 @@ HiiStringIdToImage (
   if (EFI_ERROR (Status)) {\r
     goto Exit;\r
   }\r
\r
+\r
   if (Language == NULL) {\r
     Language = "";\r
   }\r
@@ -2391,7 +2404,7 @@ HiiStringIdToImage (
     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
@@ -2429,33 +2442,33 @@ HiiStringIdToImage (
   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
     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
+    NewStringInfo->FontInfo.FontSize  = StringFontInfo->FontSize;\r
     StrCpyS (NewStringInfo->FontInfo.FontName, NameSize / sizeof (CHAR16), StringFontInfo->FontName);\r
-  \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
@@ -2622,7 +2635,7 @@ HiiGetGlyph (
     //\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
@@ -2697,7 +2710,7 @@ Exit:
   @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
+                                  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
@@ -2716,7 +2729,7 @@ EFIAPI
 HiiGetFontInfo (\r
   IN  CONST EFI_HII_FONT_PROTOCOL    *This,\r
   IN  OUT   EFI_FONT_HANDLE          *FontHandle,\r
-  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfoIn, OPTIONAL\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
@@ -2782,7 +2795,7 @@ HiiGetFontInfo (
       goto Exit;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // StringInfoIn must not be NULL if it is not system default font info.\r
   //\r
@@ -2790,15 +2803,15 @@ HiiGetFontInfo (
   //\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
@@ -2820,7 +2833,7 @@ HiiGetFontInfo (
 \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
@@ -2830,7 +2843,7 @@ HiiGetFontInfo (
   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
@@ -2838,7 +2851,7 @@ HiiGetFontInfo (
   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
@@ -2855,21 +2868,21 @@ HiiGetFontInfo (
     //\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
@@ -2887,5 +2900,3 @@ Exit:
   }\r
   return Status;\r
 }\r
-\r
-\r