Fix crash when attempting to use a font fallback chain with a custom font.
This is a cherry-pick of a CL that has already been merged into Android. Review URL: https://codereview.chromium.org/16005011 git-svn-id: http://skia.googlecode.com/svn/trunk@9468 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
2c84aa3598
commit
e47e7d17a6
@ -569,18 +569,24 @@ SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontI
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
|
|
||||||
SkASSERT(currTypeface != 0);
|
|
||||||
|
|
||||||
FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
|
FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
|
||||||
SkASSERT(currentFallbackList);
|
SkASSERT(currentFallbackList);
|
||||||
|
|
||||||
// we must convert currTypeface into a FontRecID
|
// we must convert currTypeface into a FontRecID
|
||||||
FontRecID currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
|
FontRecID currFontRecID = INVALID_FONT_REC_ID;
|
||||||
SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
|
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);
|
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;
|
int nextFallbackFontIndex = currFallbackFontIndex + 1;
|
||||||
|
|
||||||
if(nextFallbackFontIndex >= currentFallbackList->count()) {
|
if(nextFallbackFontIndex >= currentFallbackList->count()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user