summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2016-06-30 16:48:45 +0900
committerRaph Levien <raph@google.com>2016-07-13 14:05:02 -0700
commitc2642f9a33b640e0ad25b17dc6f9d0734297166a (patch)
treeb88eea3c876412ecf83899467276c1f730d04527
parentfab99dde4be50b6377ecc0873ac33f3f4cacf36a (diff)
downloadandroid_frameworks_minikin-c2642f9a33b640e0ad25b17dc6f9d0734297166a.tar.gz
android_frameworks_minikin-c2642f9a33b640e0ad25b17dc6f9d0734297166a.tar.bz2
android_frameworks_minikin-c2642f9a33b640e0ad25b17dc6f9d0734297166a.zip
Treat U+2695, U+2640, U+2642 as emoji characters.
Bug: 29885295 Change-Id: I1bf191a46d05e7099265d863bae0523c50817d0b
-rw-r--r--libs/minikin/FontCollection.cpp41
-rw-r--r--libs/minikin/MinikinInternal.cpp5
-rw-r--r--tests/FontCollectionTest.cpp14
-rw-r--r--tests/GraphemeBreakTests.cpp11
-rw-r--r--tests/data/ColorEmojiFont.ttfbin996 -> 996 bytes
-rw-r--r--tests/data/ColorEmojiFont.ttx4
-rw-r--r--tests/data/TextEmojiFont.ttfbin892 -> 908 bytes
-rw-r--r--tests/data/TextEmojiFont.ttx7
8 files changed, 63 insertions, 19 deletions
diff --git a/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index 78f102e..33418ab 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/libs/minikin/FontCollection.cpp
@@ -40,7 +40,9 @@ static inline T max(T a, T b) {
const uint32_t EMOJI_STYLE_VS = 0xFE0F;
const uint32_t TEXT_STYLE_VS = 0xFE0E;
-// See http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants-9.0.0d1.txt
+// See http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants.txt
+// U+2640, U+2642, U+2695 are now in emoji category but not listed in above file, so added them by
+// manual.
// Must be sorted.
const uint32_t EMOJI_STYLE_VS_BASES[] = {
0x0023, 0x002A, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
@@ -48,24 +50,25 @@ const uint32_t EMOJI_STYLE_VS_BASES[] = {
0x21A9, 0x21AA, 0x231A, 0x231B, 0x2328, 0x23CF, 0x23ED, 0x23EE, 0x23EF, 0x23F1, 0x23F2, 0x23F8,
0x23F9, 0x23FA, 0x24C2, 0x25AA, 0x25AB, 0x25B6, 0x25C0, 0x25FB, 0x25FC, 0x25FD, 0x25FE, 0x2600,
0x2601, 0x2602, 0x2603, 0x2604, 0x260E, 0x2611, 0x2614, 0x2615, 0x2618, 0x261D, 0x2620, 0x2622,
- 0x2623, 0x2626, 0x262A, 0x262E, 0x262F, 0x2638, 0x2639, 0x263A, 0x2648, 0x2649, 0x264A, 0x264B,
- 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, 0x2653, 0x2660, 0x2663, 0x2665, 0x2666,
- 0x2668, 0x267B, 0x267F, 0x2692, 0x2693, 0x2694, 0x2696, 0x2697, 0x2699, 0x269B, 0x269C, 0x26A0,
- 0x26A1, 0x26AA, 0x26AB, 0x26B0, 0x26B1, 0x26BD, 0x26BE, 0x26C4, 0x26C5, 0x26C8, 0x26CF, 0x26D1,
- 0x26D3, 0x26D4, 0x26E9, 0x26EA, 0x26F0, 0x26F1, 0x26F2, 0x26F3, 0x26F4, 0x26F5, 0x26F7, 0x26F8,
- 0x26F9, 0x26FA, 0x26FD, 0x2702, 0x2708, 0x2709, 0x270C, 0x270D, 0x270F, 0x2712, 0x2714, 0x2716,
- 0x271D, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2757, 0x2763, 0x2764, 0x27A1, 0x2934, 0x2935,
- 0x2B05, 0x2B06, 0x2B07, 0x2B1B, 0x2B1C, 0x2B50, 0x2B55, 0x3030, 0x303D, 0x3297, 0x3299,
- 0x1F004, 0x1F170, 0x1F171, 0x1F17E, 0x1F17F, 0x1F202, 0x1F21A, 0x1F22F, 0x1F237, 0x1F321,
- 0x1F324, 0x1F325, 0x1F326, 0x1F327, 0x1F328, 0x1F329, 0x1F32A, 0x1F32B, 0x1F32C, 0x1F336,
- 0x1F37D, 0x1F396, 0x1F397, 0x1F399, 0x1F39A, 0x1F39B, 0x1F39E, 0x1F39F, 0x1F3CB, 0x1F3CC,
- 0x1F3CD, 0x1F3CE, 0x1F3D4, 0x1F3D5, 0x1F3D6, 0x1F3D7, 0x1F3D8, 0x1F3D9, 0x1F3DA, 0x1F3DB,
- 0x1F3DC, 0x1F3DD, 0x1F3DE, 0x1F3DF, 0x1F3F3, 0x1F3F5, 0x1F3F7, 0x1F43F, 0x1F441, 0x1F4FD,
- 0x1F549, 0x1F54A, 0x1F56F, 0x1F570, 0x1F573, 0x1F574, 0x1F575, 0x1F576, 0x1F577, 0x1F578,
- 0x1F579, 0x1F587, 0x1F58A, 0x1F58B, 0x1F58C, 0x1F58D, 0x1F590, 0x1F5A5, 0x1F5A8, 0x1F5B1,
- 0x1F5B2, 0x1F5BC, 0x1F5C2, 0x1F5C3, 0x1F5C4, 0x1F5D1, 0x1F5D2, 0x1F5D3, 0x1F5DC, 0x1F5DD,
- 0x1F5DE, 0x1F5E1, 0x1F5E3, 0x1F5E8, 0x1F5EF, 0x1F5F3, 0x1F5FA, 0x1F6CB, 0x1F6CD, 0x1F6CE,
- 0x1F6CF, 0x1F6E0, 0x1F6E1, 0x1F6E2, 0x1F6E3, 0x1F6E4, 0x1F6E5, 0x1F6E9, 0x1F6F0, 0x1F6F3,
+ 0x2623, 0x2626, 0x262A, 0x262E, 0x262F, 0x2638, 0x2639, 0x263A, 0x2640, 0x2642, 0x2648, 0x2649,
+ 0x264A, 0x264B, 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, 0x2653, 0x2660, 0x2663,
+ 0x2665, 0x2666, 0x2668, 0x267B, 0x267F, 0x2692, 0x2693, 0x2694, 0x2695, 0x2696, 0x2697, 0x2699,
+ 0x269B, 0x269C, 0x26A0, 0x26A1, 0x26AA, 0x26AB, 0x26B0, 0x26B1, 0x26BD, 0x26BE, 0x26C4, 0x26C5,
+ 0x26C8, 0x26CF, 0x26D1, 0x26D3, 0x26D4, 0x26E9, 0x26EA, 0x26F0, 0x26F1, 0x26F2, 0x26F3, 0x26F4,
+ 0x26F5, 0x26F7, 0x26F8, 0x26F9, 0x26FA, 0x26FD, 0x2702, 0x2708, 0x2709, 0x270C, 0x270D, 0x270F,
+ 0x2712, 0x2714, 0x2716, 0x271D, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2757, 0x2763, 0x2764,
+ 0x27A1, 0x2934, 0x2935, 0x2B05, 0x2B06, 0x2B07, 0x2B1B, 0x2B1C, 0x2B50, 0x2B55, 0x3030, 0x303D,
+ 0x3297, 0x3299, 0x1F004, 0x1F170, 0x1F171, 0x1F17E, 0x1F17F, 0x1F202, 0x1F21A, 0x1F22F, 0x1F237,
+ 0x1F321, 0x1F324, 0x1F325, 0x1F326, 0x1F327, 0x1F328, 0x1F329, 0x1F32A, 0x1F32B, 0x1F32C,
+ 0x1F336, 0x1F37D, 0x1F396, 0x1F397, 0x1F399, 0x1F39A, 0x1F39B, 0x1F39E, 0x1F39F, 0x1F3CB,
+ 0x1F3CC, 0x1F3CD, 0x1F3CE, 0x1F3D4, 0x1F3D5, 0x1F3D6, 0x1F3D7, 0x1F3D8, 0x1F3D9, 0x1F3DA,
+ 0x1F3DB, 0x1F3DC, 0x1F3DD, 0x1F3DE, 0x1F3DF, 0x1F3F3, 0x1F3F5, 0x1F3F7, 0x1F43F, 0x1F441,
+ 0x1F4FD, 0x1F549, 0x1F54A, 0x1F56F, 0x1F570, 0x1F573, 0x1F574, 0x1F575, 0x1F576, 0x1F577,
+ 0x1F578, 0x1F579, 0x1F587, 0x1F58A, 0x1F58B, 0x1F58C, 0x1F58D, 0x1F590, 0x1F5A5, 0x1F5A8,
+ 0x1F5B1, 0x1F5B2, 0x1F5BC, 0x1F5C2, 0x1F5C3, 0x1F5C4, 0x1F5D1, 0x1F5D2, 0x1F5D3, 0x1F5DC,
+ 0x1F5DD, 0x1F5DE, 0x1F5E1, 0x1F5E3, 0x1F5E8, 0x1F5EF, 0x1F5F3, 0x1F5FA, 0x1F6CB, 0x1F6CD,
+ 0x1F6CE, 0x1F6CF, 0x1F6E0, 0x1F6E1, 0x1F6E2, 0x1F6E3, 0x1F6E4, 0x1F6E5, 0x1F6E9, 0x1F6F0,
+ 0x1F6F3,
};
static bool isEmojiStyleVSBase(uint32_t cp) {
diff --git a/libs/minikin/MinikinInternal.cpp b/libs/minikin/MinikinInternal.cpp
index 7fcc7b7..5cb9491 100644
--- a/libs/minikin/MinikinInternal.cpp
+++ b/libs/minikin/MinikinInternal.cpp
@@ -33,6 +33,11 @@ void assertMinikinLocked() {
}
bool isEmoji(uint32_t c) {
+ // U+2695 U+2640 U+2642 are not in emoji category in Unicode 9 but they are now emoji category.
+ // TODO: remove once emoji database is updated.
+ if (c == 0x2695 || c == 0x2640 || c == 0x2642) {
+ return true;
+ }
const size_t length = sizeof(generated::EMOJI_LIST) / sizeof(generated::EMOJI_LIST[0]);
return std::binary_search(generated::EMOJI_LIST, generated::EMOJI_LIST + length, c);
}
diff --git a/tests/FontCollectionTest.cpp b/tests/FontCollectionTest.cpp
index 5a03f60..fa95242 100644
--- a/tests/FontCollectionTest.cpp
+++ b/tests/FontCollectionTest.cpp
@@ -105,6 +105,20 @@ TEST(FontCollectionTest, hasVariationSelectorTest_emoji) {
// VS15/VS16 is only for emoji, should return false for not an emoji code point.
EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0E));
EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0F));
+
+}
+
+TEST(FontCollectionTest, newEmojiTest) {
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
+
+ // U+2695, U+2640, U+2642 are not in emoji catrgory in Unicode 9 but they are now in emoji
+ // category. Should return true even if U+FE0E was appended.
+ // These three emojis are only avalilable in TextEmoji.ttf but U+2695 is excluded here since it
+ // is used in other tests.
+ EXPECT_TRUE(collection->hasVariationSelector(0x2640, 0xFE0E));
+ EXPECT_FALSE(collection->hasVariationSelector(0x2640, 0xFE0F));
+ EXPECT_TRUE(collection->hasVariationSelector(0x2642, 0xFE0E));
+ EXPECT_FALSE(collection->hasVariationSelector(0x2642, 0xFE0F));
}
} // namespace android
diff --git a/tests/GraphemeBreakTests.cpp b/tests/GraphemeBreakTests.cpp
index cec5308..9dfd426 100644
--- a/tests/GraphemeBreakTests.cpp
+++ b/tests/GraphemeBreakTests.cpp
@@ -179,6 +179,17 @@ TEST(GraphemeBreak, emojiModifiers) {
// rat is not an emoji modifer
EXPECT_TRUE(IsBreak("U+1F466 | U+1F400")); // boy + rat
+
+}
+
+TEST(GraphemeBreak, genderBalancedEmoji) {
+ // U+1F469 is WOMAN, U+200D is ZWJ, U+1F4BC is BRIEFCASE.
+ EXPECT_FALSE(IsBreak("U+1F469 | U+200D U+1F4BC"));
+ EXPECT_FALSE(IsBreak("U+1F469 U+200D | U+1F4BC"));
+
+ // U+2695 has now emoji property, so should be part of ZWJ sequence.
+ EXPECT_FALSE(IsBreak("U+1F469 | U+200D U+2695"));
+ EXPECT_FALSE(IsBreak("U+1F469 U+200D | U+2695"));
}
TEST(GraphemeBreak, offsets) {
diff --git a/tests/data/ColorEmojiFont.ttf b/tests/data/ColorEmojiFont.ttf
index a809431..eee1c37 100644
--- a/tests/data/ColorEmojiFont.ttf
+++ b/tests/data/ColorEmojiFont.ttf
Binary files differ
diff --git a/tests/data/ColorEmojiFont.ttx b/tests/data/ColorEmojiFont.ttx
index 1a15f24..5e16574 100644
--- a/tests/data/ColorEmojiFont.ttx
+++ b/tests/data/ColorEmojiFont.ttx
@@ -163,6 +163,8 @@
<map code="0x1F373" name="defaultGlyph" />
<map code="0x200D" name="defaultGlyph" />
<map code="0x2695" name="defaultGlyph" />
+
+ <!-- U+2640, U+2642 are reserved for FontCollectionTest.newEmojiTest -->
</cmap_format_12>
<cmap_format_14 format="14" platformID="0" platEncID="5" length="40" numVarSelectorRecords="2">
<!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
@@ -171,6 +173,8 @@
<!--For FontCollectionItemizeTest,.itemize_genderBalancedEmoji -->
<map uvs="0xFE0F" uv="0x2695" name="None" />
+
+ <!-- U+2640, U+2642 are reserved for FontCollectionTest.newEmojiTest -->
</cmap_format_14>
</cmap>
diff --git a/tests/data/TextEmojiFont.ttf b/tests/data/TextEmojiFont.ttf
index ea477b8..6a5e9d9 100644
--- a/tests/data/TextEmojiFont.ttf
+++ b/tests/data/TextEmojiFont.ttf
Binary files differ
diff --git a/tests/data/TextEmojiFont.ttx b/tests/data/TextEmojiFont.ttx
index d351fe6..eb49422 100644
--- a/tests/data/TextEmojiFont.ttx
+++ b/tests/data/TextEmojiFont.ttx
@@ -161,6 +161,11 @@
<!-- U+1F469 is reserved. -->
<!-- U+1F373 is reserved. -->
<map code="0x2695" name="defaultGlyph" />
+
+ <!-- For FontCollectionTest.newEmojiTest -->
+ <map code="0x2640" name="defaultGlyph" />
+ <map code="0x2642" name="defaultGlyph" />
+
</cmap_format_4>
<cmap_format_14 format="14" platformID="0" platEncID="5" length="40" numVarSelectorRecords="2">
<!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
@@ -169,6 +174,8 @@
<!--For FontCollectionItemizeTest,.itemize_genderBalancedEmoji -->
<map uvs="0xFE0E" uv="0x2695" name="None" />
+
+ <!-- U+2640, U+2642 are reserved for FontCollectionTest.newEmojiTest -->
</cmap_format_14>
</cmap>