diff --git a/Platform/OpenCanopy/BitmapFont.c b/Platform/OpenCanopy/BitmapFont.c index 1d048fbc..df9ab4a3 100644 --- a/Platform/OpenCanopy/BitmapFont.c +++ b/Platform/OpenCanopy/BitmapFont.c @@ -490,7 +490,8 @@ BmfGetTextInfo ( IN CONST BMF_CONTEXT *Context, IN CONST CHAR16 *String, IN UINTN StringLen, - IN UINTN MaxWidth + IN UINT8 PosX, + IN UINT8 PosY ) { BOOLEAN Result; @@ -512,6 +513,11 @@ BmfGetTextInfo ( return NULL; } + if (PosY < Context->OffsetY) { + DEBUG ((DEBUG_WARN, "BMF: Font has invalid minimum y offset.\n")); + return NULL; + } + ASSERT (String[0] != 0); Char = BmfGetChar (Context, String[0]); @@ -532,7 +538,7 @@ BmfGetTextInfo ( InfoPairs = (CONST BMF_KERNING_PAIR **)&TextInfo->Chars[StringLen]; TextInfo->Chars[0] = Char; - Width = Char->xadvance; + Width = PosX + Char->xadvance; for (Index = 1; Index < StringLen; ++Index) { ASSERT (String[Index] != 0); @@ -573,7 +579,7 @@ BmfGetTextInfo ( TextInfo->Width = (UINT16)Width; TextInfo->Height = Context->Height; - TextInfo->OffsetY = Context->OffsetY; + TextInfo->OffsetY = PosY; return TextInfo; } @@ -634,7 +640,13 @@ GuiGetLabel ( ASSERT (Context != NULL); ASSERT (String != NULL); - TextInfo = BmfGetTextInfo (&Context->BmfContext, String, StringLen, 0); + TextInfo = BmfGetTextInfo ( + &Context->BmfContext, + String, + StringLen, + 2 * Context->Scale, + 2 * Context->Scale + ); if (TextInfo == NULL) { DEBUG ((DEBUG_WARN, "BMF: GetTextInfo failed\n")); return FALSE; @@ -648,7 +660,7 @@ GuiGetLabel ( } InfoPairs = (CONST BMF_KERNING_PAIR **)&TextInfo->Chars[StringLen]; - TargetCharX = 0; + TargetCharX = 2 * Context->Scale; InitialCharX = -TextInfo->Chars[0]->xoffset; InitialWidthOffset = TextInfo->Chars[0]->xoffset; @@ -706,7 +718,8 @@ GuiFontConstruct ( IN VOID *FontImage, IN UINTN FontImageSize, IN VOID *FileBuffer, - IN UINT32 FileSize + IN UINT32 FileSize, + IN UINT8 Scale ) { EFI_STATUS Status; @@ -740,6 +753,8 @@ GuiFontConstruct ( return FALSE; } + Context->Scale = Scale; + // TODO: check file size return TRUE; } diff --git a/Platform/OpenCanopy/BmfLib.h b/Platform/OpenCanopy/BmfLib.h index 789adff4..f88a0e93 100644 --- a/Platform/OpenCanopy/BmfLib.h +++ b/Platform/OpenCanopy/BmfLib.h @@ -27,6 +27,7 @@ typedef struct { GUI_IMAGE FontImage; BMF_CONTEXT BmfContext; VOID *KerningData; + UINT8 Scale; } GUI_FONT_CONTEXT; BOOLEAN @@ -35,7 +36,8 @@ GuiFontConstruct ( IN VOID *FontImage, IN UINTN FontImageSize, IN VOID *FileBuffer, - IN UINT32 FileSize + IN UINT32 FileSize, + IN UINT8 Scale ); VOID diff --git a/Platform/OpenCanopy/GuiApp.c b/Platform/OpenCanopy/GuiApp.c index e33ce7f4..6720d125 100644 --- a/Platform/OpenCanopy/GuiApp.c +++ b/Platform/OpenCanopy/GuiApp.c @@ -487,7 +487,8 @@ InternalContextConstruct ( FontImage, FontImageSize, FontData, - FontDataSize + FontDataSize, + Context->Scale ); if (Context->FontContext.BmfContext.Height != BOOT_ENTRY_LABEL_HEIGHT * Context->Scale) { DEBUG(( diff --git a/Utilities/TestBmf/Bmf.c b/Utilities/TestBmf/Bmf.c index fc521f6d..51613a6a 100644 --- a/Utilities/TestBmf/Bmf.c +++ b/Utilities/TestBmf/Bmf.c @@ -69,7 +69,7 @@ int main (int argc, char** argv) FontImage = UserReadFile (argv[1], &FontImageSize); FontMetrics = UserReadFile (argv[2], &FontMetricsSize); - Result = GuiFontConstruct (&Context, FontImage, FontImageSize, FontMetrics, FontMetricsSize); + Result = GuiFontConstruct (&Context, FontImage, FontImageSize, FontMetrics, FontMetricsSize, 1); if (!Result) { DEBUG ((DEBUG_WARN, "BMF: Helvetica failed\n")); return -1;