mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
Support proportional Font and Font output flags.
1. Abstract the maximum baseline and character height in Proportional Font package as its baseline and line height, and use fixed height as base line and line height for simple font packages. 2. Update logic to handle string without EFI_HII_OUT_FLAG_CLIP_CLEAN_Y flag when string height exceeds the line height, and handle the string without EFI_HII_OUT_FLAG_CLIP_CLEAN_X flag when string wide exceeds the screen wide. 3. Calculate Origin point by adding BaseLine on Starting position, and calculate the left-top corner of character by Origin point and CELL information. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11270 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8db466cc13
commit
f6cf5cf800
@ -2,7 +2,7 @@
|
|||||||
Implementation for EFI_HII_FONT_PROTOCOL.
|
Implementation for EFI_HII_FONT_PROTOCOL.
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -76,6 +76,9 @@ NewCell (
|
|||||||
//
|
//
|
||||||
GlyphInfo->Signature = HII_GLYPH_INFO_SIGNATURE;
|
GlyphInfo->Signature = HII_GLYPH_INFO_SIGNATURE;
|
||||||
GlyphInfo->CharId = CharValue;
|
GlyphInfo->CharId = CharValue;
|
||||||
|
if (Cell->AdvanceX == 0) {
|
||||||
|
Cell->AdvanceX = Cell->Width;
|
||||||
|
}
|
||||||
CopyMem (&GlyphInfo->Cell, Cell, sizeof (EFI_HII_GLYPH_INFO));
|
CopyMem (&GlyphInfo->Cell, Cell, sizeof (EFI_HII_GLYPH_INFO));
|
||||||
InsertTailList (GlyphInfoList, &GlyphInfo->Entry);
|
InsertTailList (GlyphInfoList, &GlyphInfo->Entry);
|
||||||
|
|
||||||
@ -221,7 +224,6 @@ GetGlyphBuffer (
|
|||||||
}
|
}
|
||||||
Cell->Width = EFI_GLYPH_WIDTH;
|
Cell->Width = EFI_GLYPH_WIDTH;
|
||||||
Cell->Height = EFI_GLYPH_HEIGHT;
|
Cell->Height = EFI_GLYPH_HEIGHT;
|
||||||
Cell->OffsetY = NARROW_BASELINE;
|
|
||||||
Cell->AdvanceX = Cell->Width;
|
Cell->AdvanceX = Cell->Width;
|
||||||
CopyMem (*GlyphBuffer, Narrow.GlyphCol1, Cell->Height);
|
CopyMem (*GlyphBuffer, Narrow.GlyphCol1, Cell->Height);
|
||||||
if (Attributes != NULL) {
|
if (Attributes != NULL) {
|
||||||
@ -243,7 +245,6 @@ GetGlyphBuffer (
|
|||||||
}
|
}
|
||||||
Cell->Width = EFI_GLYPH_WIDTH * 2;
|
Cell->Width = EFI_GLYPH_WIDTH * 2;
|
||||||
Cell->Height = EFI_GLYPH_HEIGHT;
|
Cell->Height = EFI_GLYPH_HEIGHT;
|
||||||
Cell->OffsetY = WIDE_BASELINE;
|
|
||||||
Cell->AdvanceX = Cell->Width;
|
Cell->AdvanceX = Cell->Width;
|
||||||
CopyMem (*GlyphBuffer, Wide.GlyphCol1, EFI_GLYPH_HEIGHT);
|
CopyMem (*GlyphBuffer, Wide.GlyphCol1, EFI_GLYPH_HEIGHT);
|
||||||
CopyMem (*GlyphBuffer + EFI_GLYPH_HEIGHT, Wide.GlyphCol2, EFI_GLYPH_HEIGHT);
|
CopyMem (*GlyphBuffer + EFI_GLYPH_HEIGHT, Wide.GlyphCol2, EFI_GLYPH_HEIGHT);
|
||||||
@ -270,10 +271,9 @@ GetGlyphBuffer (
|
|||||||
bitmap.
|
bitmap.
|
||||||
@param Background The color of the "off" pixels in the glyph in the
|
@param Background The color of the "off" pixels in the glyph in the
|
||||||
bitmap.
|
bitmap.
|
||||||
@param ImageWidth Width of the character or character cell, in
|
@param ImageWidth Width of the whole image in pixels.
|
||||||
pixels.
|
@param RowWidth The width of the text on the line, in pixels.
|
||||||
@param ImageHeight Height of the character or character cell, in
|
@param RowHeight The height of the line, in pixels.
|
||||||
pixels.
|
|
||||||
@param Transparent If TRUE, the Background color is ignored and all
|
@param Transparent If TRUE, the Background color is ignored and all
|
||||||
"off" pixels in the character's drawn wil use the
|
"off" pixels in the character's drawn wil use the
|
||||||
pixel value from BltBuffer.
|
pixel value from BltBuffer.
|
||||||
@ -287,8 +287,9 @@ NarrowGlyphToBlt (
|
|||||||
IN UINT8 *GlyphBuffer,
|
IN UINT8 *GlyphBuffer,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
||||||
IN UINTN ImageWidth,
|
IN UINT16 ImageWidth,
|
||||||
IN UINTN ImageHeight,
|
IN UINTN RowWidth,
|
||||||
|
IN UINTN RowHeight,
|
||||||
IN BOOLEAN Transparent,
|
IN BOOLEAN Transparent,
|
||||||
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
||||||
)
|
)
|
||||||
@ -304,23 +305,34 @@ NarrowGlyphToBlt (
|
|||||||
Height = EFI_GLYPH_HEIGHT;
|
Height = EFI_GLYPH_HEIGHT;
|
||||||
Width = EFI_GLYPH_WIDTH;
|
Width = EFI_GLYPH_WIDTH;
|
||||||
|
|
||||||
ASSERT (Width <= ImageWidth && Height <= ImageHeight);
|
//
|
||||||
|
// Move position to the left-top corner of char.
|
||||||
|
//
|
||||||
|
Buffer = *Origin - EFI_GLYPH_HEIGHT * ImageWidth;
|
||||||
|
|
||||||
Buffer = *Origin;
|
//
|
||||||
|
// Char may be partially displayed when CLIP_X or CLIP_Y is not set.
|
||||||
|
//
|
||||||
|
if (RowHeight < Height) {
|
||||||
|
Height = (UINT8) RowHeight;
|
||||||
|
}
|
||||||
|
if (RowWidth < Width) {
|
||||||
|
Width = (UINT8) RowWidth;
|
||||||
|
}
|
||||||
|
|
||||||
for (Ypos = 0; Ypos < Height; Ypos++) {
|
for (Ypos = 0; Ypos < Height; Ypos++) {
|
||||||
for (Xpos = 0; Xpos < Width; Xpos++) {
|
for (Xpos = 0; Xpos < Width; Xpos++) {
|
||||||
if ((GlyphBuffer[Ypos] & (1 << Xpos)) != 0) {
|
if ((GlyphBuffer[Ypos] & (1 << (EFI_GLYPH_WIDTH - Xpos - 1))) != 0) {
|
||||||
Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Foreground;
|
Buffer[Ypos * ImageWidth + Xpos] = Foreground;
|
||||||
} else {
|
} else {
|
||||||
if (!Transparent) {
|
if (!Transparent) {
|
||||||
Buffer[Ypos * ImageWidth + (Width - Xpos - 1)] = Background;
|
Buffer[Ypos * ImageWidth + Xpos] = Background;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*Origin = Buffer + Width;
|
*Origin = *Origin + EFI_GLYPH_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -334,10 +346,10 @@ NarrowGlyphToBlt (
|
|||||||
bitmap.
|
bitmap.
|
||||||
@param Background The color of the "off" pixels in the glyph in the
|
@param Background The color of the "off" pixels in the glyph in the
|
||||||
bitmap.
|
bitmap.
|
||||||
@param ImageWidth Width of the character or character cell, in
|
@param ImageWidth Width of the whole image in pixels.
|
||||||
pixels.
|
@param BaseLine BaseLine in the line.
|
||||||
@param ImageHeight Height of the character or character cell, in
|
@param RowWidth The width of the text on the line, in pixels.
|
||||||
pixels.
|
@param RowHeight The height of the line, in pixels.
|
||||||
@param Transparent If TRUE, the Background color is ignored and all
|
@param Transparent If TRUE, the Background color is ignored and all
|
||||||
"off" pixels in the character's drawn wil use the
|
"off" pixels in the character's drawn wil use the
|
||||||
pixel value from BltBuffer.
|
pixel value from BltBuffer.
|
||||||
@ -354,25 +366,38 @@ GlyphToBlt (
|
|||||||
IN UINT8 *GlyphBuffer,
|
IN UINT8 *GlyphBuffer,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
||||||
IN UINTN ImageWidth,
|
IN UINT16 ImageWidth,
|
||||||
IN UINTN ImageHeight,
|
IN UINT16 BaseLine,
|
||||||
|
IN UINTN RowWidth,
|
||||||
|
IN UINTN RowHeight,
|
||||||
IN BOOLEAN Transparent,
|
IN BOOLEAN Transparent,
|
||||||
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
||||||
IN UINT8 Attributes,
|
IN UINT8 Attributes,
|
||||||
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **Origin
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 Xpos;
|
UINT16 Xpos;
|
||||||
UINT8 Ypos;
|
UINT16 Ypos;
|
||||||
UINT8 Data;
|
UINT8 Data;
|
||||||
UINT8 Index;
|
UINT16 Index;
|
||||||
|
UINT16 YposOffset;
|
||||||
UINTN OffsetY;
|
UINTN OffsetY;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
||||||
|
|
||||||
ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);
|
ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);
|
||||||
ASSERT (Cell->Width <= ImageWidth && Cell->Height <= ImageHeight);
|
|
||||||
|
|
||||||
BltBuffer = *Origin;
|
//
|
||||||
|
// 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));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Since non-spacing key will be printed OR'd with the previous glyph, don't
|
// Since non-spacing key will be printed OR'd with the previous glyph, don't
|
||||||
@ -386,7 +411,7 @@ GlyphToBlt (
|
|||||||
// The glyph's upper left hand corner pixel is the most significant bit of the
|
// The glyph's upper left hand corner pixel is the most significant bit of the
|
||||||
// first bitmap byte.
|
// first bitmap byte.
|
||||||
//
|
//
|
||||||
for (Ypos = 0; Ypos < Cell->Height; Ypos++) {
|
for (Ypos = 0; Ypos < Cell->Height && ((UINTN) (Ypos + YposOffset) < RowHeight); Ypos++) {
|
||||||
OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);
|
OffsetY = BITMAP_LEN_1_BIT (Cell->Width, Ypos);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -394,12 +419,12 @@ GlyphToBlt (
|
|||||||
//
|
//
|
||||||
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {
|
for (Xpos = 0; Xpos < Cell->Width / 8; Xpos++) {
|
||||||
Data = *(GlyphBuffer + OffsetY + Xpos);
|
Data = *(GlyphBuffer + OffsetY + Xpos);
|
||||||
for (Index = 0; Index < 8; Index++) {
|
for (Index = 0; Index < 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
|
||||||
if ((Data & (1 << Index)) != 0) {
|
if ((Data & (1 << (8 - Index - 1))) != 0) {
|
||||||
BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Foreground;
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
|
||||||
} else {
|
} else {
|
||||||
if (!Transparent) {
|
if (!Transparent) {
|
||||||
BltBuffer[Ypos * ImageWidth + Xpos * 8 + (8 - Index - 1)] = Background;
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Background;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,7 +435,7 @@ GlyphToBlt (
|
|||||||
// There are some padding bits in this byte. Ignore them.
|
// There are some padding bits in this byte. Ignore them.
|
||||||
//
|
//
|
||||||
Data = *(GlyphBuffer + OffsetY + Xpos);
|
Data = *(GlyphBuffer + OffsetY + Xpos);
|
||||||
for (Index = 0; Index < Cell->Width % 8; Index++) {
|
for (Index = 0; Index < Cell->Width % 8 && ((UINTN) (Xpos * 8 + Index + Cell->OffsetX) < RowWidth); Index++) {
|
||||||
if ((Data & (1 << (8 - Index - 1))) != 0) {
|
if ((Data & (1 << (8 - Index - 1))) != 0) {
|
||||||
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
|
BltBuffer[Ypos * ImageWidth + Xpos * 8 + Index] = Foreground;
|
||||||
} else {
|
} else {
|
||||||
@ -423,7 +448,7 @@ GlyphToBlt (
|
|||||||
|
|
||||||
} // end of for (Ypos=0...)
|
} // end of for (Ypos=0...)
|
||||||
|
|
||||||
*Origin = BltBuffer + Cell->Width;
|
*Origin = *Origin + Cell->AdvanceX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -437,10 +462,10 @@ GlyphToBlt (
|
|||||||
bitmap.
|
bitmap.
|
||||||
@param Background The color of the "off" pixels in the glyph in the
|
@param Background The color of the "off" pixels in the glyph in the
|
||||||
bitmap.
|
bitmap.
|
||||||
@param ImageWidth Width of the character or character cell, in
|
@param ImageWidth Width of the whole image in pixels.
|
||||||
pixels.
|
@param BaseLine BaseLine in the line.
|
||||||
@param ImageHeight Height of the character or character cell, in
|
@param RowWidth The width of the text on the line, in pixels.
|
||||||
pixels.
|
@param RowHeight The height of the line, in pixels.
|
||||||
@param Transparent If TRUE, the Background color is ignored and all
|
@param Transparent If TRUE, the Background color is ignored and all
|
||||||
"off" pixels in the character's drawn wil use the
|
"off" pixels in the character's drawn wil use the
|
||||||
pixel value from BltBuffer.
|
pixel value from BltBuffer.
|
||||||
@ -458,8 +483,10 @@ GlyphToImage (
|
|||||||
IN UINT8 *GlyphBuffer,
|
IN UINT8 *GlyphBuffer,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
|
||||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
|
||||||
IN UINTN ImageWidth,
|
IN UINT16 ImageWidth,
|
||||||
IN UINTN ImageHeight,
|
IN UINT16 BaseLine,
|
||||||
|
IN UINTN RowWidth,
|
||||||
|
IN UINTN RowHeight,
|
||||||
IN BOOLEAN Transparent,
|
IN BOOLEAN Transparent,
|
||||||
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
IN CONST EFI_HII_GLYPH_INFO *Cell,
|
||||||
IN UINT8 Attributes,
|
IN UINT8 Attributes,
|
||||||
@ -468,8 +495,7 @@ GlyphToImage (
|
|||||||
{
|
{
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Buffer;
|
||||||
|
|
||||||
ASSERT (GlyphBuffer != NULL && Origin != NULL && *Origin != NULL);
|
ASSERT (Origin != NULL && *Origin != NULL && Cell != NULL);
|
||||||
ASSERT (Cell->Width <= ImageWidth && Cell->Height <= ImageHeight);
|
|
||||||
|
|
||||||
Buffer = *Origin;
|
Buffer = *Origin;
|
||||||
|
|
||||||
@ -478,13 +504,15 @@ GlyphToImage (
|
|||||||
// This character is a non-spacing key, print it OR'd with the previous glyph.
|
// This character is a non-spacing key, print it OR'd with the previous glyph.
|
||||||
// without advancing cursor.
|
// without advancing cursor.
|
||||||
//
|
//
|
||||||
Buffer -= Cell->Width;
|
Buffer -= Cell->AdvanceX;
|
||||||
GlyphToBlt (
|
GlyphToBlt (
|
||||||
GlyphBuffer,
|
GlyphBuffer,
|
||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
ImageWidth,
|
ImageWidth,
|
||||||
ImageHeight,
|
BaseLine,
|
||||||
|
RowWidth,
|
||||||
|
RowHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
Cell,
|
Cell,
|
||||||
Attributes,
|
Attributes,
|
||||||
@ -501,7 +529,8 @@ GlyphToImage (
|
|||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
ImageWidth,
|
ImageWidth,
|
||||||
ImageHeight,
|
RowWidth,
|
||||||
|
RowHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
Origin
|
Origin
|
||||||
);
|
);
|
||||||
@ -511,7 +540,8 @@ GlyphToImage (
|
|||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
ImageWidth,
|
ImageWidth,
|
||||||
ImageHeight,
|
RowWidth,
|
||||||
|
RowHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
Origin
|
Origin
|
||||||
);
|
);
|
||||||
@ -525,7 +555,8 @@ GlyphToImage (
|
|||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
ImageWidth,
|
ImageWidth,
|
||||||
ImageHeight,
|
RowWidth,
|
||||||
|
RowHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
Origin
|
Origin
|
||||||
);
|
);
|
||||||
@ -539,7 +570,9 @@ GlyphToImage (
|
|||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
ImageWidth,
|
ImageWidth,
|
||||||
ImageHeight,
|
BaseLine,
|
||||||
|
RowWidth,
|
||||||
|
RowHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
Cell,
|
Cell,
|
||||||
Attributes,
|
Attributes,
|
||||||
@ -581,7 +614,7 @@ WriteOutputParam (
|
|||||||
OUT UINTN *GlyphBufferLen OPTIONAL
|
OUT UINTN *GlyphBufferLen OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (BufferIn == NULL || BufferLen < 1 || InputCell == NULL) {
|
if (BufferIn == NULL || InputCell == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +622,7 @@ WriteOutputParam (
|
|||||||
CopyMem (Cell, InputCell, sizeof (EFI_HII_GLYPH_INFO));
|
CopyMem (Cell, InputCell, sizeof (EFI_HII_GLYPH_INFO));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlyphBuffer != NULL) {
|
if (GlyphBuffer != NULL && BufferLen > 0) {
|
||||||
*GlyphBuffer = (UINT8 *) AllocateZeroPool (BufferLen);
|
*GlyphBuffer = (UINT8 *) AllocateZeroPool (BufferLen);
|
||||||
if (*GlyphBuffer == NULL) {
|
if (*GlyphBuffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
@ -645,9 +678,13 @@ FindGlyphBlock (
|
|||||||
UINT16 Index;
|
UINT16 Index;
|
||||||
EFI_HII_GLYPH_INFO DefaultCell;
|
EFI_HII_GLYPH_INFO DefaultCell;
|
||||||
EFI_HII_GLYPH_INFO LocalCell;
|
EFI_HII_GLYPH_INFO LocalCell;
|
||||||
|
INT16 MinOffsetY;
|
||||||
|
UINT16 BaseLine;
|
||||||
|
|
||||||
ASSERT (FontPackage != NULL);
|
ASSERT (FontPackage != NULL);
|
||||||
ASSERT (FontPackage->Signature == HII_FONT_PACKAGE_SIGNATURE);
|
ASSERT (FontPackage->Signature == HII_FONT_PACKAGE_SIGNATURE);
|
||||||
|
BaseLine = 0;
|
||||||
|
MinOffsetY = 0;
|
||||||
|
|
||||||
if (CharValue == (CHAR16) (-1)) {
|
if (CharValue == (CHAR16) (-1)) {
|
||||||
//
|
//
|
||||||
@ -662,6 +699,15 @@ FindGlyphBlock (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
CopyMem (
|
||||||
|
&LocalCell,
|
||||||
|
(UINT8 *) FontPackage->FontPkgHdr + 3 * sizeof (UINT32),
|
||||||
|
sizeof (EFI_HII_GLYPH_INFO)
|
||||||
|
);
|
||||||
|
BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);
|
||||||
|
if (MinOffsetY > LocalCell.OffsetY) {
|
||||||
|
MinOffsetY = LocalCell.OffsetY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPtr = FontPackage->GlyphBlock;
|
BlockPtr = FontPackage->GlyphBlock;
|
||||||
@ -684,6 +730,17 @@ FindGlyphBlock (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BlockPtr += sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK);
|
BlockPtr += sizeof (EFI_HII_GIBT_DEFAULTS_BLOCK);
|
||||||
break;
|
break;
|
||||||
@ -725,6 +782,14 @@ FindGlyphBlock (
|
|||||||
BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),
|
BlockPtr + sizeof (EFI_HII_GLYPH_BLOCK),
|
||||||
sizeof (EFI_HII_GLYPH_INFO)
|
sizeof (EFI_HII_GLYPH_INFO)
|
||||||
);
|
);
|
||||||
|
if (CharValue == (CHAR16) (-1)) {
|
||||||
|
if (BaseLine < LocalCell.Height + LocalCell.OffsetY) {
|
||||||
|
BaseLine = (UINT16) (LocalCell.Height + LocalCell.OffsetY);
|
||||||
|
}
|
||||||
|
if (MinOffsetY > LocalCell.OffsetY) {
|
||||||
|
MinOffsetY = LocalCell.OffsetY;
|
||||||
|
}
|
||||||
|
}
|
||||||
BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);
|
BufferLen = BITMAP_LEN_1_BIT (LocalCell.Width, LocalCell.Height);
|
||||||
if (CharCurrent == CharValue) {
|
if (CharCurrent == CharValue) {
|
||||||
return WriteOutputParam (
|
return WriteOutputParam (
|
||||||
@ -747,6 +812,15 @@ FindGlyphBlock (
|
|||||||
CopyMem (&Glyphs.Count, BlockPtr, sizeof (UINT16));
|
CopyMem (&Glyphs.Count, BlockPtr, sizeof (UINT16));
|
||||||
BlockPtr += sizeof (UINT16);
|
BlockPtr += sizeof (UINT16);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BufferLen = BITMAP_LEN_1_BIT (Glyphs.Cell.Width, Glyphs.Cell.Height);
|
BufferLen = BITMAP_LEN_1_BIT (Glyphs.Cell.Width, Glyphs.Cell.Height);
|
||||||
for (Index = 0; Index < Glyphs.Count; Index++) {
|
for (Index = 0; Index < Glyphs.Count; Index++) {
|
||||||
if (CharCurrent + Index == CharValue) {
|
if (CharCurrent + Index == CharValue) {
|
||||||
@ -829,6 +903,8 @@ FindGlyphBlock (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CharValue == (CHAR16) (-1)) {
|
if (CharValue == (CHAR16) (-1)) {
|
||||||
|
FontPackage->BaseLine = BaseLine;
|
||||||
|
FontPackage->Height = (UINT16) (BaseLine - MinOffsetY);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1501,10 +1577,13 @@ HiiStringToImage (
|
|||||||
EFI_HII_ROW_INFO *RowInfo;
|
EFI_HII_ROW_INFO *RowInfo;
|
||||||
UINTN LineWidth;
|
UINTN LineWidth;
|
||||||
UINTN LineHeight;
|
UINTN LineHeight;
|
||||||
|
UINTN LineOffset;
|
||||||
|
UINTN LastLineHeight;
|
||||||
UINTN BaseLineOffset;
|
UINTN BaseLineOffset;
|
||||||
UINT16 MaxRowNum;
|
UINT16 MaxRowNum;
|
||||||
UINT16 RowIndex;
|
UINT16 RowIndex;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
UINTN NextIndex;
|
||||||
UINTN Index1;
|
UINTN Index1;
|
||||||
EFI_FONT_DISPLAY_INFO *StringInfoOut;
|
EFI_FONT_DISPLAY_INFO *StringInfoOut;
|
||||||
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
EFI_FONT_DISPLAY_INFO *SystemDefault;
|
||||||
@ -1512,6 +1591,7 @@ HiiStringToImage (
|
|||||||
EFI_STRING StringIn;
|
EFI_STRING StringIn;
|
||||||
EFI_STRING StringIn2;
|
EFI_STRING StringIn2;
|
||||||
UINT16 Height;
|
UINT16 Height;
|
||||||
|
UINT16 BaseLine;
|
||||||
EFI_FONT_INFO *FontInfo;
|
EFI_FONT_INFO *FontInfo;
|
||||||
BOOLEAN SysFontFlag;
|
BOOLEAN SysFontFlag;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
||||||
@ -1522,6 +1602,8 @@ HiiStringToImage (
|
|||||||
UINTN RowInfoSize;
|
UINTN RowInfoSize;
|
||||||
BOOLEAN LineBreak;
|
BOOLEAN LineBreak;
|
||||||
UINTN StrLength;
|
UINTN StrLength;
|
||||||
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *RowBufferPtr;
|
||||||
|
HII_GLOBAL_FONT_INFO *GlobalFont;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check incoming parameters.
|
// Check incoming parameters.
|
||||||
@ -1607,6 +1689,7 @@ HiiStringToImage (
|
|||||||
if (SysFontFlag) {
|
if (SysFontFlag) {
|
||||||
FontInfo = NULL;
|
FontInfo = NULL;
|
||||||
Height = SystemDefault->FontInfo.FontSize;
|
Height = SystemDefault->FontInfo.FontSize;
|
||||||
|
BaseLine = SystemDefault->FontInfo.FontSize;
|
||||||
Foreground = SystemDefault->ForegroundColor;
|
Foreground = SystemDefault->ForegroundColor;
|
||||||
Background = SystemDefault->BackgroundColor;
|
Background = SystemDefault->BackgroundColor;
|
||||||
|
|
||||||
@ -1624,12 +1707,15 @@ HiiStringToImage (
|
|||||||
SysFontFlag = TRUE;
|
SysFontFlag = TRUE;
|
||||||
FontInfo = NULL;
|
FontInfo = NULL;
|
||||||
Height = SystemDefault->FontInfo.FontSize;
|
Height = SystemDefault->FontInfo.FontSize;
|
||||||
|
BaseLine = SystemDefault->FontInfo.FontSize;
|
||||||
Foreground = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->ForegroundColor;
|
Foreground = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->ForegroundColor;
|
||||||
Background = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->BackgroundColor;
|
Background = ((EFI_FONT_DISPLAY_INFO *) StringInfo)->BackgroundColor;
|
||||||
|
|
||||||
} else if (Status == EFI_SUCCESS) {
|
} else if (Status == EFI_SUCCESS) {
|
||||||
FontInfo = &StringInfoOut->FontInfo;
|
FontInfo = &StringInfoOut->FontInfo;
|
||||||
Height = StringInfoOut->FontInfo.FontSize;
|
IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont);
|
||||||
|
Height = GlobalFont->FontPackage->Height;
|
||||||
|
BaseLine = GlobalFont->FontPackage->BaseLine;
|
||||||
Foreground = StringInfoOut->ForegroundColor;
|
Foreground = StringInfoOut->ForegroundColor;
|
||||||
Background = StringInfoOut->BackgroundColor;
|
Background = StringInfoOut->BackgroundColor;
|
||||||
} else {
|
} else {
|
||||||
@ -1637,6 +1723,14 @@ HiiStringToImage (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use the maxinum height of font as the base line.
|
||||||
|
// And, use the maxinum height as line height.
|
||||||
|
//
|
||||||
|
LineHeight = Height;
|
||||||
|
LastLineHeight = Height;
|
||||||
|
BaseLineOffset = Height - BaseLine;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse the string to be displayed to drop some ignored characters.
|
// Parse the string to be displayed to drop some ignored characters.
|
||||||
//
|
//
|
||||||
@ -1677,12 +1771,18 @@ HiiStringToImage (
|
|||||||
StringTmp = StringIn2;
|
StringTmp = StringIn2;
|
||||||
StrLength = StrLen(StringPtr);
|
StrLength = StrLen(StringPtr);
|
||||||
while (*StringPtr != 0 && Index < StrLength) {
|
while (*StringPtr != 0 && Index < StrLength) {
|
||||||
|
if (IsLineBreak (*StringPtr) == 0) {
|
||||||
|
*StringTmp++ = *StringPtr++;
|
||||||
|
Index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);
|
Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);
|
||||||
if (Status == EFI_NOT_FOUND) {
|
if (Status == EFI_NOT_FOUND) {
|
||||||
if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {
|
if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {
|
||||||
GlyphBuf[Index] = NULL;
|
GlyphBuf[Index] = NULL;
|
||||||
*StringTmp++ = *StringPtr++;
|
ZeroMem (&Cell[Index], sizeof (Cell[Index]));
|
||||||
Index++;
|
Status = EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Unicode 0xFFFD must exist in current hii database if this flag is not set.
|
// Unicode 0xFFFD must exist in current hii database if this flag is not set.
|
||||||
@ -1697,18 +1797,17 @@ HiiStringToImage (
|
|||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
*StringTmp++ = *StringPtr++;
|
*StringTmp++ = *StringPtr++;
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
} else if (EFI_ERROR (Status)) {
|
|
||||||
goto Exit;
|
|
||||||
} else {
|
|
||||||
*StringTmp++ = *StringPtr++;
|
|
||||||
Index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*StringTmp = 0;
|
*StringTmp = 0;
|
||||||
StringPtr = StringIn2;
|
StringPtr = StringIn2;
|
||||||
|
|
||||||
@ -1720,8 +1819,10 @@ HiiStringToImage (
|
|||||||
//
|
//
|
||||||
Image = *Blt;
|
Image = *Blt;
|
||||||
BufferPtr = Image->Image.Bitmap + Image->Width * BltY + BltX;
|
BufferPtr = Image->Image.Bitmap + Image->Width * BltY + BltX;
|
||||||
MaxRowNum = (UINT16) (Image->Height / Height);
|
ASSERT (Image->Height >= BltY);
|
||||||
if (Image->Height % Height != 0) {
|
MaxRowNum = (UINT16) ((Image->Height - BltY) / Height);
|
||||||
|
if ((Image->Height - BltY) % Height != 0) {
|
||||||
|
LastLineHeight = (Image->Height - BltY) % Height;
|
||||||
MaxRowNum++;
|
MaxRowNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1734,25 +1835,26 @@ HiiStringToImage (
|
|||||||
//
|
//
|
||||||
// Format the glyph buffer according to flags.
|
// Format the glyph buffer according to flags.
|
||||||
//
|
//
|
||||||
|
|
||||||
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);
|
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);
|
||||||
if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
|
|
||||||
//
|
|
||||||
// Don't draw at all if there is only one row and
|
|
||||||
// the row's bottom-most on pixel cannot fit.
|
|
||||||
//
|
|
||||||
if (MaxRowNum == 1 && SysFontFlag) {
|
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
goto Exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (RowIndex = 0, Index = 0; RowIndex < MaxRowNum && StringPtr[Index] != 0; ) {
|
for (RowIndex = 0, Index = 0; RowIndex < MaxRowNum && StringPtr[Index] != 0; ) {
|
||||||
LineWidth = 0;
|
LineWidth = 0;
|
||||||
LineHeight = 0;
|
|
||||||
BaseLineOffset = 0;
|
|
||||||
LineBreak = FALSE;
|
LineBreak = FALSE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate how many characters there are in a row.
|
// Calculate how many characters there are in a row.
|
||||||
//
|
//
|
||||||
@ -1760,7 +1862,6 @@ HiiStringToImage (
|
|||||||
|
|
||||||
while (LineWidth + BltX < Image->Width && StringPtr[Index] != 0) {
|
while (LineWidth + BltX < Image->Width && StringPtr[Index] != 0) {
|
||||||
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&
|
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0 &&
|
||||||
(Flags & EFI_HII_OUT_FLAG_WRAP) == 0 &&
|
|
||||||
IsLineBreak (StringPtr[Index]) == 0) {
|
IsLineBreak (StringPtr[Index]) == 0) {
|
||||||
//
|
//
|
||||||
// It forces a line break that ends this row.
|
// It forces a line break that ends this row.
|
||||||
@ -1773,25 +1874,32 @@ HiiStringToImage (
|
|||||||
//
|
//
|
||||||
// If the glyph of the character is existing, then accumulate the actual printed width
|
// If the glyph of the character is existing, then accumulate the actual printed width
|
||||||
//
|
//
|
||||||
if (GlyphBuf[Index] != NULL) {
|
|
||||||
LineWidth += (UINTN) Cell[Index].AdvanceX;
|
LineWidth += (UINTN) Cell[Index].AdvanceX;
|
||||||
if (LineHeight < Cell[Index].Height) {
|
|
||||||
LineHeight = (UINTN) Cell[Index].Height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If this character is the last character of a row, we need not
|
// Record index of next char.
|
||||||
// draw its (AdvanceX - Width) for next character.
|
//
|
||||||
|
NextIndex = Index;
|
||||||
|
//
|
||||||
|
// Return to the previous char.
|
||||||
//
|
//
|
||||||
Index--;
|
Index--;
|
||||||
if (!SysFontFlag) {
|
if (LineBreak && Index > 0 ) {
|
||||||
LineWidth -= (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width);
|
//
|
||||||
|
// Return the previous non line break char.
|
||||||
|
//
|
||||||
|
Index --;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If this character is the last character of a row, we need not
|
||||||
|
// draw its (AdvanceX - Width - OffsetX) for next character.
|
||||||
|
//
|
||||||
|
LineWidth -= (UINTN) (Cell[Index].AdvanceX - Cell[Index].Width - Cell[Index].OffsetX);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
|
// Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
|
||||||
//
|
//
|
||||||
@ -1810,13 +1918,15 @@ HiiStringToImage (
|
|||||||
// if its right-most on pixel cannot fit.
|
// if its right-most on pixel cannot fit.
|
||||||
//
|
//
|
||||||
if (Index > 0) {
|
if (Index > 0) {
|
||||||
|
//
|
||||||
|
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
|
||||||
|
//
|
||||||
|
LineWidth -= (UINTN) (Cell[Index].Width + Cell[Index].OffsetX);
|
||||||
|
LineWidth -= (UINTN) (Cell[Index - 1].AdvanceX - Cell[Index - 1].Width - Cell[Index - 1].OffsetX);
|
||||||
RowInfo[RowIndex].EndIndex = Index - 1;
|
RowInfo[RowIndex].EndIndex = Index - 1;
|
||||||
RowInfo[RowIndex].LineWidth = LineWidth - Cell[Index].AdvanceX;
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
||||||
RowInfo[RowIndex].BaselineOffset = BaseLineOffset;
|
|
||||||
if (LineHeight > Cell[Index - 1].Height) {
|
|
||||||
LineHeight = Cell[Index - 1].Height;
|
|
||||||
}
|
|
||||||
RowInfo[RowIndex].LineHeight = LineHeight;
|
RowInfo[RowIndex].LineHeight = LineHeight;
|
||||||
|
RowInfo[RowIndex].BaselineOffset = BaseLineOffset;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// There is only one column and it can not be drawn so that return directly.
|
// There is only one column and it can not be drawn so that return directly.
|
||||||
@ -1831,16 +1941,24 @@ HiiStringToImage (
|
|||||||
// opportunity prior to a character whose right-most extent would exceed Width.
|
// opportunity prior to a character whose right-most extent would exceed Width.
|
||||||
// Search the right-most line-break opportunity here.
|
// Search the right-most line-break opportunity here.
|
||||||
//
|
//
|
||||||
if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP) {
|
if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP && StringPtr[NextIndex] != 0 && !LineBreak) {
|
||||||
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {
|
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {
|
||||||
|
LineWidth = RowInfo[RowIndex].LineWidth;
|
||||||
for (Index1 = RowInfo[RowIndex].EndIndex; Index1 >= RowInfo[RowIndex].StartIndex; Index1--) {
|
for (Index1 = RowInfo[RowIndex].EndIndex; Index1 >= RowInfo[RowIndex].StartIndex; Index1--) {
|
||||||
|
if (Index1 == RowInfo[RowIndex].EndIndex) {
|
||||||
|
LineWidth -= (Cell[Index1].Width + Cell[Index1].OffsetX);
|
||||||
|
} else {
|
||||||
|
LineWidth -= Cell[Index1].AdvanceX;
|
||||||
|
}
|
||||||
if (IsLineBreak (StringPtr[Index1]) > 0) {
|
if (IsLineBreak (StringPtr[Index1]) > 0) {
|
||||||
LineBreak = TRUE;
|
LineBreak = TRUE;
|
||||||
|
if (Index1 > RowInfo[RowIndex].StartIndex) {
|
||||||
RowInfo[RowIndex].EndIndex = Index1 - 1;
|
RowInfo[RowIndex].EndIndex = Index1 - 1;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// relocate to the character after the right-most line break opportunity of this line
|
// relocate to the character after the right-most line break opportunity of this line
|
||||||
//
|
//
|
||||||
Index = Index1 + 1;
|
NextIndex = Index1 + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -1850,6 +1968,18 @@ HiiStringToImage (
|
|||||||
if (Index1 == RowInfo[RowIndex].StartIndex)
|
if (Index1 == RowInfo[RowIndex].StartIndex)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update LineWidth to the real width
|
||||||
|
//
|
||||||
|
if (IsLineBreak (StringPtr[Index1]) > 0) {
|
||||||
|
if (Index1 == RowInfo[RowIndex].StartIndex) {
|
||||||
|
LineWidth = 0;
|
||||||
|
} else {
|
||||||
|
LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
|
||||||
|
}
|
||||||
|
RowInfo[RowIndex].LineWidth = LineWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// If no line-break opportunity can be found, then the text will
|
// If no line-break opportunity can be found, then the text will
|
||||||
@ -1862,32 +1992,32 @@ HiiStringToImage (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clip the final row if the row's bottom-most on pixel cannot fit when
|
// LineWidth can't exceed Image width.
|
||||||
// EFI_HII_OUT_FLAG_CLEAN_Y is set.
|
|
||||||
//
|
//
|
||||||
if (RowIndex == MaxRowNum - 1 && Image->Height < LineHeight) {
|
if (RowInfo[RowIndex].LineWidth + BltX > Image->Width) {
|
||||||
LineHeight = Image->Height;
|
RowInfo[RowIndex].LineWidth = Image->Width - BltX;
|
||||||
if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
|
|
||||||
//
|
|
||||||
// Don't draw at all if the row's bottom-most on pixel cannot fit.
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw it to screen or existing bitmap depending on whether
|
// Draw it to screen or existing bitmap depending on whether
|
||||||
// EFI_HII_DIRECT_TO_SCREEN is set.
|
// EFI_HII_DIRECT_TO_SCREEN is set.
|
||||||
//
|
//
|
||||||
|
LineOffset = 0;
|
||||||
if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) {
|
if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) {
|
||||||
|
BltBuffer = NULL;
|
||||||
|
if (RowInfo[RowIndex].LineWidth != 0) {
|
||||||
BltBuffer = AllocateZeroPool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
BltBuffer = AllocateZeroPool (RowInfo[RowIndex].LineWidth * RowInfo[RowIndex].LineHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||||
if (BltBuffer == NULL) {
|
if (BltBuffer == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
BufferPtr = BltBuffer;
|
//
|
||||||
|
// Set BufferPtr to Origin by adding baseline to the starting position.
|
||||||
|
//
|
||||||
|
BufferPtr = BltBuffer + BaseLine * RowInfo[RowIndex].LineWidth;
|
||||||
|
}
|
||||||
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
||||||
if (GlyphBuf[Index1] != NULL) {
|
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
|
||||||
//
|
//
|
||||||
// Only BLT these character which have corrsponding glyph in font basebase.
|
// Only BLT these character which have corrsponding glyph in font basebase.
|
||||||
//
|
//
|
||||||
@ -1895,7 +2025,9 @@ HiiStringToImage (
|
|||||||
GlyphBuf[Index1],
|
GlyphBuf[Index1],
|
||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
RowInfo[RowIndex].LineWidth,
|
(UINT16) RowInfo[RowIndex].LineWidth,
|
||||||
|
BaseLine,
|
||||||
|
RowInfo[RowIndex].LineWidth - LineOffset,
|
||||||
RowInfo[RowIndex].LineHeight,
|
RowInfo[RowIndex].LineHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
&Cell[Index1],
|
&Cell[Index1],
|
||||||
@ -1904,22 +2036,18 @@ HiiStringToImage (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (ColumnInfoArray != NULL) {
|
if (ColumnInfoArray != NULL) {
|
||||||
if (GlyphBuf[Index1] == NULL) {
|
if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)
|
||||||
*ColumnInfoArray = 0;
|
|| RowInfo[RowIndex].LineWidth == 0) {
|
||||||
|
*ColumnInfoArray = (UINTN) ~0;
|
||||||
} else {
|
} else {
|
||||||
*ColumnInfoArray = Cell[Index1 -1].AdvanceX;
|
*ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;
|
||||||
}
|
}
|
||||||
ColumnInfoArray++;
|
ColumnInfoArray++;
|
||||||
}
|
}
|
||||||
}
|
LineOffset += Cell[Index1].AdvanceX;
|
||||||
//
|
|
||||||
// Recalculate the start point of X/Y axis to draw multi-lines with the order of top-to-down
|
|
||||||
//
|
|
||||||
if (RowIndex != 0) {
|
|
||||||
BltX = 0;
|
|
||||||
BltY += RowInfo[RowIndex].LineHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BltBuffer != NULL) {
|
||||||
Status = Image->Image.Screen->Blt (
|
Status = Image->Image.Screen->Blt (
|
||||||
Image->Image.Screen,
|
Image->Image.Screen,
|
||||||
BltBuffer,
|
BltBuffer,
|
||||||
@ -1938,10 +2066,18 @@ HiiStringToImage (
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreePool (BltBuffer);
|
FreePool (BltBuffer);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//
|
||||||
|
// Save the starting position for calculate the starting postition of next row.
|
||||||
|
//
|
||||||
|
RowBufferPtr = BufferPtr;
|
||||||
|
//
|
||||||
|
// Set BufferPtr to Origin by adding baseline to the starting position.
|
||||||
|
//
|
||||||
|
BufferPtr = BufferPtr + BaseLine * Image->Width;
|
||||||
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
|
||||||
if (GlyphBuf[Index1] != NULL) {
|
if (RowInfo[RowIndex].LineWidth > 0 && RowInfo[RowIndex].LineWidth > LineOffset) {
|
||||||
//
|
//
|
||||||
// Only BLT these character which have corrsponding glyph in font basebase.
|
// Only BLT these character which have corrsponding glyph in font basebase.
|
||||||
//
|
//
|
||||||
@ -1950,7 +2086,9 @@ HiiStringToImage (
|
|||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
Image->Width,
|
Image->Width,
|
||||||
Image->Height,
|
BaseLine,
|
||||||
|
RowInfo[RowIndex].LineWidth - LineOffset,
|
||||||
|
RowInfo[RowIndex].LineHeight,
|
||||||
Transparent,
|
Transparent,
|
||||||
&Cell[Index1],
|
&Cell[Index1],
|
||||||
Attributes[Index1],
|
Attributes[Index1],
|
||||||
@ -1958,22 +2096,35 @@ HiiStringToImage (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (ColumnInfoArray != NULL) {
|
if (ColumnInfoArray != NULL) {
|
||||||
if (GlyphBuf[Index1] == NULL) {
|
if ((GlyphBuf[Index1] == NULL && Cell[Index1].AdvanceX == 0)
|
||||||
*ColumnInfoArray = 0;
|
|| RowInfo[RowIndex].LineWidth == 0) {
|
||||||
|
*ColumnInfoArray = (UINTN) ~0;
|
||||||
} else {
|
} else {
|
||||||
*ColumnInfoArray = Cell[Index1 -1].AdvanceX;
|
*ColumnInfoArray = LineOffset + Cell[Index1].OffsetX + BltX;
|
||||||
}
|
}
|
||||||
ColumnInfoArray++;
|
ColumnInfoArray++;
|
||||||
}
|
}
|
||||||
}
|
LineOffset += Cell[Index1].AdvanceX;
|
||||||
//
|
|
||||||
// Jump to next row
|
|
||||||
//
|
|
||||||
BufferPtr += BltX + Image->Width * (LineHeight - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Index++;
|
//
|
||||||
|
// Jump to starting position of next row.
|
||||||
|
//
|
||||||
|
if (RowIndex == 0) {
|
||||||
|
BufferPtr = RowBufferPtr - BltX + LineHeight * Image->Width;
|
||||||
|
} else {
|
||||||
|
BufferPtr = RowBufferPtr + LineHeight * Image->Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Recalculate the start point of X/Y axis to draw multi-lines with the order of top-to-down
|
||||||
|
//
|
||||||
|
BltX = 0;
|
||||||
|
BltY += RowInfo[RowIndex].LineHeight;
|
||||||
|
|
||||||
RowIndex++;
|
RowIndex++;
|
||||||
|
Index = NextIndex;
|
||||||
|
|
||||||
if (!LineBreak) {
|
if (!LineBreak) {
|
||||||
//
|
//
|
||||||
@ -1988,12 +2139,16 @@ HiiStringToImage (
|
|||||||
//
|
//
|
||||||
RowInfoSize = RowIndex * sizeof (EFI_HII_ROW_INFO);
|
RowInfoSize = RowIndex * sizeof (EFI_HII_ROW_INFO);
|
||||||
if (RowInfoArray != NULL) {
|
if (RowInfoArray != NULL) {
|
||||||
|
if (RowInfoSize > 0) {
|
||||||
*RowInfoArray = AllocateZeroPool (RowInfoSize);
|
*RowInfoArray = AllocateZeroPool (RowInfoSize);
|
||||||
if (*RowInfoArray == NULL) {
|
if (*RowInfoArray == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
CopyMem (*RowInfoArray, RowInfo, RowInfoSize);
|
CopyMem (*RowInfoArray, RowInfo, RowInfoSize);
|
||||||
|
} else {
|
||||||
|
*RowInfoArray = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (RowInfoArraySize != NULL) {
|
if (RowInfoArraySize != NULL) {
|
||||||
*RowInfoArraySize = RowIndex;
|
*RowInfoArraySize = RowIndex;
|
||||||
@ -2354,6 +2509,7 @@ HiiGetGlyph (
|
|||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
||||||
|
UINT16 BaseLine;
|
||||||
|
|
||||||
if (This == NULL || Blt == NULL || *Blt != NULL) {
|
if (This == NULL || Blt == NULL || *Blt != NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -2414,6 +2570,7 @@ HiiGetGlyph (
|
|||||||
Image->Width = Cell.Width;
|
Image->Width = Cell.Width;
|
||||||
Image->Height = Cell.Height;
|
Image->Height = Cell.Height;
|
||||||
|
|
||||||
|
if (Image->Width * Image->Height > 0) {
|
||||||
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||||
if (Image->Image.Bitmap == NULL) {
|
if (Image->Image.Bitmap == NULL) {
|
||||||
FreePool (Image);
|
FreePool (Image);
|
||||||
@ -2421,18 +2578,28 @@ HiiGetGlyph (
|
|||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
BltBuffer = Image->Image.Bitmap;
|
//
|
||||||
|
// Set BaseLine to the char height.
|
||||||
|
//
|
||||||
|
BaseLine = (UINT16) (Cell.Height + Cell.OffsetY);
|
||||||
|
//
|
||||||
|
// Set BltBuffer to the position of Origin.
|
||||||
|
//
|
||||||
|
BltBuffer = Image->Image.Bitmap + (Cell.Height + Cell.OffsetY) * Image->Width - Cell.OffsetX;
|
||||||
GlyphToImage (
|
GlyphToImage (
|
||||||
GlyphBuffer,
|
GlyphBuffer,
|
||||||
Foreground,
|
Foreground,
|
||||||
Background,
|
Background,
|
||||||
Image->Width,
|
Image->Width,
|
||||||
Image->Height,
|
BaseLine,
|
||||||
|
Cell.Width + Cell.OffsetX,
|
||||||
|
BaseLine - Cell.OffsetY,
|
||||||
FALSE,
|
FALSE,
|
||||||
&Cell,
|
&Cell,
|
||||||
Attributes,
|
Attributes,
|
||||||
&BltBuffer
|
&BltBuffer
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
*Blt = Image;
|
*Blt = Image;
|
||||||
if (Baseline != NULL) {
|
if (Baseline != NULL) {
|
||||||
|
@ -158,6 +158,8 @@ typedef struct _HII_SIMPLE_FONT_PACKAGE_INSTANCE {
|
|||||||
typedef struct _HII_FONT_PACKAGE_INSTANCE {
|
typedef struct _HII_FONT_PACKAGE_INSTANCE {
|
||||||
UINTN Signature;
|
UINTN Signature;
|
||||||
EFI_HII_FONT_PACKAGE_HDR *FontPkgHdr;
|
EFI_HII_FONT_PACKAGE_HDR *FontPkgHdr;
|
||||||
|
UINT16 Height;
|
||||||
|
UINT16 BaseLine;
|
||||||
UINT8 *GlyphBlock;
|
UINT8 *GlyphBlock;
|
||||||
LIST_ENTRY FontEntry;
|
LIST_ENTRY FontEntry;
|
||||||
LIST_ENTRY GlyphInfoList;
|
LIST_ENTRY GlyphInfoList;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user