OpenCanopy: Draw label text at (2,2) to match Apple bless

This commit is contained in:
Marvin Häuser 2021-03-27 00:02:29 +01:00
parent 52cd37f23a
commit 017175ab92
4 changed files with 27 additions and 9 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -487,7 +487,8 @@ InternalContextConstruct (
FontImage,
FontImageSize,
FontData,
FontDataSize
FontDataSize,
Context->Scale
);
if (Context->FontContext.BmfContext.Height != BOOT_ENTRY_LABEL_HEIGHT * Context->Scale) {
DEBUG((

View File

@ -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;