From 275e11f9859a45ce6d20dd8a5621ab463c148622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc=20Serf=C5=91z=C5=91?= Date: Fri, 14 Jun 2024 15:48:18 +0200 Subject: [PATCH] fix: Load full font glyph range --- src/ResourceLoader.cpp | 79 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index c25e61b..63a4f37 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -14,6 +14,82 @@ bool ImGui_ImplSDLRenderer2_CreateFontsTexture(); namespace mc { +namespace +{ + +constexpr ImWchar droid_sans_glyph_ranges[]{ + // clang-format off + 0x20, 0x7e, + 0xa0, 0x17f, + 0x192, 0x192, + 0x1a0, 0x1a1, + 0x1af, 0x1b0, + 0x1f0, 0x1f0, + 0x1fa, 0x1ff, + 0x218, 0x21b, + 0x2bc, 0x2bc, + 0x2c6, 0x2c7, + 0x2c9, 0x2c9, + 0x2d8, 0x2dd, + 0x2f3, 0x2f3, + 0x300, 0x301, + 0x303, 0x303, + 0x309, 0x309, + 0x30f, 0x30f, + 0x323, 0x323, + 0x384, 0x38a, + 0x38c, 0x38c, + 0x38e, 0x3a1, + 0x3a3, 0x3ce, + 0x3d1, 0x3d2, + 0x3d6, 0x3d6, + 0x400, 0x486, + 0x488, 0x513, + 0x1e00, 0x1e01, + 0x1e3e, 0x1e3f, + 0x1e80, 0x1e85, + 0x1ea0, 0x1ef9, + 0x1f4d, 0x1f4d, + 0x2000, 0x200b, + 0x2013, 0x2015, + 0x2017, 0x201e, + 0x2020, 0x2022, + 0x2026, 0x2026, + 0x2030, 0x2030, + 0x2032, 0x2033, + 0x2039, 0x203a, + 0x203c, 0x203c, + 0x2044, 0x2044, + 0x207f, 0x207f, + 0x20a3, 0x20a4, + 0x20a7, 0x20a7, + 0x20ab, 0x20ac, + 0x2105, 0x2105, + 0x2113, 0x2113, + 0x2116, 0x2116, + 0x2122, 0x2122, + 0x2126, 0x2126, + 0x212e, 0x212e, + 0x215b, 0x215e, + 0x2202, 0x2202, + 0x2206, 0x2206, + 0x220f, 0x220f, + 0x2211, 0x2212, + 0x221a, 0x221a, + 0x221e, 0x221e, + 0x222b, 0x222b, + 0x2248, 0x2248, + 0x2260, 0x2260, + 0x2264, 0x2265, + 0x25ca, 0x25ca, + 0xfb01, 0xfb04, + 0xfeff, 0xfeff, + 0xfffc, 0xfffd, + 0 + // clang-format on +}; + +} Texture::~Texture() { @@ -88,7 +164,8 @@ void ResourceLoader::load_fonts(const float scale) io.Fonts->AddFontFromMemoryTTF(const_cast(font_file.begin()), std::distance(font_file.begin(), font_file.end()), 16 * scale, - &font_config); + &font_config, + droid_sans_glyph_ranges); const auto icons_file = embedded_fs.open("fonts/forkawesome-webfont.ttf"); const ImWchar icons_ranges[] = {ICON_MIN_FK, ICON_MAX_16_FK, 0};