summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-01 06:40:17 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-01 06:40:17 +0000
commitfbf82a2cf22e0073b3a221629562184b129925ac (patch)
treee9870d4c01d96eede9ff325772123ea55e263358 /MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
parent1261fe23ca7dba7d4ba28b858329920dbd96f46b (diff)
downloadedk2-platforms-fbf82a2cf22e0073b3a221629562184b129925ac.tar.xz
Fixes two issues in HiiFontProtocol->StringToImage() implementation on how to show string with wrap flag.
Signed-off-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12064 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/HiiDatabaseDxe/Font.c')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Font.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
index ba937d2bfd..4d2fcc081b 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -1917,7 +1917,7 @@ HiiStringToImage (
// When EFI_HII_OUT_FLAG_CLEAN_X is set, it will not draw a character
// if its right-most on pixel cannot fit.
//
- if (Index > 0) {
+ if (Index > RowInfo[RowIndex].StartIndex) {
//
// Don't draw the last char on this row. And, don't draw the second last char (AdvanceX - Width - OffsetX).
//
@@ -1929,10 +1929,11 @@ HiiStringToImage (
RowInfo[RowIndex].BaselineOffset = BaseLineOffset;
} else {
//
- // There is only one column and it can not be drawn so that return directly.
+ // 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.
//
- Status = EFI_SUCCESS;
- goto Exit;
+ RowInfo[RowIndex].LineWidth = 0;
+ goto NextLine;
}
}
@@ -1941,7 +1942,9 @@ HiiStringToImage (
// opportunity prior to a character whose right-most extent would exceed Width.
// Search the right-most line-break opportunity here.
//
- if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP && StringPtr[NextIndex] != 0 && !LineBreak) {
+ if ((Flags & EFI_HII_OUT_FLAG_WRAP) == EFI_HII_OUT_FLAG_WRAP &&
+ (RowInfo[RowIndex].LineWidth + BltX > Image->Width || StringPtr[NextIndex] != 0) &&
+ !LineBreak) {
if ((Flags & EFI_HII_IGNORE_LINE_BREAK) == 0) {
LineWidth = RowInfo[RowIndex].LineWidth;
for (Index1 = RowInfo[RowIndex].EndIndex; Index1 >= RowInfo[RowIndex].StartIndex; Index1--) {
@@ -1986,8 +1989,26 @@ HiiStringToImage (
// behave as if EFI_HII_OUT_FLAG_CLEAN_X is set.
//
if (!LineBreak) {
- Flags &= (~ (EFI_HII_OUT_FLAGS) EFI_HII_OUT_FLAG_WRAP);
- Flags |= EFI_HII_OUT_FLAG_CLIP_CLEAN_X;
+ 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).
+ //
+ LineWidth -= (UINTN) (Cell[Index1].Width + Cell[Index1].OffsetX);
+ LineWidth -= (UINTN) (Cell[Index1 - 1].AdvanceX - Cell[Index1 - 1].Width - Cell[Index1 - 1].OffsetX);
+ 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;
+ }
+ }
}
}
@@ -2117,6 +2138,7 @@ HiiStringToImage (
}
}
+NextLine:
//
// Recalculate the start point of X/Y axis to draw multi-lines with the order of top-to-down
//