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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 The Android Open Source Project 3 * Copyright 2013 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkFontConfigInterface.h" 9 #include "SkFontConfigInterface.h"
10 #include "SkTypeface_android.h" 10 #include "SkTypeface_android.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 SkFontID origFontI D, 562 SkFontID origFontI D,
563 const SkPaintOptio nsAndroid& opts) { 563 const SkPaintOptio nsAndroid& opts) {
564 // Skia does not support font fallback by default. This enables clients such 564 // Skia does not support font fallback by default. This enables clients such
565 // as WebKit to customize their font selection. In any case, clients can use 565 // as WebKit to customize their font selection. In any case, clients can use
566 // GetFallbackFamilyNameForChar() to get the fallback font for individual 566 // GetFallbackFamilyNameForChar() to get the fallback font for individual
567 // characters. 567 // characters.
568 if (!opts.isUsingFontFallbacks()) { 568 if (!opts.isUsingFontFallbacks()) {
569 return NULL; 569 return NULL;
570 } 570 }
571 571
572 const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
573 SkASSERT(currTypeface != 0);
574
575 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguag e()); 572 FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguag e());
576 SkASSERT(currentFallbackList); 573 SkASSERT(currentFallbackList);
577 574
578 // we must convert currTypeface into a FontRecID 575 // we must convert currTypeface into a FontRecID
579 FontRecID currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity() .fID; 576 FontRecID currFontRecID = INVALID_FONT_REC_ID;
580 SkASSERT(INVALID_FONT_REC_ID != currFontRecID); 577 const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
578 // non-system fonts are not in the font cache so if we are asked to fallback
579 // for a non-system font we will start at the front of the chain.
580 if (NULL != currTypeface && currFontID == origFontID) {
581 currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
582 SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
583 }
581 584
582 // TODO lookup the index next font in the chain 585 // lookup the index next font in the chain
583 int currFallbackFontIndex = currentFallbackList->find(currFontRecID); 586 int currFallbackFontIndex = currentFallbackList->find(currFontRecID);
587 // We add 1 to the returned index for 2 reasons: (1) if find succeeds it mov es
588 // our index to the next entry in the list; (2) if find() fails it returns
589 // -1 and incrementing it will set our starting index to 0 (the head of the list)
584 int nextFallbackFontIndex = currFallbackFontIndex + 1; 590 int nextFallbackFontIndex = currFallbackFontIndex + 1;
585 591
586 if(nextFallbackFontIndex >= currentFallbackList->count()) { 592 if(nextFallbackFontIndex >= currentFallbackList->count()) {
587 return NULL; 593 return NULL;
588 } 594 }
589 595
590 // If a rec object is set to prefer "kDefault_Variant" it means they have no preference 596 // If a rec object is set to prefer "kDefault_Variant" it means they have no preference
591 // In this case, we set the value to "kCompact_Variant" 597 // In this case, we set the value to "kCompact_Variant"
592 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant(); 598 SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
593 if (variant == SkPaintOptionsAndroid::kDefault_Variant) { 599 if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 return SkCreateTypefaceForScriptNG(getHBScriptFromHBScriptOld(script), style , fontVariant); 795 return SkCreateTypefaceForScriptNG(getHBScriptFromHBScriptOld(script), style , fontVariant);
790 } 796 }
791 797
792 #endif 798 #endif
793 799
794 /////////////////////////////////////////////////////////////////////////////// 800 ///////////////////////////////////////////////////////////////////////////////
795 801
796 SkFontMgr* SkFontMgr::Factory() { 802 SkFontMgr* SkFontMgr::Factory() {
797 return NULL; 803 return NULL;
798 } 804 }
OLDNEW
« 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