]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Font.c
index 9e99a120125548e5faeaea6ef6efd29bb9cfc60f..06b09e7f7625185baedfb912bad3987f26c85c70 100644 (file)
@@ -1,4 +1,6 @@
 /** @file\r
+Implementation for EFI_HII_FONT_PROTOCOL.\r
+\r
 \r
 Copyright (c) 2007 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -9,23 +11,12 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-    Font.c\r
-\r
-Abstract:\r
-\r
-    Implementation for EFI_HII_FONT_PROTOCOL.\r
-\r
-Revision History\r
-\r
-\r
 **/\r
 \r
 \r
 #include "HiiDatabase.h"\r
 \r
-static EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {\r
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {\r
   //\r
   // B     G     R\r
   //\r
@@ -51,6 +42,8 @@ static EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {
 /**\r
   Insert a character cell information to the list specified by GlyphInfoList.\r
 \r
+  This is a internal function.\r
+\r
   @param  CharValue               Unicode character value, which identifies a glyph\r
                                   block.\r
   @param  GlyphInfoList           HII_GLYPH_INFO list head.\r
@@ -61,7 +54,6 @@ static EFI_GRAPHICS_OUTPUT_BLT_PIXEL        mEfiColors[16] = {
                                   task.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 NewCell (\r
   IN  CHAR16                         CharValue,\r
@@ -94,6 +86,8 @@ NewCell (
 /**\r
   Get a character cell information from the list specified by GlyphInfoList.\r
 \r
+  This is a internal function.\r
+\r
   @param  CharValue               Unicode character value, which identifies a glyph\r
                                   block.\r
   @param  GlyphInfoList           HII_GLYPH_INFO list head.\r
@@ -105,7 +99,6 @@ NewCell (
                                   not exist.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 GetCell (\r
   IN  CHAR16                         CharValue,\r
@@ -143,6 +136,8 @@ GetCell (
 /**\r
   Convert the glyph for a single character into a bitmap.\r
 \r
+  This is a internal function.\r
+\r
   @param  Private                 HII database driver private data.\r
   @param  Char                    Character to retrieve.\r
   @param  StringInfo              Points to the string font and color information\r
@@ -158,7 +153,6 @@ GetCell (
   @retval EFI_INVALID_PARAMETER   Any input parameter is invalid.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 GetGlyphBuffer (\r
   IN  HII_DATABASE_PRIVATE_DATA      *Private,\r
@@ -266,7 +260,28 @@ GetGlyphBuffer (
   return EFI_NOT_FOUND;\r
 }\r
 \r
-STATIC\r
+/**\r
+  Convert bitmap data of the glyph to blt structure.\r
+\r
+  This is a internal function.\r
+\r
+  @param GlyphBuffer     Buffer points to bitmap data of glyph.\r
+  @param  Foreground     The color of the "on" pixels in the glyph in the\r
+                         bitmap.\r
+  @param  Background     The color of the "off" pixels in the glyph in the\r
+                         bitmap.\r
+  @param  ImageWidth     Width of the character or character cell, in\r
+                         pixels.\r
+  @param  ImageHeight    Height of the character or character cell, in\r
+                         pixels.\r
+  @param  Transparent             If TRUE, the Background color is ignored and all\r
+                                  "off" pixels in the character's drawn wil use the\r
+                                  pixel value from BltBuffer.\r
+  @param  Origin                  On input, points to the origin of the to be\r
+                                  displayed character, on output, points to the\r
+                                  next glyph's origin.\r
+\r
+**/\r
 VOID\r
 NarrowGlyphToBlt (\r
   IN     UINT8                         *GlyphBuffer,\r
@@ -278,8 +293,8 @@ NarrowGlyphToBlt (
   IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
   )\r
 {\r
-  UINT8                                X;\r
-  UINT8                                Y;\r
+  UINT8                                Xpos;\r
+  UINT8                                Ypos;\r
   UINT8                                Height;\r
   UINT8                                Width;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL        *Buffer;\r
@@ -293,13 +308,13 @@ NarrowGlyphToBlt (
 \r
   Buffer = *Origin;\r
 \r
-  for (Y = 0; Y < Height; Y++) {\r
-    for (X = 0; X < Width; X++) {\r
-      if ((GlyphBuffer[Y] & (1 << X)) != 0) {\r
-        Buffer[Y * ImageWidth + (Width - X - 1)] = Foreground;\r
+  for (Ypos = 0; Ypos < Height; Ypos++) {\r
+    for (Xpos = 0; Xpos < Width; Xpos++) {\r
+      if ((GlyphBuffer[Ypos] & (1 << Xpos)) != 0) {\r
+        Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Foreground;\r
       } else {\r
         if (!Transparent) {\r
-          Buffer[Y * ImageWidth + (Width - X - 1)] = Background;\r
+          Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Background;\r
         }\r
       }\r
     }\r
@@ -312,23 +327,28 @@ NarrowGlyphToBlt (
 /**\r
   Convert bitmap data of the glyph to blt structure.\r
 \r
+  This is a internal function.\r
+\r
   @param  GlyphBuffer             Buffer points to bitmap data of glyph.\r
   @param  Foreground              The color of the "on" pixels in the glyph in the\r
                                   bitmap.\r
   @param  Background              The color of the "off" pixels in the glyph in the\r
                                   bitmap.\r
-  @param  Width                   Width of the character or character cell, in\r
+  @param  ImageWidth              Width of the character or character cell, in\r
                                   pixels.\r
-  @param  Height                  Height of the character or character cell, in\r
+  @param  ImageHeight             Height of the character or character cell, in\r
                                   pixels.\r
   @param  Transparent             If TRUE, the Background color is ignored and all\r
                                   "off" pixels in the character's drawn wil use the\r
                                   pixel value from BltBuffer.\r
-  @param  BltBuffer               Points to the blt buffer.\r
+  @param  Cell                    Points to EFI_HII_GLYPH_INFO structure.\r
+  @param  Attributes              The attribute of incoming glyph in GlyphBuffer.\r
+  @param  Origin                  On input, points to the origin of the to be\r
+                                  displayed character, on output, points to the\r
+                                  next glyph's origin.\r
 \r
 \r
 **/\r
-STATIC\r
 VOID\r
 GlyphToBlt (\r
   IN     UINT8                         *GlyphBuffer,\r
@@ -342,8 +362,8 @@ GlyphToBlt (
   IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin\r
   )\r
 {\r
-  UINT8                                X;\r
-  UINT8                                Y;\r
+  UINT8                                Xpos;\r
+  UINT8                                Ypos;\r
   UINT8                                Data;\r
   UINT8                                Index;\r
   UINTN                                OffsetY;\r
@@ -366,20 +386,20 @@ GlyphToBlt (
   // The glyph's upper left hand corner pixel is the most significant bit of the\r
   // first bitmap byte.\r
   //\r
-  for (Y = 0; Y < Cell->Height; Y++) {\r
-    OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Y);\r
+  for (Ypos = 0; Ypos < Cell->Height; Ypos++) {\r
+    OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);\r
 \r
     //\r
     // All bits in these bytes are meaningful.\r
     //\r
-    for (X = 0; X < Cell->Width / 8; X++) {\r
-      Data  = *(GlyphBuffer + OffsetY + X);\r
+    for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {\r
+      Data  = *(GlyphBuffer + OffsetY + Xpos);\r
       for (Index = 0; Index < 8; Index++) {\r
         if ((Data & (1 << Index)) != 0) {\r
-          BltBuffer[Y * ImageWidth + X * 8 + (8 - Index - 1)] = Foreground;\r
+          BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Foreground;\r
         } else {\r
           if (!Transparent) {\r
-            BltBuffer[Y * ImageWidth + X * 8 + (8 - Index - 1)] = Background;\r
+            BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Background;\r
           }\r
         }\r
       }\r
@@ -389,19 +409,19 @@ GlyphToBlt (
       //\r
       // There are some padding bits in this byte. Ignore them.\r
       //\r
-      Data  = *(GlyphBuffer + OffsetY + X);\r
+      Data  = *(GlyphBuffer + OffsetY + Xpos);\r
       for (Index = 0; Index < Cell->Width % 8; Index++) {\r
         if ((Data & (1 << (8 - Index - 1))) != 0) {\r
-          BltBuffer[Y * ImageWidth + X * 8 + Index] = Foreground;\r
+          BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;\r
         } else {\r
           if (!Transparent) {\r
-            BltBuffer[Y * ImageWidth + X * 8 + Index] = Background;\r
+            BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Background;\r
           }\r
         }\r
       }\r
     } // end of if (Width % 8...)\r
 \r
-  } // end of for (Y=0...)\r
+  } // end of for (Ypos=0...)\r
 \r
   *Origin = BltBuffer + Cell->Width;\r
 }\r
@@ -410,14 +430,16 @@ GlyphToBlt (
 /**\r
   Convert bitmap data of the glyph to blt structure.\r
 \r
+  This is a internal function.\r
+\r
   @param  GlyphBuffer             Buffer points to bitmap data of glyph.\r
   @param  Foreground              The color of the "on" pixels in the glyph in the\r
                                   bitmap.\r
   @param  Background              The color of the "off" pixels in the glyph in the\r
                                   bitmap.\r
-  @param  Width                   Width of the character or character cell, in\r
+  @param  ImageWidth              Width of the character or character cell, in\r
                                   pixels.\r
-  @param  Height                  Height of the character or character cell, in\r
+  @param  ImageHeight             Height of the character or character cell, in\r
                                   pixels.\r
   @param  Transparent             If TRUE, the Background color is ignored and all\r
                                   "off" pixels in the character's drawn wil use the\r
@@ -431,7 +453,6 @@ GlyphToBlt (
   @return Points to the address of next origin node in BltBuffer.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 GlyphToImage (\r
   IN     UINT8                         *GlyphBuffer,\r
@@ -531,6 +552,8 @@ GlyphToImage (
 /**\r
   Write the output parameters of FindGlyphBlock().\r
 \r
+  This is a internal function.\r
+\r
   @param  BufferIn                Buffer which stores the bitmap data of the found\r
                                   block.\r
   @param  BufferLen               Length of BufferIn.\r
@@ -548,7 +571,6 @@ GlyphToImage (
                                   task.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 WriteOutputParam (\r
   IN  UINT8                          *BufferIn,\r
@@ -817,6 +839,8 @@ FindGlyphBlock (
 /**\r
   Copy a Font Name to a new created EFI_FONT_INFO structure.\r
 \r
+  This is a internal function.\r
+\r
   @param  FontName                NULL-terminated string.\r
   @param  FontInfo                a new EFI_FONT_INFO which stores the FontName.\r
                                   It's caller's responsibility to free this buffer.\r
@@ -826,7 +850,6 @@ FindGlyphBlock (
                                   task.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 SaveFontName (\r
   IN  EFI_STRING                       FontName,\r
@@ -908,6 +931,8 @@ GetSystemFont (
   Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or\r
   returns the system default according to the optional inputs.\r
 \r
+  This is a internal function.\r
+\r
   @param  Private                 HII database driver private data.\r
   @param  StringInfo              Points to the string output information,\r
                                   including the color and font.\r
@@ -920,7 +945,6 @@ GetSystemFont (
   @retval FALSE                   No.\r
 \r
 **/\r
-STATIC\r
 BOOLEAN\r
 IsSystemFontInfo (\r
   IN  HII_DATABASE_PRIVATE_DATA      *Private,\r
@@ -1000,7 +1024,9 @@ IsSystemFontInfo (
 \r
 Exit:\r
   if (SystemInfo == NULL) {\r
-    SafeFreePool (SystemDefault);    \r
+    if (SystemDefault != NULL) {\r
+      FreePool (SystemDefault);\r
+    }\r
   }\r
   return Flag;\r
 }\r
@@ -1318,6 +1344,8 @@ IsFontInfoExisted (
 /**\r
   Check whether the unicode represents a line break or not.\r
 \r
+  This is a internal function.\r
+\r
   @param  Char                    Unicode character\r
 \r
   @retval 0                       Yes, it is a line break.\r
@@ -1328,7 +1356,6 @@ IsFontInfoExisted (
   @retval -1                      No, it is not a link break.\r
 \r
 **/\r
-STATIC\r
 INT8\r
 IsLineBreak (\r
   IN  CHAR16    Char\r
@@ -1413,7 +1440,10 @@ IsLineBreak (
                                   will be allocated to hold the generated image and\r
                                   the pointer updated on exit. It is the caller's\r
                                   responsibility to free this buffer.\r
-  @param  BltX,BLTY               Specifies the offset from the left and top edge\r
+  @param  BltX                    Specifies the offset from the left and top edge\r
+                                  of the image of the first character cell in the\r
+                                  image.\r
+  @param  BltY                    Specifies the offset from the left and top edge\r
                                   of the image of the first character cell in the\r
                                   image.\r
   @param  RowInfoArray            If this is non-NULL on entry, then on exit, this\r
@@ -1618,7 +1648,9 @@ HiiStringToImage (
     Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);\r
     if (Status == EFI_NOT_FOUND) {\r
       if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {\r
-        SafeFreePool (GlyphBuf[Index]);\r
+        if (GlyphBuf[Index] != NULL) {\r
+          FreePool (GlyphBuf[Index]);\r
+        }\r
         GlyphBuf[Index] = NULL;\r
         StringPtr++;\r
       } else {\r
@@ -1702,7 +1734,6 @@ HiiStringToImage (
         if (LineHeight < Cell[Index].Height) {\r
           LineHeight = (UINTN) Cell[Index].Height;\r
         }\r
-        BaseLineOffset += (UINTN) Cell[Index].OffsetY;\r
 \r
         if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&\r
             (Flags & EFI_HII_OUT_FLAG_WRAP) == 0 &&\r
@@ -1771,7 +1802,7 @@ HiiStringToImage (
         if (Index > 0) {\r
           RowInfo[RowIndex].EndIndex       = Index - 1;\r
           RowInfo[RowIndex].LineWidth      = LineWidth - Cell[Index].AdvanceX;\r
-          RowInfo[RowIndex].BaselineOffset = BaseLineOffset - Cell[Index].OffsetY;\r
+          RowInfo[RowIndex].BaselineOffset = BaseLineOffset;\r
           if (LineHeight > Cell[Index - 1].Height) {\r
             LineHeight = Cell[Index - 1].Height;\r
           }\r
@@ -1844,11 +1875,11 @@ HiiStringToImage (
                                         0\r
                                         );\r
         if (EFI_ERROR (Status)) {\r
-          SafeFreePool (BltBuffer);\r
+          FreePool (BltBuffer);\r
           goto Exit;\r
         }\r
 \r
-        SafeFreePool (BltBuffer);\r
+        FreePool (BltBuffer);\r
 \r
       } else {\r
         for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {\r
@@ -1911,7 +1942,7 @@ HiiStringToImage (
     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
-      SafeFreePool (Image);\r
+      FreePool (Image);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -1943,16 +1974,34 @@ HiiStringToImage (
 Exit:\r
 \r
   for (Index = 0; Index < MAX_STRING_LENGTH; Index++) {\r
-    SafeFreePool (GlyphBuf[Index]);\r
+    if (GlyphBuf[Index] != NULL) {\r
+      FreePool (GlyphBuf[Index]);\r
+    }\r
+  }\r
+  if (StringIn != NULL) {\r
+    FreePool (StringIn);\r
+  }\r
+  if (StringIn2 != NULL) {\r
+    FreePool (StringIn2);\r
+  }\r
+  if (StringInfoOut != NULL) {\r
+    FreePool (StringInfoOut);\r
+  }\r
+  if (RowInfo != NULL) {\r
+    FreePool (RowInfo);\r
+  }\r
+  if (SystemDefault != NULL) {\r
+    FreePool (SystemDefault);\r
+  }\r
+  if (GlyphBuf != NULL) {\r
+    FreePool (GlyphBuf);\r
+  }\r
+  if (Cell != NULL) {\r
+    FreePool (Cell);\r
+  }\r
+  if (Attributes != NULL) {\r
+    FreePool (Attributes);\r
   }\r
-  SafeFreePool (StringIn);\r
-  SafeFreePool (StringIn2);\r
-  SafeFreePool (StringInfoOut);\r
-  SafeFreePool (RowInfo);\r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (GlyphBuf);\r
-  SafeFreePool (Cell);\r
-  SafeFreePool (Attributes);\r
 \r
   return Status;\r
 }\r
@@ -1983,7 +2032,10 @@ Exit:
                                   will be allocated to hold the generated image and\r
                                   the pointer updated on exit. It is the caller's\r
                                   responsibility to free this buffer.\r
-  @param  BltX,BLTY               Specifies the offset from the left and top edge\r
+  @param  BltX                    Specifies the offset from the left and top edge\r
+                                  of the image of the first character cell in the\r
+                                  image.\r
+  @param  BltY                    Specifies the offset from the left and top edge\r
                                   of the image of the first character cell in the\r
                                   image.\r
   @param  RowInfoArray            If this is non-NULL on entry, then on exit, this\r
@@ -2056,7 +2108,7 @@ HiiStringIdToImage (
   if (Language != NULL) {\r
     AsciiStrCpy (CurrentLang, (CHAR8 *) Language);\r
   } else {\r
-    HiiLibGetCurrentLanguage (CurrentLang);\r
+    GetCurrentLanguage (CurrentLang);\r
   }\r
 \r
   //\r
@@ -2083,7 +2135,7 @@ HiiStringIdToImage (
                                 &StringFontInfo\r
                                 );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    SafeFreePool (String);\r
+    FreePool (String);\r
     String = (EFI_STRING) AllocateZeroPool (StringSize);\r
     if (String == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -2150,9 +2202,15 @@ HiiStringIdToImage (
            );\r
 \r
 Exit:\r
-  SafeFreePool (String);\r
-  SafeFreePool (StringFontInfo);\r
-  SafeFreePool (NewStringInfo);\r
+  if (String != NULL) {\r
+    FreePool (String);\r
+  }\r
+  if (StringFontInfo != NULL) {\r
+    FreePool (StringFontInfo);\r
+  }\r
+  if (NewStringInfo != NULL) {\r
+    FreePool (NewStringInfo);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -2266,7 +2324,7 @@ HiiGetGlyph (
 \r
   Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
   if (Image->Image.Bitmap == NULL) {\r
-    SafeFreePool (Image);\r
+    FreePool (Image);\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Exit;\r
   }\r
@@ -2307,10 +2365,18 @@ Exit:
     }\r
   }\r
 \r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (StringInfoOut);\r
-  SafeFreePool (String);\r
-  SafeFreePool (GlyphBuffer);\r
+  if (SystemDefault != NULL) {\r
+   FreePool (SystemDefault);\r
+  }\r
+  if (StringInfoOut != NULL) {\r
+    FreePool (StringInfoOut);\r
+  }\r
+  if (String != NULL) {\r
+    FreePool (String);\r
+  }\r
+  if (GlyphBuffer != NULL) {\r
+    FreePool (GlyphBuffer);\r
+  }\r
 \r
   return Status;\r
 }\r
@@ -2466,10 +2532,10 @@ HiiGetFontInfo (
   FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;\r
 \r
   if (IsFontInfoExisted (Private, FontInfo, &InfoOut.FontInfoMask, LocalFontHandle, &GlobalFont)) {\r
+    //\r
+    // Test to guarantee all characters are available in the found font.\r
+    //    \r
     if (String != NULL) {\r
-      //\r
-      // Test to guarantee all characters are available in the found font.\r
-      //\r
       StringIn = String;\r
       while (*StringIn != 0) {\r
         Status = FindGlyphBlock (GlobalFont->FontPackage, *StringIn, NULL, NULL, NULL);\r
@@ -2479,29 +2545,27 @@ HiiGetFontInfo (
         }\r
         StringIn++;\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
-        if (*StringInfoOut == NULL) {\r
-          Status = EFI_OUT_OF_RESOURCES;\r
-          LocalFontHandle = NULL;\r
-          goto Exit;\r
-        }\r
-        CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));\r
-        CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);\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
+      if (*StringInfoOut == NULL) {\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        LocalFontHandle = NULL;\r
+        goto Exit;\r
       }\r
-      LocalFontHandle = GlobalFont->Entry.ForwardLink;\r
-\r
-      Status = EFI_SUCCESS;\r
-      goto Exit;\r
+      \r
+      CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));\r
+      CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);\r
     }\r
-  } else {\r
-    LocalFontHandle = NULL;\r
-  }\r
+    \r
+    LocalFontHandle = GlobalFont->Entry.ForwardLink;    \r
+    Status = EFI_SUCCESS;\r
+    goto Exit;\r
+  }  \r
 \r
   Status = EFI_NOT_FOUND;\r
 \r
@@ -2511,8 +2575,12 @@ Exit:
     *FontHandle = LocalFontHandle;\r
   }\r
 \r
-  SafeFreePool (SystemDefault);\r
-  SafeFreePool (FontInfo);\r
+  if (SystemDefault != NULL) {\r
+   FreePool (SystemDefault);\r
+  }\r
+  if (FontInfo != NULL) {\r
+   FreePool (FontInfo);\r
+  }\r
   return Status;\r
 }\r
 \r