From 04e54a2d579f8a4e325508f30878db57b7015d5c Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 14 Feb 2022 20:35:39 +0100 Subject: [PATCH] Partial unicode support (the proper way), only cyrillic at the moment --- core/src/gui/style.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/gui/style.cpp b/core/src/gui/style.cpp index 75da7a18..c796dc65 100644 --- a/core/src/gui/style.cpp +++ b/core/src/gui/style.cpp @@ -10,6 +10,8 @@ namespace style { ImFont* baseFont; ImFont* bigFont; ImFont* hugeFont; + ImVector ranges; + ImFontGlyphRangesBuilder builder; #ifndef __ANDROID__ float uiScale = 1.0f; @@ -23,9 +25,16 @@ namespace style { return false; } - baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f * uiScale); - bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 45.0f * uiScale); - hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f * uiScale); + // Create font range + ImFontAtlas* fonts = ImGui::GetIO().Fonts; + builder.AddRanges(fonts->GetGlyphRangesDefault()); + builder.AddRanges(fonts->GetGlyphRangesCyrillic()); + builder.BuildRanges(&ranges); + + // Add bigger fonts for frequency select and title + baseFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f * uiScale, NULL, ranges.Data); + bigFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 45.0f * uiScale); + hugeFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f * uiScale); return true; }