summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-03-21 02:08:12 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-03-21 02:08:12 +0000
commit113e931e24182ae4b8c875d81a9670dbef587c8c (patch)
tree46043186107489ca635d0deb9782f13dd8f5aff3
parent31de42399be420e876712e9c2d7d6b60a956cab4 (diff)
parentd26e5a84987f46b1c8f726b068dbce438b9073a3 (diff)
downloadminikin-android11-tests-release.tar.gz
Change-Id: If39ea38480323bcb8ea9ba69d44d88e54c0c49f8
-rw-r--r--libs/minikin/Emoji.cpp33
-rw-r--r--tests/unittest/EmojiTest.cpp24
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