]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Font.c
index 3629b249caebb213db0e064d90b6c54de8b84f42..399f90feb783bb578921941faeee3441c4de87d3 100644 (file)
@@ -7,32 +7,30 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 **/\r
 \r
-\r
 #include "HiiDatabase.h"\r
 \r
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mHiiEfiColors[16] = {\r
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mHiiEfiColors[16] = {\r
   //\r
   // B     G     R\r
   //\r
-  {0x00, 0x00, 0x00, 0x00},  // BLACK\r
-  {0x98, 0x00, 0x00, 0x00},  // BLUE\r
-  {0x00, 0x98, 0x00, 0x00},  // GREEN\r
-  {0x98, 0x98, 0x00, 0x00},  // CYAN\r
-  {0x00, 0x00, 0x98, 0x00},  // RED\r
-  {0x98, 0x00, 0x98, 0x00},  // MAGENTA\r
-  {0x00, 0x98, 0x98, 0x00},  // BROWN\r
-  {0x98, 0x98, 0x98, 0x00},  // LIGHTGRAY\r
-  {0x30, 0x30, 0x30, 0x00},  // DARKGRAY - BRIGHT BLACK\r
-  {0xff, 0x00, 0x00, 0x00},  // LIGHTBLUE\r
-  {0x00, 0xff, 0x00, 0x00},  // LIGHTGREEN\r
-  {0xff, 0xff, 0x00, 0x00},  // LIGHTCYAN\r
-  {0x00, 0x00, 0xff, 0x00},  // LIGHTRED\r
-  {0xff, 0x00, 0xff, 0x00},  // LIGHTMAGENTA\r
-  {0x00, 0xff, 0xff, 0x00},  // YELLOW\r
-  {0xff, 0xff, 0xff, 0x00},  // WHITE\r
+  { 0x00, 0x00, 0x00, 0x00 },  // BLACK\r
+  { 0x98, 0x00, 0x00, 0x00 },  // BLUE\r
+  { 0x00, 0x98, 0x00, 0x00 },  // GREEN\r
+  { 0x98, 0x98, 0x00, 0x00 },  // CYAN\r
+  { 0x00, 0x00, 0x98, 0x00 },  // RED\r
+  { 0x98, 0x00, 0x98, 0x00 },  // MAGENTA\r
+  { 0x00, 0x98, 0x98, 0x00 },  // BROWN\r
+  { 0x98, 0x98, 0x98, 0x00 },  // LIGHTGRAY\r
+  { 0x30, 0x30, 0x30, 0x00 },  // DARKGRAY - BRIGHT BLACK\r
+  { 0xff, 0x00, 0x00, 0x00 },  // LIGHTBLUE\r
+  { 0x00, 0xff, 0x00, 0x00 },  // LIGHTGREEN\r
+  { 0xff, 0xff, 0x00, 0x00 },  // LIGHTCYAN\r
+  { 0x00, 0x00, 0xff, 0x00 },  // LIGHTRED\r
+  { 0xff, 0x00, 0xff, 0x00 },  // LIGHTMAGENTA\r
+  { 0x00, 0xff, 0xff, 0x00 },  // YELLOW\r
+  { 0xff, 0xff, 0xff, 0x00 },  // WHITE\r
 };\r
 \r
-\r
 /**\r
   Insert a character cell information to the list specified by GlyphInfoList.\r
 \r
@@ -50,16 +48,16 @@ EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mHiiEfiColors[16] = {
 **/\r
 EFI_STATUS\r
 NewCell (\r
-  IN  CHAR16                         CharValue,\r
-  IN  LIST_ENTRY                     *GlyphInfoList,\r
-  IN  EFI_HII_GLYPH_INFO             *Cell\r
+  IN  CHAR16              CharValue,\r
+  IN  LIST_ENTRY          *GlyphInfoList,\r
+  IN  EFI_HII_GLYPH_INFO  *Cell\r
   )\r
 {\r
-  HII_GLYPH_INFO           *GlyphInfo;\r
+  HII_GLYPH_INFO  *GlyphInfo;\r
 \r
   ASSERT (Cell != NULL && GlyphInfoList != NULL);\r
 \r
-  GlyphInfo = (HII_GLYPH_INFO *) AllocateZeroPool (sizeof (HII_GLYPH_INFO));\r
+  GlyphInfo = (HII_GLYPH_INFO *)AllocateZeroPool (sizeof (HII_GLYPH_INFO));\r
   if (GlyphInfo == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -73,13 +71,13 @@ NewCell (
   if (Cell->AdvanceX == 0) {\r
     Cell->AdvanceX = Cell->Width;\r
   }\r
+\r
   CopyMem (&GlyphInfo->Cell, Cell, sizeof (EFI_HII_GLYPH_INFO));\r
   InsertTailList (GlyphInfoList, &GlyphInfo->Entry);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Get a character cell information from the list specified by GlyphInfoList.\r
 \r
@@ -98,13 +96,13 @@ NewCell (
 **/\r
 EFI_STATUS\r
 GetCell (\r
-  IN  CHAR16                         CharValue,\r
-  IN  LIST_ENTRY                     *GlyphInfoList,\r
-  OUT EFI_HII_GLYPH_INFO             *Cell\r
+  IN  CHAR16              CharValue,\r
+  IN  LIST_ENTRY          *GlyphInfoList,\r
+  OUT EFI_HII_GLYPH_INFO  *Cell\r
   )\r
 {\r
-  HII_GLYPH_INFO           *GlyphInfo;\r
-  LIST_ENTRY               *Link;\r
+  HII_GLYPH_INFO  *GlyphInfo;\r
+  LIST_ENTRY      *Link;\r
 \r
   ASSERT (Cell != NULL && GlyphInfoList != NULL);\r
 \r
@@ -129,7 +127,6 @@ GetCell (
   return EFI_NOT_FOUND;\r
 }\r
 \r
-\r
 /**\r
   Convert the glyph for a single character into a bitmap.\r
 \r
@@ -152,30 +149,31 @@ GetCell (
 **/\r
 EFI_STATUS\r
 GetGlyphBuffer (\r
-  IN  HII_DATABASE_PRIVATE_DATA      *Private,\r
-  IN  CHAR16                         Char,\r
-  IN  EFI_FONT_INFO                  *StringInfo,\r
-  OUT UINT8                          **GlyphBuffer,\r
-  OUT EFI_HII_GLYPH_INFO             *Cell,\r
-  OUT UINT8                          *Attributes OPTIONAL\r
+  IN  HII_DATABASE_PRIVATE_DATA  *Private,\r
+  IN  CHAR16                     Char,\r
+  IN  EFI_FONT_INFO              *StringInfo,\r
+  OUT UINT8                      **GlyphBuffer,\r
+  OUT EFI_HII_GLYPH_INFO         *Cell,\r
+  OUT UINT8                      *Attributes OPTIONAL\r
   )\r
 {\r
-  HII_DATABASE_RECORD                *Node;\r
-  LIST_ENTRY                         *Link;\r
-  HII_SIMPLE_FONT_PACKAGE_INSTANCE   *SimpleFont;\r
-  LIST_ENTRY                         *Link1;\r
-  UINT16                             Index;\r
-  EFI_NARROW_GLYPH                   Narrow;\r
-  EFI_WIDE_GLYPH                     Wide;\r
-  HII_GLOBAL_FONT_INFO               *GlobalFont;\r
-  UINTN                              HeaderSize;\r
-  EFI_NARROW_GLYPH                   *NarrowPtr;\r
-  EFI_WIDE_GLYPH                     *WidePtr;\r
-\r
-  if (GlyphBuffer == NULL || Cell == NULL) {\r
+  HII_DATABASE_RECORD               *Node;\r
+  LIST_ENTRY                        *Link;\r
+  HII_SIMPLE_FONT_PACKAGE_INSTANCE  *SimpleFont;\r
+  LIST_ENTRY                        *Link1;\r
+  UINT16                            Index;\r
+  EFI_NARROW_GLYPH                  Narrow;\r
+  EFI_WIDE_GLYPH                    Wide;\r
+  HII_GLOBAL_FONT_INFO              *GlobalFont;\r
+  UINTN                             HeaderSize;\r
+  EFI_NARROW_GLYPH                  *NarrowPtr;\r
+  EFI_WIDE_GLYPH                    *WidePtr;\r
+\r
+  if ((GlyphBuffer == NULL) || (Cell == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  if (Private == NULL || Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE) {\r
+\r
+  if ((Private == NULL) || (Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -188,12 +186,14 @@ GetGlyphBuffer (
   // default system font is the fixed font (narrow or wide glyph).\r
   //\r
   if (StringInfo != NULL) {\r
-    if(!IsFontInfoExisted (Private, StringInfo, NULL, NULL, &GlobalFont)) {\r
+    if (!IsFontInfoExisted (Private, StringInfo, NULL, NULL, &GlobalFont)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
+\r
     if (Attributes != NULL) {\r
       *Attributes = PROPORTIONAL_GLYPH;\r
     }\r
+\r
     return FindGlyphBlock (GlobalFont->FontPackage, Char, GlyphBuffer, Cell, NULL);\r
   } else {\r
     HeaderSize = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR);\r
@@ -203,48 +203,54 @@ GetGlyphBuffer (
       for (Link1 = Node->PackageList->SimpleFontPkgHdr.ForwardLink;\r
            Link1 != &Node->PackageList->SimpleFontPkgHdr;\r
            Link1 = Link1->ForwardLink\r
-          ) {\r
+           )\r
+      {\r
         SimpleFont = CR (Link1, HII_SIMPLE_FONT_PACKAGE_INSTANCE, SimpleFontEntry, HII_S_FONT_PACKAGE_SIGNATURE);\r
         //\r
         // Search the narrow glyph array\r
         //\r
-        NarrowPtr = (EFI_NARROW_GLYPH *) ((UINT8 *) (SimpleFont->SimpleFontPkgHdr) + HeaderSize);\r
+        NarrowPtr = (EFI_NARROW_GLYPH *)((UINT8 *)(SimpleFont->SimpleFontPkgHdr) + HeaderSize);\r
         for (Index = 0; Index < SimpleFont->SimpleFontPkgHdr->NumberOfNarrowGlyphs; Index++) {\r
-          CopyMem (&Narrow, NarrowPtr + Index,sizeof (EFI_NARROW_GLYPH));\r
+          CopyMem (&Narrow, NarrowPtr + Index, sizeof (EFI_NARROW_GLYPH));\r
           if (Narrow.UnicodeWeight == Char) {\r
-            *GlyphBuffer = (UINT8 *) AllocateZeroPool (EFI_GLYPH_HEIGHT);\r
+            *GlyphBuffer = (UINT8 *)AllocateZeroPool (EFI_GLYPH_HEIGHT);\r
             if (*GlyphBuffer == NULL) {\r
               return EFI_OUT_OF_RESOURCES;\r
             }\r
+\r
             Cell->Width    = EFI_GLYPH_WIDTH;\r
             Cell->Height   = EFI_GLYPH_HEIGHT;\r
             Cell->AdvanceX = Cell->Width;\r
             CopyMem (*GlyphBuffer, Narrow.GlyphCol1, Cell->Height);\r
             if (Attributes != NULL) {\r
-              *Attributes = (UINT8) (Narrow.Attributes | NARROW_GLYPH);\r
+              *Attributes = (UINT8)(Narrow.Attributes | NARROW_GLYPH);\r
             }\r
+\r
             return EFI_SUCCESS;\r
           }\r
         }\r
+\r
         //\r
         // Search the wide glyph array\r
         //\r
-        WidePtr = (EFI_WIDE_GLYPH *) (NarrowPtr + SimpleFont->SimpleFontPkgHdr->NumberOfNarrowGlyphs);\r
+        WidePtr = (EFI_WIDE_GLYPH *)(NarrowPtr + SimpleFont->SimpleFontPkgHdr->NumberOfNarrowGlyphs);\r
         for (Index = 0; Index < SimpleFont->SimpleFontPkgHdr->NumberOfWideGlyphs; Index++) {\r
           CopyMem (&Wide, WidePtr + Index, sizeof (EFI_WIDE_GLYPH));\r
           if (Wide.UnicodeWeight == Char) {\r
-            *GlyphBuffer    = (UINT8 *) AllocateZeroPool (EFI_GLYPH_HEIGHT * 2);\r
+            *GlyphBuffer = (UINT8 *)AllocateZeroPool (EFI_GLYPH_HEIGHT * 2);\r
             if (*GlyphBuffer == NULL) {\r
               return EFI_OUT_OF_RESOURCES;\r
             }\r
+\r
             Cell->Width    = EFI_GLYPH_WIDTH * 2;\r
             Cell->Height   = EFI_GLYPH_HEIGHT;\r
             Cell->AdvanceX = Cell->Width;\r
             CopyMem (*GlyphBuffer, Wide.GlyphCol1, EFI_GLYPH_HEIGHT);\r
             CopyMem (*GlyphBuffer + EFI_GLYPH_HEIGHT, Wide.GlyphCol2, EFI_GLYPH_HEIGHT);\r
             if (Attributes != NULL) {\r
-              *Attributes = (UINT8) (Wide.Attributes | EFI_GLYPH_WIDE);\r
+              *Attributes = (UINT8)(Wide.Attributes | EFI_GLYPH_WIDE);\r
             }\r
+\r
             return EFI_SUCCESS;\r
           }\r
         }\r
@@ -278,21 +284,21 @@ GetGlyphBuffer (
 **/\r
 VOID\r
 NarrowGlyphToBlt (\r
-  IN     UINT8                         *GlyphBuffer,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
-  IN     UINT16                        ImageWidth,\r
-  IN     UINTN                         RowWidth,\r
-  IN     UINTN                         RowHeight,\r
-  IN     BOOLEAN                       Transparent,\r
-  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
+  IN     UINT8                          *GlyphBuffer,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,\r
+  IN     UINT16                         ImageWidth,\r
+  IN     UINTN                          RowWidth,\r
+  IN     UINTN                          RowHeight,\r
+  IN     BOOLEAN                        Transparent,\r
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  **Origin\r
   )\r
 {\r
-  UINT8                                Xpos;\r
-  UINT8                                Ypos;\r
-  UINT8                                Height;\r
-  UINT8                                Width;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL        *Buffer;\r
+  UINT8                          Xpos;\r
+  UINT8                          Ypos;\r
+  UINT8                          Height;\r
+  UINT8                          Width;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Buffer;\r
 \r
   ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);\r
 \r
@@ -308,10 +314,11 @@ NarrowGlyphToBlt (
   // Char may be partially displayed when CLIP_X or CLIP_Y is not set.\r
   //\r
   if (RowHeight < Height) {\r
-    Height = (UINT8) RowHeight;\r
+    Height = (UINT8)RowHeight;\r
   }\r
+\r
   if (RowWidth < Width) {\r
-    Width = (UINT8) RowWidth;\r
+    Width = (UINT8)RowWidth;\r
   }\r
 \r
   for (Ypos = 0; Ypos < Height; Ypos++) {\r
@@ -329,7 +336,6 @@ NarrowGlyphToBlt (
   *Origin = *Origin + EFI_GLYPH_WIDTH;\r
 }\r
 \r
-\r
 /**\r
   Convert bitmap data of the glyph to blt structure.\r
 \r
@@ -357,26 +363,26 @@ NarrowGlyphToBlt (
 **/\r
 VOID\r
 GlyphToBlt (\r
-  IN     UINT8                         *GlyphBuffer,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
-  IN     UINT16                        ImageWidth,\r
-  IN     UINT16                        BaseLine,\r
-  IN     UINTN                         RowWidth,\r
-  IN     UINTN                         RowHeight,\r
-  IN     BOOLEAN                       Transparent,\r
-  IN     CONST EFI_HII_GLYPH_INFO      *Cell,\r
-  IN     UINT8                         Attributes,\r
-  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
+  IN     UINT8                          *GlyphBuffer,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,\r
+  IN     UINT16                         ImageWidth,\r
+  IN     UINT16                         BaseLine,\r
+  IN     UINTN                          RowWidth,\r
+  IN     UINTN                          RowHeight,\r
+  IN     BOOLEAN                        Transparent,\r
+  IN     CONST EFI_HII_GLYPH_INFO       *Cell,\r
+  IN     UINT8                          Attributes,\r
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  **Origin\r
   )\r
 {\r
-  UINT16                                Xpos;\r
-  UINT16                                Ypos;\r
-  UINT8                                 Data;\r
-  UINT16                                Index;\r
-  UINT16                                YposOffset;\r
-  UINTN                                 OffsetY;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL         *BltBuffer;\r
+  UINT16                         Xpos;\r
+  UINT16                         Ypos;\r
+  UINT8                          Data;\r
+  UINT16                         Index;\r
+  UINT16                         YposOffset;\r
+  UINTN                          OffsetY;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer;\r
 \r
   ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);\r
 \r
@@ -387,11 +393,12 @@ GlyphToBlt (
     *Origin = *Origin + Cell->AdvanceX;\r
     return;\r
   }\r
+\r
   //\r
   // Move position to the left-top corner of char.\r
   //\r
   BltBuffer  = *Origin + Cell->OffsetX - (Cell->OffsetY + Cell->Height) * ImageWidth;\r
-  YposOffset = (UINT16) (BaseLine - (Cell->OffsetY + Cell->Height));\r
+  YposOffset = (UINT16)(BaseLine - (Cell->OffsetY + Cell->Height));\r
 \r
   //\r
   // Since non-spacing key will be printed OR'd with the previous glyph, don't\r
@@ -405,15 +412,15 @@ 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 && (((UINT32) 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
     // All bits in these bytes are meaningful.\r
     //\r
     for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {\r
-      Data  = *(GlyphBuffer + OffsetY + Xpos);\r
-      for (Index = 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+      Data = *(GlyphBuffer + OffsetY + Xpos);\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
@@ -428,8 +435,8 @@ GlyphToBlt (
       //\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 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {\r
+      Data = *(GlyphBuffer + OffsetY + Xpos);\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
@@ -439,13 +446,11 @@ GlyphToBlt (
         }\r
       }\r
     } // end of if (Width % 8...)\r
-\r
   } // end of for (Ypos=0...)\r
 \r
   *Origin = *Origin + Cell->AdvanceX;\r
 }\r
 \r
-\r
 /**\r
   Convert bitmap data of the glyph to blt structure.\r
 \r
@@ -474,20 +479,20 @@ GlyphToBlt (
 **/\r
 VOID\r
 GlyphToImage (\r
-  IN     UINT8                         *GlyphBuffer,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
-  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
-  IN     UINT16                        ImageWidth,\r
-  IN     UINT16                        BaseLine,\r
-  IN     UINTN                         RowWidth,\r
-  IN     UINTN                         RowHeight,\r
-  IN     BOOLEAN                       Transparent,\r
-  IN     CONST EFI_HII_GLYPH_INFO      *Cell,\r
-  IN     UINT8                         Attributes,\r
-  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
+  IN     UINT8                          *GlyphBuffer,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,\r
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,\r
+  IN     UINT16                         ImageWidth,\r
+  IN     UINT16                         BaseLine,\r
+  IN     UINTN                          RowWidth,\r
+  IN     UINTN                          RowHeight,\r
+  IN     BOOLEAN                        Transparent,\r
+  IN     CONST EFI_HII_GLYPH_INFO       *Cell,\r
+  IN     UINT8                          Attributes,\r
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  **Origin\r
   )\r
 {\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL        *Buffer;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Buffer;\r
 \r
   ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);\r
 \r
@@ -512,7 +517,6 @@ GlyphToImage (
       Attributes,\r
       &Buffer\r
       );\r
-\r
   } else if ((Attributes & EFI_GLYPH_WIDE) == EFI_GLYPH_WIDE) {\r
     //\r
     // This character is wide glyph, i.e. 16 pixels * 19 pixels.\r
@@ -539,7 +543,6 @@ GlyphToImage (
       Transparent,\r
       Origin\r
       );\r
-\r
   } else if ((Attributes & NARROW_GLYPH) == NARROW_GLYPH) {\r
     //\r
     // This character is narrow glyph, i.e. 8 pixels * 19 pixels.\r
@@ -554,7 +557,6 @@ GlyphToImage (
       Transparent,\r
       Origin\r
       );\r
-\r
   } else if ((Attributes & PROPORTIONAL_GLYPH) == PROPORTIONAL_GLYPH) {\r
     //\r
     // This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.\r
@@ -575,7 +577,6 @@ GlyphToImage (
   }\r
 }\r
 \r
-\r
 /**\r
   Write the output parameters of FindGlyphBlock().\r
 \r
@@ -600,15 +601,15 @@ GlyphToImage (
 **/\r
 EFI_STATUS\r
 WriteOutputParam (\r
-  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 UINTN                          *GlyphBufferLen OPTIONAL\r
+  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 UINTN               *GlyphBufferLen OPTIONAL\r
   )\r
 {\r
-  if (BufferIn == NULL || InputCell == NULL) {\r
+  if ((BufferIn == NULL) || (InputCell == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -616,11 +617,12 @@ WriteOutputParam (
     CopyMem (Cell, InputCell, sizeof (EFI_HII_GLYPH_INFO));\r
   }\r
 \r
-  if (GlyphBuffer != NULL && BufferLen > 0) {\r
-    *GlyphBuffer = (UINT8 *) AllocateZeroPool (BufferLen);\r
+  if ((GlyphBuffer != NULL) && (BufferLen > 0)) {\r
+    *GlyphBuffer = (UINT8 *)AllocateZeroPool (BufferLen);\r
     if (*GlyphBuffer == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
+\r
     CopyMem (*GlyphBuffer, BufferIn, BufferLen);\r
   }\r
 \r
@@ -631,7 +633,6 @@ WriteOutputParam (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Parse all glyph blocks to find a glyph block specified by CharValue.\r
   If CharValue = (CHAR16) (-1), collect all default character cell information\r
@@ -655,32 +656,32 @@ WriteOutputParam (
 **/\r
 EFI_STATUS\r
 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 UINTN                          *GlyphBufferLen OPTIONAL\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 UINTN                      *GlyphBufferLen OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                          Status;\r
-  UINT8                               *BlockPtr;\r
-  UINT16                              CharCurrent;\r
-  UINT16                              Length16;\r
-  UINT32                              Length32;\r
-  EFI_HII_GIBT_GLYPHS_BLOCK           Glyphs;\r
-  UINTN                               BufferLen;\r
-  UINT16                              Index;\r
-  EFI_HII_GLYPH_INFO                  DefaultCell;\r
-  EFI_HII_GLYPH_INFO                  LocalCell;\r
-  INT16                               MinOffsetY;\r
-  UINT16                              BaseLine;\r
+  EFI_STATUS                 Status;\r
+  UINT8                      *BlockPtr;\r
+  UINT16                     CharCurrent;\r
+  UINT16                     Length16;\r
+  UINT32                     Length32;\r
+  EFI_HII_GIBT_GLYPHS_BLOCK  Glyphs;\r
+  UINTN                      BufferLen;\r
+  UINT16                     Index;\r
+  EFI_HII_GLYPH_INFO         DefaultCell;\r
+  EFI_HII_GLYPH_INFO         LocalCell;\r
+  INT16                      MinOffsetY;\r
+  UINT16                     BaseLine;\r
 \r
   ASSERT (FontPackage != NULL);\r
   ASSERT (FontPackage->Signature == HII_FONT_PACKAGE_SIGNATURE);\r
-  BaseLine  = 0;\r
+  BaseLine   = 0;\r
   MinOffsetY = 0;\r
 \r
-  if (CharValue == (CHAR16) (-1)) {\r
+  if (CharValue == (CHAR16)(-1)) {\r
     //\r
     // Collect the cell information specified in font package fixed header.\r
     // Use CharValue =0 to represent this particular cell.\r
@@ -688,14 +689,15 @@ FindGlyphBlock (
     Status = NewCell (\r
                0,\r
                &FontPackage->GlyphInfoList,\r
-               (EFI_HII_GLYPH_INFO *) ((UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32))\r
+               (EFI_HII_GLYPH_INFO *)((UINT8 *)FontPackage->FontPkgHdr + 3 * sizeof (UINT32))\r
                );\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
+\r
     CopyMem (\r
       &LocalCell,\r
-      (UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32),\r
+      (UINT8 *)FontPackage->FontPkgHdr + 3 * sizeof (UINT32),\r
       sizeof (EFI_HII_GLYPH_INFO)\r
       );\r
   }\r
@@ -706,177 +708,159 @@ FindGlyphBlock (
 \r
   while (*BlockPtr != EFI_HII_GIBT_END) {\r
     switch (*BlockPtr) {\r
-    case EFI_HII_GIBT_DEFAULTS:\r
-      //\r
-      // Collect all default character cell information specified by\r
-      // EFI_HII_GIBT_DEFAULTS.\r
-      //\r
-      if (CharValue == (CHAR16) (-1)) {\r
-        Status = NewCell (\r
-                   CharCurrent,\r
-                   &FontPackage->GlyphInfoList,\r
-                   (EFI_HII_GLYPH_INFO *) (BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))\r
-                   );\r
-        if (EFI_ERROR (Status)) {\r
-          return Status;\r
+      case EFI_HII_GIBT_DEFAULTS:\r
+        //\r
+        // Collect all default character cell information specified by\r
+        // EFI_HII_GIBT_DEFAULTS.\r
+        //\r
+        if (CharValue == (CHAR16)(-1)) {\r
+          Status = NewCell (\r
+                     CharCurrent,\r
+                     &FontPackage->GlyphInfoList,\r
+                     (EFI_HII_GLYPH_INFO *)(BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))\r
+                     );\r
+          if (EFI_ERROR (Status)) {\r
+            return Status;\r
+          }\r
+\r
+          CopyMem (\r
+            &LocalCell,\r
+            BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),\r
+            sizeof (EFI_HII_GLYPH_INFO)\r
+            );\r
+          if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {\r
+            BaseLine = (UINT16)(LocalCell.Height + LocalCell.OffsetY);\r
+          }\r
+\r
+          if (MinOffsetY > LocalCell.OffsetY) {\r
+            MinOffsetY = LocalCell.OffsetY;\r
+          }\r
         }\r
+\r
+        BlockPtr += sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK);\r
+        break;\r
+\r
+      case EFI_HII_GIBT_DUPLICATE:\r
+        if (CharCurrent == CharValue) {\r
+          CopyMem (&CharValue, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (CHAR16));\r
+          CharCurrent = 1;\r
+          BlockPtr    = FontPackage->GlyphBlock;\r
+          continue;\r
+        }\r
+\r
+        CharCurrent++;\r
+        BlockPtr += sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK);\r
+        break;\r
+\r
+      case EFI_HII_GIBT_EXT1:\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
+          (UINT8 *)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
+          sizeof (UINT16)\r
+          );\r
+        BlockPtr += Length16;\r
+        break;\r
+      case EFI_HII_GIBT_EXT4:\r
+        CopyMem (\r
+          &Length32,\r
+          (UINT8 *)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
+          sizeof (UINT32)\r
+          );\r
+        BlockPtr += Length32;\r
+        break;\r
+\r
+      case EFI_HII_GIBT_GLYPH:\r
         CopyMem (\r
           &LocalCell,\r
           BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),\r
           sizeof (EFI_HII_GLYPH_INFO)\r
           );\r
-        if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {\r
-          BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);\r
-        }\r
-        if (MinOffsetY > LocalCell.OffsetY) {\r
-          MinOffsetY = LocalCell.OffsetY;\r
-        }\r
-      }\r
-      BlockPtr += sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK);\r
-      break;\r
-\r
-    case EFI_HII_GIBT_DUPLICATE:\r
-      if (CharCurrent == CharValue) {\r
-        CopyMem (&CharValue, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (CHAR16));\r
-        CharCurrent = 1;\r
-        BlockPtr    = FontPackage->GlyphBlock;\r
-        continue;\r
-      }\r
-      CharCurrent++;\r
-      BlockPtr += sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK);\r
-      break;\r
-\r
-    case EFI_HII_GIBT_EXT1:\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
-        (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
-        sizeof (UINT16)\r
-        );\r
-      BlockPtr += Length16;\r
-      break;\r
-    case EFI_HII_GIBT_EXT4:\r
-      CopyMem (\r
-        &Length32,\r
-        (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),\r
-        sizeof (UINT32)\r
-        );\r
-      BlockPtr += Length32;\r
-      break;\r
-\r
-    case EFI_HII_GIBT_GLYPH:\r
-      CopyMem (\r
-        &LocalCell,\r
-        BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),\r
-        sizeof (EFI_HII_GLYPH_INFO)\r
-        );\r
-      if (CharValue == (CHAR16) (-1)) {\r
-        if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {\r
-          BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);\r
-        }\r
-        if (MinOffsetY > LocalCell.OffsetY) {\r
-          MinOffsetY = LocalCell.OffsetY;\r
-        }\r
-      }\r
-      BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);\r
-      if (CharCurrent == CharValue) {\r
-        return WriteOutputParam (\r
-                 (UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8)),\r
-                 BufferLen,\r
-                 &LocalCell,\r
-                 GlyphBuffer,\r
-                 Cell,\r
-                 GlyphBufferLen\r
-                 );\r
-      }\r
-      CharCurrent++;\r
-      BlockPtr += sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8) + BufferLen;\r
-      break;\r
-\r
-    case EFI_HII_GIBT_GLYPHS:\r
-      BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK);\r
-      CopyMem (&Glyphs.Cell, BlockPtr, sizeof (EFI_HII_GLYPH_INFO));\r
-      BlockPtr += sizeof (EFI_HII_GLYPH_INFO);\r
-      CopyMem (&Glyphs.Count, BlockPtr, sizeof (UINT16));\r
-      BlockPtr += sizeof (UINT16);\r
+        if (CharValue == (CHAR16)(-1)) {\r
+          if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {\r
+            BaseLine = (UINT16)(LocalCell.Height + LocalCell.OffsetY);\r
+          }\r
 \r
-      if (CharValue == (CHAR16) (-1)) {\r
-        if (BaseLine < Glyphs.Cell.Height + Glyphs.Cell.OffsetY) {\r
-          BaseLine = (UINT16) (Glyphs.Cell.Height + Glyphs.Cell.OffsetY);\r
-        }\r
-        if (MinOffsetY > Glyphs.Cell.OffsetY) {\r
-          MinOffsetY = Glyphs.Cell.OffsetY;\r
+          if (MinOffsetY > LocalCell.OffsetY) {\r
+            MinOffsetY = LocalCell.OffsetY;\r
+          }\r
         }\r
-      }\r
 \r
-      BufferLen = BITMAP_LEN_1_BIT (Glyphs.Cell.Width, Glyphs.Cell.Height);\r
-      for (Index = 0; Index < Glyphs.Count; Index++) {\r
-        if (CharCurrent + Index == CharValue) {\r
+        BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);\r
+        if (CharCurrent == CharValue) {\r
           return WriteOutputParam (\r
-                   BlockPtr,\r
+                   (UINT8 *)((UINTN)BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8)),\r
                    BufferLen,\r
-                   &Glyphs.Cell,\r
+                   &LocalCell,\r
                    GlyphBuffer,\r
                    Cell,\r
                    GlyphBufferLen\r
                    );\r
         }\r
-        BlockPtr += BufferLen;\r
-      }\r
-      CharCurrent = (UINT16) (CharCurrent + Glyphs.Count);\r
-      break;\r
 \r
-    case EFI_HII_GIBT_GLYPH_DEFAULT:\r
-      Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);\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
+        CharCurrent++;\r
+        BlockPtr += sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8) + BufferLen;\r
+        break;\r
+\r
+      case EFI_HII_GIBT_GLYPHS:\r
+        BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK);\r
+        CopyMem (&Glyphs.Cell, BlockPtr, sizeof (EFI_HII_GLYPH_INFO));\r
+        BlockPtr += sizeof (EFI_HII_GLYPH_INFO);\r
+        CopyMem (&Glyphs.Count, BlockPtr, sizeof (UINT16));\r
+        BlockPtr += sizeof (UINT16);\r
+\r
+        if (CharValue == (CHAR16)(-1)) {\r
+          if (BaseLine < Glyphs.Cell.Height + Glyphs.Cell.OffsetY) {\r
+            BaseLine = (UINT16)(Glyphs.Cell.Height + Glyphs.Cell.OffsetY);\r
+          }\r
+\r
+          if (MinOffsetY > Glyphs.Cell.OffsetY) {\r
+            MinOffsetY = Glyphs.Cell.OffsetY;\r
+          }\r
         }\r
-        if (MinOffsetY > DefaultCell.OffsetY) {\r
-          MinOffsetY = DefaultCell.OffsetY;\r
+\r
+        BufferLen = BITMAP_LEN_1_BIT (Glyphs.Cell.Width, Glyphs.Cell.Height);\r
+        for (Index = 0; Index < Glyphs.Count; Index++) {\r
+          if (CharCurrent + Index == CharValue) {\r
+            return WriteOutputParam (\r
+                     BlockPtr,\r
+                     BufferLen,\r
+                     &Glyphs.Cell,\r
+                     GlyphBuffer,\r
+                     Cell,\r
+                     GlyphBufferLen\r
+                     );\r
+          }\r
+\r
+          BlockPtr += BufferLen;\r
         }\r
-      }\r
-      BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);\r
-\r
-      if (CharCurrent == CharValue) {\r
-        return WriteOutputParam (\r
-                 BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),\r
-                 BufferLen,\r
-                 &DefaultCell,\r
-                 GlyphBuffer,\r
-                 Cell,\r
-                 GlyphBufferLen\r
-                 );\r
-      }\r
-      CharCurrent++;\r
-      BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK) + BufferLen;\r
-      break;\r
 \r
-    case EFI_HII_GIBT_GLYPHS_DEFAULT:\r
-      CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));\r
-      Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);\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
+        CharCurrent = (UINT16)(CharCurrent + Glyphs.Count);\r
+        break;\r
+\r
+      case EFI_HII_GIBT_GLYPH_DEFAULT:\r
+        Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);\r
+        if (EFI_ERROR (Status)) {\r
+          return Status;\r
         }\r
-        if (MinOffsetY > DefaultCell.OffsetY) {\r
-          MinOffsetY = DefaultCell.OffsetY;\r
+\r
+        if (CharValue == (CHAR16)(-1)) {\r
+          if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {\r
+            BaseLine = (UINT16)(DefaultCell.Height + DefaultCell.OffsetY);\r
+          }\r
+\r
+          if (MinOffsetY > DefaultCell.OffsetY) {\r
+            MinOffsetY = DefaultCell.OffsetY;\r
+          }\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
-        if (CharCurrent + Index == CharValue) {\r
+\r
+        BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);\r
+\r
+        if (CharCurrent == CharValue) {\r
           return WriteOutputParam (\r
-                   BlockPtr,\r
+                   BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),\r
                    BufferLen,\r
                    &DefaultCell,\r
                    GlyphBuffer,\r
@@ -884,23 +868,60 @@ FindGlyphBlock (
                    GlyphBufferLen\r
                    );\r
         }\r
-        BlockPtr += BufferLen;\r
-      }\r
-      CharCurrent = (UINT16) (CharCurrent + Length16);\r
-      break;\r
 \r
-    case EFI_HII_GIBT_SKIP1:\r
-      CharCurrent = (UINT16) (CharCurrent + (UINT16) (*(BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))));\r
-      BlockPtr    += sizeof (EFI_HII_GIBT_SKIP1_BLOCK);\r
-      break;\r
-    case EFI_HII_GIBT_SKIP2:\r
-      CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));\r
-      CharCurrent = (UINT16) (CharCurrent + Length16);\r
-      BlockPtr    += sizeof (EFI_HII_GIBT_SKIP2_BLOCK);\r
-      break;\r
-    default:\r
-      ASSERT (FALSE);\r
-      break;\r
+        CharCurrent++;\r
+        BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK) + BufferLen;\r
+        break;\r
+\r
+      case EFI_HII_GIBT_GLYPHS_DEFAULT:\r
+        CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));\r
+        Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);\r
+        if (EFI_ERROR (Status)) {\r
+          return Status;\r
+        }\r
+\r
+        if (CharValue == (CHAR16)(-1)) {\r
+          if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {\r
+            BaseLine = (UINT16)(DefaultCell.Height + DefaultCell.OffsetY);\r
+          }\r
+\r
+          if (MinOffsetY > DefaultCell.OffsetY) {\r
+            MinOffsetY = DefaultCell.OffsetY;\r
+          }\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
+          if (CharCurrent + Index == CharValue) {\r
+            return WriteOutputParam (\r
+                     BlockPtr,\r
+                     BufferLen,\r
+                     &DefaultCell,\r
+                     GlyphBuffer,\r
+                     Cell,\r
+                     GlyphBufferLen\r
+                     );\r
+          }\r
+\r
+          BlockPtr += BufferLen;\r
+        }\r
+\r
+        CharCurrent = (UINT16)(CharCurrent + Length16);\r
+        break;\r
+\r
+      case EFI_HII_GIBT_SKIP1:\r
+        CharCurrent = (UINT16)(CharCurrent + (UINT16)(*(BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))));\r
+        BlockPtr   += sizeof (EFI_HII_GIBT_SKIP1_BLOCK);\r
+        break;\r
+      case EFI_HII_GIBT_SKIP2:\r
+        CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));\r
+        CharCurrent = (UINT16)(CharCurrent + Length16);\r
+        BlockPtr   += sizeof (EFI_HII_GIBT_SKIP2_BLOCK);\r
+        break;\r
+      default:\r
+        ASSERT (FALSE);\r
+        break;\r
     }\r
 \r
     if (CharValue < CharCurrent) {\r
@@ -908,16 +929,15 @@ FindGlyphBlock (
     }\r
   }\r
 \r
