Skip to content

Commit 2cc031f

Browse files
committed
Merge pull request godotengine#112636 from bruvzg/emvar_n_dt
[TextServer] Fix some emoji sequences and add missing ICU emoji property data.
2 parents 5328a65 + e4ba8c5 commit 2cc031f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

modules/text_server_adv/script_iterator.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@
3232

3333
// This implementation is derived from ICU: icu4c/source/extra/scrptrun/scrptrun.cpp
3434

35+
inline constexpr UChar32 ZERO_WIDTH_JOINER = 0x200d;
36+
inline constexpr UChar32 VARIATION_SELECTOR_15 = 0xfe0e;
37+
inline constexpr UChar32 VARIATION_SELECTOR_16 = 0xfe0f;
38+
3539
inline bool ScriptIterator::same_script(int32_t p_script_one, int32_t p_script_two) {
3640
return p_script_one <= USCRIPT_INHERITED || p_script_two <= USCRIPT_INHERITED || p_script_one == p_script_two;
3741
}
3842

3943
inline bool ScriptIterator::is_emoji(UChar32 p_c, UChar32 p_next) {
40-
if (p_next == 0xFE0E) { // Variation Selector-15
44+
if (p_next == VARIATION_SELECTOR_15 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) {
4145
return false;
42-
} else if (p_next == 0xFE0F) { // Variation Selector-16
46+
} else if (p_next == VARIATION_SELECTOR_16 && (u_hasBinaryProperty(p_c, UCHAR_EMOJI) || u_hasBinaryProperty(p_c, UCHAR_EXTENDED_PICTOGRAPHIC))) {
4347
return true;
4448
} else {
45-
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);
49+
return u_hasBinaryProperty(p_c, UCHAR_EMOJI_PRESENTATION) || u_hasBinaryProperty(p_c, UCHAR_EMOJI_MODIFIER) || u_hasBinaryProperty(p_c, UCHAR_REGIONAL_INDICATOR);
4650
}
4751
}
4852

@@ -119,8 +123,7 @@ ScriptIterator::ScriptIterator(const String &p_string, int p_start, int p_length
119123
}
120124

121125
if (script_code == USCRIPT_SYMBOLS_EMOJI && script_code != sc) {
122-
UCharCategory cat = (UCharCategory)u_charType(ch);
123-
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)) {
126+
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))) {
124127
break;
125128
}
126129
} else if (same_script(script_code, sc)) {

thirdparty/icu4c/godot_data.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
misc: include
88
normalization: include
99
confusables: include
10+
uemoji: include
11+
uprops: include
1012
}
1113
}

thirdparty/icu4c/icudt_godot.dat

13 KB
Binary file not shown.

0 commit comments

Comments
 (0)