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
This commit is contained in:
committed by
Raph Levien
parent
04b29bcbbb
commit
2fd057eb70
@@ -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++) {
|
||||
|
||||
@@ -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<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
|
||||
std::vector<FontCollection::Run> 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]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user