mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 03:43:15 +08:00
feat(fonts): add Cyrillic support
This commit is contained in:
@@ -117,6 +117,36 @@ namespace YimMenu
|
||||
style.GrabRounding = style.FrameRounding = style.ChildRounding = style.WindowRounding = 8.0f;
|
||||
}
|
||||
|
||||
static const ImWchar* GetGlyphRangesCyrillicOnly()
|
||||
{
|
||||
static const ImWchar ranges[] =
|
||||
{
|
||||
0x0400,
|
||||
0x052F, // Cyrillic + Cyrillic Supplement
|
||||
0x2DE0,
|
||||
0x2DFF, // Cyrillic Extended-A
|
||||
0xA640,
|
||||
0xA69F, // Cyrillic Extended-B
|
||||
0,
|
||||
};
|
||||
return &ranges[0];
|
||||
}
|
||||
|
||||
static ImFont* CreateFontWithCyrillicSupport(ImGuiIO& io, float size)
|
||||
{
|
||||
ImFontConfig FontCfg{};
|
||||
FontCfg.FontDataOwnedByAtlas = false;
|
||||
|
||||
auto font = io.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), size, &FontCfg, io.Fonts->GetGlyphRangesDefault());
|
||||
|
||||
// just use Arial for Cyrillic
|
||||
|
||||
FontCfg.MergeMode = true;
|
||||
io.Fonts->AddFontFromFileTTF((std::filesystem::path(std::getenv("SYSTEMROOT")) / "Fonts" / "arial.ttf").string().c_str(), size, &FontCfg, GetGlyphRangesCyrillicOnly());
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void Menu::SetupFonts()
|
||||
{
|
||||
auto& IO = ImGui::GetIO();
|
||||
@@ -127,11 +157,12 @@ namespace YimMenu
|
||||
ImFontConfig FontCfg{};
|
||||
FontCfg.FontDataOwnedByAtlas = false;
|
||||
|
||||
Menu::Font::g_DefaultFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_DefaultFontSize, &FontCfg);
|
||||
Menu::Font::g_OptionsFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_OptionsFontSize, &FontCfg);
|
||||
Menu::Font::g_ChildTitleFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_ChildTitleFontSize, &FontCfg);
|
||||
Menu::Font::g_ChatFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_ChatFontSize, &FontCfg);
|
||||
Menu::Font::g_OverlayFont = IO.Fonts->AddFontFromMemoryTTF(const_cast<std::uint8_t*>(Fonts::MainFont), sizeof(Fonts::MainFont), Menu::Font::g_OverlayFontSize, &FontCfg);
|
||||
IO.Fonts->Clear();
|
||||
Menu::Font::g_DefaultFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_DefaultFontSize);
|
||||
Menu::Font::g_OptionsFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_OptionsFontSize);
|
||||
Menu::Font::g_ChatFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_ChatFontSize);
|
||||
Menu::Font::g_OverlayFont = CreateFontWithCyrillicSupport(IO, Menu::Font::g_OverlayFontSize);
|
||||
IO.Fonts->Build();
|
||||
UIManager::SetOptionsFont(Menu::Font::g_OptionsFont);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user