diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index ecb20c6cb..cb9c2eb0a 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -191,14 +191,14 @@ void gui_init() case 950: // Traditional Chinese { font_cfg.FontNo = 1; // Microsoft JhengHei UI Regular - ImFont* font = io.Fonts->AddFontFromFileTTF((fontDir + "Msjh.ttc").c_str(), 17.f * scaling, &font_cfg, io.Fonts->GetGlyphRangesChineseFull()); + ImFont* font = io.Fonts->AddFontFromFileTTF((fontDir + "Msjh.ttc").c_str(), 17.f * scaling, &font_cfg, GetGlyphRangesChineseTraditionalOfficial()); font_cfg.FontNo = 0; if (font == nullptr) - io.Fonts->AddFontFromFileTTF((fontDir + "MSJH.ttf").c_str(), 17.f * scaling, &font_cfg, io.Fonts->GetGlyphRangesChineseFull()); + io.Fonts->AddFontFromFileTTF((fontDir + "MSJH.ttf").c_str(), 17.f * scaling, &font_cfg, GetGlyphRangesChineseTraditionalOfficial()); } break; case 936: // Simplified Chinese - io.Fonts->AddFontFromFileTTF((fontDir + "Simsun.ttc").c_str(), 17.f * scaling, &font_cfg, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); + io.Fonts->AddFontFromFileTTF((fontDir + "Simsun.ttc").c_str(), 17.f * scaling, &font_cfg, GetGlyphRangesChineseSimplifiedOfficial()); break; default: break; diff --git a/core/rend/gui_util.cpp b/core/rend/gui_util.cpp index c161772ea..e4959fb9e 100644 --- a/core/rend/gui_util.cpp +++ b/core/rend/gui_util.cpp @@ -292,3 +292,252 @@ void ScrollWhenDraggingOnVoid(const ImVec2& delta, ImGuiMouseButton mouse_button if (held && delta.y != 0.0f) ImGui::SetScrollY(window, window->Scroll.y + delta.y); } + +static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) +{ + for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) + { + out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]); + base_codepoint += accumulative_offsets[n]; + } + out_ranges[0] = 0; +} + +const ImWchar* GetGlyphRangesChineseSimplifiedOfficial() +{ + // Store all official characters for Simplified Chinese. + // Sourced from https://en.wikipedia.org/wiki/Table_of_General_Standard_Chinese_Characters + // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) + static const short accumulative_offsets_from_0x4E00[] = + { + 0,1,2,4,1,1,1,1,2,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,4,2,1,2,3,1,2,3,2,2,4,1,1,1,2,1,4,1,2,3,1,2,1,1,1,1,1,2,1,1,2,2,1,3,1,1,1,1,1,5,3,7,1,2,5,6, + 8,2,1,2,1,1,1,1,2,1,1,1,1,3,2,1,4,2,1,2,1,1,1,1,1,2,1,1,1,4,1,2,1,2,1,1,5,1,1,1,1,1,1,1,1,2,1,1,2,1,3,2,1,1,1,1,1,1,4,1,1,2,2,1,1,3,2,1,1, + 4,2,1,2,1,1,4,2,2,2,7,1,1,1,2,1,1,1,1,6,1,1,1,1,3,1,1,2,1,1,1,1,1,3,1,2,2,1,2,2,2,2,2,2,1,1,3,2,3,7,1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,3,1, + 1,4,3,3,1,3,1,2,2,2,1,1,1,1,1,2,1,1,1,4,1,2,2,2,2,3,3,1,3,2,3,3,2,1,1,1,1,1,2,2,1,5,1,4,6,4,1,1,5,3,1,1,1,1,6,1,1,1,2,1,1,1,2,2,3,2,1,1,1, + 2,1,1,2,2,2,1,2,2,4,14,1,2,3,1,1,1,3,1,1,2,2,1,2,4,1,1,1,1,1,2,1,1,6,6,1,1,2,3,2,4,1,4,2,1,4,2,5,2,5,4,7,1,3,2,4,1,4,3,1,1,3,2,3,1,4,5,3, + 14,2,2,1,1,3,6,8,1,12,7,1,5,2,4,12,1,5,1,1,2,3,2,6,11,1,4,7,15,5,13,1,11,1,1,2,1,1,1,2,1,2,2,4,3,1,1,4,2,6,3,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,5,1,1,2,2,4,1,1,1,2,6,1,2,3,2,5,9,1,4,5,2,2,10,2,2,6,5,7,3,1,5,7,4,12,3,4,1,4,1,5,1,1,1,1, + 1,1,1,1,2,2,2,2,3,296,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,315,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,10,1,1,2,5,1,3,6,1,1,3,7, + 2,7,18,1,2,2,1,6,3,2,4,1,1,2,3,4,3,1,1,2,1,1,1,3,2,2,1,5,10,2,1,2,13,2,1,2,2,1,4,2,7,2,7,2,1,3,2,6,2,2,2,1,3,6,2,7,1,46,1,1,1,1,1,1,1,1,1, + 1,1,1,1,13,1,1,4,1,2,43,1,1 + }; + static ImWchar base_ranges[] = // not zero-terminated + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF // Half-width characters + }; + static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; + if (!full_ranges[0]) + { + memcpy(full_ranges, base_ranges, sizeof(base_ranges)); + UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); + } + return &full_ranges[0]; +} + +const ImWchar* GetGlyphRangesChineseTraditionalOfficial() +{ + // Store all official characters for Traditional Chinese. + // Sourced from https://https://en.wikipedia.org/wiki/List_of_Graphemes_of_Commonly-Used_Chinese_Characters + // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) + static const short accumulative_offsets_from_0x4E00[] = + { + 0,1,2,5,1,1,1,2,3,1,3,1,1,2,1,5,1,3,4,5,2,5,6,1,2,8,2,6,2,1,1,3,1,3,2,1,4,1,1,10,10,11,4,4,2,3,1,2,3,1,2,1,4,2,3,1,2,3,1,1,2,3,1,1,1,12,6,1, + 2,1,2,1,3,1,2,7,1,1,1,1,1,5,1,4,1,1,11,2,1,3,5,1,1,2,2,8,1,3,2,1,1,4,4,22,1,4,2,2,2,2,1,6,3,1,1,5,1,1,1,1,3,1,2,2,2,1,1,1,2,3,6,3,3,1,3,2,6, + 4,4,3,2,3,2,2,7,5,2,17,1,6,1,9,3,1,1,6,4,1,1,1,6,1,2,3,1,1,1,1,13,1,4,5,2,4,2,6,3,2,1,1,2,2,1,2,2,2,1,1,5,2,2,2,1,2,1,1,1,2,9,6,7,4,2,3,2,1, + 6,5,2,9,15,1,1,1,6,3,5,8,4,5,2,1,9,10,1,5,1,2,2,4,3,7,10,2,4,1,4,9,2,2,7,3,4,4,2,5,2,2,4,1,7,2,2,4,7,2,9,8,5,5,4,1,2,1,1,1,1,1,1,2,1,1,4,1,2, + 1,2,5,6,3,2,1,1,2,1,1,1,3,4,1,1,1,4,4,9,1,3,4,1,3,11,2,2,1,7,4,6,1,6,9,5,1,1,15,1,3,1,15,1,2,3,2,1,1,3,3,1,2,3,1,1,2,4,3,1,5,6,7,4,1,1,1,3,2, +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,13,1,14,3,13,2,10,1,1,1,248,9,2,1,6,2,4,2,1,1,1,4,9,2,1,1,3,1,4,4,1,9,11,2,2,1,1,4,4,2,6,5,1,58,5,9,4, + 3,1,9,4,1,4,7,1,1,3,11,1,5,1,1,1,6,6,2,1,2,1,1,1,5,8,1,4,1,2,1,6,1,3,1,2,1,11,1,2,7,3,4,3,5,1,3,1,1,1,2,2,1,1,8,1,3,2,1,2,4,1,5,2,5,3,4,1,2, + 2,5,4,2,1,2,4,1,1,2,2,3,6,2,9,3,8,6,1,4,1,4,2,4,10,4,5,1,2,2,1,1,4,2,1,4,7,2,6,9,6,2,2,9,8,3,3,7,20,2,3,5,1,7,9,17,6,2,1,5,4,2,1,1,2,1,2,4, + 4,1,1,1,4,1,9,3,9,3,7,1,1,2,11,6,1,1,1,9,3,3,9,4,4,1,1,55,7,2,2,3,4,2,8,23,4,3,5,2,1,3,2,3,2,8,1,1,5,2,4,1,2,4,2,1,5,3,3,3,7,13,8,1,1,6,12, + 1,10,2,56,3,12,3,4,1,1,3,2,1,13,15,1,1,3,4,2,2,2,3,11,4,14,2,13,8,3,18,5,7,7,2,3,2,16,2,3,1,4,3,3,5,62,7,1,7,1,4,19,3,1,1,4,14,7,1,1,12,8,3, + 7,13,8,3,2,1,9,11,5,1,2,1,10,5,4,2,21,8,26,26,3,27,1,30,21,16,6,18,8,4,10,3,22,2,1,32,1,109,4,10,1,2,16,3,12,6,8,3,2,19,4,18,12,3,1,9,2,6, + 23,38,5,14,17,4,14,20,1,32,4,87,4,3,1,2,12,7,1,4,6,2,6,4,1,10,7,1,1,1,5,10,1,1,2,3,4,3,1,1,1,2,8,7,5,3,16,1,6,5,2,4,7,12,8,7,3,12,1,7,13,2, + 2,3,4,2,6,5,22,3,4,8, + }; + static ImWchar base_ranges[] = // not zero-terminated + { + 0x0020, 0x00FF, // Basic Latin + Latin Supplement + 0x2000, 0x206F, // General Punctuation + 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana + 0x31F0, 0x31FF, // Katakana Phonetic Extensions + 0xFF00, 0xFFEF // Half-width characters + }; + static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; + if (!full_ranges[0]) + { + memcpy(full_ranges, base_ranges, sizeof(base_ranges)); + UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); + } + return &full_ranges[0]; +} diff --git a/core/rend/gui_util.h b/core/rend/gui_util.h index 1bcbf7e15..d35a4bc02 100644 --- a/core/rend/gui_util.h +++ b/core/rend/gui_util.h @@ -65,3 +65,6 @@ static inline void ImGui_impl_RenderDrawData(ImDrawData *draw_data, bool save_ba } void ScrollWhenDraggingOnVoid(const ImVec2& delta, ImGuiMouseButton mouse_button); + +IMGUI_API const ImWchar* GetGlyphRangesChineseSimplifiedOfficial();// Default + Half-Width + Japanese Hiragana/Katakana + set of 7800 CJK Unified Ideographs from General Standard Chinese Characters +IMGUI_API const ImWchar* GetGlyphRangesChineseTraditionalOfficial();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs from Hong Kong's List of Graphemes of Commonly-Used Chinese Characters