diff --git a/resource/common/fonts/header.ttf b/resource/common/fonts/header.ttf deleted file mode 100644 index 468cbe0..0000000 Binary files a/resource/common/fonts/header.ttf and /dev/null differ diff --git a/resource/common/fonts/text.ttf b/resource/common/fonts/text.ttf index 3742457..6a25d04 100644 Binary files a/resource/common/fonts/text.ttf and b/resource/common/fonts/text.ttf differ diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 3fe8e3b..0d51795 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -78,7 +78,6 @@ void CheatMenu::ProcessPages() ImGuiStyle &style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - ImGui::PushFont(FontMgr::Get("header")); m_nMenuPage = Updater::IsUpdateAvailable() ? eMenuPages::UPDATE : m_nMenuPage; // Check once if it's anniversary day @@ -166,7 +165,6 @@ void CheatMenu::ProcessPages() ImGui::SameLine(); } } - ImGui::PopFont(); ImGui::PopStyleVar(); ImGui::Dummy(ImVec2(0, 10)); diff --git a/src/d3dhook.cpp b/src/d3dhook.cpp index 781a265..54ec201 100644 --- a/src/d3dhook.cpp +++ b/src/d3dhook.cpp @@ -139,9 +139,8 @@ void D3dHook::ProcessFrame(void* ptr) ImGui_ImplWin32_EnableDpiAwareness(); // Loading fonts - io.FontDefault = FontMgr::Load("text", 1.0f); + io.FontDefault = FontMgr::Load("text", 1.1f); FontMgr::Load("title", 2.0f); - FontMgr::Load("header", 1.25f); io.IniFilename = nullptr; io.LogFilename = nullptr; diff --git a/src/fontmgr.cpp b/src/fontmgr.cpp index bc3f3e3..52290a9 100644 --- a/src/fontmgr.cpp +++ b/src/fontmgr.cpp @@ -14,12 +14,37 @@ ImFont* FontMgr::Get(const char* fontName) return nullptr; } +const ImWchar* FontMgr::GetGlyphRanges() +{ + static const ImWchar ranges[] = + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x2000, 0x206F, // General Punctuation + + // Chinease + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF, // Half-width characters + 0xFFFD, 0xFFFD, // Invalid + 0x4e00, 0x9FAF, // CJK Ideograms + + // Russian + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement + 0x2DE0, 0x2DFF, // Cyrillic Extended-A + 0xA640, 0xA69F, // Cyrillic Extended-B + 0x2212, 0x2212, // Minus Sign + 0, + }; + return &ranges[0]; +} + ImFont* FontMgr::Load(const char* fontName, float fontMul) { ImGuiIO& io = ImGui::GetIO(); size_t fontSize = static_cast(screen::GetScreenHeight() / 54.85f) * fontMul; std::string fullPath = std::format("{}{}.ttf", PLUGIN_PATH((char*)FILE_NAME "/fonts/"), fontName); - ImFont *pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), fontSize); + ImFont *pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), fontSize, NULL, GetGlyphRanges()); m_vecFonts.push_back({pFont, fontSize, fontMul, std::string(fontName)}); io.Fonts->Build(); @@ -41,7 +66,7 @@ void FontMgr::ReloadAll() { size_t fontSize = static_cast(screen::GetScreenHeight() / 54.85f) * data.m_fMul; std::string fullPath = PLUGIN_PATH((char*)FILE_NAME "/fonts/") + data.m_path + ".ttf"; - data.m_pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), data.m_nSize); + data.m_pFont = io.Fonts->AddFontFromFileTTF(fullPath.c_str(), data.m_nSize, NULL, GetGlyphRanges()); } io.FontDefault = Get("text"); io.Fonts->Build(); diff --git a/src/fontmgr.h b/src/fontmgr.h index 6776352..0e776ef 100644 --- a/src/fontmgr.h +++ b/src/fontmgr.h @@ -26,6 +26,9 @@ public: // Loads a font into memory static ImFont* Load(const char* fontName, float fontMul = 1.0f); + // Get the glyph ranges for our needed fonts + static const ImWchar* GetGlyphRanges(); + // Unloads all the loaded fonts from fontmgr // ImGui::GetIO().Default font must be loaded after unloading all fonts static void UnloadAll(); diff --git a/src/menu.cpp b/src/menu.cpp index 75cac8e..eefb254 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -328,6 +328,7 @@ void Menu::ShowPage() { CheatMenu::ResetMenuSize(); } + ImGui::Spacing(); static int selected = Locale::GetCurrentLocaleIndex();