-  if (CharValue == (CHAR16) (-1)) {\r
+  if (CharValue == (CHAR16)(-1)) {\r
     FontPackage->BaseLine = BaseLine;\r
-    FontPackage->Height   = (UINT16) (BaseLine - MinOffsetY);\r
+    FontPackage->Height   = (UINT16)(BaseLine - MinOffsetY);\r
     return EFI_SUCCESS;\r
   }\r
 \r
   return EFI_NOT_FOUND;\r
 }\r
 \r
-\r
 /**\r
   Copy a Font Name to a new created EFI_FONT_INFO structure.\r
 \r
@@ -934,18 +954,18 @@ FindGlyphBlock (
 **/\r
 EFI_STATUS\r
 SaveFontName (\r
-  IN  EFI_STRING                       FontName,\r
-  OUT EFI_FONT_INFO                    **FontInfo\r
+  IN  EFI_STRING     FontName,\r
+  OUT EFI_FONT_INFO  **FontInfo\r
   )\r
 {\r
-  UINTN         FontInfoLen;\r
-  UINTN         NameSize;\r
+  UINTN  FontInfoLen;\r
+  UINTN  NameSize;\r
 \r
   ASSERT (FontName != NULL && FontInfo != NULL);\r
 \r
-  NameSize = StrSize (FontName);\r
+  NameSize    = StrSize (FontName);\r
   FontInfoLen = sizeof (EFI_FONT_INFO) - sizeof (CHAR16) + NameSize;\r
-  *FontInfo = (EFI_FONT_INFO *) AllocateZeroPool (FontInfoLen);\r
+  *FontInfo   = (EFI_FONT_INFO *)AllocateZeroPool (FontInfoLen);\r
   if (*FontInfo == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -954,7 +974,6 @@ SaveFontName (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   Retrieve system default font and color.\r
 \r
@@ -972,18 +991,19 @@ SaveFontName (
 **/\r
 EFI_STATUS\r
 GetSystemFont (\r
-  IN  HII_DATABASE_PRIVATE_DATA      *Private,\r
-  OUT EFI_FONT_DISPLAY_INFO          **FontInfo,\r
-  OUT UINTN                          *FontInfoSize OPTIONAL\r
+  IN  HII_DATABASE_PRIVATE_DATA  *Private,\r
+  OUT EFI_FONT_DISPLAY_INFO      **FontInfo,\r
+  OUT UINTN                      *FontInfoSize OPTIONAL\r
   )\r
 {\r
-  EFI_FONT_DISPLAY_INFO              *Info;\r
-  UINTN                              InfoSize;\r
-  UINTN                              NameSize;\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
+  if ((Private == NULL) || (Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\r
   if (FontInfo == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -993,12 +1013,12 @@ GetSystemFont (
   //\r
   NameSize = StrSize (L"sysdefault");\r
   InfoSize = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + NameSize;\r
-  Info = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (InfoSize);\r
+  Info     = (EFI_FONT_DISPLAY_INFO *)AllocateZeroPool (InfoSize);\r
   if (Info == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  Info->ForegroundColor    = mHiiEfiColors[Private->Attribute & 0x0f];\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
@@ -1010,10 +1030,10 @@ GetSystemFont (
   if (FontInfoSize != NULL) {\r
     *FontInfoSize = InfoSize;\r
   }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\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
@@ -1034,20 +1054,20 @@ GetSystemFont (
 **/\r
 BOOLEAN\r
 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 UINTN                          *SystemInfoLen OPTIONAL\r
+  IN  HII_DATABASE_PRIVATE_DATA  *Private,\r
+  IN  EFI_FONT_DISPLAY_INFO      *StringInfo,\r
+  OUT EFI_FONT_DISPLAY_INFO      **SystemInfo  OPTIONAL,\r
+  OUT UINTN                      *SystemInfoLen OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                          Status;\r
-  EFI_FONT_DISPLAY_INFO               *SystemDefault;\r
-  UINTN                               DefaultLen;\r
-  BOOLEAN                             Flag;\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
-  if (StringInfo == NULL && SystemInfo == NULL) {\r
+  if ((StringInfo == NULL) && (SystemInfo == NULL)) {\r
     return TRUE;\r
   }\r
 \r
@@ -1082,31 +1102,37 @@ IsSystemFontInfo (
       goto Exit;\r
     }\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
+\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
+\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
+          ) != 0)\r
+    {\r
       goto Exit;\r
     }\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
+          ) != 0)\r
+    {\r
       goto Exit;\r
     }\r
   }\r
@@ -1119,10 +1145,10 @@ Exit:
       FreePool (SystemDefault);\r
     }\r
   }\r
+\r
   return Flag;\r
 }\r
 \r
-\r
 /**\r
   This function checks whether EFI_FONT_INFO exists in current database. If\r
   FontInfoMask is specified, check what options can be used to make a match.\r
@@ -1147,21 +1173,21 @@ Exit:
 **/\r
 BOOLEAN\r
 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
-  OUT HII_GLOBAL_FONT_INFO      **GlobalFontInfo OPTIONAL\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
+  OUT HII_GLOBAL_FONT_INFO       **GlobalFontInfo OPTIONAL\r
   )\r
 {\r
-  HII_GLOBAL_FONT_INFO          *GlobalFont;\r
-  HII_GLOBAL_FONT_INFO          *GlobalFontBackup1;\r
-  HII_GLOBAL_FONT_INFO          *GlobalFontBackup2;\r
-  LIST_ENTRY                    *Link;\r
-  EFI_FONT_INFO_MASK            Mask;\r
-  BOOLEAN                       Matched;\r
-  BOOLEAN                       VagueMatched1;\r
-  BOOLEAN                       VagueMatched2;\r
+  HII_GLOBAL_FONT_INFO  *GlobalFont;\r
+  HII_GLOBAL_FONT_INFO  *GlobalFontBackup1;\r
+  HII_GLOBAL_FONT_INFO  *GlobalFontBackup2;\r
+  LIST_ENTRY            *Link;\r
+  EFI_FONT_INFO_MASK    Mask;\r
+  BOOLEAN               Matched;\r
+  BOOLEAN               VagueMatched1;\r
+  BOOLEAN               VagueMatched2;\r
 \r
   ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);\r
   ASSERT (FontInfo != NULL);\r
@@ -1170,9 +1196,9 @@ IsFontInfoExisted (
   // 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
-  VagueMatched1     = FALSE;\r
-  VagueMatched2     = FALSE;\r
+  Matched       = FALSE;\r
+  VagueMatched1 = FALSE;\r
+  VagueMatched2 = FALSE;\r
 \r
   Mask              = 0;\r
   GlobalFontBackup1 = NULL;\r
@@ -1192,16 +1218,17 @@ IsFontInfoExisted (
   if (FontHandle == NULL) {\r
     Link = Private->FontInfoList.ForwardLink;\r
   } else {\r
-    Link = (LIST_ENTRY     *) FontHandle;\r
+    Link = (LIST_ENTRY     *)FontHandle;\r
   }\r
 \r
-  for (; Link != &Private->FontInfoList; Link = Link->ForwardLink) {\r
+  for ( ; Link != &Private->FontInfoList; Link = Link->ForwardLink) {\r
     GlobalFont = CR (Link, HII_GLOBAL_FONT_INFO, Entry, HII_GLOBAL_FONT_INFO_SIGNATURE);\r
     if (FontInfoMask == NULL) {\r
       if (CompareMem (GlobalFont->FontInfo, FontInfo, GlobalFont->FontInfoSize) == 0) {\r
         if (GlobalFontInfo != NULL) {\r
           *GlobalFontInfo = GlobalFont;\r
         }\r
+\r
         return TRUE;\r
       }\r
     } else {\r
@@ -1209,208 +1236,232 @@ IsFontInfoExisted (
       // Check which options could be used to make a match.\r
       //\r
       switch (Mask) {\r
-      case EFI_FONT_INFO_ANY_FONT:\r
-        if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle &&\r
-            GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE:\r
-        if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE:\r
-        if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_ANY_STYLE:\r
-        Matched   = TRUE;\r
-        break;\r
-      //\r
-      // If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to\r
-      // remove some of the specified styles to meet the style requested.\r
-      //\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE:\r
-        if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {\r
+        case EFI_FONT_INFO_ANY_FONT:\r
+          if ((GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) &&\r
+              (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize))\r
+          {\r
+            Matched = TRUE;\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE:\r
+          if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {\r
+            Matched = TRUE;\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE:\r
           if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-            Matched           = TRUE;\r
-          } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
+            Matched = TRUE;\r
           }\r
-        }\r
-        break;\r
-      //\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
-        if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-          if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-            Matched           = TRUE;\r
-          } else {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_ANY_STYLE:\r
+          Matched = TRUE;\r
+          break;\r
+        //\r
+        // If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to\r
+        // remove some of the specified styles to meet the style requested.\r
+        //\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE:\r
+          if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {\r
+            if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+              Matched = TRUE;\r
+            } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
+            }\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_RESIZE:\r
-        if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-          if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-            Matched           = TRUE;\r
-          } else {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
+\r
+          break;\r
+        //\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
+          if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+            if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+              Matched = TRUE;\r
+            } else {\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
+            }\r
           }\r
-        } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
-          if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
-          } else {\r
-            VagueMatched2     = TRUE;\r
-            GlobalFontBackup2 = GlobalFont;\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_RESIZE:\r
+          if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+            if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+              Matched = TRUE;\r
+            } else {\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
+            }\r
+          } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
+            if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
+            } else {\r
+              VagueMatched2     = TRUE;\r
+              GlobalFontBackup2 = GlobalFont;\r
+            }\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:\r
-        if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-          Matched           = TRUE;\r
-        } else {\r
-          VagueMatched1     = TRUE;\r
-          GlobalFontBackup1 = GlobalFont;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:\r
-        if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-          Matched           = TRUE;\r
-        } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
-          VagueMatched1     = TRUE;\r
-          GlobalFontBackup1 = GlobalFont;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_STYLE:\r
-        if ((CompareMem (\r
-               GlobalFont->FontInfo->FontName,\r
-               FontInfo->FontName,\r
-               StrSize (FontInfo->FontName)\r
-               ) == 0) &&\r
-            GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_ANY_SIZE:\r
-        if (CompareMem (\r
-              GlobalFont->FontInfo->FontName,\r
-              FontInfo->FontName,\r
-              StrSize (FontInfo->FontName)\r
-              ) == 0) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:\r
-        if (CompareMem (\r
-              GlobalFont->FontInfo->FontName,\r
-              FontInfo->FontName,\r
-              StrSize (FontInfo->FontName)\r
-              ) == 0) {\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:\r
           if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-            Matched           = TRUE;\r
+            Matched = TRUE;\r
           } else {\r
             VagueMatched1     = TRUE;\r
             GlobalFontBackup1 = GlobalFont;\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_SIZE:\r
-        if ((CompareMem (\r
-               GlobalFont->FontInfo->FontName,\r
-               FontInfo->FontName,\r
-               StrSize (FontInfo->FontName)\r
-               ) == 0) &&\r
-            GlobalFont->FontInfo->FontStyle  == FontInfo->FontStyle) {\r
-          Matched = TRUE;\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:\r
-        if (CompareMem (\r
-              GlobalFont->FontInfo->FontName,\r
-              FontInfo->FontName,\r
-              StrSize (FontInfo->FontName)\r
-              ) == 0) {\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:\r
           if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-            Matched           = TRUE;\r
+            Matched = TRUE;\r
           } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
             VagueMatched1     = TRUE;\r
             GlobalFontBackup1 = GlobalFont;\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_RESTYLE:\r
-        if ((CompareMem (\r
-               GlobalFont->FontInfo->FontName,\r
-               FontInfo->FontName,\r
-               StrSize (FontInfo->FontName)\r
-               ) == 0) &&\r
-            GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
 \r
-          if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
-            Matched           = TRUE;\r
-          } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
+          break;\r
+        case EFI_FONT_INFO_ANY_STYLE:\r
+          if ((CompareMem (\r
+                 GlobalFont->FontInfo->FontName,\r
+                 FontInfo->FontName,\r
+                 StrSize (FontInfo->FontName)\r
+                 ) == 0) &&\r
+              (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize))\r
+          {\r
+            Matched = TRUE;\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_RESIZE:\r
-        if ((CompareMem (\r
-               GlobalFont->FontInfo->FontName,\r
-               FontInfo->FontName,\r
-               StrSize (FontInfo->FontName)\r
-               ) == 0) &&\r
-            GlobalFont->FontInfo->FontStyle  == FontInfo->FontStyle) {\r
 \r
-          if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-            Matched           = TRUE;\r
-          } else {\r
-            VagueMatched1     = TRUE;\r
-            GlobalFontBackup1 = GlobalFont;\r
+          break;\r
+        case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_ANY_SIZE:\r
+          if (CompareMem (\r
+                GlobalFont->FontInfo->FontName,\r
+                FontInfo->FontName,\r
+                StrSize (FontInfo->FontName)\r
+                ) == 0)\r
+          {\r
+            Matched = TRUE;\r
           }\r
-        }\r
-        break;\r
-      case EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_RESTYLE:\r
-        if (CompareMem (\r
-              GlobalFont->FontInfo->FontName,\r
-              FontInfo->FontName,\r
-              StrSize (FontInfo->FontName)\r
-              ) == 0) {\r
-          if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:\r
+          if (CompareMem (\r
+                GlobalFont->FontInfo->FontName,\r
+                FontInfo->FontName,\r
+                StrSize (FontInfo->FontName)\r
+                ) == 0)\r
+          {\r
             if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
-              Matched           = TRUE;\r
+              Matched = TRUE;\r
             } else {\r
               VagueMatched1     = TRUE;\r
               GlobalFontBackup1 = GlobalFont;\r
             }\r
-          } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
-            if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_SIZE:\r
+          if ((CompareMem (\r
+                 GlobalFont->FontInfo->FontName,\r
+                 FontInfo->FontName,\r
+                 StrSize (FontInfo->FontName)\r
+                 ) == 0) &&\r
+              (GlobalFont->FontInfo->FontStyle  == FontInfo->FontStyle))\r
+          {\r
+            Matched = TRUE;\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:\r
+          if (CompareMem (\r
+                GlobalFont->FontInfo->FontName,\r
+                FontInfo->FontName,\r
+                StrSize (FontInfo->FontName)\r
+                ) == 0)\r
+          {\r
+            if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+              Matched = TRUE;\r
+            } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
               VagueMatched1     = TRUE;\r
               GlobalFontBackup1 = GlobalFont;\r
+            }\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_RESTYLE:\r
+          if ((CompareMem (\r
+                 GlobalFont->FontInfo->FontName,\r
+                 FontInfo->FontName,\r
+                 StrSize (FontInfo->FontName)\r
+                 ) == 0) &&\r
+              (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize))\r
+          {\r
+            if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+              Matched = TRUE;\r
+            } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
+            }\r
+          }\r
+\r
+          break;\r
+        case EFI_FONT_INFO_RESIZE:\r
+          if ((CompareMem (\r
+                 GlobalFont->FontInfo->FontName,\r
+                 FontInfo->FontName,\r
+                 StrSize (FontInfo->FontName)\r
+                 ) == 0) &&\r
+              (GlobalFont->FontInfo->FontStyle  == FontInfo->FontStyle))\r
+          {\r
+            if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+              Matched = TRUE;\r
             } else {\r
-              VagueMatched2     = TRUE;\r
-              GlobalFontBackup2 = GlobalFont;\r
+              VagueMatched1     = TRUE;\r
+              GlobalFontBackup1 = GlobalFont;\r
             }\r
           }\r
-        }\r
-        break;\r
-      default:\r
-        break;\r
+\r
+          break;\r
+        case EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_RESTYLE:\r
+          if (CompareMem (\r
+                GlobalFont->FontInfo->FontName,\r
+                FontInfo->FontName,\r
+                StrSize (FontInfo->FontName)\r
+                ) == 0)\r
+          {\r
+            if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {\r
+              if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+                Matched = TRUE;\r
+              } else {\r
+                VagueMatched1     = TRUE;\r
+                GlobalFontBackup1 = GlobalFont;\r
+              }\r
+            } else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {\r
+              if (GlobalFont->FontInfo->FontSize  == FontInfo->FontSize) {\r
+                VagueMatched1     = TRUE;\r
+                GlobalFontBackup1 = GlobalFont;\r
+              } else {\r
+                VagueMatched2     = TRUE;\r
+                GlobalFontBackup2 = GlobalFont;\r
+              }\r
+            }\r
+          }\r
+\r
+          break;\r
+        default:\r
+          break;\r
       }\r
 \r
       if (Matched) {\r
         if (GlobalFontInfo != NULL) {\r
           *GlobalFontInfo = GlobalFont;\r
         }\r
+\r
         return TRUE;\r
       }\r
     }\r
