From dc6138ffeb80368d532f3b8f55b42f287e966170 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Fri, 8 Jul 2016 15:19:22 +0900 Subject: [PATCH] Add some gender balanced components in to the sticky whitelist. FEMALE SIGN(U+2640), MALE SIGN(U+2642), StAFF OF AESCULAPIUS(U+2695) will be used as the ZWJ sequenced in gender balanced emoji sequence. To be in the same run with ZWJ, mark these emoji as sticky chracters. With this fix, Female police officer sequence will be shown correctly regardless of VS16. Bug: 30026374 Change-Id: I503fc061eaa943d45208bb69e885151610c430ce --- .../flutter/libs/minikin/FontCollection.cpp | 5 +++- .../unittest/FontCollectionItemizeTest.cpp | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index 90b67d2550..d1a1924ae0 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -336,11 +336,14 @@ const uint32_t ZWJ = 0x200c; const uint32_t ZWNJ = 0x200d; const uint32_t HYPHEN = 0x2010; const uint32_t NB_HYPHEN = 0x2011; +const uint32_t FEMALE_SIGN = 0x2640; +const uint32_t MALE_SIGN = 0x2642; +const uint32_t STAFF_OF_AESCULAPIUS = 0x2695; // Characters where we want to continue using existing font run instead of // recomputing the best match in the fallback list. static const uint32_t stickyWhitelist[] = { '!', ',', '-', '.', ':', ';', '?', NBSP, ZWJ, ZWNJ, - HYPHEN, NB_HYPHEN }; + HYPHEN, NB_HYPHEN, FEMALE_SIGN, MALE_SIGN, STAFF_OF_AESCULAPIUS }; static bool isStickyWhitelisted(uint32_t c) { for (size_t i = 0; i < sizeof(stickyWhitelist) / sizeof(stickyWhitelist[0]); i++) { diff --git a/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp b/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp index b28820b1f8..367739683d 100644 --- a/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp +++ b/engine/src/flutter/tests/unittest/FontCollectionItemizeTest.cpp @@ -1367,4 +1367,29 @@ TEST_F(FontCollectionItemizeTest, itemize_PrivateUseArea) { EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0])); } +TEST_F(FontCollectionItemizeTest, itemize_genderBalancedEmoji) { + MinikinAutoUnref collection(getFontCollection(kTestFontDir, kEmojiXmlFile)); + std::vector runs; + + const FontStyle kDefaultFontStyle; + + itemize(collection.get(), "U+1F469 U+200D U+1F373", kDefaultFontStyle, &runs); + ASSERT_EQ(1U, runs.size()); + EXPECT_EQ(0, runs[0].start); + EXPECT_EQ(5, runs[0].end); + EXPECT_EQ(kColorEmojiFont, getFontPath(runs[0])); + + itemize(collection.get(), "U+1F469 U+200D U+2695 U+FE0F", kDefaultFontStyle, &runs); + ASSERT_EQ(1U, runs.size()); + EXPECT_EQ(0, runs[0].start); + EXPECT_EQ(5, runs[0].end); + EXPECT_EQ(kColorEmojiFont, getFontPath(runs[0])); + + itemize(collection.get(), "U+1F469 U+200D U+2695", kDefaultFontStyle, &runs); + ASSERT_EQ(1U, runs.size()); + EXPECT_EQ(0, runs[0].start); + EXPECT_EQ(4, runs[0].end); + EXPECT_EQ(kColorEmojiFont, getFontPath(runs[0])); +} + } // namespace minikin