 Chromium Code Reviews
 Chromium Code Reviews Issue 692553002:
  Add a flag indicating locally-created fonts to SkCreateTypefaceFromCTFont  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master
    
  
    Issue 692553002:
  Add a flag indicating locally-created fonts to SkCreateTypefaceFromCTFont  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master| OLD | NEW | 
|---|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 #ifdef SK_BUILD_FOR_MAC | 9 #ifdef SK_BUILD_FOR_MAC | 
| 10 #import <ApplicationServices/ApplicationServices.h> | 10 #import <ApplicationServices/ApplicationServices.h> | 
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 | 568 | 
| 569 /* This function is visible on the outside. It first searches the cache, and if | 569 /* This function is visible on the outside. It first searches the cache, and if | 
| 570 * not found, returns a new entry (after adding it to the cache). | 570 * not found, returns a new entry (after adding it to the cache). | 
| 571 */ | 571 */ | 
| 572 SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef) { | 572 SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef) { | 
| 573 SkFontID fontID = CTFontRef_to_SkFontID(fontRef); | 573 SkFontID fontID = CTFontRef_to_SkFontID(fontRef); | 
| 574 SkTypeface* face = SkTypefaceCache::FindByID(fontID); | 574 SkTypeface* face = SkTypefaceCache::FindByID(fontID); | 
| 575 if (face) { | 575 if (face) { | 
| 576 face->ref(); | 576 face->ref(); | 
| 577 } else { | 577 } else { | 
| 578 face = NewFromFontRef(fontRef, NULL, false); | 578 bool isLocal = false; | 
| 579 AutoCFRelease<CTFontDescriptorRef> fontDescriptor(CTFontCopyFontDescript or(fontRef)); | |
| 580 AutoCFRelease<CFTypeRef> priority(CTFontDescriptorCopyAttribute(fontDesc riptor, kCTFontPriorityAttribute)); | |
| 
reed1
2014/10/29 15:36:33
nit: 100cols
 | |
| 581 if (CFGetTypeID(priority) == CFNumberGetTypeID()) { | |
| 582 uint32_t priorityValue; | |
| 583 isLocal = CFNumberGetValue(reinterpret_cast<CFNumberRef>(priority.ge t()), kCFNumberSInt32Type, &priorityValue) && priorityValue >= kCTFontPriorityPr ocess; | |
| 584 } | |
| 585 face = NewFromFontRef(fontRef, NULL, isLocal); | |
| 579 SkTypefaceCache::Add(face, face->fontStyle()); | 586 SkTypefaceCache::Add(face, face->fontStyle()); | 
| 580 // NewFromFontRef doesn't retain the parameter, but the typeface it | 587 // NewFromFontRef doesn't retain the parameter, but the typeface it | 
| 581 // creates does release it in its destructor, so we balance that with | 588 // creates does release it in its destructor, so we balance that with | 
| 582 // a retain call here. | 589 // a retain call here. | 
| 583 CFRetain(fontRef); | 590 CFRetain(fontRef); | 
| 584 } | 591 } | 
| 585 SkASSERT(face->getRefCnt() > 1); | 592 SkASSERT(face->getRefCnt() > 1); | 
| 586 return face; | 593 return face; | 
| 587 } | 594 } | 
| 588 | 595 | 
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 } | 2262 } | 
| 2256 return face; | 2263 return face; | 
| 2257 } | 2264 } | 
| 2258 }; | 2265 }; | 
| 2259 | 2266 | 
| 2260 /////////////////////////////////////////////////////////////////////////////// | 2267 /////////////////////////////////////////////////////////////////////////////// | 
| 2261 | 2268 | 
| 2262 SkFontMgr* SkFontMgr::Factory() { | 2269 SkFontMgr* SkFontMgr::Factory() { | 
| 2263 return SkNEW(SkFontMgr_Mac); | 2270 return SkNEW(SkFontMgr_Mac); | 
| 2264 } | 2271 } | 
| OLD | NEW |