From dcb632153153e8ce319f84d1011cf08375c5c556 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Sun, 4 Sep 2022 18:00:39 +0200 Subject: [PATCH] Fixed android text bug and updated readme --- core/src/gui/style.cpp | 34 ++++++++++++++++++++++++---------- readme.md | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/core/src/gui/style.cpp b/core/src/gui/style.cpp index 58918230..5cfb8797 100644 --- a/core/src/gui/style.cpp +++ b/core/src/gui/style.cpp @@ -9,8 +9,9 @@ namespace style { ImFont* baseFont; ImFont* bigFont; ImFont* hugeFont; - ImVector ranges; - ImFontGlyphRangesBuilder builder; + ImVector baseRanges; + ImVector bigRanges; + ImVector hugeRanges; #ifndef __ANDROID__ float uiScale = 1.0f; @@ -19,21 +20,34 @@ namespace style { #endif bool loadFonts(std::string resDir) { + ImFontAtlas* fonts = ImGui::GetIO().Fonts; if (!std::filesystem::is_directory(resDir)) { spdlog::error("Invalid resource directory: {0}", resDir); return false; } - // Create font range - ImFontAtlas* fonts = ImGui::GetIO().Fonts; - builder.AddRanges(fonts->GetGlyphRangesDefault()); - builder.AddRanges(fonts->GetGlyphRangesCyrillic()); - builder.BuildRanges(&ranges); + // Create base font range + ImFontGlyphRangesBuilder baseBuilder; + baseBuilder.AddRanges(fonts->GetGlyphRangesDefault()); + baseBuilder.AddRanges(fonts->GetGlyphRangesCyrillic()); + baseBuilder.BuildRanges(&baseRanges); + + // Create big font range + ImFontGlyphRangesBuilder bigBuilder; + const ImWchar bigRange[] = { '.', '9', 0 }; + bigBuilder.AddRanges(bigRange); + bigBuilder.BuildRanges(&bigRanges); + + // Create huge font range + ImFontGlyphRangesBuilder hugeBuilder; + const ImWchar hugeRange[] = { 'S', 'S', 'D', 'D', 'R', 'R', '+', '+', ' ', ' ', 0 }; + hugeBuilder.AddRanges(hugeRange); + hugeBuilder.BuildRanges(&hugeRanges); // 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); + baseFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f * uiScale, NULL, baseRanges.Data); + bigFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 45.0f * uiScale, NULL, bigRanges.Data); + hugeFont = fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f * uiScale, NULL, hugeRanges.Data); return true; } diff --git a/readme.md b/readme.md index 72431012..9891c46f 100644 --- a/readme.md +++ b/readme.md @@ -354,6 +354,7 @@ Modules in beta are still included in releases for the most part but not enabled | frequency_manager | Working | - | OPT_BUILD_FREQUENCY_MANAGER | ✅ | ✅ | ✅ | | recorder | Working | - | OPT_BUILD_RECORDER | ✅ | ✅ | ✅ | | rigctl_server | Working | - | OPT_BUILD_RIGCTL_SERVER | ✅ | ✅ | ⛔ | +| scanner | Beta | - | OPT_BUILD_SCANNER | ✅ | ✅ | ✅ | # Troubleshooting