@@ -1420,18 +1471,19 @@ IsFontInfoExisted (
     if (GlobalFontInfo != NULL) {\r
       *GlobalFontInfo = GlobalFontBackup1;\r
     }\r
+\r
     return TRUE;\r
   } else if (VagueMatched2) {\r
     if (GlobalFontInfo != NULL) {\r
       *GlobalFontInfo = GlobalFontBackup2;\r
     }\r
+\r
     return TRUE;\r
   }\r
 \r
   return FALSE;\r
 }\r
 \r
-\r
 /**\r
   Check whether the unicode represents a line break or not.\r
 \r
@@ -1448,7 +1500,7 @@ IsFontInfoExisted (
 **/\r
 INT8\r
 IsLineBreak (\r
-  IN  CHAR16    Char\r
+  IN  CHAR16  Char\r
   )\r
 {\r
   switch (Char) {\r
@@ -1509,10 +1561,10 @@ IsLineBreak (
     case 0x2014:\r
       return 2;\r
   }\r
+\r
   return -1;\r
 }\r
 \r
-\r
 /**\r
   Renders a string to a bitmap or to the display.\r
 \r
@@ -1570,65 +1622,66 @@ IsLineBreak (
 EFI_STATUS\r
 EFIAPI\r
 HiiStringToImage (\r
-  IN  CONST EFI_HII_FONT_PROTOCOL    *This,\r
-  IN  EFI_HII_OUT_FLAGS              Flags,\r
-  IN  CONST EFI_STRING               String,\r
-  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo       OPTIONAL,\r
-  IN  OUT EFI_IMAGE_OUTPUT           **Blt,\r
-  IN  UINTN                          BltX,\r
-  IN  UINTN                          BltY,\r
-  OUT EFI_HII_ROW_INFO               **RowInfoArray    OPTIONAL,\r
-  OUT UINTN                          *RowInfoArraySize OPTIONAL,\r
-  OUT UINTN                          *ColumnInfoArray  OPTIONAL\r
+  IN  CONST EFI_HII_FONT_PROTOCOL  *This,\r
+  IN  EFI_HII_OUT_FLAGS            Flags,\r
+  IN  CONST EFI_STRING             String,\r
+  IN  CONST EFI_FONT_DISPLAY_INFO  *StringInfo       OPTIONAL,\r
+  IN  OUT EFI_IMAGE_OUTPUT         **Blt,\r
+  IN  UINTN                        BltX,\r
+  IN  UINTN                        BltY,\r
+  OUT EFI_HII_ROW_INFO             **RowInfoArray    OPTIONAL,\r
+  OUT UINTN                        *RowInfoArraySize OPTIONAL,\r
+  OUT UINTN                        *ColumnInfoArray  OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                          Status;\r
-  HII_DATABASE_PRIVATE_DATA           *Private;\r
-  UINT8                               **GlyphBuf;\r
-  EFI_HII_GLYPH_INFO                  *Cell;\r
-  UINT8                               *Attributes;\r
-  EFI_IMAGE_OUTPUT                    *Image;\r
-  EFI_STRING                          StringPtr;\r
-  EFI_STRING                          StringTmp;\r
-  EFI_HII_ROW_INFO                    *RowInfo;\r
-  UINTN                               LineWidth;\r
-  UINTN                               LineHeight;\r
-  UINTN                               LineOffset;\r
-  UINTN                               LastLineHeight;\r
-  UINTN                               BaseLineOffset;\r
-  UINT16                              MaxRowNum;\r
-  UINT16                              RowIndex;\r
-  UINTN                               Index;\r
-  UINTN                               NextIndex;\r
-  UINTN                               Index1;\r
-  EFI_FONT_DISPLAY_INFO               *StringInfoOut;\r
-  EFI_FONT_DISPLAY_INFO               *SystemDefault;\r
-  EFI_FONT_HANDLE                     FontHandle;\r
-  EFI_STRING                          StringIn;\r
-  EFI_STRING                          StringIn2;\r
-  UINT16                              Height;\r
-  UINT16                              BaseLine;\r
-  EFI_FONT_INFO                       *FontInfo;\r
-  BOOLEAN                             SysFontFlag;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL       Foreground;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL       Background;\r
-  BOOLEAN                             Transparent;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL       *BltBuffer;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL       *BufferPtr;\r
-  UINTN                               RowInfoSize;\r
-  BOOLEAN                             LineBreak;\r
-  UINTN                               StrLength;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL       *RowBufferPtr;\r
-  HII_GLOBAL_FONT_INFO                *GlobalFont;\r
-  UINT32                              PreInitBkgnd;\r
+  EFI_STATUS                     Status;\r
+  HII_DATABASE_PRIVATE_DATA      *Private;\r
+  UINT8                          **GlyphBuf;\r
+  EFI_HII_GLYPH_INFO             *Cell;\r
+  UINT8                          *Attributes;\r
+  EFI_IMAGE_OUTPUT               *Image;\r
+  EFI_STRING                     StringPtr;\r
+  EFI_STRING                     StringTmp;\r
+  EFI_HII_ROW_INFO               *RowInfo;\r
+  UINTN                          LineWidth;\r
+  UINTN                          LineHeight;\r
+  UINTN                          LineOffset;\r
+  UINTN                          LastLineHeight;\r
+  UINTN                          BaseLineOffset;\r
+  UINT16                         MaxRowNum;\r
+  UINT16                         RowIndex;\r
+  UINTN                          Index;\r
+  UINTN                          NextIndex;\r
+  UINTN                          Index1;\r
+  EFI_FONT_DISPLAY_INFO          *StringInfoOut;\r
+  EFI_FONT_DISPLAY_INFO          *SystemDefault;\r
+  EFI_FONT_HANDLE                FontHandle;\r
+  EFI_STRING                     StringIn;\r
+  EFI_STRING                     StringIn2;\r
+  UINT16                         Height;\r
+  UINT16                         BaseLine;\r
+  EFI_FONT_INFO                  *FontInfo;\r
+  BOOLEAN                        SysFontFlag;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background;\r
+  BOOLEAN                        Transparent;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BufferPtr;\r
+  UINTN                          RowInfoSize;\r
+  BOOLEAN                        LineBreak;\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
   //\r
 \r
-  if (This == NULL || String == NULL || Blt == NULL) {\r
+  if ((This == NULL) || (String == NULL) || (Blt == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\r
   if (*Blt == NULL) {\r
     //\r
     // These two flag cannot be used if Blt is NULL upon entry.\r
@@ -1636,19 +1689,23 @@ HiiStringToImage (
     if ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
+\r
     if ((Flags & EFI_HII_OUT_FLAG_CLIP) == EFI_HII_OUT_FLAG_CLIP) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
+\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_CLIP_CLEAN_X)) ==  EFI_HII_OUT_FLAG_CLIP_CLEAN_X) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\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
   //\r
   // This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.\r
   //\r
@@ -1664,8 +1721,9 @@ HiiStringToImage (
     if (Image == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
-    Image->Width  = 800;\r
-    Image->Height = 600;\r
+\r
+    Image->Width        = 800;\r
+    Image->Height       = 600;\r
     Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height *sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
     if (Image->Image.Bitmap == NULL) {\r
       FreePool (Image);\r
@@ -1676,15 +1734,15 @@ HiiStringToImage (
     // Other flags are not permitted when Blt is NULL.\r
     //\r
     Flags &= EFI_HII_OUT_FLAG_WRAP | EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_IGNORE_LINE_BREAK;\r
-    *Blt = Image;\r
+    *Blt   = Image;\r
   }\r
 \r
-  StrLength = StrLen(String);\r
-  GlyphBuf = (UINT8 **) AllocateZeroPool (StrLength * sizeof (UINT8 *));\r
+  StrLength = StrLen (String);\r
+  GlyphBuf  = (UINT8 **)AllocateZeroPool (StrLength * sizeof (UINT8 *));\r
   ASSERT (GlyphBuf != NULL);\r
-  Cell = (EFI_HII_GLYPH_INFO *) AllocateZeroPool (StrLength * sizeof (EFI_HII_GLYPH_INFO));\r
+  Cell = (EFI_HII_GLYPH_INFO *)AllocateZeroPool (StrLength * sizeof (EFI_HII_GLYPH_INFO));\r
   ASSERT (Cell != NULL);\r
-  Attributes = (UINT8 *) AllocateZeroPool (StrLength * sizeof (UINT8));\r
+  Attributes = (UINT8 *)AllocateZeroPool (StrLength * sizeof (UINT8));\r
   ASSERT (Attributes != NULL);\r
 \r
   RowInfo       = NULL;\r
@@ -1701,7 +1759,7 @@ HiiStringToImage (
   StringInfoOut = NULL;\r
   FontHandle    = NULL;\r
   Private       = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
-  SysFontFlag   = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);\r
+  SysFontFlag   = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *)StringInfo, &SystemDefault, NULL);\r
 \r
   if (SysFontFlag) {\r
     ASSERT (SystemDefault != NULL);\r
@@ -1710,13 +1768,12 @@ HiiStringToImage (
     BaseLine   = SystemDefault->FontInfo.FontSize;\r
     Foreground = SystemDefault->ForegroundColor;\r
     Background = SystemDefault->BackgroundColor;\r
-\r
   } else {\r
     //\r
     //  StringInfo must not be NULL if it is not system info.\r
     //\r
     ASSERT (StringInfo != NULL);\r
-    Status = HiiGetFontInfo (This, &FontHandle, (EFI_FONT_DISPLAY_INFO *) StringInfo, &StringInfoOut, NULL);\r
+    Status = HiiGetFontInfo (This, &FontHandle, (EFI_FONT_DISPLAY_INFO *)StringInfo, &StringInfoOut, NULL);\r
     if (Status == EFI_NOT_FOUND) {\r
       //\r
       // The specified EFI_FONT_DISPLAY_INFO does not exist in current database.\r
@@ -1726,11 +1783,10 @@ HiiStringToImage (
       FontInfo    = NULL;\r
       Height      = SystemDefault->FontInfo.FontSize;\r
       BaseLine    = SystemDefault->FontInfo.FontSize;\r
-      Foreground  = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->ForegroundColor;\r
-      Background  = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->BackgroundColor;\r
-\r
+      Foreground  = ((EFI_FONT_DISPLAY_INFO *)StringInfo)->ForegroundColor;\r
+      Background  = ((EFI_FONT_DISPLAY_INFO *)StringInfo)->BackgroundColor;\r
     } else if (Status == EFI_SUCCESS) {\r
-      FontInfo   = &StringInfoOut->FontInfo;\r
+      FontInfo = &StringInfoOut->FontInfo;\r
       IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont);\r
       Height     = GlobalFont->FontPackage->Height;\r
       BaseLine   = GlobalFont->FontPackage->BaseLine;\r
@@ -1765,6 +1821,7 @@ HiiStringToImage (
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Exit;\r
     }\r
+\r
     StringTmp = StringIn;\r
     while (*StringPtr != 0) {\r
       if (IsLineBreak (*StringPtr) == 0) {\r
@@ -1773,21 +1830,24 @@ HiiStringToImage (
         *StringTmp++ = *StringPtr++;\r
       }\r
     }\r
+\r
     *StringTmp = 0;\r
     StringPtr  = StringIn;\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 with Unicode character 0xFFFD.\r
   //\r
-  StringIn2  = AllocateZeroPool (StrSize (StringPtr));\r
+  StringIn2 = AllocateZeroPool (StrSize (StringPtr));\r
   if (StringIn2 == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
   }\r
+\r
   Index     = 0;\r
   StringTmp = StringIn2;\r
-  StrLength = StrLen(StringPtr);\r
+  StrLength = StrLen (StringPtr);\r
   while (*StringPtr != 0 && Index < StrLength) {\r
     if (IsLineBreak (*StringPtr) == 0) {\r
       *StringTmp++ = *StringPtr++;\r
@@ -1826,6 +1886,7 @@ HiiStringToImage (
     *StringTmp++ = *StringPtr++;\r
     Index++;\r
   }\r
+\r
   *StringTmp = 0;\r
   StringPtr  = StringIn2;\r
 \r
@@ -1844,13 +1905,14 @@ HiiStringToImage (
     Status = EFI_INVALID_PARAMETER;\r
     goto Exit;\r
   }\r
-  MaxRowNum = (UINT16) ((Image->Height - BltY) / Height);\r
+\r
+  MaxRowNum = (UINT16)((Image->Height - BltY) / Height);\r
   if ((Image->Height - BltY) % Height != 0) {\r
     LastLineHeight = (Image->Height - BltY) % Height;\r
     MaxRowNum++;\r
   }\r
 \r
-  RowInfo = (EFI_HII_ROW_INFO *) AllocateZeroPool (MaxRowNum * sizeof (EFI_HII_ROW_INFO));\r
+  RowInfo = (EFI_HII_ROW_INFO *)AllocateZeroPool (MaxRowNum * sizeof (EFI_HII_ROW_INFO));\r
   if (RowInfo == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
@@ -1859,23 +1921,24 @@ HiiStringToImage (
   //\r
   // Format the glyph buffer according to flags.\r
   //\r
-  Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);\r
+  Transparent = (BOOLEAN)((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);\r
 \r
   for (RowIndex = 0, Index = 0; RowIndex < MaxRowNum && StringPtr[Index] != 0; ) {\r
-    LineWidth      = 0;\r
-    LineBreak      = FALSE;\r
+    LineWidth = 0;\r
+    LineBreak = FALSE;\r
 \r
     //\r
     // Clip the final row if the row's bottom-most on pixel cannot fit when\r
     // EFI_HII_OUT_FLAG_CLEAN_Y is set.\r
     //\r
     if (RowIndex == MaxRowNum - 1) {\r
-      if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y && LastLineHeight < LineHeight ) {\r
+      if (((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) && (LastLineHeight < LineHeight)) {\r
         //\r
         // Don't draw at all if the row's bottom-most on pixel cannot fit.\r
         //\r
         break;\r
       }\r
+\r
       LineHeight = LastLineHeight;\r
     }\r
 \r
@@ -1885,8 +1948,9 @@ HiiStringToImage (
     RowInfo[RowIndex].StartIndex = Index;\r
 \r
     while (LineWidth + BltX < Image->Width && StringPtr[Index] != 0) {\r
-      if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&\r
-           IsLineBreak (StringPtr[Index]) == 0) {\r
+      if (((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) &&\r
+          (IsLineBreak (StringPtr[Index]) == 0))\r
+      {\r
         //\r
         // It forces a line break that ends this row.\r
         //\r
@@ -1898,7 +1962,7 @@ HiiStringToImage (
       //\r
       // If the glyph of the character is existing, then accumulate the actual printed width\r
       //\r
-      LineWidth += (UINTN) Cell[Index].AdvanceX;\r
+      LineWidth += (UINTN)Cell[Index].AdvanceX;\r
 \r
       Index++;\r
     }\r
@@ -1911,11 +1975,11 @@ HiiStringToImage (
     // Return to the previous char.\r
     //\r
     Index--;\r
-    if (LineBreak && Index > 0 ) {\r
+    if (LineBreak && (Index > 0)) {\r
       //\r
       // Return the previous non line break char.\r
       //\r
-      Index --;\r
+      Index--;\r
     }\r
 \r
     //\r
@@ -1927,8 +1991,9 @@ HiiStringToImage (
     //\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_CLIP_CLEAN_X) == 0)) {\r
+    if ((LineWidth + BltX <= Image->Width) ||\r
+        ((LineWidth + BltX > Image->Width) && ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_X) == 0)))\r
+    {\r
       //\r
       // Record right-most character in RowInfo even if it is partially displayed.\r
       //\r
@@ -1945,8 +2010,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 -= (Cell[Index].Width + Cell[Index].OffsetX);\r
-        LineWidth -= (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
@@ -1956,7 +2021,7 @@ HiiStringToImage (
         // There is no enough column to draw any character, so set current line width to zero.\r
         // And go to draw Next line if LineBreak is set.\r
         //\r
-        RowInfo[RowIndex].LineWidth      = 0;\r
+        RowInfo[RowIndex].LineWidth = 0;\r
         goto NextLine;\r
       }\r
     }\r
@@ -1966,9 +2031,10 @@ 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
-        !LineBreak) {\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
+    {\r
       if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {\r
         LineWidth = RowInfo[RowIndex].LineWidth;\r
         for (Index1 = RowInfo[RowIndex].EndIndex; Index1 >= RowInfo[RowIndex].StartIndex; Index1--) {\r
@@ -1977,23 +2043,27 @@ HiiStringToImage (
           } else {\r
             LineWidth -= Cell[Index1].AdvanceX;\r
           }\r
+\r
           if (IsLineBreak (StringPtr[Index1]) > 0) {\r
             LineBreak = TRUE;\r
             if (Index1 > RowInfo[RowIndex].StartIndex) {\r
               RowInfo[RowIndex].EndIndex = Index1 - 1;\r
             }\r
+\r
             //\r
             // relocate to the character after the right-most line break opportunity of this line\r
             //\r
             NextIndex = Index1 + 1;\r
             break;\r
           }\r
+\r
           //\r
           // If don't find a line break opportunity from EndIndex to StartIndex,\r
           // then jump out.\r
           //\r
-          if (Index1 == RowInfo[RowIndex].StartIndex)\r
+          if (Index1 == RowInfo[RowIndex].StartIndex) {\r
             break;\r
+          }\r
         }\r
 \r
         //\r
@@ -2005,9 +2075,11 @@ HiiStringToImage (
           } else {\r
             LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);\r
           }\r
+\r
           RowInfo[RowIndex].LineWidth = LineWidth;\r
         }\r
       }\r
+\r
       //\r
       // If no line-break opportunity can be found, then the text will\r
       // behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.\r
@@ -2020,10 +2092,10 @@ 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 -= (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
+            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
             // There is no enough column to draw any character, so set current line width to zero.\r
@@ -2056,18 +2128,20 @@ HiiStringToImage (
           Status = EFI_OUT_OF_RESOURCES;\r
           goto Exit;\r
         }\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
+        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
       }\r
+\r
       for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
-        if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {\r
+        if ((RowInfo[RowIndex].LineWidth > 0) && (RowInfo[RowIndex].LineWidth > LineOffset)) {\r
           //\r
           // Only BLT these character which have corresponding glyph in font database.\r
           //\r
@@ -2075,7 +2149,7 @@ HiiStringToImage (
             GlyphBuf[Index1],\r
             Foreground,\r
             Background,\r
-            (UINT16) RowInfo[RowIndex].LineWidth,\r
+            (UINT16)RowInfo[RowIndex].LineWidth,\r
             BaseLine,\r
             RowInfo[RowIndex].LineWidth - LineOffset,\r
             RowInfo[RowIndex].LineHeight,\r
@@ -2083,17 +2157,21 @@ HiiStringToImage (
             &Cell[Index1],\r
             Attributes[Index1],\r
             &BufferPtr\r
-          );\r
+            );\r
         }\r
+\r
         if (ColumnInfoArray != NULL) {\r
-          if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)\r
-              || RowInfo[RowIndex].LineWidth == 0) {\r
+          if (  ((GlyphBuf[Index1] == NULL) && (Cell[Index1].AdvanceX == 0))\r
+             || (RowInfo[RowIndex].LineWidth == 0))\r
+          {\r
             *ColumnInfoArray = (UINTN) ~0;\r
           } else {\r
             *ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;\r
           }\r
+\r
           ColumnInfoArray++;\r
         }\r
+\r
         LineOffset += Cell[Index1].AdvanceX;\r
       }\r
 \r
@@ -2127,7 +2205,7 @@ HiiStringToImage (
       //\r
       BufferPtr = BufferPtr + BaseLine * Image->Width;\r
       for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
-        if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {\r
+        if ((RowInfo[RowIndex].LineWidth > 0) && (RowInfo[RowIndex].LineWidth > LineOffset)) {\r
           //\r
           // Only BLT these character which have corresponding glyph in font database.\r
           //\r
@@ -2143,17 +2221,21 @@ HiiStringToImage (
             &Cell[Index1],\r
             Attributes[Index1],\r
             &BufferPtr\r
-          );\r
+            );\r
         }\r
+\r
         if (ColumnInfoArray != NULL) {\r
-          if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)\r
-              || RowInfo[RowIndex].LineWidth == 0) {\r
+          if (  ((GlyphBuf[Index1] == NULL) && (Cell[Index1].AdvanceX == 0))\r
+             || (RowInfo[RowIndex].LineWidth == 0))\r
+          {\r
             *ColumnInfoArray = (UINTN) ~0;\r
           } else {\r
             *ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;\r
           }\r
+\r
           ColumnInfoArray++;\r
         }\r
+\r
         LineOffset += Cell[Index1].AdvanceX;\r
       }\r
 \r
@@ -2195,11 +2277,13 @@ NextLine:
         Status = EFI_OUT_OF_RESOURCES;\r
         goto Exit;\r
       }\r
+\r
       CopyMem (*RowInfoArray, RowInfo, RowInfoSize);\r
     } else {\r
       *RowInfoArray = NULL;\r
     }\r
   }\r
+\r
   if (RowInfoArraySize != NULL) {\r
     *RowInfoArraySize = RowIndex;\r
   }\r
@@ -2213,27 +2297,35 @@ Exit:
       FreePool (GlyphBuf[Index]);\r
     }\r
   }\r
+\r
   if (StringIn != NULL) {\r
     FreePool (StringIn);\r
   }\r
+\r
   if (StringIn2 != NULL) {\r
     FreePool (StringIn2);\r
   }\r
+\r
   if (StringInfoOut != NULL) {\r
     FreePool (StringInfoOut);\r
   }\r
+\r
   if (RowInfo != NULL) {\r
     FreePool (RowInfo);\r
   }\r
+\r
   if (SystemDefault != NULL) {\r
     FreePool (SystemDefault);\r
   }\r
+\r
   if (GlyphBuf != NULL) {\r
     FreePool (GlyphBuf);\r
   }\r
+\r
   if (Cell != NULL) {\r
     FreePool (Cell);\r
   }\r
+\r
   if (Attributes != NULL) {\r
     FreePool (Attributes);\r
   }\r
@@ -2241,7 +2333,6 @@ Exit:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Render a string to a bitmap or the screen containing the contents of the specified string.\r
 \r
@@ -2306,36 +2397,36 @@ Exit:
 EFI_STATUS\r
 EFIAPI\r
 HiiStringIdToImage (\r
-  IN  CONST EFI_HII_FONT_PROTOCOL    *This,\r
-  IN  EFI_HII_OUT_FLAGS              Flags,\r
-  IN  EFI_HII_HANDLE                 PackageList,\r
-  IN  EFI_STRING_ID                  StringId,\r
-  IN  CONST CHAR8*                   Language,\r
-  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo       OPTIONAL,\r
-  IN  OUT EFI_IMAGE_OUTPUT           **Blt,\r
-  IN  UINTN                          BltX,\r
-  IN  UINTN                          BltY,\r
-  OUT EFI_HII_ROW_INFO               **RowInfoArray    OPTIONAL,\r
-  OUT UINTN                          *RowInfoArraySize OPTIONAL,\r
-  OUT UINTN                          *ColumnInfoArray  OPTIONAL\r
+  IN  CONST EFI_HII_FONT_PROTOCOL  *This,\r
+  IN  EFI_HII_OUT_FLAGS            Flags,\r
+  IN  EFI_HII_HANDLE               PackageList,\r
+  IN  EFI_STRING_ID                StringId,\r
+  IN  CONST CHAR8                  *Language,\r
+  IN  CONST EFI_FONT_DISPLAY_INFO  *StringInfo       OPTIONAL,\r
+  IN  OUT EFI_IMAGE_OUTPUT         **Blt,\r
+  IN  UINTN                        BltX,\r
+  IN  UINTN                        BltY,\r
+  OUT EFI_HII_ROW_INFO             **RowInfoArray    OPTIONAL,\r
+  OUT UINTN                        *RowInfoArraySize OPTIONAL,\r
+  OUT UINTN                        *ColumnInfoArray  OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                          Status;\r
-  HII_DATABASE_PRIVATE_DATA           *Private;\r
-  EFI_HII_STRING_PROTOCOL             *HiiString;\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
-  CHAR8                               *SupportedLanguages;\r
-  UINTN                               SupportedLanguagesSize;\r
-  CHAR8                               *CurrentLanguage;\r
-  CHAR8                               *BestLanguage;\r
-\r
-  if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {\r
+  EFI_STATUS                 Status;\r
+  HII_DATABASE_PRIVATE_DATA  *Private;\r
+  EFI_HII_STRING_PROTOCOL    *HiiString;\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
+  CHAR8                      *SupportedLanguages;\r
+  UINTN                      SupportedLanguagesSize;\r
+  CHAR8                      *CurrentLanguage;\r
+  CHAR8                      *BestLanguage;\r
+\r
+  if ((This == NULL) || (PackageList == NULL) || (Blt == NULL) || (PackageList == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -2363,12 +2454,12 @@ HiiStringIdToImage (
   // Get the size of supported language.\r
   //\r
   SupportedLanguagesSize = 0;\r
-  Status = HiiString->GetLanguages (\r
-                        HiiString,\r
-                        PackageList,\r
-                        &TempSupportedLanguages,\r
-                        &SupportedLanguagesSize\r
-                        );\r
+  Status                 = HiiString->GetLanguages (\r
+                                        HiiString,\r
+                                        PackageList,\r
+                                        &TempSupportedLanguages,\r
+                                        &SupportedLanguagesSize\r
+                                        );\r
   if (Status != EFI_BUFFER_TOO_SMALL) {\r
     return Status;\r
   }\r
@@ -2391,13 +2482,14 @@ HiiStringIdToImage (
   if (Language == NULL) {\r
     Language = "";\r
   }\r
-  GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLanguage, NULL);\r
+\r
+  GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&CurrentLanguage, NULL);\r
   BestLanguage = GetBestLanguage (\r
                    SupportedLanguages,\r
                    FALSE,\r
                    Language,\r
                    (CurrentLanguage == NULL) ? CurrentLanguage : "",\r
-                   (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang),\r
+                   (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang),\r
                    NULL\r
                    );\r
   if (BestLanguage == NULL) {\r
@@ -2406,7 +2498,7 @@ HiiStringIdToImage (
   }\r
 \r
   StringSize = MAX_STRING_LENGTH;\r
-  String = (EFI_STRING) AllocateZeroPool (StringSize);\r
+  String     = (EFI_STRING)AllocateZeroPool (StringSize);\r
   if (String == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
@@ -2423,11 +2515,12 @@ HiiStringIdToImage (
                         );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     FreePool (String);\r
-    String = (EFI_STRING) AllocateZeroPool (StringSize);\r
+    String = (EFI_STRING)AllocateZeroPool (StringSize);\r
     if (String == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Exit;\r
     }\r
+\r
     Status = HiiString->GetString (\r
                           HiiString,\r
                           BestLanguage,\r
@@ -2448,14 +2541,15 @@ HiiStringIdToImage (
   // 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
+  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
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Exit;\r
     }\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
@@ -2477,34 +2571,39 @@ HiiStringIdToImage (
   }\r
 \r
   Status = HiiStringToImage (\r
-           This,\r
-           Flags,\r
-           String,\r
-           StringInfo,\r
-           Blt,\r
-           BltX,\r
-           BltY,\r
-           RowInfoArray,\r
-           RowInfoArraySize,\r
-           ColumnInfoArray\r
-           );\r
+             This,\r
+             Flags,\r
+             String,\r
+             StringInfo,\r
+             Blt,\r
+             BltX,\r
+             BltY,\r
+             RowInfoArray,\r
+             RowInfoArraySize,\r
+             ColumnInfoArray\r
+             );\r
 \r
 Exit:\r
   if (SupportedLanguages != NULL) {\r
     FreePool (SupportedLanguages);\r
   }\r
+\r
   if (CurrentLanguage != NULL) {\r
     FreePool (CurrentLanguage);\r
   }\r
+\r
   if (BestLanguage != NULL) {\r
     FreePool (BestLanguage);\r
   }\r
+\r
   if (String != NULL) {\r
     FreePool (String);\r
   }\r
+\r
   if (StringFontInfo != NULL) {\r
     FreePool (StringFontInfo);\r
   }\r
+\r
   if (NewStringInfo != NULL) {\r
     FreePool (NewStringInfo);\r
   }\r
@@ -2512,7 +2611,6 @@ Exit:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Convert the glyph for a single character into a bitmap.\r
 \r
@@ -2538,31 +2636,31 @@ Exit:
 EFI_STATUS\r
 EFIAPI\r
 HiiGetGlyph (\r
-  IN  CONST EFI_HII_FONT_PROTOCOL    *This,\r
-  IN  CHAR16                         Char,\r
-  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo,\r
-  OUT EFI_IMAGE_OUTPUT               **Blt,\r
-  OUT UINTN                          *Baseline OPTIONAL\r
+  IN  CONST EFI_HII_FONT_PROTOCOL  *This,\r
+  IN  CHAR16                       Char,\r
+  IN  CONST EFI_FONT_DISPLAY_INFO  *StringInfo,\r
+  OUT EFI_IMAGE_OUTPUT             **Blt,\r
+  OUT UINTN                        *Baseline OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS                         Status;\r
-  HII_DATABASE_PRIVATE_DATA          *Private;\r
-  EFI_IMAGE_OUTPUT                   *Image;\r
-  UINT8                              *GlyphBuffer;\r
-  EFI_FONT_DISPLAY_INFO              *SystemDefault;\r
-  EFI_FONT_DISPLAY_INFO              *StringInfoOut;\r
-  BOOLEAN                            Default;\r
-  EFI_FONT_HANDLE                    FontHandle;\r
-  EFI_STRING                         String;\r
-  EFI_HII_GLYPH_INFO                 Cell;\r
-  EFI_FONT_INFO                      *FontInfo;\r
-  UINT8                              Attributes;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      Foreground;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      Background;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer;\r
-  UINT16                             BaseLine;\r
-\r
-  if (This == NULL || Blt == NULL || *Blt != NULL) {\r
+  EFI_STATUS                     Status;\r
+  HII_DATABASE_PRIVATE_DATA      *Private;\r
+  EFI_IMAGE_OUTPUT               *Image;\r
+  UINT8                          *GlyphBuffer;\r
+  EFI_FONT_DISPLAY_INFO          *SystemDefault;\r
+  EFI_FONT_DISPLAY_INFO          *StringInfoOut;\r
+  BOOLEAN                        Default;\r
+  EFI_FONT_HANDLE                FontHandle;\r
+  EFI_STRING                     String;\r
+  EFI_HII_GLYPH_INFO             Cell;\r
+  EFI_FONT_INFO                  *FontInfo;\r
+  UINT8                          Attributes;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer;\r
+  UINT16                         BaseLine;\r
+\r
+  if ((This == NULL) || (Blt == NULL) || (*Blt != NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -2580,25 +2678,27 @@ HiiGetGlyph (
   ZeroMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
   ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
 \r
-  Default = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);\r
+  Default = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *)StringInfo, &SystemDefault, NULL);\r
 \r
   if (!Default) {\r
     //\r
     // Find out a EFI_FONT_DISPLAY_INFO which could display the character in\r
     // the specified color and font.\r
     //\r
-    String = (EFI_STRING) AllocateZeroPool (sizeof (CHAR16) * 2);\r
+    String = (EFI_STRING)AllocateZeroPool (sizeof (CHAR16) * 2);\r
     if (String == NULL) {\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto Exit;\r
     }\r
-    *String = Char;\r
+\r
+    *String       = Char;\r
     *(String + 1) = 0;\r
 \r
     Status = HiiGetFontInfo (This, &FontHandle, StringInfo, &StringInfoOut, String);\r
     if (EFI_ERROR (Status)) {\r
       goto Exit;\r
     }\r
+\r
     ASSERT (StringInfoOut != NULL);\r
     FontInfo   = &StringInfoOut->FontInfo;\r
     Foreground = StringInfoOut->ForegroundColor;\r
@@ -2614,13 +2714,14 @@ HiiGetGlyph (
     goto Exit;\r
   }\r
 \r
-  Image = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
+  Image = (EFI_IMAGE_OUTPUT *)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
   if (Image == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
   }\r
-  Image->Width   = Cell.Width;\r
-  Image->Height  = Cell.Height;\r
+\r
+  Image->Width  = Cell.Width;\r
+  Image->Height = Cell.Height;\r
 \r
   if (Image->Width * Image->Height > 0) {\r
     Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
@@ -2633,7 +2734,7 @@ HiiGetGlyph (
     //\r
     // Set BaseLine to the char height.\r
     //\r
-    BaseLine  = (UINT16) (Cell.Height + Cell.OffsetY);\r
+    BaseLine = (UINT16)(Cell.Height + Cell.OffsetY);\r
     //\r
     // Set BltBuffer to the position of Origin.\r
     //\r
@@ -2677,14 +2778,17 @@ Exit:
   }\r
 \r
   if (SystemDefault != NULL) {\r
-   FreePool (SystemDefault);\r
+    FreePool (SystemDefault);\r
   }\r
+\r
   if (StringInfoOut != NULL) {\r
     FreePool (StringInfoOut);\r
   }\r
+\r
   if (String != NULL) {\r
     FreePool (String);\r
   }\r
+\r
   if (GlyphBuffer != NULL) {\r
     FreePool (GlyphBuffer);\r
   }\r
@@ -2692,7 +2796,6 @@ Exit:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   This function iterates through fonts which match the specified font, using\r
   the specified criteria. If String is non-NULL, then all of the characters in\r
@@ -2727,31 +2830,31 @@ Exit:
 EFI_STATUS\r
 EFIAPI\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  OPTIONAL,\r
-  OUT       EFI_FONT_DISPLAY_INFO    **StringInfoOut,\r
-  IN  CONST EFI_STRING               String OPTIONAL\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
+  OUT       EFI_FONT_DISPLAY_INFO  **StringInfoOut,\r
+  IN  CONST EFI_STRING             String OPTIONAL\r
   )\r
 {\r
-  HII_DATABASE_PRIVATE_DATA          *Private;\r
-  EFI_STATUS                         Status;\r
-  EFI_FONT_DISPLAY_INFO              *SystemDefault;\r
-  EFI_FONT_DISPLAY_INFO              InfoOut;\r
-  UINTN                              StringInfoOutLen;\r
-  EFI_FONT_INFO                      *FontInfo;\r
-  HII_GLOBAL_FONT_INFO               *GlobalFont;\r
-  EFI_STRING                         StringIn;\r
-  EFI_FONT_HANDLE                    LocalFontHandle;\r
+  HII_DATABASE_PRIVATE_DATA  *Private;\r
+  EFI_STATUS                 Status;\r
+  EFI_FONT_DISPLAY_INFO      *SystemDefault;\r
+  EFI_FONT_DISPLAY_INFO      InfoOut;\r
+  UINTN                      StringInfoOutLen;\r
+  EFI_FONT_INFO              *FontInfo;\r
+  HII_GLOBAL_FONT_INFO       *GlobalFont;\r
+  EFI_STRING                 StringIn;\r
+  EFI_FONT_HANDLE            LocalFontHandle;\r
 \r
   if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   StringInfoOutLen = 0;\r
-  FontInfo        = NULL;\r
-  SystemDefault   = NULL;\r
-  LocalFontHandle = NULL;\r
+  FontInfo         = NULL;\r
+  SystemDefault    = NULL;\r
+  LocalFontHandle  = NULL;\r
   if (FontHandle != NULL) {\r
     LocalFontHandle = *FontHandle;\r
   }\r
@@ -2763,7 +2866,7 @@ HiiGetFontInfo (
   //\r
   if (LocalFontHandle == &Private->FontInfoList) {\r
     LocalFontHandle = NULL;\r
-    Status = EFI_NOT_FOUND;\r
+    Status          = EFI_NOT_FOUND;\r
     goto Exit;\r
   }\r
 \r
@@ -2771,7 +2874,7 @@ HiiGetFontInfo (
   // Get default system display info, if StringInfoIn points to\r
   // system display info, return it directly.\r
   //\r
-  if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, &SystemDefault, &StringInfoOutLen)) {\r
+  if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *)StringInfoIn, &SystemDefault, &StringInfoOutLen)) {\r
     //\r
     // System font is the first node. When handle is not NULL, system font can not\r
     // be found any more.\r
@@ -2780,18 +2883,18 @@ HiiGetFontInfo (
       if (StringInfoOut != NULL) {\r
         *StringInfoOut = AllocateCopyPool (StringInfoOutLen, SystemDefault);\r
         if (*StringInfoOut == NULL) {\r
-          Status = EFI_OUT_OF_RESOURCES;\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
+      Status          = EFI_SUCCESS;\r
       goto Exit;\r
     } else {\r
       LocalFontHandle = NULL;\r
-      Status = EFI_NOT_FOUND;\r
+      Status          = EFI_NOT_FOUND;\r
       goto Exit;\r
     }\r
   }\r
@@ -2812,7 +2915,8 @@ HiiGetFontInfo (
       ((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
+       (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)))\r
+  {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -2820,13 +2924,14 @@ HiiGetFontInfo (
   // Parse the font information mask to find a matching font.\r
   //\r
 \r
-  CopyMem (&InfoOut, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, sizeof (EFI_FONT_DISPLAY_INFO));\r
+  CopyMem (&InfoOut, (EFI_FONT_DISPLAY_INFO *)StringInfoIn, sizeof (EFI_FONT_DISPLAY_INFO));\r
 \r
   if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FONT) == EFI_FONT_INFO_SYS_FONT) {\r
     Status = SaveFontName (SystemDefault->FontInfo.FontName, &FontInfo);\r
   } else {\r
-    Status = SaveFontName (((EFI_FONT_DISPLAY_INFO *) StringInfoIn)->FontInfo.FontName, &FontInfo);\r
+    Status = SaveFontName (((EFI_FONT_DISPLAY_INFO *)StringInfoIn)->FontInfo.FontName, &FontInfo);\r
   }\r
+\r
   if (EFI_ERROR (Status)) {\r
     goto Exit;\r
   }\r
@@ -2834,12 +2939,15 @@ HiiGetFontInfo (
   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
+\r
   if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {\r
     InfoOut.ForegroundColor = SystemDefault->ForegroundColor;\r
   }\r
+\r
   if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {\r
     InfoOut.BackgroundColor = SystemDefault->BackgroundColor;\r
   }\r
@@ -2860,17 +2968,19 @@ HiiGetFontInfo (
           LocalFontHandle = NULL;\r
           goto Exit;\r
         }\r
+\r
         StringIn++;\r
       }\r
     }\r
+\r
     //\r
     // Write to output parameter\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
+        Status          = EFI_OUT_OF_RESOURCES;\r
         LocalFontHandle = NULL;\r
         goto Exit;\r
       }\r
@@ -2880,7 +2990,7 @@ HiiGetFontInfo (
     }\r
 \r
     LocalFontHandle = GlobalFont->Entry.ForwardLink;\r
-    Status = EFI_SUCCESS;\r
+    Status          = EFI_SUCCESS;\r
     goto Exit;\r
   }\r
 \r
@@ -2893,10 +3003,12 @@ Exit:
   }\r
 \r
   if (SystemDefault != NULL) {\r
-   FreePool (SystemDefault);\r
+    FreePool (SystemDefault);\r
   }\r
+\r
   if (FontInfo != NULL) {\r
-   FreePool (FontInfo);\r
+    FreePool (FontInfo);\r
   }\r
+\r
   return Status;\r
 }\r