2008-01-21 15:39:56 +01:00
|
|
|
/** @file
|
2008-07-15 08:29:27 +02:00
|
|
|
Implementation for EFI_HII_FONT_PROTOCOL.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2018-06-27 15:08:52 +02:00
|
|
|
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
|
#include "HiiDatabase.h"
|
|
|
|
|
2009-05-20 04:12:26 +02:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL mHiiEfiColors[16] = {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
// B G R
|
|
|
|
//
|
2008-05-23 08:26:23 +02:00
|
|
|
{0x00, 0x00, 0x00, 0x00}, // BLACK
|
|
|
|
{0x98, 0x00, 0x00, 0x00}, // BLUE
|
|
|
|
{0x00, 0x98, 0x00, 0x00}, // GREEN
|
|
|
|
{0x98, 0x98, 0x00, 0x00}, // CYAN
|
|
|
|
{0x00, 0x00, 0x98, 0x00}, // RED
|
|
|
|
{0x98, 0x00, 0x98, 0x00}, // MAGENTA
|
|
|
|
{0x00, 0x98, 0x98, 0x00}, // BROWN
|
|
|
|
{0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
|
|
|
|
{0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
|
|
|
|
{0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE
|
|
|
|
{0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN
|
|
|
|
{0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
|
|
|
|
{0x00, 0x00, 0xff, 0x00}, // LIGHTRED
|
|
|
|
{0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
|
|
|
|
{0x00, 0xff, 0xff, 0x00}, // YELLOW
|
|
|
|
{0xff, 0xff, 0xff, 0x00}, // WHITE
|
2008-01-21 15:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Insert a character cell information to the list specified by GlyphInfoList.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param CharValue Unicode character value, which identifies a glyph
|
|
|
|
block.
|
|
|
|
@param GlyphInfoList HII_GLYPH_INFO list head.
|
|
|
|
@param Cell Incoming character cell information.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
|
|
|
task.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
NewCell (
|
|
|
|
IN CHAR16 CharValue,
|
|
|
|
IN LIST_ENTRY *GlyphInfoList,
|
|
|
|
IN EFI_HII_GLYPH_INFO *Cell
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HII_GLYPH_INFO *GlyphInfo;
|
|
|
|
|
|
|
|
ASSERT (Cell != NULL && GlyphInfoList != NULL);
|
|
|
|
|
|
|
|
GlyphInfo = (HII_GLYPH_INFO *) AllocateZeroPool (sizeof (HII_GLYPH_INFO));
|
|
|
|
if (GlyphInfo == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GlyphInfoList stores a list of default character cell information, each is
|
|
|
|
// identified by "CharId".
|
|
|
|
//
|
|
|
|
GlyphInfo->Signature = HII_GLYPH_INFO_SIGNATURE;
|
|
|
|
GlyphInfo->CharId = CharValue;
|
2011-01-24 05:58:45 +01:00
|
|
|
if (Cell->AdvanceX == 0) {
|
|
|
|
Cell->AdvanceX = Cell->Width;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
CopyMem (&GlyphInfo->Cell, Cell, sizeof (EFI_HII_GLYPH_INFO));
|
|
|
|
InsertTailList (GlyphInfoList, &GlyphInfo->Entry);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Get a character cell information from the list specified by GlyphInfoList.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param CharValue Unicode character value, which identifies a glyph
|
|
|
|
block.
|
|
|
|
@param GlyphInfoList HII_GLYPH_INFO list head.
|
|
|
|
@param Cell Buffer which stores output character cell
|
|
|
|
information.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
|
|
|
|
@retval EFI_NOT_FOUND The character info specified by CharValue does
|
|
|
|
not exist.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetCell (
|
|
|
|
IN CHAR16 CharValue,
|
|
|
|
IN LIST_ENTRY *GlyphInfoList,
|
|
|
|
OUT EFI_HII_GLYPH_INFO *Cell
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HII_GLYPH_INFO *GlyphInfo;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
ASSERT (Cell != NULL && GlyphInfoList != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Since the EFI_HII_GIBT_DEFAULTS block won't increment CharValueCurrent,
|
|
|
|
// the value of "CharId" of a default character cell which is used for a
|
|
|
|
// EFI_HII_GIBT_GLYPH_DEFAULT or EFI_HII_GIBT_GLYPHS_DEFAULT should be
|
|
|
|
// less or equal to the value of "CharValueCurrent" of this default block.
|
|
|
|
//
|
|
|
|
// For instance, if the CharId of a GlyphInfoList is {1, 3, 7}, a default glyph
|
|
|
|
// with CharValue equals "7" uses the GlyphInfo with CharId = 7;
|
|
|
|
// a default glyph with CharValue equals "6" uses the GlyphInfo with CharId = 3.
|
|
|
|
//
|
|
|
|
for (Link = GlyphInfoList->BackLink; Link != GlyphInfoList; Link = Link->BackLink) {
|
|
|
|
GlyphInfo = CR (Link, HII_GLYPH_INFO, Entry, HII_GLYPH_INFO_SIGNATURE);
|
|
|
|
if (GlyphInfo->CharId <= CharValue) {
|
|
|
|
CopyMem (Cell, &GlyphInfo->Cell, sizeof (EFI_HII_GLYPH_INFO));
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert the glyph for a single character into a bitmap.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param Private HII database driver private data.
|
|
|
|
@param Char Character to retrieve.
|
|
|
|
@param StringInfo Points to the string font and color information
|
|
|
|
or NULL if the string should use the default
|
|
|
|
system font and color.
|
|
|
|
@param GlyphBuffer Buffer to store the retrieved bitmap data.
|
|
|
|
@param Cell Points to EFI_HII_GLYPH_INFO structure.
|
|
|
|
@param Attributes If not NULL, output the glyph attributes if any.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Glyph bitmap outputted.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer GlyphBuffer.
|
|
|
|
@retval EFI_NOT_FOUND The glyph was unknown can not be found.
|
|
|
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetGlyphBuffer (
|
|
|
|
IN HII_DATABASE_PRIVATE_DATA *Private,
|
|
|
|
IN CHAR16 Char,
|
|
|
|
IN EFI_FONT_INFO *StringInfo,
|
|
|
|
OUT UINT8 **GlyphBuffer,
|
|
|
|
OUT EFI_HII_GLYPH_INFO *Cell,
|
|
|
|
OUT UINT8 *Attributes OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HII_DATABASE_RECORD *Node;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
HII_SIMPLE_FONT_PACKAGE_INSTANCE *SimpleFont;
|
|
|
|
LIST_ENTRY *Link1;
|
|
|
|
UINT16 Index;
|
|
|
|
EFI_NARROW_GLYPH Narrow;
|
|
|
|
EFI_WIDE_GLYPH Wide;
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFont;
|
|
|
|
UINTN HeaderSize;
|
|
|
|
EFI_NARROW_GLYPH *NarrowPtr;
|
|
|
|
EFI_WIDE_GLYPH *WidePtr;
|
|
|
|
|
|
|
|
if (GlyphBuffer == NULL || Cell == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (Private == NULL || Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMem (Cell, sizeof (EFI_HII_GLYPH_INFO));
|
|
|
|
|
|
|
|
//
|
|
|
|
// If StringInfo is not NULL, it must point to an existing EFI_FONT_INFO rather
|
|
|
|
// than system default font and color.
|
|
|
|
// If NULL, try to find the character in simplified font packages since
|
|
|
|
// default system font is the fixed font (narrow or wide glyph).
|
|
|
|
//
|
|
|
|
if (StringInfo != NULL) {
|
|
|
|
if(!IsFontInfoExisted (Private, StringInfo, NULL, NULL, &GlobalFont)) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (Attributes != NULL) {
|
|
|
|
*Attributes = PROPORTIONAL_GLYPH;
|
|
|
|
}
|
|
|
|
return FindGlyphBlock (GlobalFont->FontPackage, Char, GlyphBuffer, Cell, NULL);
|
|
|
|
} else {
|
|
|
|
HeaderSize = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR);
|
|
|
|
|
|
|
|
for (Link = Private->DatabaseList.ForwardLink; Link != &Private->DatabaseList; Link = Link->ForwardLink) {
|
|
|
|
Node = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
|
|
|
|
for (Link1 = Node->PackageList->SimpleFontPkgHdr.ForwardLink;
|
|
|
|
Link1 != &Node->PackageList->SimpleFontPkgHdr;
|
|
|
|
Link1 = Link1->ForwardLink
|
|
|
|
) {
|
|
|
|
SimpleFont = CR (Link1, HII_SIMPLE_FONT_PACKAGE_INSTANCE, SimpleFontEntry, HII_S_FONT_PACKAGE_SIGNATURE);
|
|
|
|
//
|
|
|
|
// Search the narrow glyph array
|
|
|
|
//
|
|
|
|
NarrowPtr = (EFI_NARROW_GLYPH *) ((UINT8 *) (SimpleFont->SimpleFontPkgHdr) + HeaderSize);
|
|
|
|
for (Index = 0; Index < SimpleFont->SimpleFontPkgHdr->NumberOfNarrowGlyphs; Index++) {
|
|
|
|
CopyMem (&Narrow, NarrowPtr + Index,sizeof (EFI_NARROW_GLYPH));
|
|
|
|
if (Narrow.UnicodeWeight == Char) {
|
|
|
|
*GlyphBuffer = (UINT8 *) AllocateZeroPool (EFI_GLYPH_HEIGHT);
|
|
|
|
if (*GlyphBuffer == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
Cell->Width = EFI_GLYPH_WIDTH;
|
|
|
|
Cell->Height = EFI_GLYPH_HEIGHT;
|
|
|
|
Cell->AdvanceX = Cell->Width;
|
|
|
|
CopyMem (*GlyphBuffer, Narrow.GlyphCol1, Cell->Height);
|
|
|
|
if (Attributes != NULL) {
|
|
|
|
*Attributes = (UINT8) (Narrow.Attributes | NARROW_GLYPH);
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Search the wide glyph array
|
|
|
|
//
|
|
|
|
WidePtr = (EFI_WIDE_GLYPH *) (NarrowPtr + SimpleFont->SimpleFontPkgHdr->NumberOfNarrowGlyphs);
|
|
|
|
for (Index = 0; Index < SimpleFont->SimpleFontPkgHdr->NumberOfWideGlyphs; Index++) {
|
|
|
|
CopyMem (&Wide, WidePtr + Index, sizeof (EFI_WIDE_GLYPH));
|
|
|
|
if (Wide.UnicodeWeight == Char) {
|
|
|
|
*GlyphBuffer = (UINT8 *) AllocateZeroPool (EFI_GLYPH_HEIGHT * 2);
|
|
|
|
if (*GlyphBuffer == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
Cell->Width = EFI_GLYPH_WIDTH * 2;
|
|
|
|
Cell->Height = EFI_GLYPH_HEIGHT;
|
|
|
|
Cell->AdvanceX = Cell->Width;
|
|
|
|
CopyMem (*GlyphBuffer, Wide.GlyphCol1, EFI_GLYPH_HEIGHT);
|
|
|
|
CopyMem (*GlyphBuffer + EFI_GLYPH_HEIGHT, Wide.GlyphCol2, EFI_GLYPH_HEIGHT);
|
|
|
|
if (Attributes != NULL) {
|
|
|
|
*Attributes = (UINT8) (Wide.Attributes | EFI_GLYPH_WIDE);
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
/**
|
|
|
|
Convert bitmap data of the glyph to blt structure.
|
|
|
|
|
|
|
|
This is a internal function.
|
|
|
|
|
|
|
|
@param GlyphBuffer Buffer points to bitmap data of glyph.
|
|
|
|
@param Foreground The color of the "on" pixels in the glyph in the
|
|
|
|
bitmap.
|
|
|
|
@param Background The color of the "off" pixels in the glyph in the
|
|
|
|
bitmap.
|
2011-01-24 05:58:45 +01:00
|
|
|
@param ImageWidth Width of the whole image in pixels.
|
|
|
|
@param RowWidth The width of the text on the line, in pixels.
|
|
|
|
@param RowHeight The height of the line, in pixels.
|
|
|
|
@param Transparent If TRUE, the Background color is ignored and all
|
2016-09-21 06:48:10 +02:00
|
|
|
"off" pixels in the character's drawn will use the
|
2011-01-24 05:58:45 +01:00
|
|
|
pixel value from BltBuffer.
|
|
|
|
@param Origin On input, points to the origin of the to be
|
|
|
|
displayed character, on output, points to the
|
|
|
|
next glyph's origin.
|
2008-07-15 08:29:27 +02:00
|
|
|
|
|
|
|
**/
|
2008-01-21 15:39:56 +01:00
|
|
|
VOID
|
|
|
|
NarrowGlyphToBlt (
|
|
|
|
IN UINT8 *GlyphBuffer,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
2011-01-24 05:58:45 +01:00
|
|
|
IN UINT16 ImageWidth,
|
|
|
|
IN UINTN RowWidth,
|
|
|
|
IN UINTN RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
IN BOOLEAN Transparent,
|
|
|
|
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
|
|
|
)
|
|
|
|
{
|
2008-07-15 08:29:27 +02:00
|
|
|
UINT8 Xpos;
|
|
|
|
UINT8 Ypos;
|
2008-01-21 15:39:56 +01:00
|
|
|
UINT8 Height;
|
|
|
|
UINT8 Width;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;
|
|
|
|
|
|
|
|
ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);
|
|
|
|
|
|
|
|
Height = EFI_GLYPH_HEIGHT;
|
|
|
|
Width = EFI_GLYPH_WIDTH;
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// Move position to the left-top corner of char.
|
|
|
|
//
|
|
|
|
Buffer = *Origin - EFI_GLYPH_HEIGHT * ImageWidth;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
// Char may be partially displayed when CLIP_X or CLIP_Y is not set.
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
if (RowHeight < Height) {
|
|
|
|
Height = (UINT8) RowHeight;
|
|
|
|
}
|
|
|
|
if (RowWidth < Width) {
|
|
|
|
Width = (UINT8) RowWidth;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
for (Ypos = 0; Ypos < Height; Ypos++) {
|
|
|
|
for (Xpos = 0; Xpos < Width; Xpos++) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if ((GlyphBuffer[Ypos] & (1 << (EFI_GLYPH_WIDTH - Xpos - 1))) != 0) {
|
|
|
|
Buffer[Ypos * ImageWidth + Xpos] = Foreground;
|
2008-01-21 15:39:56 +01:00
|
|
|
} else {
|
|
|
|
if (!Transparent) {
|
2011-01-24 05:58:45 +01:00
|
|
|
Buffer[Ypos * ImageWidth + Xpos] = Background;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
*Origin = *Origin + EFI_GLYPH_WIDTH;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert bitmap data of the glyph to blt structure.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param GlyphBuffer Buffer points to bitmap data of glyph.
|
|
|
|
@param Foreground The color of the "on" pixels in the glyph in the
|
|
|
|
bitmap.
|
|
|
|
@param Background The color of the "off" pixels in the glyph in the
|
|
|
|
bitmap.
|
2011-01-24 05:58:45 +01:00
|
|
|
@param ImageWidth Width of the whole image in pixels.
|
|
|
|
@param BaseLine BaseLine in the line.
|
|
|
|
@param RowWidth The width of the text on the line, in pixels.
|
|
|
|
@param RowHeight The height of the line, in pixels.
|
2008-01-21 15:39:56 +01:00
|
|
|
@param Transparent If TRUE, the Background color is ignored and all
|
2016-09-21 06:48:10 +02:00
|
|
|
"off" pixels in the character's drawn will use the
|
2008-01-21 15:39:56 +01:00
|
|
|
pixel value from BltBuffer.
|
2008-07-15 08:29:27 +02:00
|
|
|
@param Cell Points to EFI_HII_GLYPH_INFO structure.
|
|
|
|
@param Attributes The attribute of incoming glyph in GlyphBuffer.
|
|
|
|
@param Origin On input, points to the origin of the to be
|
|
|
|
displayed character, on output, points to the
|
|
|
|
next glyph's origin.
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GlyphToBlt (
|
|
|
|
IN UINT8 *GlyphBuffer,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
2011-01-24 05:58:45 +01:00
|
|
|
IN UINT16 ImageWidth,
|
|
|
|
IN UINT16 BaseLine,
|
|
|
|
IN UINTN RowWidth,
|
|
|
|
IN UINTN RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
IN BOOLEAN Transparent,
|
2008-06-19 04:35:35 +02:00
|
|
|
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
2008-01-21 15:39:56 +01:00
|
|
|
IN UINT8 Attributes,
|
|
|
|
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
|
|
|
)
|
|
|
|
{
|
2011-01-24 05:58:45 +01:00
|
|
|
UINT16 Xpos;
|
|
|
|
UINT16 Ypos;
|
|
|
|
UINT8 Data;
|
|
|
|
UINT16 Index;
|
|
|
|
UINT16 YposOffset;
|
|
|
|
UINTN OffsetY;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// Only adjust origin position if char has no bitmap.
|
|
|
|
//
|
|
|
|
if (GlyphBuffer == NULL) {
|
|
|
|
*Origin = *Origin + Cell->AdvanceX;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Move position to the left-top corner of char.
|
|
|
|
//
|
|
|
|
BltBuffer = *Origin + Cell->OffsetX - (Cell->OffsetY + Cell->Height) * ImageWidth;
|
|
|
|
YposOffset = (UINT16) (BaseLine - (Cell->OffsetY + Cell->Height));
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Since non-spacing key will be printed OR'd with the previous glyph, don't
|
|
|
|
// write 0.
|
|
|
|
//
|
|
|
|
if ((Attributes & EFI_GLYPH_NON_SPACING) == EFI_GLYPH_NON_SPACING) {
|
|
|
|
Transparent = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The glyph's upper left hand corner pixel is the most significant bit of the
|
|
|
|
// first bitmap byte.
|
|
|
|
//
|
2017-02-24 03:01:34 +01:00
|
|
|
for (Ypos = 0; Ypos < Cell->Height && (((UINT32) Ypos + YposOffset) < RowHeight); Ypos++) {
|
2008-07-15 08:29:27 +02:00
|
|
|
OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// All bits in these bytes are meaningful.
|
|
|
|
//
|
2008-07-15 08:29:27 +02:00
|
|
|
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {
|
|
|
|
Data = *(GlyphBuffer + OffsetY + Xpos);
|
2017-02-24 03:01:34 +01:00
|
|
|
for (Index = 0; Index < 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if ((Data & (1 << (8 - Index - 1))) != 0) {
|
|
|
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
|
2008-01-21 15:39:56 +01:00
|
|
|
} else {
|
|
|
|
if (!Transparent) {
|
2011-01-24 05:58:45 +01:00
|
|
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Background;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-19 04:35:35 +02:00
|
|
|
if (Cell->Width % 8 != 0) {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
// There are some padding bits in this byte. Ignore them.
|
|
|
|
//
|
2008-07-15 08:29:27 +02:00
|
|
|
Data = *(GlyphBuffer + OffsetY + Xpos);
|
2017-02-24 03:01:34 +01:00
|
|
|
for (Index = 0; Index < Cell->Width % 8 && (((UINT32) Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
|
2008-01-21 15:39:56 +01:00
|
|
|
if ((Data & (1 << (8 - Index - 1))) != 0) {
|
2008-07-15 08:29:27 +02:00
|
|
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
|
2008-01-21 15:39:56 +01:00
|
|
|
} else {
|
|
|
|
if (!Transparent) {
|
2008-07-15 08:29:27 +02:00
|
|
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Background;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end of if (Width % 8...)
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
} // end of for (Ypos=0...)
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
*Origin = *Origin + Cell->AdvanceX;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert bitmap data of the glyph to blt structure.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param GlyphBuffer Buffer points to bitmap data of glyph.
|
|
|
|
@param Foreground The color of the "on" pixels in the glyph in the
|
|
|
|
bitmap.
|
|
|
|
@param Background The color of the "off" pixels in the glyph in the
|
|
|
|
bitmap.
|
2011-01-24 05:58:45 +01:00
|
|
|
@param ImageWidth Width of the whole image in pixels.
|
|
|
|
@param BaseLine BaseLine in the line.
|
|
|
|
@param RowWidth The width of the text on the line, in pixels.
|
|
|
|
@param RowHeight The height of the line, in pixels.
|
2008-01-21 15:39:56 +01:00
|
|
|
@param Transparent If TRUE, the Background color is ignored and all
|
2016-09-21 06:48:10 +02:00
|
|
|
"off" pixels in the character's drawn will use the
|
2008-01-21 15:39:56 +01:00
|
|
|
pixel value from BltBuffer.
|
|
|
|
@param Cell Points to EFI_HII_GLYPH_INFO structure.
|
|
|
|
@param Attributes The attribute of incoming glyph in GlyphBuffer.
|
|
|
|
@param Origin On input, points to the origin of the to be
|
|
|
|
displayed character, on output, points to the
|
|
|
|
next glyph's origin.
|
|
|
|
|
|
|
|
@return Points to the address of next origin node in BltBuffer.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GlyphToImage (
|
|
|
|
IN UINT8 *GlyphBuffer,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
|
|
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
2011-01-24 05:58:45 +01:00
|
|
|
IN UINT16 ImageWidth,
|
|
|
|
IN UINT16 BaseLine,
|
|
|
|
IN UINTN RowWidth,
|
|
|
|
IN UINTN RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
IN BOOLEAN Transparent,
|
2008-06-19 04:35:35 +02:00
|
|
|
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
2008-01-21 15:39:56 +01:00
|
|
|
IN UINT8 Attributes,
|
|
|
|
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;
|
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
Buffer = *Origin;
|
|
|
|
|
|
|
|
if ((Attributes & EFI_GLYPH_NON_SPACING) == EFI_GLYPH_NON_SPACING) {
|
|
|
|
//
|
|
|
|
// This character is a non-spacing key, print it OR'd with the previous glyph.
|
|
|
|
// without advancing cursor.
|
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
Buffer -= Cell->AdvanceX;
|
2008-01-21 15:39:56 +01:00
|
|
|
GlyphToBlt (
|
|
|
|
GlyphBuffer,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
ImageWidth,
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine,
|
|
|
|
RowWidth,
|
|
|
|
RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
|
|
|
Cell,
|
|
|
|
Attributes,
|
|
|
|
&Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
} else if ((Attributes & EFI_GLYPH_WIDE) == EFI_GLYPH_WIDE) {
|
|
|
|
//
|
|
|
|
// This character is wide glyph, i.e. 16 pixels * 19 pixels.
|
|
|
|
// Draw it as two narrow glyphs.
|
|
|
|
//
|
|
|
|
NarrowGlyphToBlt (
|
|
|
|
GlyphBuffer,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
ImageWidth,
|
2011-01-24 05:58:45 +01:00
|
|
|
RowWidth,
|
|
|
|
RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
|
|
|
Origin
|
|
|
|
);
|
|
|
|
|
|
|
|
NarrowGlyphToBlt (
|
|
|
|
GlyphBuffer + EFI_GLYPH_HEIGHT,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
ImageWidth,
|
2011-01-24 05:58:45 +01:00
|
|
|
RowWidth,
|
|
|
|
RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
|
|
|
Origin
|
|
|
|
);
|
|
|
|
|
|
|
|
} else if ((Attributes & NARROW_GLYPH) == NARROW_GLYPH) {
|
|
|
|
//
|
|
|
|
// This character is narrow glyph, i.e. 8 pixels * 19 pixels.
|
|
|
|
//
|
|
|
|
NarrowGlyphToBlt (
|
|
|
|
GlyphBuffer,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
ImageWidth,
|
2011-01-24 05:58:45 +01:00
|
|
|
RowWidth,
|
|
|
|
RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
|
|
|
Origin
|
|
|
|
);
|
|
|
|
|
|
|
|
} else if ((Attributes & PROPORTIONAL_GLYPH) == PROPORTIONAL_GLYPH) {
|
|
|
|
//
|
2008-06-19 04:35:35 +02:00
|
|
|
// This character is proportional glyph, i.e. Cell->Width * Cell->Height pixels.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
GlyphToBlt (
|
|
|
|
GlyphBuffer,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
ImageWidth,
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine,
|
|
|
|
RowWidth,
|
|
|
|
RowHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
|
|
|
Cell,
|
|
|
|
Attributes,
|
|
|
|
Origin
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Write the output parameters of FindGlyphBlock().
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param BufferIn Buffer which stores the bitmap data of the found
|
|
|
|
block.
|
|
|
|
@param BufferLen Length of BufferIn.
|
|
|
|
@param InputCell Buffer which stores cell information of the
|
|
|
|
encoded bitmap.
|
|
|
|
@param GlyphBuffer Output the corresponding bitmap data of the found
|
2016-09-21 06:48:10 +02:00
|
|
|
block. It is the caller's responsibility to free
|
2008-01-21 15:39:56 +01:00
|
|
|
this buffer.
|
|
|
|
@param Cell Output cell information of the encoded bitmap.
|
|
|
|
@param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation is performed successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
|
|
|
task.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
WriteOutputParam (
|
|
|
|
IN UINT8 *BufferIn,
|
|
|
|
IN UINTN BufferLen,
|
|
|
|
IN EFI_HII_GLYPH_INFO *InputCell,
|
|
|
|
OUT UINT8 **GlyphBuffer, OPTIONAL
|
|
|
|
OUT EFI_HII_GLYPH_INFO *Cell, OPTIONAL
|
|
|
|
OUT UINTN *GlyphBufferLen OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
2011-01-24 05:58:45 +01:00
|
|
|
if (BufferIn == NULL || InputCell == NULL) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cell != NULL) {
|
|
|
|
CopyMem (Cell, InputCell, sizeof (EFI_HII_GLYPH_INFO));
|
|
|
|
}
|
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
if (GlyphBuffer != NULL && BufferLen > 0) {
|
2008-01-21 15:39:56 +01:00
|
|
|
*GlyphBuffer = (UINT8 *) AllocateZeroPool (BufferLen);
|
|
|
|
if (*GlyphBuffer == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
CopyMem (*GlyphBuffer, BufferIn, BufferLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GlyphBufferLen != NULL) {
|
|
|
|
*GlyphBufferLen = BufferLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Parse all glyph blocks to find a glyph block specified by CharValue.
|
|
|
|
If CharValue = (CHAR16) (-1), collect all default character cell information
|
|
|
|
within this font package and backup its information.
|
|
|
|
|
|
|
|
@param FontPackage Hii string package instance.
|
|
|
|
@param CharValue Unicode character value, which identifies a glyph
|
|
|
|
block.
|
|
|
|
@param GlyphBuffer Output the corresponding bitmap data of the found
|
2016-09-21 06:48:10 +02:00
|
|
|
block. It is the caller's responsibility to free
|
2008-01-21 15:39:56 +01:00
|
|
|
this buffer.
|
|
|
|
@param Cell Output cell information of the encoded bitmap.
|
|
|
|
@param GlyphBufferLen If not NULL, output the length of GlyphBuffer.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The bitmap data is retrieved successfully.
|
|
|
|
@retval EFI_NOT_FOUND The specified CharValue does not exist in current
|
|
|
|
database.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
|
|
|
task.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
FindGlyphBlock (
|
|
|
|
IN HII_FONT_PACKAGE_INSTANCE *FontPackage,
|
|
|
|
IN CHAR16 CharValue,
|
|
|
|
OUT UINT8 **GlyphBuffer, OPTIONAL
|
|
|
|
OUT EFI_HII_GLYPH_INFO *Cell, OPTIONAL
|
|
|
|
OUT UINTN *GlyphBufferLen OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINT8 *BlockPtr;
|
|
|
|
UINT16 CharCurrent;
|
|
|
|
UINT16 Length16;
|
|
|
|
UINT32 Length32;
|
|
|
|
EFI_HII_GIBT_GLYPHS_BLOCK Glyphs;
|
|
|
|
UINTN BufferLen;
|
|
|
|
UINT16 Index;
|
|
|
|
EFI_HII_GLYPH_INFO DefaultCell;
|
|
|
|
EFI_HII_GLYPH_INFO LocalCell;
|
2011-01-24 05:58:45 +01:00
|
|
|
INT16 MinOffsetY;
|
|
|
|
UINT16 BaseLine;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
ASSERT (FontPackage != NULL);
|
|
|
|
ASSERT (FontPackage->Signature == HII_FONT_PACKAGE_SIGNATURE);
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine = 0;
|
|
|
|
MinOffsetY = 0;
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
//
|
|
|
|
// Collect the cell information specified in font package fixed header.
|
|
|
|
// Use CharValue =0 to represent this particular cell.
|
|
|
|
//
|
|
|
|
Status = NewCell (
|
|
|
|
0,
|
|
|
|
&FontPackage->GlyphInfoList,
|
|
|
|
(EFI_HII_GLYPH_INFO *) ((UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32))
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
CopyMem (
|
|
|
|
&LocalCell,
|
|
|
|
(UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32),
|
|
|
|
sizeof (EFI_HII_GLYPH_INFO)
|
|
|
|
);
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BlockPtr = FontPackage->GlyphBlock;
|
|
|
|
CharCurrent = 1;
|
|
|
|
BufferLen = 0;
|
|
|
|
|
|
|
|
while (*BlockPtr != EFI_HII_GIBT_END) {
|
|
|
|
switch (*BlockPtr) {
|
|
|
|
case EFI_HII_GIBT_DEFAULTS:
|
|
|
|
//
|
|
|
|
// Collect all default character cell information specified by
|
|
|
|
// EFI_HII_GIBT_DEFAULTS.
|
|
|
|
//
|
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
Status = NewCell (
|
|
|
|
CharCurrent,
|
|
|
|
&FontPackage->GlyphInfoList,
|
|
|
|
(EFI_HII_GLYPH_INFO *) (BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
CopyMem (
|
|
|
|
&LocalCell,
|
|
|
|
BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),
|
|
|
|
sizeof (EFI_HII_GLYPH_INFO)
|
|
|
|
);
|
|
|
|
if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {
|
|
|
|
BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);
|
|
|
|
}
|
|
|
|
if (MinOffsetY > LocalCell.OffsetY) {
|
|
|
|
MinOffsetY = LocalCell.OffsetY;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_DUPLICATE:
|
|
|
|
if (CharCurrent == CharValue) {
|
|
|
|
CopyMem (&CharValue, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (CHAR16));
|
|
|
|
CharCurrent = 1;
|
|
|
|
BlockPtr = FontPackage->GlyphBlock;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
CharCurrent++;
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_DUPLICATE_BLOCK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_EXT1:
|
2014-08-07 10:54:34 +02:00
|
|
|
BlockPtr += *(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8));
|
2008-01-21 15:39:56 +01:00
|
|
|
break;
|
|
|
|
case EFI_HII_GIBT_EXT2:
|
|
|
|
CopyMem (
|
|
|
|
&Length16,
|
2014-08-07 10:54:34 +02:00
|
|
|
(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),
|
2008-01-21 15:39:56 +01:00
|
|
|
sizeof (UINT16)
|
|
|
|
);
|
|
|
|
BlockPtr += Length16;
|
|
|
|
break;
|
|
|
|
case EFI_HII_GIBT_EXT4:
|
|
|
|
CopyMem (
|
|
|
|
&Length32,
|
2014-08-07 10:54:34 +02:00
|
|
|
(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK) + sizeof (UINT8)),
|
2008-01-21 15:39:56 +01:00
|
|
|
sizeof (UINT32)
|
|
|
|
);
|
|
|
|
BlockPtr += Length32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_GLYPH:
|
|
|
|
CopyMem (
|
|
|
|
&LocalCell,
|
|
|
|
BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),
|
|
|
|
sizeof (EFI_HII_GLYPH_INFO)
|
|
|
|
);
|
2011-01-24 05:58:45 +01:00
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {
|
|
|
|
BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);
|
|
|
|
}
|
|
|
|
if (MinOffsetY > LocalCell.OffsetY) {
|
|
|
|
MinOffsetY = LocalCell.OffsetY;
|
|
|
|
}
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);
|
|
|
|
if (CharCurrent == CharValue) {
|
|
|
|
return WriteOutputParam (
|
2014-08-07 10:54:34 +02:00
|
|
|
(UINT8*)((UINTN)BlockPtr + sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8)),
|
2008-01-21 15:39:56 +01:00
|
|
|
BufferLen,
|
|
|
|
&LocalCell,
|
|
|
|
GlyphBuffer,
|
|
|
|
Cell,
|
|
|
|
GlyphBufferLen
|
|
|
|
);
|
|
|
|
}
|
|
|
|
CharCurrent++;
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_GLYPH_BLOCK) - sizeof (UINT8) + BufferLen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_GLYPHS:
|
|
|
|
BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK);
|
|
|
|
CopyMem (&Glyphs.Cell, BlockPtr, sizeof (EFI_HII_GLYPH_INFO));
|
|
|
|
BlockPtr += sizeof (EFI_HII_GLYPH_INFO);
|
|
|
|
CopyMem (&Glyphs.Count, BlockPtr, sizeof (UINT16));
|
|
|
|
BlockPtr += sizeof (UINT16);
|
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
if (BaseLine < Glyphs.Cell.Height + Glyphs.Cell.OffsetY) {
|
|
|
|
BaseLine = (UINT16) (Glyphs.Cell.Height + Glyphs.Cell.OffsetY);
|
|
|
|
}
|
|
|
|
if (MinOffsetY > Glyphs.Cell.OffsetY) {
|
|
|
|
MinOffsetY = Glyphs.Cell.OffsetY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
BufferLen = BITMAP_LEN_1_BIT (Glyphs.Cell.Width, Glyphs.Cell.Height);
|
|
|
|
for (Index = 0; Index < Glyphs.Count; Index++) {
|
|
|
|
if (CharCurrent + Index == CharValue) {
|
|
|
|
return WriteOutputParam (
|
|
|
|
BlockPtr,
|
|
|
|
BufferLen,
|
|
|
|
&Glyphs.Cell,
|
|
|
|
GlyphBuffer,
|
|
|
|
Cell,
|
|
|
|
GlyphBufferLen
|
|
|
|
);
|
|
|
|
}
|
|
|
|
BlockPtr += BufferLen;
|
|
|
|
}
|
|
|
|
CharCurrent = (UINT16) (CharCurrent + Glyphs.Count);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_GLYPH_DEFAULT:
|
|
|
|
Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2016-06-08 08:13:36 +02:00
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {
|
|
|
|
BaseLine = (UINT16) (DefaultCell.Height + DefaultCell.OffsetY);
|
|
|
|
}
|
|
|
|
if (MinOffsetY > DefaultCell.OffsetY) {
|
|
|
|
MinOffsetY = DefaultCell.OffsetY;
|
|
|
|
}
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);
|
|
|
|
|
|
|
|
if (CharCurrent == CharValue) {
|
|
|
|
return WriteOutputParam (
|
|
|
|
BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),
|
|
|
|
BufferLen,
|
|
|
|
&DefaultCell,
|
|
|
|
GlyphBuffer,
|
|
|
|
Cell,
|
|
|
|
GlyphBufferLen
|
|
|
|
);
|
|
|
|
}
|
|
|
|
CharCurrent++;
|
|
|
|
BlockPtr += sizeof (EFI_HII_GLYPH_BLOCK) + BufferLen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_GLYPHS_DEFAULT:
|
|
|
|
CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));
|
|
|
|
Status = GetCell (CharCurrent, &FontPackage->GlyphInfoList, &DefaultCell);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2016-06-08 08:13:36 +02:00
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
|
|
|
if (BaseLine < DefaultCell.Height + DefaultCell.OffsetY) {
|
|
|
|
BaseLine = (UINT16) (DefaultCell.Height + DefaultCell.OffsetY);
|
|
|
|
}
|
|
|
|
if (MinOffsetY > DefaultCell.OffsetY) {
|
|
|
|
MinOffsetY = DefaultCell.OffsetY;
|
|
|
|
}
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
BufferLen = BITMAP_LEN_1_BIT (DefaultCell.Width, DefaultCell.Height);
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK) - sizeof (UINT8);
|
|
|
|
for (Index = 0; Index < Length16; Index++) {
|
|
|
|
if (CharCurrent + Index == CharValue) {
|
|
|
|
return WriteOutputParam (
|
|
|
|
BlockPtr,
|
|
|
|
BufferLen,
|
|
|
|
&DefaultCell,
|
|
|
|
GlyphBuffer,
|
|
|
|
Cell,
|
|
|
|
GlyphBufferLen
|
|
|
|
);
|
|
|
|
}
|
|
|
|
BlockPtr += BufferLen;
|
|
|
|
}
|
|
|
|
CharCurrent = (UINT16) (CharCurrent + Length16);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_HII_GIBT_SKIP1:
|
|
|
|
CharCurrent = (UINT16) (CharCurrent + (UINT16) (*(BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK))));
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_SKIP1_BLOCK);
|
|
|
|
break;
|
|
|
|
case EFI_HII_GIBT_SKIP2:
|
|
|
|
CopyMem (&Length16, BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK), sizeof (UINT16));
|
|
|
|
CharCurrent = (UINT16) (CharCurrent + Length16);
|
|
|
|
BlockPtr += sizeof (EFI_HII_GIBT_SKIP2_BLOCK);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CharValue < CharCurrent) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CharValue == (CHAR16) (-1)) {
|
2011-01-24 05:58:45 +01:00
|
|
|
FontPackage->BaseLine = BaseLine;
|
|
|
|
FontPackage->Height = (UINT16) (BaseLine - MinOffsetY);
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Copy a Font Name to a new created EFI_FONT_INFO structure.
|
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param FontName NULL-terminated string.
|
|
|
|
@param FontInfo a new EFI_FONT_INFO which stores the FontName.
|
|
|
|
It's caller's responsibility to free this buffer.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS FontInfo is allocated and copied with FontName.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
|
|
|
task.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
SaveFontName (
|
|
|
|
IN EFI_STRING FontName,
|
|
|
|
OUT EFI_FONT_INFO **FontInfo
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN FontInfoLen;
|
2015-06-29 04:36:31 +02:00
|
|
|
UINTN NameSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
ASSERT (FontName != NULL && FontInfo != NULL);
|
|
|
|
|
2015-06-29 04:36:31 +02:00
|
|
|
NameSize = StrSize (FontName);
|
|
|
|
FontInfoLen = sizeof (EFI_FONT_INFO) - sizeof (CHAR16) + NameSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
*FontInfo = (EFI_FONT_INFO *) AllocateZeroPool (FontInfoLen);
|
|
|
|
if (*FontInfo == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2015-06-29 04:36:31 +02:00
|
|
|
StrCpyS ((*FontInfo)->FontName, NameSize / sizeof (CHAR16), FontName);
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieve system default font and color.
|
|
|
|
|
|
|
|
@param Private HII database driver private data.
|
|
|
|
@param FontInfo Points to system default font output-related
|
|
|
|
information. It's caller's responsibility to free
|
|
|
|
this buffer.
|
|
|
|
@param FontInfoSize If not NULL, output the size of buffer FontInfo.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
|
|
|
task.
|
|
|
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetSystemFont (
|
|
|
|
IN HII_DATABASE_PRIVATE_DATA *Private,
|
|
|
|
OUT EFI_FONT_DISPLAY_INFO **FontInfo,
|
|
|
|
OUT UINTN *FontInfoSize OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_FONT_DISPLAY_INFO *Info;
|
|
|
|
UINTN InfoSize;
|
2015-06-29 04:36:31 +02:00
|
|
|
UINTN NameSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
if (Private == NULL || Private->Signature != HII_DATABASE_PRIVATE_DATA_SIGNATURE) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (FontInfo == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The standard font always has the name "sysdefault".
|
|
|
|
//
|
2015-06-29 04:36:31 +02:00
|
|
|
NameSize = StrSize (L"sysdefault");
|
|
|
|
InfoSize = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + NameSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
Info = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (InfoSize);
|
|
|
|
if (Info == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2009-05-20 04:12:26 +02:00
|
|
|
Info->ForegroundColor = mHiiEfiColors[Private->Attribute & 0x0f];
|
2019-10-15 08:27:32 +02:00
|
|
|
ASSERT ((Private->Attribute >> 4) < 8);
|
2009-05-20 04:12:26 +02:00
|
|
|
Info->BackgroundColor = mHiiEfiColors[Private->Attribute >> 4];
|
2008-01-21 15:39:56 +01:00
|
|
|
Info->FontInfoMask = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;
|
|
|
|
Info->FontInfo.FontStyle = 0;
|
|
|
|
Info->FontInfo.FontSize = EFI_GLYPH_HEIGHT;
|
2015-06-29 04:36:31 +02:00
|
|
|
StrCpyS (Info->FontInfo.FontName, NameSize / sizeof (CHAR16), L"sysdefault");
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
*FontInfo = Info;
|
|
|
|
if (FontInfoSize != NULL) {
|
|
|
|
*FontInfoSize = InfoSize;
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-23 11:41:33 +02:00
|
|
|
Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
|
|
|
|
returns the system default according to the optional inputs.
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2008-07-15 08:29:27 +02:00
|
|
|
This is a internal function.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param Private HII database driver private data.
|
|
|
|
@param StringInfo Points to the string output information,
|
|
|
|
including the color and font.
|
2008-06-23 11:41:33 +02:00
|
|
|
@param SystemInfo If not NULL, points to system default font and color.
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param SystemInfoLen If not NULL, output the length of default system
|
|
|
|
info.
|
|
|
|
|
|
|
|
@retval TRUE Yes, it points to system default.
|
|
|
|
@retval FALSE No.
|
|
|
|
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
IsSystemFontInfo (
|
|
|
|
IN HII_DATABASE_PRIVATE_DATA *Private,
|
|
|
|
IN EFI_FONT_DISPLAY_INFO *StringInfo,
|
|
|
|
OUT EFI_FONT_DISPLAY_INFO **SystemInfo, OPTIONAL
|
|
|
|
OUT UINTN *SystemInfoLen OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
|
|
|
UINTN DefaultLen;
|
2008-06-23 11:41:33 +02:00
|
|
|
BOOLEAN Flag;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);
|
|
|
|
|
|
|
|
if (StringInfo == NULL && SystemInfo == NULL) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-06-26 05:24:25 +02:00
|
|
|
SystemDefault = NULL;
|
|
|
|
DefaultLen = 0;
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2014-06-26 05:24:25 +02:00
|
|
|
ASSERT ((SystemDefault != NULL) && (DefaultLen != 0));
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
|
|
|
// Record the system default info.
|
|
|
|
//
|
2008-01-21 15:39:56 +01:00
|
|
|
if (SystemInfo != NULL) {
|
|
|
|
*SystemInfo = SystemDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SystemInfoLen != NULL) {
|
|
|
|
*SystemInfoLen = DefaultLen;
|
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
if (StringInfo == NULL) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
Flag = FALSE;
|
|
|
|
//
|
|
|
|
// Check the FontInfoMask to see whether it is retrieving system info.
|
|
|
|
//
|
|
|
|
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) == 0) {
|
|
|
|
if (StrCmp (StringInfo->FontInfo.FontName, SystemDefault->FontInfo.FontName) != 0) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) == 0) {
|
|
|
|
if (StringInfo->FontInfo.FontSize != SystemDefault->FontInfo.FontSize) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) == 0) {
|
|
|
|
if (StringInfo->FontInfo.FontStyle != SystemDefault->FontInfo.FontStyle) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == 0) {
|
|
|
|
if (CompareMem (
|
2018-06-27 15:08:52 +02:00
|
|
|
&StringInfo->ForegroundColor,
|
|
|
|
&SystemDefault->ForegroundColor,
|
2008-06-23 11:41:33 +02:00
|
|
|
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
|
|
|
) != 0) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == 0) {
|
|
|
|
if (CompareMem (
|
2018-06-27 15:08:52 +02:00
|
|
|
&StringInfo->BackgroundColor,
|
|
|
|
&SystemDefault->BackgroundColor,
|
2008-06-23 11:41:33 +02:00
|
|
|
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
|
|
|
) != 0) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Flag = TRUE;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if (SystemInfo == NULL) {
|
2008-10-30 08:32:46 +01:00
|
|
|
if (SystemDefault != NULL) {
|
|
|
|
FreePool (SystemDefault);
|
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
}
|
|
|
|
return Flag;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function checks whether EFI_FONT_INFO exists in current database. If
|
|
|
|
FontInfoMask is specified, check what options can be used to make a match.
|
|
|
|
Note that the masks relate to where the system default should be supplied
|
|
|
|
are ignored by this function.
|
|
|
|
|
|
|
|
@param Private Hii database private structure.
|
|
|
|
@param FontInfo Points to EFI_FONT_INFO structure.
|
|
|
|
@param FontInfoMask If not NULL, describes what options can be used
|
|
|
|
to make a match between the font requested and
|
|
|
|
the font available. The caller must guarantee
|
|
|
|
this mask is valid.
|
|
|
|
@param FontHandle On entry, Points to the font handle returned by a
|
|
|
|
previous call to GetFontInfo() or NULL to start
|
|
|
|
with the first font.
|
2016-09-21 06:48:10 +02:00
|
|
|
@param GlobalFontInfo If not NULL, output the corresponding global font
|
2008-01-21 15:39:56 +01:00
|
|
|
info.
|
|
|
|
|
|
|
|
@retval TRUE Existed
|
|
|
|
@retval FALSE Not existed
|
|
|
|
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
IsFontInfoExisted (
|
|
|
|
IN HII_DATABASE_PRIVATE_DATA *Private,
|
|
|
|
IN EFI_FONT_INFO *FontInfo,
|
|
|
|
IN EFI_FONT_INFO_MASK *FontInfoMask, OPTIONAL
|
|
|
|
IN EFI_FONT_HANDLE FontHandle, OPTIONAL
|
|
|
|
OUT HII_GLOBAL_FONT_INFO **GlobalFontInfo OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFont;
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFontBackup1;
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFontBackup2;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_FONT_INFO_MASK Mask;
|
|
|
|
BOOLEAN Matched;
|
|
|
|
BOOLEAN VagueMatched1;
|
|
|
|
BOOLEAN VagueMatched2;
|
|
|
|
|
|
|
|
ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);
|
|
|
|
ASSERT (FontInfo != NULL);
|
|
|
|
|
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// Matched flag represents an exactly match; VagueMatched1 represents a RESIZE
|
2008-01-21 15:39:56 +01:00
|
|
|
// or RESTYLE match; VagueMatched2 represents a RESIZE | RESTYLE match.
|
|
|
|
//
|
|
|
|
Matched = FALSE;
|
|
|
|
VagueMatched1 = FALSE;
|
|
|
|
VagueMatched2 = FALSE;
|
|
|
|
|
|
|
|
Mask = 0;
|
|
|
|
GlobalFontBackup1 = NULL;
|
|
|
|
GlobalFontBackup2 = NULL;
|
|
|
|
|
|
|
|
// The process of where the system default should be supplied instead of
|
|
|
|
// the specified font info beyonds this function's scope.
|
|
|
|
//
|
|
|
|
if (FontInfoMask != NULL) {
|
|
|
|
Mask = *FontInfoMask & (~SYS_FONT_INFO_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If not NULL, FontHandle points to the next node of the last searched font
|
|
|
|
// node by previous call.
|
|
|
|
//
|
|
|
|
if (FontHandle == NULL) {
|
|
|
|
Link = Private->FontInfoList.ForwardLink;
|
|
|
|
} else {
|
|
|
|
Link = (LIST_ENTRY *) FontHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; Link != &Private->FontInfoList; Link = Link->ForwardLink) {
|
|
|
|
GlobalFont = CR (Link, HII_GLOBAL_FONT_INFO, Entry, HII_GLOBAL_FONT_INFO_SIGNATURE);
|
|
|
|
if (FontInfoMask == NULL) {
|
|
|
|
if (CompareMem (GlobalFont->FontInfo, FontInfo, GlobalFont->FontInfoSize) == 0) {
|
|
|
|
if (GlobalFontInfo != NULL) {
|
|
|
|
*GlobalFontInfo = GlobalFont;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Check which options could be used to make a match.
|
|
|
|
//
|
|
|
|
switch (Mask) {
|
|
|
|
case EFI_FONT_INFO_ANY_FONT:
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle &&
|
|
|
|
GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE:
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE:
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_ANY_STYLE:
|
|
|
|
Matched = TRUE;
|
|
|
|
break;
|
|
|
|
//
|
|
|
|
// If EFI_FONT_INFO_RESTYLE is specified, then the system may attempt to
|
|
|
|
// remove some of the specified styles to meet the style requested.
|
|
|
|
//
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE:
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// If EFI_FONT_INFO_RESIZE is specified, then the system may attempt to
|
2008-01-21 15:39:56 +01:00
|
|
|
// stretch or shrink a font to meet the size requested.
|
|
|
|
//
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESIZE:
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_RESIZE:
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
} else {
|
|
|
|
VagueMatched2 = TRUE;
|
|
|
|
GlobalFontBackup2 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_FONT | EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_STYLE:
|
|
|
|
if ((CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) &&
|
|
|
|
GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_ANY_SIZE:
|
|
|
|
if (CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_STYLE | EFI_FONT_INFO_RESIZE:
|
|
|
|
if (CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_SIZE:
|
|
|
|
if ((CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) &&
|
|
|
|
GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_ANY_SIZE | EFI_FONT_INFO_RESTYLE:
|
|
|
|
if (CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) {
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_RESTYLE:
|
|
|
|
if ((CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) &&
|
|
|
|
GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_RESIZE:
|
|
|
|
if ((CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) &&
|
|
|
|
GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_RESTYLE:
|
|
|
|
if (CompareMem (
|
|
|
|
GlobalFont->FontInfo->FontName,
|
|
|
|
FontInfo->FontName,
|
|
|
|
StrSize (FontInfo->FontName)
|
|
|
|
) == 0) {
|
|
|
|
if (GlobalFont->FontInfo->FontStyle == FontInfo->FontStyle) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
Matched = TRUE;
|
|
|
|
} else {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
}
|
|
|
|
} else if ((GlobalFont->FontInfo->FontStyle & FontInfo->FontStyle) == FontInfo->FontStyle) {
|
|
|
|
if (GlobalFont->FontInfo->FontSize == FontInfo->FontSize) {
|
|
|
|
VagueMatched1 = TRUE;
|
|
|
|
GlobalFontBackup1 = GlobalFont;
|
|
|
|
} else {
|
|
|
|
VagueMatched2 = TRUE;
|
|
|
|
GlobalFontBackup2 = GlobalFont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Matched) {
|
|
|
|
if (GlobalFontInfo != NULL) {
|
|
|
|
*GlobalFontInfo = GlobalFont;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VagueMatched1) {
|
|
|
|
if (GlobalFontInfo != NULL) {
|
|
|
|
*GlobalFontInfo = GlobalFontBackup1;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
} else if (VagueMatched2) {
|
|
|
|
if (GlobalFontInfo != NULL) {
|
|
|
|
*GlobalFontInfo = GlobalFontBackup2;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check whether the unicode represents a line break or not.
|
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
This is a internal function. Please see Section 27.2.6 of the UEFI Specification
|
|
|
|
for a description of the supported string format.
|
2008-07-15 08:29:27 +02:00
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
@param Char Unicode character
|
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
@retval 0 Yes, it forces a line break.
|
|
|
|
@retval 1 Yes, it presents a line break opportunity
|
|
|
|
@retval 2 Yes, it requires a line break happen before and after it.
|
2008-01-21 15:39:56 +01:00
|
|
|
@retval -1 No, it is not a link break.
|
|
|
|
|
|
|
|
**/
|
|
|
|
INT8
|
|
|
|
IsLineBreak (
|
|
|
|
IN CHAR16 Char
|
|
|
|
)
|
|
|
|
{
|
|
|
|
switch (Char) {
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// Mandatory line break characters, which force a line-break
|
|
|
|
//
|
2015-05-21 09:02:51 +02:00
|
|
|
case 0x000A:
|
2009-05-21 11:41:59 +02:00
|
|
|
case 0x000C:
|
|
|
|
case 0x000D:
|
|
|
|
case 0x2028:
|
|
|
|
case 0x2029:
|
2008-01-21 15:39:56 +01:00
|
|
|
return 0;
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// Space characters, which is taken as a line-break opportunity
|
|
|
|
//
|
|
|
|
case 0x0020:
|
|
|
|
case 0x1680:
|
|
|
|
case 0x2000:
|
|
|
|
case 0x2001:
|
|
|
|
case 0x2002:
|
|
|
|
case 0x2003:
|
|
|
|
case 0x2004:
|
|
|
|
case 0x2005:
|
|
|
|
case 0x2006:
|
|
|
|
case 0x2008:
|
|
|
|
case 0x2009:
|
|
|
|
case 0x200A:
|
|
|
|
case 0x205F:
|
|
|
|
//
|
|
|
|
// In-Word Break Opportunities
|
|
|
|
//
|
|
|
|
case 0x200B:
|
|
|
|
return 1;
|
|
|
|
//
|
|
|
|
// A space which is not a line-break opportunity
|
|
|
|
//
|
|
|
|
case 0x00A0:
|
|
|
|
case 0x202F:
|
|
|
|
//
|
|
|
|
// A hyphen which is not a line-break opportunity
|
|
|
|
//
|
|
|
|
case 0x2011:
|
|
|
|
return -1;
|
|
|
|
//
|
|
|
|
// Hyphen characters which describe line break opportunities after the character
|
|
|
|
//
|
2008-01-21 15:39:56 +01:00
|
|
|
case 0x058A:
|
2009-05-21 11:41:59 +02:00
|
|
|
case 0x2010:
|
|
|
|
case 0x2012:
|
|
|
|
case 0x2013:
|
2008-01-21 15:39:56 +01:00
|
|
|
case 0x0F0B:
|
|
|
|
case 0x1361:
|
|
|
|
case 0x17D5:
|
|
|
|
return 1;
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// A hyphen which describes line break opportunities before and after them, but not between a pair of them
|
|
|
|
//
|
|
|
|
case 0x2014:
|
|
|
|
return 2;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Renders a string to a bitmap or to the display.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
|
|
|
|
@param Flags Describes how the string is to be drawn.
|
|
|
|
@param String Points to the null-terminated string to be
|
|
|
|
displayed.
|
|
|
|
@param StringInfo Points to the string output information,
|
|
|
|
including the color and font. If NULL, then the
|
|
|
|
string will be output in the default system font
|
|
|
|
and color.
|
|
|
|
@param Blt If this points to a non-NULL on entry, this
|
|
|
|
points to the image, which is Width pixels wide
|
|
|
|
and Height pixels high. The string will be drawn
|
|
|
|
onto this image and
|
|
|
|
EFI_HII_OUT_FLAG_CLIP is implied. If this points
|
|
|
|
to a NULL on entry, then a buffer
|
|
|
|
will be allocated to hold the generated image and
|
2008-05-27 05:24:01 +02:00
|
|
|
the pointer updated on exit. It is the caller's
|
2008-01-21 15:39:56 +01:00
|
|
|
responsibility to free this buffer.
|
2008-07-15 08:29:27 +02:00
|
|
|
@param BltX Specifies the offset from the left and top edge
|
|
|
|
of the image of the first character cell in the
|
|
|
|
image.
|
|
|
|
@param BltY Specifies the offset from the left and top edge
|
2008-01-21 15:39:56 +01:00
|
|
|
of the image of the first character cell in the
|
|
|
|
image.
|
|
|
|
@param RowInfoArray If this is non-NULL on entry, then on exit, this
|
|
|
|
will point to an allocated buffer containing
|
|
|
|
row information and RowInfoArraySize will be
|
|
|
|
updated to contain the number of elements.
|
|
|
|
This array describes the characters which were at
|
|
|
|
least partially drawn and the heights of the
|
2008-05-27 05:24:01 +02:00
|
|
|
rows. It is the caller's responsibility to free
|
2008-01-21 15:39:56 +01:00
|
|
|
this buffer.
|
|
|
|
@param RowInfoArraySize If this is non-NULL on entry, then on exit it
|
|
|
|
contains the number of elements in RowInfoArray.
|
|
|
|
@param ColumnInfoArray If this is non-NULL, then on return it will be
|
|
|
|
filled with the horizontal offset for each
|
|
|
|
character in the string on the row where it is
|
|
|
|
displayed. Non-printing characters will have
|
|
|
|
the offset ~0. The caller is responsible to
|
|
|
|
allocate a buffer large enough so that there
|
|
|
|
is one entry for each character in the string,
|
|
|
|
not including the null-terminator. It is possible
|
|
|
|
when character display is normalized that some
|
|
|
|
character cells overlap.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The string was successfully rendered.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
|
|
|
|
RowInfoArray or Blt.
|
|
|
|
@retval EFI_INVALID_PARAMETER The String or Blt was NULL.
|
2008-06-23 11:41:33 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER Flags were invalid combination..
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiStringToImage (
|
|
|
|
IN CONST EFI_HII_FONT_PROTOCOL *This,
|
|
|
|
IN EFI_HII_OUT_FLAGS Flags,
|
|
|
|
IN CONST EFI_STRING String,
|
|
|
|
IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,
|
|
|
|
IN OUT EFI_IMAGE_OUTPUT **Blt,
|
|
|
|
IN UINTN BltX,
|
|
|
|
IN UINTN BltY,
|
|
|
|
OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,
|
|
|
|
OUT UINTN *RowInfoArraySize OPTIONAL,
|
|
|
|
OUT UINTN *ColumnInfoArray OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
HII_DATABASE_PRIVATE_DATA *Private;
|
|
|
|
UINT8 **GlyphBuf;
|
|
|
|
EFI_HII_GLYPH_INFO *Cell;
|
|
|
|
UINT8 *Attributes;
|
|
|
|
EFI_IMAGE_OUTPUT *Image;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
EFI_STRING StringTmp;
|
|
|
|
EFI_HII_ROW_INFO *RowInfo;
|
|
|
|
UINTN LineWidth;
|
|
|
|
UINTN LineHeight;
|
2011-01-24 05:58:45 +01:00
|
|
|
UINTN LineOffset;
|
|
|
|
UINTN LastLineHeight;
|
2008-01-21 15:39:56 +01:00
|
|
|
UINTN BaseLineOffset;
|
|
|
|
UINT16 MaxRowNum;
|
|
|
|
UINT16 RowIndex;
|
|
|
|
UINTN Index;
|
2011-01-24 05:58:45 +01:00
|
|
|
UINTN NextIndex;
|
2008-01-21 15:39:56 +01:00
|
|
|
UINTN Index1;
|
|
|
|
EFI_FONT_DISPLAY_INFO *StringInfoOut;
|
|
|
|
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
|
|
|
EFI_FONT_HANDLE FontHandle;
|
|
|
|
EFI_STRING StringIn;
|
|
|
|
EFI_STRING StringIn2;
|
|
|
|
UINT16 Height;
|
2011-01-24 05:58:45 +01:00
|
|
|
UINT16 BaseLine;
|
2008-01-21 15:39:56 +01:00
|
|
|
EFI_FONT_INFO *FontInfo;
|
|
|
|
BOOLEAN SysFontFlag;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
|
|
|
|
BOOLEAN Transparent;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BufferPtr;
|
|
|
|
UINTN RowInfoSize;
|
|
|
|
BOOLEAN LineBreak;
|
2009-05-21 11:41:59 +02:00
|
|
|
UINTN StrLength;
|
2011-01-24 05:58:45 +01:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *RowBufferPtr;
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFont;
|
2016-05-31 10:44:47 +02:00
|
|
|
UINT32 PreInitBkgnd;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Check incoming parameters.
|
|
|
|
//
|
|
|
|
|
|
|
|
if (This == NULL || String == NULL || Blt == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if (*Blt == NULL) {
|
|
|
|
//
|
|
|
|
// These two flag cannot be used if Blt is NULL upon entry.
|
|
|
|
//
|
|
|
|
if ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
if ((Flags & EFI_HII_OUT_FLAG_CLIP) == EFI_HII_OUT_FLAG_CLIP) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
|
|
|
|
//
|
2008-06-23 11:41:33 +02:00
|
|
|
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
|
|
|
|
//
|
2008-06-23 11:41:33 +02:00
|
|
|
if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
if (*Blt == NULL) {
|
|
|
|
//
|
|
|
|
// Create a new bitmap and draw the string onto this image.
|
|
|
|
//
|
|
|
|
Image = AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
|
|
|
|
if (Image == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
Image->Width = 800;
|
|
|
|
Image->Height = 600;
|
|
|
|
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height *sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
if (Image->Image.Bitmap == NULL) {
|
|
|
|
FreePool (Image);
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Other flags are not permitted when Blt is NULL.
|
|
|
|
//
|
|
|
|
Flags &= EFI_HII_OUT_FLAG_WRAP | EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_IGNORE_LINE_BREAK;
|
|
|
|
*Blt = Image;
|
|
|
|
}
|
|
|
|
|
|
|
|
StrLength = StrLen(String);
|
|
|
|
GlyphBuf = (UINT8 **) AllocateZeroPool (StrLength * sizeof (UINT8 *));
|
2008-01-21 15:39:56 +01:00
|
|
|
ASSERT (GlyphBuf != NULL);
|
2009-05-21 11:41:59 +02:00
|
|
|
Cell = (EFI_HII_GLYPH_INFO *) AllocateZeroPool (StrLength * sizeof (EFI_HII_GLYPH_INFO));
|
2008-01-21 15:39:56 +01:00
|
|
|
ASSERT (Cell != NULL);
|
2009-05-21 11:41:59 +02:00
|
|
|
Attributes = (UINT8 *) AllocateZeroPool (StrLength * sizeof (UINT8));
|
2008-01-21 15:39:56 +01:00
|
|
|
ASSERT (Attributes != NULL);
|
|
|
|
|
|
|
|
RowInfo = NULL;
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
StringIn2 = NULL;
|
|
|
|
SystemDefault = NULL;
|
2009-01-20 02:52:02 +01:00
|
|
|
StringIn = NULL;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Calculate the string output information, including specified color and font .
|
|
|
|
// If StringInfo does not points to system font info, it must indicate an existing
|
|
|
|
// EFI_FONT_INFO.
|
|
|
|
//
|
|
|
|
StringInfoOut = NULL;
|
|
|
|
FontHandle = NULL;
|
|
|
|
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
|
|
|
|
SysFontFlag = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);
|
|
|
|
|
|
|
|
if (SysFontFlag) {
|
2014-06-26 05:24:25 +02:00
|
|
|
ASSERT (SystemDefault != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
FontInfo = NULL;
|
|
|
|
Height = SystemDefault->FontInfo.FontSize;
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine = SystemDefault->FontInfo.FontSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
Foreground = SystemDefault->ForegroundColor;
|
|
|
|
Background = SystemDefault->BackgroundColor;
|
|
|
|
|
|
|
|
} else {
|
2009-04-10 06:27:35 +02:00
|
|
|
//
|
|
|
|
// StringInfo must not be NULL if it is not system info.
|
|
|
|
//
|
|
|
|
ASSERT (StringInfo != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
Status = HiiGetFontInfo (This, &FontHandle, (EFI_FONT_DISPLAY_INFO *) StringInfo, &StringInfoOut, NULL);
|
|
|
|
if (Status == EFI_NOT_FOUND) {
|
|
|
|
//
|
|
|
|
// The specified EFI_FONT_DISPLAY_INFO does not exist in current database.
|
|
|
|
// Use the system font instead. Still use the color specified by StringInfo.
|
|
|
|
//
|
|
|
|
SysFontFlag = TRUE;
|
|
|
|
FontInfo = NULL;
|
|
|
|
Height = SystemDefault->FontInfo.FontSize;
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine = SystemDefault->FontInfo.FontSize;
|
2008-01-21 15:39:56 +01:00
|
|
|
Foreground = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->ForegroundColor;
|
|
|
|
Background = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->BackgroundColor;
|
|
|
|
|
2009-01-20 02:52:02 +01:00
|
|
|
} else if (Status == EFI_SUCCESS) {
|
2008-01-21 15:39:56 +01:00
|
|
|
FontInfo = &StringInfoOut->FontInfo;
|
2011-01-24 05:58:45 +01:00
|
|
|
IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont);
|
|
|
|
Height = GlobalFont->FontPackage->Height;
|
|
|
|
BaseLine = GlobalFont->FontPackage->BaseLine;
|
2008-01-21 15:39:56 +01:00
|
|
|
Foreground = StringInfoOut->ForegroundColor;
|
|
|
|
Background = StringInfoOut->BackgroundColor;
|
2009-01-20 02:52:02 +01:00
|
|
|
} else {
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// Use the maximum height of font as the base line.
|
|
|
|
// And, use the maximum height as line height.
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
LineHeight = Height;
|
|
|
|
LastLineHeight = Height;
|
|
|
|
BaseLineOffset = Height - BaseLine;
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
// Parse the string to be displayed to drop some ignored characters.
|
|
|
|
//
|
|
|
|
|
|
|
|
StringPtr = String;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Ignore line-break characters only. Hyphens or dash character will be displayed
|
|
|
|
// without line-break opportunity.
|
|
|
|
//
|
|
|
|
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == EFI_HII_IGNORE_LINE_BREAK) {
|
|
|
|
StringIn = AllocateZeroPool (StrSize (StringPtr));
|
|
|
|
if (StringIn == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
StringTmp = StringIn;
|
|
|
|
while (*StringPtr != 0) {
|
|
|
|
if (IsLineBreak (*StringPtr) == 0) {
|
|
|
|
StringPtr++;
|
|
|
|
} else {
|
|
|
|
*StringTmp++ = *StringPtr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*StringTmp = 0;
|
|
|
|
StringPtr = StringIn;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// If EFI_HII_IGNORE_IF_NO_GLYPH is set, then characters which have no glyphs
|
2016-09-21 06:48:10 +02:00
|
|
|
// are not drawn. Otherwise they are replaced with Unicode character 0xFFFD.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
StringIn2 = AllocateZeroPool (StrSize (StringPtr));
|
|
|
|
if (StringIn2 == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
Index = 0;
|
|
|
|
StringTmp = StringIn2;
|
2009-05-21 11:41:59 +02:00
|
|
|
StrLength = StrLen(StringPtr);
|
|
|
|
while (*StringPtr != 0 && Index < StrLength) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if (IsLineBreak (*StringPtr) == 0) {
|
|
|
|
*StringTmp++ = *StringPtr++;
|
|
|
|
Index++;
|
|
|
|
continue;
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);
|
|
|
|
if (Status == EFI_NOT_FOUND) {
|
|
|
|
if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {
|
|
|
|
GlyphBuf[Index] = NULL;
|
2011-01-24 05:58:45 +01:00
|
|
|
ZeroMem (&Cell[Index], sizeof (Cell[Index]));
|
|
|
|
Status = EFI_SUCCESS;
|
2008-01-21 15:39:56 +01:00
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Unicode 0xFFFD must exist in current hii database if this flag is not set.
|
|
|
|
//
|
|
|
|
Status = GetGlyphBuffer (
|
|
|
|
Private,
|
|
|
|
REPLACE_UNKNOWN_GLYPH,
|
|
|
|
FontInfo,
|
|
|
|
&GlyphBuf[Index],
|
|
|
|
&Cell[Index],
|
|
|
|
&Attributes[Index]
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
2008-01-21 15:39:56 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
|
|
|
|
*StringTmp++ = *StringPtr++;
|
|
|
|
Index++;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
*StringTmp = 0;
|
|
|
|
StringPtr = StringIn2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Draw the string according to the specified EFI_HII_OUT_FLAGS and Blt.
|
|
|
|
// If Blt is not NULL, then EFI_HII_OUT_FLAG_CLIP is implied, render this string
|
|
|
|
// to an existing image (bitmap or screen depending on flags) pointed by "*Blt".
|
|
|
|
// Otherwise render this string to a new allocated image and output it.
|
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
Image = *Blt;
|
|
|
|
BufferPtr = Image->Image.Bitmap + Image->Width * BltY + BltX;
|
2012-04-24 03:59:55 +02:00
|
|
|
if (Image->Height < BltY) {
|
|
|
|
//
|
|
|
|
// the top edge of the image should be in Image resolution scope.
|
|
|
|
//
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
MaxRowNum = (UINT16) ((Image->Height - BltY) / Height);
|
|
|
|
if ((Image->Height - BltY) % Height != 0) {
|
|
|
|
LastLineHeight = (Image->Height - BltY) % Height;
|
2009-05-21 11:41:59 +02:00
|
|
|
MaxRowNum++;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
RowInfo = (EFI_HII_ROW_INFO *) AllocateZeroPool (MaxRowNum * sizeof (EFI_HII_ROW_INFO));
|
|
|
|
if (RowInfo == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format the glyph buffer according to flags.
|
|
|
|
//
|
|
|
|
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);
|
|
|
|
|
|
|
|
for (RowIndex = 0, Index = 0; RowIndex < MaxRowNum && StringPtr[Index] != 0; ) {
|
|
|
|
LineWidth = 0;
|
|
|
|
LineBreak = FALSE;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// Clip the final row if the row's bottom-most on pixel cannot fit when
|
|
|
|
// EFI_HII_OUT_FLAG_CLEAN_Y is set.
|
|
|
|
//
|
|
|
|
if (RowIndex == MaxRowNum - 1) {
|
|
|
|
if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y && LastLineHeight < LineHeight ) {
|
|
|
|
//
|
|
|
|
// Don't draw at all if the row's bottom-most on pixel cannot fit.
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LineHeight = LastLineHeight;
|
|
|
|
}
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
// Calculate how many characters there are in a row.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
RowInfo[RowIndex].StartIndex = Index;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
while (LineWidth + BltX < Image->Width && StringPtr[Index] != 0) {
|
|
|
|
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&
|
|
|
|
IsLineBreak (StringPtr[Index]) == 0) {
|
|
|
|
//
|
|
|
|
// It forces a line break that ends this row.
|
|
|
|
//
|
|
|
|
Index++;
|
2009-06-03 03:43:47 +02:00
|
|
|
LineBreak = TRUE;
|
2009-05-21 11:41:59 +02:00
|
|
|
break;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
// If the glyph of the character is existing, then accumulate the actual printed width
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
LineWidth += (UINTN) Cell[Index].AdvanceX;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
Index++;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
// Record index of next char.
|
|
|
|
//
|
|
|
|
NextIndex = Index;
|
|
|
|
//
|
|
|
|
// Return to the previous char.
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
Index--;
|
2011-01-24 05:58:45 +01:00
|
|
|
if (LineBreak && Index > 0 ) {
|
|
|
|
//
|
|
|
|
// Return the previous non line break char.
|
|
|
|
//
|
|
|
|
Index --;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// If this character is the last character of a row, we need not
|
|
|
|
// draw its (AdvanceX - Width - OffsetX) for next character.
|
|
|
|
//
|
2017-02-24 03:01:34 +01:00
|
|
|
LineWidth -= (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);
|
2011-01-24 05:58:45 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
|
|
|
|
//
|
|
|
|
if (LineWidth + BltX <= Image->Width ||
|
|
|
|
(LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_X) == 0)) {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
// Record right-most character in RowInfo even if it is partially displayed.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
RowInfo[RowIndex].EndIndex = Index;
|
|
|
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
|
|
|
RowInfo[RowIndex].LineHeight = LineHeight;
|
|
|
|
RowInfo[RowIndex].BaselineOffset = BaseLineOffset;
|
|
|
|
} else {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
// When EFI_HII_OUT_FLAG_CLEAN_X is set, it will not draw a character
|
|
|
|
// if its right-most on pixel cannot fit.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2011-08-01 08:40:17 +02:00
|
|
|
if (Index > RowInfo[RowIndex].StartIndex) {
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
|
|
|
|
//
|
2017-02-24 03:01:34 +01:00
|
|
|
LineWidth -= (Cell[Index].Width + Cell[Index].OffsetX);
|
|
|
|
LineWidth -= (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);
|
2009-05-21 11:41:59 +02:00
|
|
|
RowInfo[RowIndex].EndIndex = Index - 1;
|
2011-01-24 05:58:45 +01:00
|
|
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
2009-05-21 11:41:59 +02:00
|
|
|
RowInfo[RowIndex].LineHeight = LineHeight;
|
2011-01-24 05:58:45 +01:00
|
|
|
RowInfo[RowIndex].BaselineOffset = BaseLineOffset;
|
2009-05-21 11:41:59 +02:00
|
|
|
} else {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2011-08-01 08:40:17 +02:00
|
|
|
// There is no enough column to draw any character, so set current line width to zero.
|
|
|
|
// And go to draw Next line if LineBreak is set.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2011-08-01 08:40:17 +02:00
|
|
|
RowInfo[RowIndex].LineWidth = 0;
|
|
|
|
goto NextLine;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// EFI_HII_OUT_FLAG_WRAP will wrap the text at the right-most line-break
|
|
|
|
// opportunity prior to a character whose right-most extent would exceed Width.
|
|
|
|
// Search the right-most line-break opportunity here.
|
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP &&
|
|
|
|
(RowInfo[RowIndex].LineWidth + BltX > Image->Width || StringPtr[NextIndex] != 0) &&
|
2011-08-01 08:40:17 +02:00
|
|
|
!LineBreak) {
|
2009-05-21 11:41:59 +02:00
|
|
|
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {
|
2011-01-24 05:58:45 +01:00
|
|
|
LineWidth = RowInfo[RowIndex].LineWidth;
|
2009-05-21 11:41:59 +02:00
|
|
|
for (Index1 = RowInfo[RowIndex].EndIndex; Index1 >= RowInfo[RowIndex].StartIndex; Index1--) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if (Index1 == RowInfo[RowIndex].EndIndex) {
|
|
|
|
LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);
|
|
|
|
} else {
|
|
|
|
LineWidth -= Cell[Index1].AdvanceX;
|
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
if (IsLineBreak (StringPtr[Index1]) > 0) {
|
|
|
|
LineBreak = TRUE;
|
2011-01-24 05:58:45 +01:00
|
|
|
if (Index1 > RowInfo[RowIndex].StartIndex) {
|
|
|
|
RowInfo[RowIndex].EndIndex = Index1 - 1;
|
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// relocate to the character after the right-most line break opportunity of this line
|
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
NextIndex = Index1 + 1;
|
2009-05-21 11:41:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-06-03 03:43:47 +02:00
|
|
|
//
|
|
|
|
// If don't find a line break opportunity from EndIndex to StartIndex,
|
|
|
|
// then jump out.
|
|
|
|
//
|
|
|
|
if (Index1 == RowInfo[RowIndex].StartIndex)
|
|
|
|
break;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Update LineWidth to the real width
|
|
|
|
//
|
|
|
|
if (IsLineBreak (StringPtr[Index1]) > 0) {
|
|
|
|
if (Index1 == RowInfo[RowIndex].StartIndex) {
|
|
|
|
LineWidth = 0;
|
|
|
|
} else {
|
2017-02-24 03:01:34 +01:00
|
|
|
LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
|
2011-01-24 05:58:45 +01:00
|
|
|
}
|
|
|
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
// If no line-break opportunity can be found, then the text will
|
|
|
|
// behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2009-05-21 11:41:59 +02:00
|
|
|
if (!LineBreak) {
|
2011-08-01 08:40:17 +02:00
|
|
|
LineWidth = RowInfo[RowIndex].LineWidth;
|
|
|
|
Index1 = RowInfo[RowIndex].EndIndex;
|
|
|
|
if (LineWidth + BltX > Image->Width) {
|
|
|
|
if (Index1 > RowInfo[RowIndex].StartIndex) {
|
|
|
|
//
|
|
|
|
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
|
|
|
|
//
|
2017-02-24 03:01:34 +01:00
|
|
|
LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);
|
|
|
|
LineWidth -= (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
|
2011-08-01 08:40:17 +02:00
|
|
|
RowInfo[RowIndex].EndIndex = Index1 - 1;
|
|
|
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// There is no enough column to draw any character, so set current line width to zero.
|
|
|
|
// And go to draw Next line if LineBreak is set.
|
|
|
|
//
|
|
|
|
RowInfo[RowIndex].LineWidth = 0;
|
|
|
|
goto NextLine;
|
|
|
|
}
|
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
// LineWidth can't exceed Image width.
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
if (RowInfo[RowIndex].LineWidth + BltX > Image->Width) {
|
|
|
|
RowInfo[RowIndex].LineWidth = Image->Width - BltX;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// Draw it to screen or existing bitmap depending on whether
|
|
|
|
// EFI_HII_DIRECT_TO_SCREEN is set.
|
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
LineOffset = 0;
|
2009-05-21 11:41:59 +02:00
|
|
|
if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) {
|
2011-01-24 05:58:45 +01:00
|
|
|
BltBuffer = NULL;
|
|
|
|
if (RowInfo[RowIndex].LineWidth != 0) {
|
2016-11-15 03:26:47 +01:00
|
|
|
BltBuffer = AllocatePool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
2011-01-24 05:58:45 +01:00
|
|
|
if (BltBuffer == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
//
|
2016-05-31 10:44:47 +02:00
|
|
|
// Initialize the background color.
|
|
|
|
//
|
|
|
|
PreInitBkgnd = Background.Blue | Background.Green << 8 | Background.Red << 16;
|
|
|
|
SetMem32 (BltBuffer,RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),PreInitBkgnd);
|
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
// Set BufferPtr to Origin by adding baseline to the starting position.
|
|
|
|
//
|
|
|
|
BufferPtr = BltBuffer + BaseLine * RowInfo[RowIndex].LineWidth;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
|
|
|
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// Only BLT these character which have corresponding glyph in font database.
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
GlyphToImage (
|
|
|
|
GlyphBuf[Index1],
|
|
|
|
Foreground,
|
|
|
|
Background,
|
2011-01-24 05:58:45 +01:00
|
|
|
(UINT16) RowInfo[RowIndex].LineWidth,
|
|
|
|
BaseLine,
|
|
|
|
RowInfo[RowIndex].LineWidth - LineOffset,
|
2008-01-21 15:39:56 +01:00
|
|
|
RowInfo[RowIndex].LineHeight,
|
|
|
|
Transparent,
|
2008-06-19 04:35:35 +02:00
|
|
|
&Cell[Index1],
|
2008-01-21 15:39:56 +01:00
|
|
|
Attributes[Index1],
|
|
|
|
&BufferPtr
|
2009-05-21 11:41:59 +02:00
|
|
|
);
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
if (ColumnInfoArray != NULL) {
|
2018-06-27 15:08:52 +02:00
|
|
|
if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)
|
2011-01-24 05:58:45 +01:00
|
|
|
|| RowInfo[RowIndex].LineWidth == 0) {
|
|
|
|
*ColumnInfoArray = (UINTN) ~0;
|
2009-05-21 11:41:59 +02:00
|
|
|
} else {
|
2011-01-24 05:58:45 +01:00
|
|
|
*ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
|
|
|
ColumnInfoArray++;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
LineOffset += Cell[Index1].AdvanceX;
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
if (BltBuffer != NULL) {
|
|
|
|
Status = Image->Image.Screen->Blt (
|
|
|
|
Image->Image.Screen,
|
|
|
|
BltBuffer,
|
|
|
|
EfiBltBufferToVideo,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
BltX,
|
|
|
|
BltY,
|
|
|
|
RowInfo[RowIndex].LineWidth,
|
|
|
|
RowInfo[RowIndex].LineHeight,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
FreePool (BltBuffer);
|
|
|
|
goto Exit;
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-10-30 08:32:46 +01:00
|
|
|
FreePool (BltBuffer);
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// Save the starting position for calculate the starting position of next row.
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
RowBufferPtr = BufferPtr;
|
|
|
|
//
|
|
|
|
// Set BufferPtr to Origin by adding baseline to the starting position.
|
|
|
|
//
|
|
|
|
BufferPtr = BufferPtr + BaseLine * Image->Width;
|
2009-05-21 11:41:59 +02:00
|
|
|
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2016-09-21 06:48:10 +02:00
|
|
|
// Only BLT these character which have corresponding glyph in font database.
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2008-01-21 15:39:56 +01:00
|
|
|
GlyphToImage (
|
|
|
|
GlyphBuf[Index1],
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
Image->Width,
|
2011-01-24 05:58:45 +01:00
|
|
|
BaseLine,
|
|
|
|
RowInfo[RowIndex].LineWidth - LineOffset,
|
|
|
|
RowInfo[RowIndex].LineHeight,
|
2008-01-21 15:39:56 +01:00
|
|
|
Transparent,
|
2008-06-19 04:35:35 +02:00
|
|
|
&Cell[Index1],
|
2008-01-21 15:39:56 +01:00
|
|
|
Attributes[Index1],
|
|
|
|
&BufferPtr
|
2009-05-21 11:41:59 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (ColumnInfoArray != NULL) {
|
2018-06-27 15:08:52 +02:00
|
|
|
if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)
|
2011-01-24 05:58:45 +01:00
|
|
|
|| RowInfo[RowIndex].LineWidth == 0) {
|
|
|
|
*ColumnInfoArray = (UINTN) ~0;
|
2009-05-21 11:41:59 +02:00
|
|
|
} else {
|
2011-01-24 05:58:45 +01:00
|
|
|
*ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
ColumnInfoArray++;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
LineOffset += Cell[Index1].AdvanceX;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2011-01-24 05:58:45 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
// Jump to starting position of next row.
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2011-01-24 05:58:45 +01:00
|
|
|
if (RowIndex == 0) {
|
|
|
|
BufferPtr = RowBufferPtr - BltX + LineHeight * Image->Width;
|
|
|
|
} else {
|
|
|
|
BufferPtr = RowBufferPtr + LineHeight * Image->Width;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
2011-08-01 08:40:17 +02:00
|
|
|
NextLine:
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
2016-02-19 05:24:20 +01:00
|
|
|
// Recalculate the start point of Y axis to draw multi-lines with the order of top-to-down
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
BltY += RowInfo[RowIndex].LineHeight;
|
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
RowIndex++;
|
2011-01-24 05:58:45 +01:00
|
|
|
Index = NextIndex;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-06-03 03:43:47 +02:00
|
|
|
if (!LineBreak) {
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
2009-06-03 03:43:47 +02:00
|
|
|
// If there is not a mandatory line break or line break opportunity, only render one line to image
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
break;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
//
|
|
|
|
// Write output parameters.
|
|
|
|
//
|
|
|
|
RowInfoSize = RowIndex * sizeof (EFI_HII_ROW_INFO);
|
|
|
|
if (RowInfoArray != NULL) {
|
2011-01-24 05:58:45 +01:00
|
|
|
if (RowInfoSize > 0) {
|
|
|
|
*RowInfoArray = AllocateZeroPool (RowInfoSize);
|
|
|
|
if (*RowInfoArray == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
CopyMem (*RowInfoArray, RowInfo, RowInfoSize);
|
|
|
|
} else {
|
|
|
|
*RowInfoArray = NULL;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-05-21 11:41:59 +02:00
|
|
|
}
|
|
|
|
if (RowInfoArraySize != NULL) {
|
|
|
|
*RowInfoArraySize = RowIndex;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
|
2009-05-21 11:41:59 +02:00
|
|
|
for (Index = 0; Index < StrLength; Index++) {
|
2008-10-30 08:32:46 +01:00
|
|
|
if (GlyphBuf[Index] != NULL) {
|
|
|
|
FreePool (GlyphBuf[Index]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringIn != NULL) {
|
|
|
|
FreePool (StringIn);
|
|
|
|
}
|
|
|
|
if (StringIn2 != NULL) {
|
|
|
|
FreePool (StringIn2);
|
|
|
|
}
|
|
|
|
if (StringInfoOut != NULL) {
|
|
|
|
FreePool (StringInfoOut);
|
|
|
|
}
|
|
|
|
if (RowInfo != NULL) {
|
|
|
|
FreePool (RowInfo);
|
|
|
|
}
|
|
|
|
if (SystemDefault != NULL) {
|
|
|
|
FreePool (SystemDefault);
|
|
|
|
}
|
|
|
|
if (GlyphBuf != NULL) {
|
|
|
|
FreePool (GlyphBuf);
|
|
|
|
}
|
|
|
|
if (Cell != NULL) {
|
|
|
|
FreePool (Cell);
|
|
|
|
}
|
|
|
|
if (Attributes != NULL) {
|
|
|
|
FreePool (Attributes);
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Render a string to a bitmap or the screen containing the contents of the specified string.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
|
|
|
|
@param Flags Describes how the string is to be drawn.
|
|
|
|
@param PackageList The package list in the HII database to search
|
|
|
|
for the specified string.
|
2008-05-27 05:24:01 +02:00
|
|
|
@param StringId The string's id, which is unique within
|
2008-01-21 15:39:56 +01:00
|
|
|
PackageList.
|
|
|
|
@param Language Points to the language for the retrieved string.
|
|
|
|
If NULL, then the current system language is
|
|
|
|
used.
|
|
|
|
@param StringInfo Points to the string output information,
|
|
|
|
including the color and font. If NULL, then the
|
|
|
|
string will be output in the default system font
|
|
|
|
and color.
|
|
|
|
@param Blt If this points to a non-NULL on entry, this
|
|
|
|
points to the image, which is Width pixels wide
|
|
|
|
and Height pixels high. The string will be drawn
|
|
|
|
onto this image and
|
|
|
|
EFI_HII_OUT_FLAG_CLIP is implied. If this points
|
|
|
|
to a NULL on entry, then a buffer
|
|
|
|
will be allocated to hold the generated image and
|
2008-05-27 05:24:01 +02:00
|
|
|
the pointer updated on exit. It is the caller's
|
2008-01-21 15:39:56 +01:00
|
|
|
responsibility to free this buffer.
|
2008-07-15 08:29:27 +02:00
|
|
|
@param BltX Specifies the offset from the left and top edge
|
|
|
|
of the image of the first character cell in the
|
|
|
|
image.
|
|
|
|
@param BltY Specifies the offset from the left and top edge
|
2008-01-21 15:39:56 +01:00
|
|
|
of the image of the first character cell in the
|
|
|
|
image.
|
|
|
|
@param RowInfoArray If this is non-NULL on entry, then on exit, this
|
|
|
|
will point to an allocated buffer containing
|
|
|
|
row information and RowInfoArraySize will be
|
|
|
|
updated to contain the number of elements.
|
|
|
|
This array describes the characters which were at
|
|
|
|
least partially drawn and the heights of the
|
2008-05-27 05:24:01 +02:00
|
|
|
rows. It is the caller's responsibility to free
|
2008-01-21 15:39:56 +01:00
|
|
|
this buffer.
|
|
|
|
@param RowInfoArraySize If this is non-NULL on entry, then on exit it
|
|
|
|
contains the number of elements in RowInfoArray.
|
|
|
|
@param ColumnInfoArray If this is non-NULL, then on return it will be
|
|
|
|
filled with the horizontal offset for each
|
|
|
|
character in the string on the row where it is
|
|
|
|
displayed. Non-printing characters will have
|
|
|
|
the offset ~0. The caller is responsible to
|
|
|
|
allocate a buffer large enough so that there
|
|
|
|
is one entry for each character in the string,
|
|
|
|
not including the null-terminator. It is possible
|
|
|
|
when character display is normalized that some
|
|
|
|
character cells overlap.
|
|
|
|
|
2016-09-21 06:48:10 +02:00
|
|
|
@retval EFI_SUCCESS The string was successfully rendered.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
|
|
|
|
RowInfoArray or Blt.
|
2008-06-23 11:41:33 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
|
|
|
|
@retval EFI_INVALID_PARAMETER Flags were invalid combination.
|
2016-09-21 06:48:10 +02:00
|
|
|
@retval EFI_NOT_FOUND The specified PackageList is not in the Database or the string id is not
|
|
|
|
in the specified PackageList.
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiStringIdToImage (
|
|
|
|
IN CONST EFI_HII_FONT_PROTOCOL *This,
|
|
|
|
IN EFI_HII_OUT_FLAGS Flags,
|
|
|
|
IN EFI_HII_HANDLE PackageList,
|
|
|
|
IN EFI_STRING_ID StringId,
|
|
|
|
IN CONST CHAR8* Language,
|
|
|
|
IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,
|
|
|
|
IN OUT EFI_IMAGE_OUTPUT **Blt,
|
|
|
|
IN UINTN BltX,
|
|
|
|
IN UINTN BltY,
|
|
|
|
OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,
|
|
|
|
OUT UINTN *RowInfoArraySize OPTIONAL,
|
|
|
|
OUT UINTN *ColumnInfoArray OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
HII_DATABASE_PRIVATE_DATA *Private;
|
2009-03-25 11:07:39 +01:00
|
|
|
EFI_HII_STRING_PROTOCOL *HiiString;
|
2008-01-21 15:39:56 +01:00
|
|
|
EFI_STRING String;
|
|
|
|
UINTN StringSize;
|
2008-06-23 11:41:33 +02:00
|
|
|
UINTN FontLen;
|
2015-06-29 04:36:31 +02:00
|
|
|
UINTN NameSize;
|
2008-06-23 11:41:33 +02:00
|
|
|
EFI_FONT_INFO *StringFontInfo;
|
|
|
|
EFI_FONT_DISPLAY_INFO *NewStringInfo;
|
2009-03-25 11:07:39 +01:00
|
|
|
CHAR8 TempSupportedLanguages;
|
|
|
|
CHAR8 *SupportedLanguages;
|
|
|
|
UINTN SupportedLanguagesSize;
|
|
|
|
CHAR8 *CurrentLanguage;
|
|
|
|
CHAR8 *BestLanguage;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsHiiHandleValid (PackageList)) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
2009-03-25 11:07:39 +01:00
|
|
|
// Initialize string pointers to be NULL
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
2009-03-25 11:07:39 +01:00
|
|
|
SupportedLanguages = NULL;
|
|
|
|
CurrentLanguage = NULL;
|
|
|
|
BestLanguage = NULL;
|
|
|
|
String = NULL;
|
|
|
|
StringFontInfo = NULL;
|
|
|
|
NewStringInfo = NULL;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Get the string to be displayed.
|
|
|
|
//
|
2009-03-25 11:07:39 +01:00
|
|
|
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
|
|
|
|
HiiString = &Private->HiiString;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the size of supported language.
|
|
|
|
//
|
|
|
|
SupportedLanguagesSize = 0;
|
|
|
|
Status = HiiString->GetLanguages (
|
|
|
|
HiiString,
|
|
|
|
PackageList,
|
|
|
|
&TempSupportedLanguages,
|
|
|
|
&SupportedLanguagesSize
|
|
|
|
);
|
|
|
|
if (Status != EFI_BUFFER_TOO_SMALL) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
SupportedLanguages = AllocatePool (SupportedLanguagesSize);
|
|
|
|
if (SupportedLanguages == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2009-03-25 11:07:39 +01:00
|
|
|
Status = HiiString->GetLanguages (
|
|
|
|
HiiString,
|
|
|
|
PackageList,
|
|
|
|
SupportedLanguages,
|
|
|
|
&SupportedLanguagesSize
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2009-03-25 11:07:39 +01:00
|
|
|
if (Language == NULL) {
|
|
|
|
Language = "";
|
|
|
|
}
|
2012-05-31 10:35:48 +02:00
|
|
|
GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLanguage, NULL);
|
2009-03-25 11:07:39 +01:00
|
|
|
BestLanguage = GetBestLanguage (
|
|
|
|
SupportedLanguages,
|
|
|
|
FALSE,
|
|
|
|
Language,
|
|
|
|
(CurrentLanguage == NULL) ? CurrentLanguage : "",
|
|
|
|
(CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (BestLanguage == NULL) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
StringSize = MAX_STRING_LENGTH;
|
|
|
|
String = (EFI_STRING) AllocateZeroPool (StringSize);
|
|
|
|
if (String == NULL) {
|
2009-03-25 11:07:39 +01:00
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
2009-03-25 11:07:39 +01:00
|
|
|
Status = HiiString->GetString (
|
|
|
|
HiiString,
|
|
|
|
BestLanguage,
|
|
|
|
PackageList,
|
|
|
|
StringId,
|
|
|
|
String,
|
|
|
|
&StringSize,
|
|
|
|
&StringFontInfo
|
|
|
|
);
|
2008-01-21 15:39:56 +01:00
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
2008-10-30 08:32:46 +01:00
|
|
|
FreePool (String);
|
2008-01-21 15:39:56 +01:00
|
|
|
String = (EFI_STRING) AllocateZeroPool (StringSize);
|
|
|
|
if (String == NULL) {
|
2009-03-25 11:07:39 +01:00
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2009-03-25 11:07:39 +01:00
|
|
|
Status = HiiString->GetString (
|
|
|
|
HiiString,
|
|
|
|
BestLanguage,
|
|
|
|
PackageList,
|
|
|
|
StringId,
|
|
|
|
String,
|
|
|
|
&StringSize,
|
|
|
|
NULL
|
|
|
|
);
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
2009-03-25 11:07:39 +01:00
|
|
|
goto Exit;
|
2008-06-23 11:41:33 +02:00
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
|
|
|
// When StringInfo specifies that string will be output in the system default font and color,
|
2018-06-27 15:08:52 +02:00
|
|
|
// use particular stringfontinfo described in string package instead if exists.
|
2008-06-23 11:41:33 +02:00
|
|
|
// StringFontInfo equals NULL means system default font attaches with the string block.
|
|
|
|
//
|
|
|
|
if (StringFontInfo != NULL && IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, NULL, NULL)) {
|
2015-06-29 04:36:31 +02:00
|
|
|
NameSize = StrSize (StringFontInfo->FontName);
|
|
|
|
FontLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + NameSize;
|
2008-06-23 11:41:33 +02:00
|
|
|
NewStringInfo = AllocateZeroPool (FontLen);
|
2018-06-27 15:08:52 +02:00
|
|
|
if (NewStringInfo == NULL) {
|
2008-06-23 11:41:33 +02:00
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
NewStringInfo->FontInfoMask = EFI_FONT_INFO_SYS_FORE_COLOR | EFI_FONT_INFO_SYS_BACK_COLOR;
|
|
|
|
NewStringInfo->FontInfo.FontStyle = StringFontInfo->FontStyle;
|
2018-06-27 15:08:52 +02:00
|
|
|
NewStringInfo->FontInfo.FontSize = StringFontInfo->FontSize;
|
2015-06-29 04:36:31 +02:00
|
|
|
StrCpyS (NewStringInfo->FontInfo.FontName, NameSize / sizeof (CHAR16), StringFontInfo->FontName);
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
Status = HiiStringToImage (
|
2018-06-27 15:08:52 +02:00
|
|
|
This,
|
|
|
|
Flags,
|
|
|
|
String,
|
|
|
|
NewStringInfo,
|
|
|
|
Blt,
|
|
|
|
BltX,
|
|
|
|
BltY,
|
2008-06-23 11:41:33 +02:00
|
|
|
RowInfoArray,
|
|
|
|
RowInfoArraySize,
|
|
|
|
ColumnInfoArray
|
|
|
|
);
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
Status = HiiStringToImage (
|
2008-01-21 15:39:56 +01:00
|
|
|
This,
|
|
|
|
Flags,
|
|
|
|
String,
|
|
|
|
StringInfo,
|
|
|
|
Blt,
|
|
|
|
BltX,
|
|
|
|
BltY,
|
|
|
|
RowInfoArray,
|
|
|
|
RowInfoArraySize,
|
|
|
|
ColumnInfoArray
|
|
|
|
);
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
Exit:
|
2009-03-25 11:07:39 +01:00
|
|
|
if (SupportedLanguages != NULL) {
|
|
|
|
FreePool (SupportedLanguages);
|
|
|
|
}
|
|
|
|
if (CurrentLanguage != NULL) {
|
|
|
|
FreePool (CurrentLanguage);
|
|
|
|
}
|
|
|
|
if (BestLanguage != NULL) {
|
|
|
|
FreePool (BestLanguage);
|
|
|
|
}
|
2008-10-30 08:32:46 +01:00
|
|
|
if (String != NULL) {
|
|
|
|
FreePool (String);
|
|
|
|
}
|
|
|
|
if (StringFontInfo != NULL) {
|
|
|
|
FreePool (StringFontInfo);
|
|
|
|
}
|
|
|
|
if (NewStringInfo != NULL) {
|
|
|
|
FreePool (NewStringInfo);
|
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
|
|
|
|
return Status;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert the glyph for a single character into a bitmap.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
|
|
|
|
@param Char Character to retrieve.
|
|
|
|
@param StringInfo Points to the string font and color information
|
|
|
|
or NULL if the string should use the default
|
|
|
|
system font and color.
|
|
|
|
@param Blt Thus must point to a NULL on entry. A buffer will
|
|
|
|
be allocated to hold the output and the pointer
|
2008-05-27 05:24:01 +02:00
|
|
|
updated on exit. It is the caller's
|
2008-01-21 15:39:56 +01:00
|
|
|
responsibility to free this buffer.
|
|
|
|
@param Baseline Number of pixels from the bottom of the bitmap to
|
|
|
|
the baseline.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Glyph bitmap created.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.
|
|
|
|
@retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was replaced with the
|
|
|
|
glyph for Unicode character 0xFFFD.
|
|
|
|
@retval EFI_INVALID_PARAMETER Blt is NULL or *Blt is not NULL.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiGetGlyph (
|
|
|
|
IN CONST EFI_HII_FONT_PROTOCOL *This,
|
|
|
|
IN CHAR16 Char,
|
|
|
|
IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,
|
|
|
|
OUT EFI_IMAGE_OUTPUT **Blt,
|
|
|
|
OUT UINTN *Baseline OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
HII_DATABASE_PRIVATE_DATA *Private;
|
|
|
|
EFI_IMAGE_OUTPUT *Image;
|
|
|
|
UINT8 *GlyphBuffer;
|
|
|
|
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
|
|
|
EFI_FONT_DISPLAY_INFO *StringInfoOut;
|
|
|
|
BOOLEAN Default;
|
|
|
|
EFI_FONT_HANDLE FontHandle;
|
|
|
|
EFI_STRING String;
|
|
|
|
EFI_HII_GLYPH_INFO Cell;
|
|
|
|
EFI_FONT_INFO *FontInfo;
|
|
|
|
UINT8 Attributes;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
2011-01-24 05:58:45 +01:00
|
|
|
UINT16 BaseLine;
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
if (This == NULL || Blt == NULL || *Blt != NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
|
|
|
|
|
|
|
|
Default = FALSE;
|
|
|
|
Image = NULL;
|
|
|
|
SystemDefault = NULL;
|
|
|
|
FontHandle = NULL;
|
|
|
|
String = NULL;
|
|
|
|
GlyphBuffer = NULL;
|
|
|
|
StringInfoOut = NULL;
|
|
|
|
FontInfo = NULL;
|
|
|
|
|
|
|
|
ZeroMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
|
|
|
|
Default = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);
|
|
|
|
|
|
|
|
if (!Default) {
|
|
|
|
//
|
|
|
|
// Find out a EFI_FONT_DISPLAY_INFO which could display the character in
|
|
|
|
// the specified color and font.
|
|
|
|
//
|
|
|
|
String = (EFI_STRING) AllocateZeroPool (sizeof (CHAR16) * 2);
|
|
|
|
if (String == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
*String = Char;
|
|
|
|
*(String + 1) = 0;
|
|
|
|
|
|
|
|
Status = HiiGetFontInfo (This, &FontHandle, StringInfo, &StringInfoOut, String);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
2010-02-05 07:13:18 +01:00
|
|
|
ASSERT (StringInfoOut != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
FontInfo = &StringInfoOut->FontInfo;
|
|
|
|
Foreground = StringInfoOut->ForegroundColor;
|
|
|
|
Background = StringInfoOut->BackgroundColor;
|
|
|
|
} else {
|
2014-06-26 05:24:25 +02:00
|
|
|
ASSERT (SystemDefault != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
Foreground = SystemDefault->ForegroundColor;
|
|
|
|
Background = SystemDefault->BackgroundColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = GetGlyphBuffer (Private, Char, FontInfo, &GlyphBuffer, &Cell, &Attributes);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
Image = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
|
|
|
|
if (Image == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
Image->Width = Cell.Width;
|
|
|
|
Image->Height = Cell.Height;
|
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
if (Image->Width * Image->Height > 0) {
|
|
|
|
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
if (Image->Image.Bitmap == NULL) {
|
|
|
|
FreePool (Image);
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
// Set BaseLine to the char height.
|
|
|
|
//
|
|
|
|
BaseLine = (UINT16) (Cell.Height + Cell.OffsetY);
|
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
// Set BltBuffer to the position of Origin.
|
2011-01-24 05:58:45 +01:00
|
|
|
//
|
|
|
|
BltBuffer = Image->Image.Bitmap + (Cell.Height + Cell.OffsetY) * Image->Width - Cell.OffsetX;
|
|
|
|
GlyphToImage (
|
|
|
|
GlyphBuffer,
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
Image->Width,
|
|
|
|
BaseLine,
|
|
|
|
Cell.Width + Cell.OffsetX,
|
|
|
|
BaseLine - Cell.OffsetY,
|
|
|
|
FALSE,
|
|
|
|
&Cell,
|
|
|
|
Attributes,
|
|
|
|
&BltBuffer
|
|
|
|
);
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
*Blt = Image;
|
|
|
|
if (Baseline != NULL) {
|
|
|
|
*Baseline = Cell.OffsetY;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
|
|
|
|
if (Status == EFI_NOT_FOUND) {
|
|
|
|
//
|
|
|
|
// Glyph is unknown and replaced with the glyph for unicode character 0xFFFD
|
|
|
|
//
|
|
|
|
if (Char != REPLACE_UNKNOWN_GLYPH) {
|
|
|
|
Status = HiiGetGlyph (This, REPLACE_UNKNOWN_GLYPH, StringInfo, Blt, Baseline);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_WARN_UNKNOWN_GLYPH;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Status = EFI_WARN_UNKNOWN_GLYPH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-30 08:32:46 +01:00
|
|
|
if (SystemDefault != NULL) {
|
|
|
|
FreePool (SystemDefault);
|
|
|
|
}
|
|
|
|
if (StringInfoOut != NULL) {
|
|
|
|
FreePool (StringInfoOut);
|
|
|
|
}
|
|
|
|
if (String != NULL) {
|
|
|
|
FreePool (String);
|
|
|
|
}
|
|
|
|
if (GlyphBuffer != NULL) {
|
|
|
|
FreePool (GlyphBuffer);
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function iterates through fonts which match the specified font, using
|
|
|
|
the specified criteria. If String is non-NULL, then all of the characters in
|
|
|
|
the string must exist in order for a candidate font to be returned.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.
|
|
|
|
@param FontHandle On entry, points to the font handle returned by a
|
|
|
|
previous call to GetFontInfo() or NULL to start
|
|
|
|
with the first font. On return, points to the
|
|
|
|
returned font handle or points to NULL if there
|
|
|
|
are no more matching fonts.
|
2013-08-20 09:13:28 +02:00
|
|
|
@param StringInfoIn Upon entry, points to the font to return information
|
|
|
|
about. If NULL, then the information about the system
|
|
|
|
default font will be returned.
|
|
|
|
@param StringInfoOut Upon return, contains the matching font's information.
|
|
|
|
If NULL, then no information is returned. This buffer
|
|
|
|
is allocated with a call to the Boot Service AllocatePool().
|
2018-06-27 15:08:52 +02:00
|
|
|
It is the caller's responsibility to call the Boot
|
2013-08-20 09:13:28 +02:00
|
|
|
Service FreePool() when the caller no longer requires
|
|
|
|
the contents of StringInfoOut.
|
2008-01-21 15:39:56 +01:00
|
|
|
@param String Points to the string which will be tested to
|
|
|
|
determine if all characters are available. If
|
|
|
|
NULL, then any font is acceptable.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Matching font returned successfully.
|
|
|
|
@retval EFI_NOT_FOUND No matching font was found.
|
2008-06-23 11:41:33 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
|
2008-01-21 15:39:56 +01:00
|
|
|
@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
|
|
|
|
request.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiGetFontInfo (
|
|
|
|
IN CONST EFI_HII_FONT_PROTOCOL *This,
|
|
|
|
IN OUT EFI_FONT_HANDLE *FontHandle,
|
2008-06-23 11:41:33 +02:00
|
|
|
IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL
|
2008-01-21 15:39:56 +01:00
|
|
|
OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,
|
|
|
|
IN CONST EFI_STRING String OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
HII_DATABASE_PRIVATE_DATA *Private;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
|
|
|
EFI_FONT_DISPLAY_INFO InfoOut;
|
|
|
|
UINTN StringInfoOutLen;
|
|
|
|
EFI_FONT_INFO *FontInfo;
|
|
|
|
HII_GLOBAL_FONT_INFO *GlobalFont;
|
|
|
|
EFI_STRING StringIn;
|
|
|
|
EFI_FONT_HANDLE LocalFontHandle;
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
if (This == NULL) {
|
2008-01-21 15:39:56 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-06-26 05:24:25 +02:00
|
|
|
StringInfoOutLen = 0;
|
2008-01-21 15:39:56 +01:00
|
|
|
FontInfo = NULL;
|
2008-06-23 11:41:33 +02:00
|
|
|
SystemDefault = NULL;
|
2008-01-21 15:39:56 +01:00
|
|
|
LocalFontHandle = NULL;
|
|
|
|
if (FontHandle != NULL) {
|
|
|
|
LocalFontHandle = *FontHandle;
|
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Already searched to the end of the whole list, return directly.
|
|
|
|
//
|
|
|
|
if (LocalFontHandle == &Private->FontInfoList) {
|
|
|
|
LocalFontHandle = NULL;
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2008-01-21 15:39:56 +01:00
|
|
|
//
|
|
|
|
// Get default system display info, if StringInfoIn points to
|
|
|
|
// system display info, return it directly.
|
|
|
|
//
|
|
|
|
if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, &SystemDefault, &StringInfoOutLen)) {
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
|
|
|
// System font is the first node. When handle is not NULL, system font can not
|
|
|
|
// be found any more.
|
|
|
|
//
|
|
|
|
if (LocalFontHandle == NULL) {
|
|
|
|
if (StringInfoOut != NULL) {
|
|
|
|
*StringInfoOut = AllocateCopyPool (StringInfoOutLen, SystemDefault);
|
|
|
|
if (*StringInfoOut == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
LocalFontHandle = NULL;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
|
|
|
|
LocalFontHandle = Private->FontInfoList.ForwardLink;
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
goto Exit;
|
|
|
|
} else {
|
|
|
|
LocalFontHandle = NULL;
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2009-03-27 05:56:54 +01:00
|
|
|
//
|
|
|
|
// StringInfoIn must not be NULL if it is not system default font info.
|
|
|
|
//
|
|
|
|
ASSERT (StringInfoIn != NULL);
|
2008-06-23 11:41:33 +02:00
|
|
|
//
|
|
|
|
// Check the font information mask to make sure it is valid.
|
|
|
|
//
|
2018-06-27 15:08:52 +02:00
|
|
|
if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==
|
2008-06-23 11:41:33 +02:00
|
|
|
(EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||
|
2018-06-27 15:08:52 +02:00
|
|
|
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==
|
2008-06-23 11:41:33 +02:00
|
|
|
(EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||
|
2018-06-27 15:08:52 +02:00
|
|
|
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==
|
2008-06-23 11:41:33 +02:00
|
|
|
(EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||
|
2018-06-27 15:08:52 +02:00
|
|
|
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==
|
|
|
|
(EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||
|
|
|
|
((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==
|
2008-06-23 11:41:33 +02:00
|
|
|
(EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Parse the font information mask to find a matching font.
|
|
|
|
//
|
|
|
|
|
|
|
|
CopyMem (&InfoOut, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, sizeof (EFI_FONT_DISPLAY_INFO));
|
|
|
|
|
|
|
|
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FONT) == EFI_FONT_INFO_SYS_FONT) {
|
|
|
|
Status = SaveFontName (SystemDefault->FontInfo.FontName, &FontInfo);
|
|
|
|
} else {
|
|
|
|
Status = SaveFontName (((EFI_FONT_DISPLAY_INFO *) StringInfoIn)->FontInfo.FontName, &FontInfo);
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_SIZE) == EFI_FONT_INFO_SYS_SIZE) {
|
|
|
|
InfoOut.FontInfo.FontSize = SystemDefault->FontInfo.FontSize;
|
2018-06-27 15:08:52 +02:00
|
|
|
}
|
2008-06-23 11:41:33 +02:00
|
|
|
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {
|
2008-01-21 15:39:56 +01:00
|
|
|
InfoOut.FontInfo.FontStyle = SystemDefault->FontInfo.FontStyle;
|
2008-06-23 11:41:33 +02:00
|
|
|
}
|
|
|
|
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {
|
2008-01-21 15:39:56 +01:00
|
|
|
InfoOut.ForegroundColor = SystemDefault->ForegroundColor;
|
2008-06-23 11:41:33 +02:00
|
|
|
}
|
|
|
|
if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {
|
2008-01-21 15:39:56 +01:00
|
|
|
InfoOut.BackgroundColor = SystemDefault->BackgroundColor;
|
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2010-02-05 07:13:18 +01:00
|
|
|
ASSERT (FontInfo != NULL);
|
2008-01-21 15:39:56 +01:00
|
|
|
FontInfo->FontSize = InfoOut.FontInfo.FontSize;
|
|
|
|
FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;
|
|
|
|
|
|
|
|
if (IsFontInfoExisted (Private, FontInfo, &InfoOut.FontInfoMask, LocalFontHandle, &GlobalFont)) {
|
2008-09-02 03:21:43 +02:00
|
|
|
//
|
|
|
|
// Test to guarantee all characters are available in the found font.
|
2018-06-27 15:08:52 +02:00
|
|
|
//
|
2008-01-21 15:39:56 +01:00
|
|
|
if (String != NULL) {
|
|
|
|
StringIn = String;
|
|
|
|
while (*StringIn != 0) {
|
|
|
|
Status = FindGlyphBlock (GlobalFont->FontPackage, *StringIn, NULL, NULL, NULL);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
LocalFontHandle = NULL;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
StringIn++;
|
|
|
|
}
|
2008-09-02 03:21:43 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Write to output parameter
|
|
|
|
//
|
|
|
|
if (StringInfoOut != NULL) {
|
|
|
|
StringInfoOutLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (EFI_FONT_INFO) + GlobalFont->FontInfoSize;
|
2018-06-27 15:08:52 +02:00
|
|
|
*StringInfoOut = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (StringInfoOutLen);
|
2008-09-02 03:21:43 +02:00
|
|
|
if (*StringInfoOut == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
LocalFontHandle = NULL;
|
|
|
|
goto Exit;
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
2008-09-02 03:21:43 +02:00
|
|
|
CopyMem (*StringInfoOut, &InfoOut, sizeof (EFI_FONT_DISPLAY_INFO));
|
|
|
|
CopyMem (&(*StringInfoOut)->FontInfo, GlobalFont->FontInfo, GlobalFont->FontInfoSize);
|
2008-01-21 15:39:56 +01:00
|
|
|
}
|
2018-06-27 15:08:52 +02:00
|
|
|
|
|
|
|
LocalFontHandle = GlobalFont->Entry.ForwardLink;
|
2008-09-02 03:21:43 +02:00
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
goto Exit;
|
2018-06-27 15:08:52 +02:00
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
|
|
|
|
if (FontHandle != NULL) {
|
|
|
|
*FontHandle = LocalFontHandle;
|
|
|
|
}
|
|
|
|
|
2008-10-30 08:32:46 +01:00
|
|
|
if (SystemDefault != NULL) {
|
|
|
|
FreePool (SystemDefault);
|
|
|
|
}
|
|
|
|
if (FontInfo != NULL) {
|
|
|
|
FreePool (FontInfo);
|
|
|
|
}
|
2008-01-21 15:39:56 +01:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-06-23 11:41:33 +02:00
|
|
|
|