Assign non-coverage font runs to base font

When a run has no cmap coverage in any font, use the base font. Most of
the time, this will cause rendering of the .notdef glyph, which is
preferable to displaying nothing. In some cases, Harfbuzz may be able to
decompose the characters (not in the cmap) to ones that are, in which
case we'll render those, as long as they're in the base font.

Bug: 6629748
Bug: 15816880
Change-Id: Ibb1b9242c83626e0c7db363ad65ce44a967a005e
This commit is contained in:
Raph Levien
2014-07-07 14:59:04 -07:00
parent f9490880cc
commit 293208bda8

View File

@@ -48,9 +48,6 @@ FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
FontFamily* family = typefaces[i];
MinikinFont* typeface = family->getClosestMatch(defaultStyle).font;
if (typeface == NULL) {
ALOGE("FontCollection: closest match was null");
// TODO: we shouldn't hit this, as there should be more robust
// checks upstream to prevent empty/invalid FontFamily objects
continue;
}
family->RefLocked();
@@ -76,6 +73,8 @@ FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
lastChar.push_back(instance->mCoverage->nextSetBit(0));
}
nTypefaces = mInstances.size();
LOG_ALWAYS_FATAL_IF(nTypefaces == 0,
"Font collection must have at least one valid typeface");
size_t nPages = (mMaxChar + kPageMask) >> kLogCharsPerPage;
size_t offset = 0;
for (size_t i = 0; i < nPages; i++) {
@@ -144,6 +143,9 @@ const FontCollection::FontInstance* FontCollection::getInstanceForChar(uint32_t
}
}
}
if (bestInstance == NULL) {
bestInstance = &mInstances[0];
}
return bestInstance;
}