diff --git a/modules/text_server_adv/script_iterator.cpp b/modules/text_server_adv/script_iterator.cpp index b03231b2395..41ef6f1349a 100644 --- a/modules/text_server_adv/script_iterator.cpp +++ b/modules/text_server_adv/script_iterator.cpp @@ -32,17 +32,21 @@ // This implementation is derived from ICU: icu4c/source/extra/scrptrun/scrptrun.cpp +inline constexpr UChar32 ZERO_WIDTH_JOINER = 0x200d; +inline constexpr UChar32 VARIATION_SELECTOR_15 = 0xfe0e; +inline constexpr UChar32 VARIATION_SELECTOR_16 = 0xfe0f; + inline bool ScriptIterator::same_script(int32_t p_script_one, int32_t p_script_two) { return p_script_one <= USCRIPT_INHERITED || p_script_two <= USCRIPT_INHERITED || p_script_one == p_script_two; } inline bool ScriptIterator::is_emoji(UChar32 p_c, UChar32 p_next) { - if (p_next == 0xFE0E) { // Variation Selector-15 + if (p_next == VARIATION_SELECTOR_15 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) { return false; - } else if (p_next == 0xFE0F) { // Variation Selector-16 + } else if (p_next == VARIATION_SELECTOR_16 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) { return true; } else { - return u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_PRESENTATION) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_MODIFIER) || u_hasBinaryProperty(p_c, UCHAR_REGIONAL_INDICATOR) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC); + return u_hasBinaryProperty(p_c, UCHAR_EMOJI_PRESENTATION) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_MODIFIER) || u_hasBinaryProperty(p_c, UCHAR_REGIONAL_INDICATOR); } } @@ -119,8 +123,7 @@ ScriptIterator::ScriptIterator(const String &p_string, int p_start, int p_length } if (script_code == USCRIPT_SYMBOLS_EMOJI && script_code != sc) { - UCharCategory cat = (UCharCategory)u_charType(ch); - if ((cat >= U_SPACE_SEPARATOR && cat <= U_CONTROL_CHAR) || (cat >= U_DASH_PUNCTUATION && cat <= U_OTHER_PUNCTUATION) || (cat >= U_INITIAL_PUNCTUATION && cat <= U_FINAL_PUNCTUATION)) { + if (ch == VARIATION_SELECTOR_15 || n == VARIATION_SELECTOR_15 || !(is_emoji(ch, n) || ch == ZERO_WIDTH_JOINER || ch == VARIATION_SELECTOR_16 || u_hasBinaryProperty(ch, UCHAR_EXTENDED_PICTOGRAPHIC))) { break; } } else if (same_script(script_code, sc)) { diff --git a/thirdparty/icu4c/godot_data.json b/thirdparty/icu4c/godot_data.json index e36e2b078b5..645be125df7 100644 --- a/thirdparty/icu4c/godot_data.json +++ b/thirdparty/icu4c/godot_data.json @@ -7,5 +7,7 @@ misc: include normalization: include confusables: include + uemoji: include + uprops: include } } diff --git a/thirdparty/icu4c/icudt_godot.dat b/thirdparty/icu4c/icudt_godot.dat index c6b96c477b3..16fe24004b5 100644 Binary files a/thirdparty/icu4c/icudt_godot.dat and b/thirdparty/icu4c/icudt_godot.dat differ