MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / InitializeFonts

Method InitializeFonts

KBotExt/DirectX.cpp:199–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void Direct3D11Render::InitializeFonts()
200{
201 const ImGuiIO& io = ImGui::GetIO();
202 (void)io;
203
204 static constexpr ImWchar ranges[] = { 0x1, 0x1FFFF, 0 };
205 static ImFontConfig cfg;
206 cfg.OversampleH = cfg.OversampleV = 1;
207
208 io.Fonts->AddFontDefault(&cfg);
209
210 cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_LoadColor;
211 cfg.MergeMode = true;
212
213 using tSHGetFolderPathW = HRESULT(WINAPI*)(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
214 const auto SHGetFolderPathW = reinterpret_cast<tSHGetFolderPathW>(GetProcAddress(LoadLibraryW(L"shell32.dll"), "SHGetFolderPathW"));
215
216 TCHAR szPath[MAX_PATH];
217 if (SUCCEEDED(SHGetFolderPathW(NULL, 0x0024/*CSIDL_WINDOWS*/, NULL, 0, szPath)))
218 {
219 std::filesystem::path fontsPath(szPath);
220 fontsPath = fontsPath / "Fonts";
221
222 if (is_directory(fontsPath))
223 {
224 for (const std::vector<std::string> fonts = {
225 "seguiemj.ttf", // emojis
226 "segoeuib.ttf", // cyrillic
227 "malgunbd.ttf", // korean
228 "YuGothB.ttc", // japanese
229 "simsun.ttc", // simplified chinese
230 "msjh.ttc", // traditional chinese
231 "seguisym.ttf", // symbols
232 }; const auto & f : fonts)
233 {
234 if (const std::filesystem::path path = fontsPath / f; exists(path))
235 {
236 io.Fonts->AddFontFromFileTTF(path.string().c_str(), 13.0f, &cfg, ranges);
237 }
238 }
239 }
240 }
241}
242
243void Direct3D11Render::MenuInit()
244{

Callers

nothing calls this directly

Calls 3

AddFontDefaultMethod · 0.80
AddFontFromFileTTFMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected