| 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 #include "SkTypes.h" // Keep this before any #ifdef ... | 9 #include "SkTypes.h" // Keep this before any #ifdef ... |
| 10 | 10 |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(desc, 0, NULL
)); | 2193 AutoCFRelease<CTFontRef> ctFont(CTFontCreateWithFontDescriptor(desc, 0, NULL
)); |
| 2194 if (!ctFont) { | 2194 if (!ctFont) { |
| 2195 return NULL; | 2195 return NULL; |
| 2196 } | 2196 } |
| 2197 | 2197 |
| 2198 bool isFixedPitch; | 2198 bool isFixedPitch; |
| 2199 (void)computeStyleBits(ctFont, &isFixedPitch); | 2199 (void)computeStyleBits(ctFont, &isFixedPitch); |
| 2200 | 2200 |
| 2201 face = SkNEW_ARGS(SkTypeface_Mac, (ctFont.detach(), NULL, | 2201 face = new SkTypeface_Mac(ctFont.detach(), NULL, cacheRequest.fStyle, isFixe
dPitch, |
| 2202 cacheRequest.fStyle, isFixedPitch, | 2202 skFamilyName.c_str(), false); |
| 2203 skFamilyName.c_str(), false)); | |
| 2204 SkTypefaceCache::Add(face, face->fontStyle()); | 2203 SkTypefaceCache::Add(face, face->fontStyle()); |
| 2205 return face; | 2204 return face; |
| 2206 } | 2205 } |
| 2207 | 2206 |
| 2208 class SkFontStyleSet_Mac : public SkFontStyleSet { | 2207 class SkFontStyleSet_Mac : public SkFontStyleSet { |
| 2209 public: | 2208 public: |
| 2210 SkFontStyleSet_Mac(CFStringRef familyName, CTFontDescriptorRef desc) | 2209 SkFontStyleSet_Mac(CFStringRef familyName, CTFontDescriptorRef desc) |
| 2211 : fArray(CTFontDescriptorCreateMatchingFontDescriptors(desc, NULL)) | 2210 : fArray(CTFontDescriptorCreateMatchingFontDescriptors(desc, NULL)) |
| 2212 , fFamilyName(familyName) | 2211 , fFamilyName(familyName) |
| 2213 , fCount(0) { | 2212 , fCount(0) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2291 static SkFontStyleSet* CreateSet(CFStringRef cfFamilyName) { | 2290 static SkFontStyleSet* CreateSet(CFStringRef cfFamilyName) { |
| 2292 AutoCFRelease<CFMutableDictionaryRef> cfAttr( | 2291 AutoCFRelease<CFMutableDictionaryRef> cfAttr( |
| 2293 CFDictionaryCreateMutable(kCFAllocatorDefault, 0, | 2292 CFDictionaryCreateMutable(kCFAllocatorDefault, 0, |
| 2294 &kCFTypeDictionaryKeyCallBacks, | 2293 &kCFTypeDictionaryKeyCallBacks, |
| 2295 &kCFTypeDictionaryValueCallBacks)); | 2294 &kCFTypeDictionaryValueCallBacks)); |
| 2296 | 2295 |
| 2297 CFDictionaryAddValue(cfAttr, kCTFontFamilyNameAttribute, cfFamilyName); | 2296 CFDictionaryAddValue(cfAttr, kCTFontFamilyNameAttribute, cfFamilyName); |
| 2298 | 2297 |
| 2299 AutoCFRelease<CTFontDescriptorRef> desc( | 2298 AutoCFRelease<CTFontDescriptorRef> desc( |
| 2300 CTFontDescriptorCreateWithAttributes(cfAttr)); | 2299 CTFontDescriptorCreateWithAttributes(cfAttr)); |
| 2301 return SkNEW_ARGS(SkFontStyleSet_Mac, (cfFamilyName, desc)); | 2300 return new SkFontStyleSet_Mac(cfFamilyName, desc); |
| 2302 } | 2301 } |
| 2303 | 2302 |
| 2304 public: | 2303 public: |
| 2305 SkFontMgr_Mac() | 2304 SkFontMgr_Mac() |
| 2306 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames()) | 2305 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames()) |
| 2307 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {} | 2306 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {} |
| 2308 | 2307 |
| 2309 virtual ~SkFontMgr_Mac() { | 2308 virtual ~SkFontMgr_Mac() { |
| 2310 CFSafeRelease(fNames); | 2309 CFSafeRelease(fNames); |
| 2311 } | 2310 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2481 face = GetDefaultFace(); | 2480 face = GetDefaultFace(); |
| 2482 face->ref(); | 2481 face->ref(); |
| 2483 } | 2482 } |
| 2484 } | 2483 } |
| 2485 return face; | 2484 return face; |
| 2486 } | 2485 } |
| 2487 }; | 2486 }; |
| 2488 | 2487 |
| 2489 /////////////////////////////////////////////////////////////////////////////// | 2488 /////////////////////////////////////////////////////////////////////////////// |
| 2490 | 2489 |
| 2491 SkFontMgr* SkFontMgr::Factory() { | 2490 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } |
| 2492 return SkNEW(SkFontMgr_Mac); | |
| 2493 } | |
| OLD | NEW |