diff options
author | Rod S <rsheeter@google.com> | 2020-03-14 14:23:18 -0700 |
---|---|---|
committer | Roderick Sheeter <rsheeter@google.com> | 2020-03-19 23:09:21 +0000 |
commit | d26e5a84987f46b1c8f726b068dbce438b9073a3 (patch) | |
tree | 46043186107489ca635d0deb9782f13dd8f5aff3 | |
parent | e6999ef6d5e2a7b969e0bd4338a89123b976a3bf (diff) | |
download | minikin-android11-dev.tar.gz |
Update isEmoji for Unicode 13.android-mainline-11.0.0_r35android11-dev
As ICU is updated to 66.1 this consists of just removing all the
special case logic that ws added when Unicode 12 support was added
ahead of ICU support.
Test: minikin_tests
Bug: 151964652
Change-Id: I381d582ff33eb825c6f0c8de391d0baaa5d78a4a
(cherry picked from commit 7f22730fca0a4e0cc5207ac639a46b1925a1f4e4)
-rw-r--r-- | libs/minikin/Emoji.cpp | 33 | ||||
-rw-r--r-- | tests/unittest/EmojiTest.cpp | 24 |
2 files changed, 27 insertions, 30 deletions
diff --git a/libs/minikin/Emoji.cpp b/libs/minikin/Emoji.cpp index cd52f52..c1dce4f 100644 --- a/libs/minikin/Emoji.cpp +++ b/libs/minikin/Emoji.cpp @@ -18,25 +18,8 @@ namespace minikin { -bool isNewEmoji(uint32_t c) { - // Emoji characters new in Unicode emoji 12 - // From https://www.unicode.org/Public/emoji/12.0/emoji-data.txt - // TODO: Remove once emoji-data.text 12 is in ICU or update to 12. - if (c < 0x1F6D5 || c > 0x1FA95) { - // Optimization for characters outside the new emoji range. - return false; - } - return c == 0x1F6D5 || c == 0x1F6FA || c == 0x1F93F || c == 0x1F971 || c == 0x1F97B || - (0x1F7E0 <= c && c <= 0x1F7EB) || (0x1F90D <= c && c <= 0x1F90F) || - (0x1F9A5 <= c && c <= 0x1F9AA) || (0x1F9AE <= c && c <= 0x1F9AF) || - (0x1F9BA <= c && c <= 0x1F9BF) || (0x1F9C3 <= c && c <= 0x1F9CA) || - (0x1F9CD <= c && c <= 0x1F9CF) || (0x1FA70 <= c && c <= 0x1FA73) || - (0x1FA78 <= c && c <= 0x1FA7A) || (0x1FA80 <= c && c <= 0x1FA82) || - (0x1FA90 <= c && c <= 0x1FA95); -} - bool isEmoji(uint32_t c) { - return isNewEmoji(c) || u_hasBinaryProperty(c, UCHAR_EMOJI); + return u_hasBinaryProperty(c, UCHAR_EMOJI); } bool isEmojiModifier(uint32_t c) { @@ -52,22 +35,12 @@ bool isEmojiBase(uint32_t c) { if (c == 0x1F91D || c == 0x1F93C) { return true; } - // Emoji Modifier Base characters new in Unicode emoji 11 - // From https://www.unicode.org/Public/emoji/11.0/emoji-data.txt - // TODO: Remove once emoji-data.text 11 is in ICU or update to 11. - if ((0x1F9B5 <= c && c <= 0x1F9B6) || (0x1F9B8 <= c && c <= 0x1F9B9)) { - return true; - } + return u_hasBinaryProperty(c, UCHAR_EMOJI_MODIFIER_BASE); } UCharDirection emojiBidiOverride(const void* /* context */, UChar32 c) { - if (isNewEmoji(c)) { - // All new emoji characters in Unicode 10.0 are of the bidi class ON. - return U_OTHER_NEUTRAL; - } else { - return u_charDirection(c); - } + return u_charDirection(c); } } // namespace minikin diff --git a/tests/unittest/EmojiTest.cpp b/tests/unittest/EmojiTest.cpp index 643a112..24e09e4 100644 --- a/tests/unittest/EmojiTest.cpp +++ b/tests/unittest/EmojiTest.cpp @@ -32,6 +32,7 @@ TEST(EmojiTest, isEmojiTest) { EXPECT_TRUE(isEmoji(0x1F6F7)); // SLED EXPECT_TRUE(isEmoji(0x1F9E6)); // SOCKS + // Unicode 12.0 EXPECT_TRUE(isEmoji(0x1F6D5)); // HINDU TEMPLE EXPECT_TRUE(isEmoji(0x1F7E7)); // ORANGE SQUARE EXPECT_TRUE(isEmoji(0x1F9CF)); // DEAF PERSON @@ -45,6 +46,14 @@ TEST(EmojiTest, isEmojiTest) { EXPECT_TRUE(isEmoji(0x1FA70)); // BALLET SHOES EXPECT_TRUE(isEmoji(0x1FA79)); // ADHESIVE BANDAGE + // Unicode 13.0 + EXPECT_TRUE(isEmoji(0x1F6D6)); // HUT + EXPECT_TRUE(isEmoji(0x1F977)); // NINJA + EXPECT_TRUE(isEmoji(0x1F9A3)); // MAMMOTH + EXPECT_TRUE(isEmoji(0x1FA74)); // THONG SANDAL + EXPECT_TRUE(isEmoji(0x1FAC2)); // PEOPLE HUGGING + EXPECT_TRUE(isEmoji(0x1FAD6)); // TEAPOT + EXPECT_FALSE(isEmoji(0x0000)); // <control> EXPECT_FALSE(isEmoji(0x0061)); // LATIN SMALL LETTER A EXPECT_FALSE(isEmoji(0x1F93B)); // MODERN PENTATHLON @@ -82,6 +91,21 @@ TEST(EmojiTest, isEmojiBaseTest) { EXPECT_TRUE(isEmojiBase(0x1F9D1)); // ADULT EXPECT_TRUE(isEmojiBase(0x1F9DD)); // ELF + EXPECT_TRUE(isEmojiBase(0x1F9B5)); // LEG + EXPECT_TRUE(isEmojiBase(0x1F9B6)); // FOOT + EXPECT_TRUE(isEmojiBase(0x1F9B8)); // SUPERHERO + EXPECT_TRUE(isEmojiBase(0x1F9B9)); // SUPERVILLAIN + + // Unicode 12 + EXPECT_TRUE(isEmojiBase(0x1F90F)); // PINCHING HAND + EXPECT_TRUE(isEmojiBase(0x1F9BB)); // EAR WITH HEARING AID + EXPECT_TRUE(isEmojiBase(0x1F9CD)); // PERSON STANDING + EXPECT_TRUE(isEmojiBase(0x1F9CF)); // DEAF PERSON + + // Unicode 13 + EXPECT_TRUE(isEmojiBase(0x1F90C)); // PINCHED FINGERS + EXPECT_TRUE(isEmojiBase(0x1F977)); // NINJA + EXPECT_FALSE(isEmojiBase(0x0000)); // <control> EXPECT_FALSE(isEmojiBase(0x261C)); // WHITE LEFT POINTING INDEX EXPECT_FALSE(isEmojiBase(0x1F384)); // CHRISTMAS TREE |