//code by luobing 2019-6-7 21:52:13
#include “HiiFont.h”
extern EFI_GRAPHICS_OUTPUT_PROTOCOL *gGraphicsOutput;
extern EFI_HII_FONT_PROTOCOL *gHiiFont;
//SimpleFont
extern EFI_WIDE_GLYPH gSimpleFontWideGlyphData[];
extern UINT32 gSimpleFontBytes;
static EFI_GUID gSimpleFontPackageListGuid = {0xf6643673, 0x6006, 0x3738, {0x5c, 0xcd, 0xda, 0x1a, 0xeb, 0x3b, 0x26, 0xa2}};
//Font
extern EFI_WIDE_GLYPH gDMFontWideGlyphData[];
extern UINT32 gDMFontBytes;
extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData[];
extern UINT32 mNarrowFontSize;
static EFI_GUID gDMFontPackageListGuid = {0xf6645673, 0x6106, 0x3138, {0x5c, 0xcd, 0xda, 0x1a, 0xab, 0x3b, 0x26, 0xa2}};
#define WfontWidth 16
#define WfontHight 19
CONST UINT16 WideGlyphBytes = WfontHight * WfontWidth / 8;
CONST UINT16 NrGlyphBytes = 19;
//============================== Hii Function begin==============================================
//ugly codes…
//������ע�Ẻ��simplefont�⣬������ʾ����
EFI_STATUS TestStrPackage(void)
{
EFI_STATUS Status = 0;
EFI_GUID mStrPackageGuid = { 0xedd31def, 0xf262, 0xc24e, 0xa2, 0xe4, 0xde, 0xf7, 0xde, 0xcd, 0xcd, 0xee };
EFI_HANDLE HiiHandle = HiiAddPackages (&mStrPackageGuid , gImageHandle, Luo3Strings, NULL);
Status=TestLanguage(HiiHandle);
Status=TestString(HiiHandle);
return Status;
}
//ugly codes…
EFI_STATUS TestLanguage(EFI_HANDLE HiiHandle)
{
EFI_STATUS Status = 0;
CHAR8 buf[256];
CHAR16 buf16[256];
UINTN LangSize = 256;
UINTN i = 0;
Status = gHiiString -> GetLanguages(
gHiiString,
HiiHandle,
buf,
&LangSize);
for(i =0; i< LangSize; i++){
buf16[i] = buf[i];
}
buf16[LangSize] = 0;
Print(L"Support Language: %s\n", buf16);
return Status;
}
//ugly codes…
EFI_STATUS TestString(EFI_HANDLE HiiHandle )
{
EFI_STATUS Status = 0;
//CHAR8* BestLanguage = “en-US”;
CHAR8* BestLanguage = “zh-Hans”;
EFI_STRING TempString = NULL;
UINTN StringSize = 0;
Status = gHiiString -> GetString (
gHiiString,
BestLanguage,
HiiHandle,
STRING_TOKEN (STR_LANGUAGE_SELECT),
TempString,
&StringSize,
NULL
);
//gBS->AllocatePool(EfiBootServicesData,0x100,(void**)&buffer);
if(Status == EFI_BUFFER_TOO_SMALL){
Status = gBS->AllocatePool (EfiBootServicesData,StringSize,(void**)&TempString);
if(EFI_ERROR(Status))
return 0;
Status = gHiiString -> GetString (
gHiiString,
BestLanguage,
HiiHandle,
STRING_TOKEN (STR_LANGUAGE_SELECT),
TempString,
&StringSize,
NULL
);
Print(L"%s\n", TempString);
gBS->FreePool(TempString);
}else{
Print(L"GetString %r\n", Status);
}
return 0;
}
//Name:
//Input:
//Output:
//Description:
EFI_STATUS LoadSimpleFont(void)
{
EFI_STATUS Status=0;
EFI_HII_HANDLE * handles = 0; //for simpleFont of Hii
handles = HiiGetHiiHandles(&gSimpleFontPackageListGuid);
if(handles == 0)
{
Status = CreatesimpleFontP