From e7a9a619788bf5469b04cfd0f01dfde4461b2f14 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 24 Sep 2024 22:54:50 +0200 Subject: [PATCH] Fix enabling cjk glyphs --- base/sources/translator.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/base/sources/translator.ts b/base/sources/translator.ts index 7dbecd6d..39dd6786 100644 --- a/base/sources/translator.ts +++ b/base/sources/translator.ts @@ -87,14 +87,19 @@ function translator_load_translations(new_locale: string) { let keys: string[] = map_keys(translator_translations); for (let i: i32 = 0; i < keys.length; ++i) { let s: string = map_get(translator_translations, keys[i]); - for (let i: i32 = 0; i < s.length; ++i) { - // Assume cjk in the > 1119 range for now - if (char_code_at(s, i) > 1119 && array_index_of(_g2_font_glyphs, char_code_at(s, i)) == -1) { + + for (let i: i32 = 0; char_code_at(s, i) != 0; ) { + let l: i32 = 0; + let codepoint: i32 = string_utf8_decode((s) + i, ADDRESS(l)); + i += l; + + // Assume cjk in the > 1119 range + if (codepoint > 1119 && array_index_of(_g2_font_glyphs, codepoint) == -1) { if (!cjk) { _g2_font_glyphs = _g2_make_glyphs(32, 127); cjk = true; } - array_push(_g2_font_glyphs, char_code_at(s, i)); + array_push(_g2_font_glyphs, codepoint); } } }