diff --git a/src/hello_imgui/hello_imgui_font.h b/src/hello_imgui/hello_imgui_font.h index bd3df407..0e9ed949 100644 --- a/src/hello_imgui/hello_imgui_font.h +++ b/src/hello_imgui/hello_imgui_font.h @@ -8,9 +8,13 @@ namespace HelloImGui { using ImWcharPair = std::array; - // Utility to translate DearImGui common Unicode ranges to ImWcharPair - // (GetGlyphRangesJapanese, GetGlyphRangesChinese, GetGlyphRangesCyrillic, ...) - std::vector TranslateCommonGlyphRanges(const std::vector & glyphRanges); + // Utility to translate DearImGui common Unicode ranges to ImWcharPair (Python) + // (get_glyph_ranges_chinese_simplified_common, get_glyph_ranges_japanese, ...) + std::vector translate_common_glyph_ranges(const std::vector & glyphRanges); + + // Utility to translate DearImGui common Unicode ranges to ImWcharPair (C++) + // (GetGlyphRangesChineseSimplifiedCommon, GetGlyphRangesJapanese, ...) + std::vector TranslateCommonGlyphRanges(const ImWchar* glyphRanges); // @@md#Fonts diff --git a/src/hello_imgui/impl/hello_imgui_font.cpp b/src/hello_imgui/impl/hello_imgui_font.cpp index e7c2bfe1..039e4463 100644 --- a/src/hello_imgui/impl/hello_imgui_font.cpp +++ b/src/hello_imgui/impl/hello_imgui_font.cpp @@ -328,9 +328,20 @@ namespace HelloImGui return HelloImGui::gDidCallHelloImGuiLoadFontTTF; } - // Utility to translate DearImGui common Unicode ranges to ImWcharPair - // (GetGlyphRangesJapanese, GetGlyphRangesChinese, GetGlyphRangesCyrillic, ...) - std::vector TranslateCommonGlyphRanges(const std::vector & glyphRanges) + std::vector TranslateCommonGlyphRanges(const ImWchar* glyphRanges) + { + std::vector glyphRangesPairs; + size_t idx = 0; + while (glyphRanges[idx] != 0) + { + ImWcharPair glyphRangePair = {glyphRanges[idx], glyphRanges[idx + 1]}; + glyphRangesPairs.push_back(glyphRangePair); + idx += 2; + } + return glyphRangesPairs; + } + + std::vector translate_common_glyph_ranges(const std::vector & glyphRanges) { std::vector glyphRangesPairs; for (size_t i = 0; i < glyphRanges.size(); i += 2)