Suppress log span due to returning null for itemize result.
am: 5ccdf654f5
* commit '5ccdf654f5695be1b582a3bd89482bc6915cc22a':
Suppress log span due to returning null for itemize result.
This commit is contained in:
@@ -84,9 +84,11 @@ private:
|
||||
uint32_t mMaxChar;
|
||||
|
||||
// This vector has ownership of the bitsets and typeface objects.
|
||||
// This vector can't be empty.
|
||||
std::vector<FontFamily*> mFamilies;
|
||||
|
||||
// This vector contains pointers into mInstances
|
||||
// This vector can't be empty.
|
||||
std::vector<FontFamily*> mFamilyVec;
|
||||
|
||||
// This vector has pointers to the font family instance which has cmap 14 subtable.
|
||||
|
||||
@@ -230,10 +230,11 @@ uint32_t FontCollection::calcVariantMatchingScore(int variant, const FontFamily&
|
||||
// 1. If first font in the collection has the character, it wins.
|
||||
// 2. Calculate a score for the font family. See comments in calcFamilyScore for the detail.
|
||||
// 3. Highest score wins, with ties resolved to the first font.
|
||||
// This method never returns nullptr.
|
||||
FontFamily* FontCollection::getFamilyForChar(uint32_t ch, uint32_t vs,
|
||||
uint32_t langListId, int variant) const {
|
||||
if (ch >= mMaxChar) {
|
||||
return NULL;
|
||||
return mFamilies[0];
|
||||
}
|
||||
|
||||
const std::vector<FontFamily*>* familyVec = &mFamilyVec;
|
||||
@@ -272,7 +273,7 @@ FontFamily* FontCollection::getFamilyForChar(uint32_t ch, uint32_t vs,
|
||||
bestFamily = family;
|
||||
}
|
||||
}
|
||||
if (bestFamily == nullptr && !mFamilyVec.empty()) {
|
||||
if (bestFamily == nullptr) {
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
const UNormalizer2* normalizer = unorm2_getNFDInstance(&errorCode);
|
||||
if (U_SUCCESS(errorCode)) {
|
||||
@@ -396,11 +397,7 @@ void FontCollection::itemize(const uint16_t *string, size_t string_size, FontSty
|
||||
Run dummy;
|
||||
result->push_back(dummy);
|
||||
run = &result->back();
|
||||
if (family == NULL) {
|
||||
run->fakedFont.font = NULL;
|
||||
} else {
|
||||
run->fakedFont = family->getClosestMatch(style);
|
||||
}
|
||||
run->fakedFont = family->getClosestMatch(style);
|
||||
lastFamily = family;
|
||||
run->start = start;
|
||||
}
|
||||
@@ -415,9 +412,6 @@ MinikinFont* FontCollection::baseFont(FontStyle style) {
|
||||
}
|
||||
|
||||
FakedFont FontCollection::baseFontFaked(FontStyle style) {
|
||||
if (mFamilies.empty()) {
|
||||
return FakedFont();
|
||||
}
|
||||
return mFamilies[0]->getClosestMatch(style);
|
||||
}
|
||||
|
||||
|
||||
@@ -1156,7 +1156,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0E) {
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(2, runs[0].end);
|
||||
EXPECT_TRUE(runs[0].fakedFont.font == NULL || kNoGlyphFont == getFontPath(runs[0]));
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
|
||||
// U+231A is a emoji default emoji which is available only in TextEmojifFont.
|
||||
// TextEmojiFont.ttf sohuld be selected.
|
||||
@@ -1190,7 +1190,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0E) {
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(2, runs[0].end);
|
||||
EXPECT_TRUE(runs[0].fakedFont.font == NULL || kNoGlyphFont == getFontPath(runs[0]));
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
|
||||
// U+26FA U+FE0E is specified but ColorTextMixedEmojiFont has a variation sequence U+26F9 U+FE0F
|
||||
// in its cmap, so ColorTextMixedEmojiFont should be selected instaed of ColorEmojiFont.
|
||||
@@ -1239,7 +1239,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0F) {
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(2, runs[0].end);
|
||||
EXPECT_TRUE(runs[0].fakedFont.font == NULL || kNoGlyphFont == getFontPath(runs[0]));
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
|
||||
// U+231A is a emoji default emoji which is available only in TextEmojiFont.ttf.
|
||||
// TextEmojiFont.ttf should be selected.
|
||||
@@ -1272,7 +1272,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0F) {
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(2, runs[0].end);
|
||||
EXPECT_TRUE(runs[0].fakedFont.font == NULL || kNoGlyphFont == getFontPath(runs[0]));
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
|
||||
// U+26F9 U+FE0F is specified but ColorTextMixedEmojiFont has a variation sequence U+26F9 U+FE0F
|
||||
// in its cmap, so ColorTextMixedEmojiFont should be selected instaed of ColorEmojiFont.
|
||||
@@ -1321,3 +1321,23 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_with_skinTone) {
|
||||
EXPECT_EQ(4, runs[1].end);
|
||||
EXPECT_EQ(kColorEmojiFont, getFontPath(runs[1]));
|
||||
}
|
||||
|
||||
TEST_F(FontCollectionItemizeTest, itemize_PrivateUseArea) {
|
||||
std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kEmojiXmlFile);
|
||||
std::vector<FontCollection::Run> runs;
|
||||
|
||||
const FontStyle kDefaultFontStyle;
|
||||
|
||||
// Should not set nullptr to the result run. (Issue 26808815)
|
||||
itemize(collection.get(), "U+FEE10", kDefaultFontStyle, &runs);
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(2, runs[0].end);
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
|
||||
itemize(collection.get(), "U+FEE40 U+FE4C5", kDefaultFontStyle, &runs);
|
||||
ASSERT_EQ(1U, runs.size());
|
||||
EXPECT_EQ(0, runs[0].start);
|
||||
EXPECT_EQ(4, runs[0].end);
|
||||
EXPECT_EQ(kNoGlyphFont, getFontPath(runs[0]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user