| 84 | *Height = ScaledHeight; |
| 85 | } |
| 86 | void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols) |
| 87 | { |
| 88 | EFI_STATUS Status = EFI_NOT_FOUND; |
| 89 | XImage NewImage; //tempopary image from file |
| 90 | |
| 91 | INTN ImageWidth, ImageHeight; |
| 92 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelPtr; |
| 93 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FontPtr; |
| 94 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL FirstPixel; |
| 95 | BOOLEAN isKorean = (gLanguage == korean); |
| 96 | XStringW fontFilePath; |
| 97 | const XStringW& commonFontDir = L"EFI\\CLOVER\\font"_XSW; |
| 98 | |
| 99 | if (IsEmbeddedTheme() && !isKorean) { //or initial screen before theme init |
| 100 | Status = NewImage.FromPNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data)); //always success |
| 101 | MsgLog("Using embedded font\n"); |
| 102 | } else if (isKorean){ |
| 103 | Status = NewImage.LoadXImage(ThemeDir, L"FontKorean.png"_XSW); |
| 104 | MsgLog("Loading korean font from ThemeDir: %s\n", efiStrError(Status)); |
| 105 | if (!EFI_ERROR(Status)) { |
| 106 | CharWidth = 22; //standard for korean |
| 107 | } else { |
| 108 | MsgLog("...using english\n"); |
| 109 | gLanguage = english; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | if (EFI_ERROR(Status)) { |
| 114 | //not loaded, use common |
| 115 | Rows = 16; //standard for english |
| 116 | Cols = 16; |
| 117 | Status = NewImage.LoadXImage(ThemeDir, FontFileName); |
| 118 | } |
| 119 | |
| 120 | if (EFI_ERROR(Status)) { |
| 121 | //then take from common font folder |
| 122 | // fontFilePath = SWPrintf(L"%s\\%s", commonFontDir, isKorean ? L"FontKorean.png" : ThemeX.FontFileName.data()); |
| 123 | fontFilePath = commonFontDir + FontFileName; |
| 124 | Status = NewImage.LoadXImage(SelfRootDir, fontFilePath); |
| 125 | //else use embedded even if it is not embedded |
| 126 | if (EFI_ERROR(Status)) { |
| 127 | Status = NewImage.FromPNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data)); |
| 128 | } |
| 129 | if (EFI_ERROR(Status)) { |
| 130 | MsgLog("No font found!\n"); |
| 131 | return; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | ImageWidth = NewImage.GetWidth(); |
| 136 | // DBG("ImageWidth=%lld\n", ImageWidth); |
| 137 | ImageHeight = NewImage.GetHeight(); |
| 138 | // DBG("ImageHeight=%lld\n", ImageHeight); |
| 139 | PixelPtr = NewImage.GetPixelPtr(0,0); |
| 140 | |
| 141 | FontImage.setSizeInPixels(ImageWidth * Rows, ImageHeight / Rows); |
| 142 | FontPtr = FontImage.GetPixelPtr(0,0); |
| 143 |
nothing calls this directly
no test coverage detected