From 43e8943dfd9812fdf1f62e05f61ef85a2a0868f6 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Wed, 11 Jun 2014 15:02:11 -0700 Subject: [PATCH] Fix missing text on nonexistent font file Fix for bug 15570313 "Missing text on nonexistent font file" This patch makes sure that the lastChar and mInstances arrays are in sync with each other even when a FontFamily being added has no valid fonts in it. Previously, when they got out of sync, unicode coverage calculation would be wrong, resulting in missing text. Change-Id: I69c727ef69e2c61e2b2d6b81d5a28c806327f865 --- engine/src/flutter/libs/minikin/FontCollection.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/libs/minikin/FontCollection.cpp b/engine/src/flutter/libs/minikin/FontCollection.cpp index 6115ecc3b43..45e5d060325 100644 --- a/engine/src/flutter/libs/minikin/FontCollection.cpp +++ b/engine/src/flutter/libs/minikin/FontCollection.cpp @@ -46,12 +46,6 @@ FontCollection::FontCollection(const vector& typefaces) : const FontStyle defaultStyle; for (size_t i = 0; i < nTypefaces; i++) { FontFamily* family = typefaces[i]; - family->RefLocked(); - FontInstance dummy; - mInstances.push_back(dummy); // emplace_back would be better - FontInstance* instance = &mInstances.back(); - instance->mFamily = family; - instance->mCoverage = new SparseBitSet; MinikinFont* typeface = family->getClosestMatch(defaultStyle).font; if (typeface == NULL) { ALOGE("FontCollection: closest match was null"); @@ -59,6 +53,12 @@ FontCollection::FontCollection(const vector& typefaces) : // checks upstream to prevent empty/invalid FontFamily objects continue; } + family->RefLocked(); + FontInstance dummy; + mInstances.push_back(dummy); // emplace_back would be better + FontInstance* instance = &mInstances.back(); + instance->mFamily = family; + instance->mCoverage = new SparseBitSet; #ifdef VERBOSE_DEBUG ALOGD("closest match = %p, family size = %d\n", typeface, family->getNumFonts()); #endif @@ -75,6 +75,7 @@ FontCollection::FontCollection(const vector& typefaces) : mMaxChar = max(mMaxChar, instance->mCoverage->length()); lastChar.push_back(instance->mCoverage->nextSetBit(0)); } + nTypefaces = mInstances.size(); size_t nPages = (mMaxChar + kPageMask) >> kLogCharsPerPage; size_t offset = 0; for (size_t i = 0; i < nPages; i++) {