summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2014-06-11 15:02:11 -0700
committerRaph Levien <raph@google.com>2014-06-11 16:03:49 -0700
commitbd36ec766a451c62ffdd407d5ce1a355e8f7dfd8 (patch)
tree0fa31fdf5db3f65a000dbc31e96301365bf09200
parent1c7b403ad8026fdebd0185319183d0a7a2c377bd (diff)
downloadandroid_frameworks_minikin-bd36ec766a451c62ffdd407d5ce1a355e8f7dfd8.tar.gz
android_frameworks_minikin-bd36ec766a451c62ffdd407d5ce1a355e8f7dfd8.tar.bz2
android_frameworks_minikin-bd36ec766a451c62ffdd407d5ce1a355e8f7dfd8.zip
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
-rw-r--r--libs/minikin/FontCollection.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index 6115ecc..45e5d06 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/libs/minikin/FontCollection.cpp
@@ -46,12 +46,6 @@ FontCollection::FontCollection(const vector<FontFamily*>& 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<FontFamily*>& 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<FontFamily*>& 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++) {