Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1166)

Unified Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 16005011: Fix crash when attempting to use a font fallback chain with a custom font. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_android.cpp
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 8039906ab678d89d4755293aed1ea1a9ac2e3c0a..2e2d88d689bbdfaf80cb4d6e221ac5ab291012e5 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -569,18 +569,24 @@ SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontI
return NULL;
}
- const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
- SkASSERT(currTypeface != 0);
-
FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
SkASSERT(currentFallbackList);
// we must convert currTypeface into a FontRecID
- FontRecID currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
- SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
+ FontRecID currFontRecID = INVALID_FONT_REC_ID;
+ const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
+ // non-system fonts are not in the font cache so if we are asked to fallback
+ // for a non-system font we will start at the front of the chain.
+ if (NULL != currTypeface && currFontID == origFontID) {
+ currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
+ SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
+ }
- // TODO lookup the index next font in the chain
+ // lookup the index next font in the chain
int currFallbackFontIndex = currentFallbackList->find(currFontRecID);
+ // We add 1 to the returned index for 2 reasons: (1) if find succeeds it moves
+ // our index to the next entry in the list; (2) if find() fails it returns
+ // -1 and incrementing it will set our starting index to 0 (the head of the list)
int nextFallbackFontIndex = currFallbackFontIndex + 1;
if(nextFallbackFontIndex >= currentFallbackList->count()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698