From 293208bda839a5726e294a22c85b1c9e1c4b9844 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 7 Jul 2014 14:59:04 -0700 Subject: [PATCH] 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 --- engine/src/flutter/libs/minikin/FontCollection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index 348c5dc273..a6977fd6c6 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -48,9 +48,6 @@ FontCollection::FontCollection(const vector& 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& 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; }