From 2fd057eb7048f3739f3135b2cf108ef5aca42a31 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 +++- .../tests/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 b1b0aaf95f..78f102e17c 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/FontCollectionItemizeTest.cpp b/engine/src/flutter/tests/FontCollectionItemizeTest.cpp index 8ad9472490..468b4a28fa 100644 --- a/engine/src/flutter/tests/FontCollectionItemizeTest.cpp +++ b/engine/src/flutter/tests/FontCollectionItemizeTest.cpp @@ -1372,3 +1372,28 @@ TEST_F(FontCollectionItemizeTest, itemize_PrivateUseArea) { EXPECT_EQ(4, runs[0].end); 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])); +}