| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 SkString fRequestedName; | 465 SkString fRequestedName; |
| 466 AutoCFRelease<CTFontRef> fFontRef; | 466 AutoCFRelease<CTFontRef> fFontRef; |
| 467 | 467 |
| 468 protected: | 468 protected: |
| 469 friend class SkFontHost; // to access our protected members for deprecate
d methods | 469 friend class SkFontHost; // to access our protected members for deprecate
d methods |
| 470 | 470 |
| 471 virtual int onGetUPEM() const SK_OVERRIDE; | 471 int onGetUPEM() const SK_OVERRIDE; |
| 472 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 472 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
| 473 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; | 473 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; |
| 474 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 474 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE
; |
| 475 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 475 int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
| 476 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 476 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
| 477 size_t length, void* data) const SK_OVERRIDE; | 477 size_t length, void* data) const SK_OVERRIDE; |
| 478 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 478 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRID
E; |
| 479 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 479 void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
| 480 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; | 480 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; |
| 481 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 481 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
| 482 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 482 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
| 483 const uint32_t*, uint32_t) const SK_OVERRIDE; | 483 const uint32_t*, uint32_t) const SK_OVERRIDE; |
| 484 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 484 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
| 485 int glyphCount) const SK_OVERRIDE; | 485 int glyphCount) const SK_OVERRIDE; |
| 486 virtual int onCountGlyphs() const SK_OVERRIDE; | 486 int onCountGlyphs() const SK_OVERRIDE; |
| 487 | 487 |
| 488 private: | 488 private: |
| 489 bool fIsLocalStream; | 489 bool fIsLocalStream; |
| 490 bool fHasSbixTable; | 490 bool fHasSbixTable; |
| 491 | 491 |
| 492 typedef SkTypeface INHERITED; | 492 typedef SkTypeface INHERITED; |
| 493 }; | 493 }; |
| 494 | 494 |
| 495 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL
ocalStream) { | 495 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL
ocalStream) { |
| 496 SkASSERT(fontRef); | 496 SkASSERT(fontRef); |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 fArray = CFArrayCreate(NULL, NULL, 0, NULL); | 2102 fArray = CFArrayCreate(NULL, NULL, 0, NULL); |
| 2103 } | 2103 } |
| 2104 fCount = SkToInt(CFArrayGetCount(fArray)); | 2104 fCount = SkToInt(CFArrayGetCount(fArray)); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 virtual ~SkFontStyleSet_Mac() { | 2107 virtual ~SkFontStyleSet_Mac() { |
| 2108 CFRelease(fArray); | 2108 CFRelease(fArray); |
| 2109 CFRelease(fFamilyName); | 2109 CFRelease(fFamilyName); |
| 2110 } | 2110 } |
| 2111 | 2111 |
| 2112 virtual int count() SK_OVERRIDE { | 2112 int count() SK_OVERRIDE { |
| 2113 return fCount; | 2113 return fCount; |
| 2114 } | 2114 } |
| 2115 | 2115 |
| 2116 virtual void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVER
RIDE { | 2116 void getStyle(int index, SkFontStyle* style, SkString* name) SK_OVERRIDE { |
| 2117 SkASSERT((unsigned)index < (unsigned)fCount); | 2117 SkASSERT((unsigned)index < (unsigned)fCount); |
| 2118 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f
Array, index); | 2118 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f
Array, index); |
| 2119 if (style) { | 2119 if (style) { |
| 2120 *style = fontstyle_from_descriptor(desc); | 2120 *style = fontstyle_from_descriptor(desc); |
| 2121 } | 2121 } |
| 2122 if (name) { | 2122 if (name) { |
| 2123 if (!find_desc_str(desc, kCTFontStyleNameAttribute, name)) { | 2123 if (!find_desc_str(desc, kCTFontStyleNameAttribute, name)) { |
| 2124 name->reset(); | 2124 name->reset(); |
| 2125 } | 2125 } |
| 2126 } | 2126 } |
| 2127 } | 2127 } |
| 2128 | 2128 |
| 2129 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { | 2129 SkTypeface* createTypeface(int index) SK_OVERRIDE { |
| 2130 SkASSERT((unsigned)index < (unsigned)CFArrayGetCount(fArray)); | 2130 SkASSERT((unsigned)index < (unsigned)CFArrayGetCount(fArray)); |
| 2131 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f
Array, index); | 2131 CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(f
Array, index); |
| 2132 | 2132 |
| 2133 return createFromDesc(fFamilyName, desc); | 2133 return createFromDesc(fFamilyName, desc); |
| 2134 } | 2134 } |
| 2135 | 2135 |
| 2136 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { | 2136 SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { |
| 2137 if (0 == fCount) { | 2137 if (0 == fCount) { |
| 2138 return NULL; | 2138 return NULL; |
| 2139 } | 2139 } |
| 2140 return createFromDesc(fFamilyName, findMatchingDesc(pattern)); | 2140 return createFromDesc(fFamilyName, findMatchingDesc(pattern)); |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 private: | 2143 private: |
| 2144 CFArrayRef fArray; | 2144 CFArrayRef fArray; |
| 2145 CFStringRef fFamilyName; | 2145 CFStringRef fFamilyName; |
| 2146 int fCount; | 2146 int fCount; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 public: | 2190 public: |
| 2191 SkFontMgr_Mac() | 2191 SkFontMgr_Mac() |
| 2192 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames()) | 2192 : fNames(SkCTFontManagerCopyAvailableFontFamilyNames()) |
| 2193 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {} | 2193 , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {} |
| 2194 | 2194 |
| 2195 virtual ~SkFontMgr_Mac() { | 2195 virtual ~SkFontMgr_Mac() { |
| 2196 CFSafeRelease(fNames); | 2196 CFSafeRelease(fNames); |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 protected: | 2199 protected: |
| 2200 virtual int onCountFamilies() const SK_OVERRIDE { | 2200 int onCountFamilies() const SK_OVERRIDE { |
| 2201 return fCount; | 2201 return fCount; |
| 2202 } | 2202 } |
| 2203 | 2203 |
| 2204 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR
IDE { | 2204 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE { |
| 2205 if ((unsigned)index < (unsigned)fCount) { | 2205 if ((unsigned)index < (unsigned)fCount) { |
| 2206 CFStringToSkString(this->stringAt(index), familyName); | 2206 CFStringToSkString(this->stringAt(index), familyName); |
| 2207 } else { | 2207 } else { |
| 2208 familyName->reset(); | 2208 familyName->reset(); |
| 2209 } | 2209 } |
| 2210 } | 2210 } |
| 2211 | 2211 |
| 2212 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { | 2212 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { |
| 2213 if ((unsigned)index >= (unsigned)fCount) { | 2213 if ((unsigned)index >= (unsigned)fCount) { |
| 2214 return NULL; | 2214 return NULL; |
| 2215 } | 2215 } |
| 2216 return CreateSet(this->stringAt(index)); | 2216 return CreateSet(this->stringAt(index)); |
| 2217 } | 2217 } |
| 2218 | 2218 |
| 2219 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER
RIDE { | 2219 SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE { |
| 2220 AutoCFRelease<CFStringRef> cfName(make_CFString(familyName)); | 2220 AutoCFRelease<CFStringRef> cfName(make_CFString(familyName)); |
| 2221 return CreateSet(cfName); | 2221 return CreateSet(cfName); |
| 2222 } | 2222 } |
| 2223 | 2223 |
| 2224 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 2224 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
| 2225 const SkFontStyle&) const SK_OVERRIDE
{ | 2225 const SkFontStyle&) const SK_OVERRIDE
{ |
| 2226 return NULL; | 2226 return NULL; |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, | 2229 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, |
| 2230 const char* bcp47[], int bcp
47Count, | 2230 const char* bcp47[], int bcp
47Count, |
| 2231 SkUnichar character) const S
K_OVERRIDE { | 2231 SkUnichar character) const S
K_OVERRIDE { |
| 2232 return NULL; | 2232 return NULL; |
| 2233 } | 2233 } |
| 2234 | 2234 |
| 2235 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 2235 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, |
| 2236 const SkFontStyle&) const SK_OVERRIDE { | 2236 const SkFontStyle&) const SK_OVERRIDE { |
| 2237 return NULL; | 2237 return NULL; |
| 2238 } | 2238 } |
| 2239 | 2239 |
| 2240 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV
ERRIDE { | 2240 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE { |
| 2241 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data)); | 2241 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data)); |
| 2242 if (NULL == pr) { | 2242 if (NULL == pr) { |
| 2243 return NULL; | 2243 return NULL; |
| 2244 } | 2244 } |
| 2245 return create_from_dataProvider(pr); | 2245 return create_from_dataProvider(pr); |
| 2246 } | 2246 } |
| 2247 | 2247 |
| 2248 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const
SK_OVERRIDE { | 2248 SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER
RIDE { |
| 2249 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(strea
m)); | 2249 AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(strea
m)); |
| 2250 if (NULL == pr) { | 2250 if (NULL == pr) { |
| 2251 return NULL; | 2251 return NULL; |
| 2252 } | 2252 } |
| 2253 return create_from_dataProvider(pr); | 2253 return create_from_dataProvider(pr); |
| 2254 } | 2254 } |
| 2255 | 2255 |
| 2256 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
SK_OVERRIDE { | 2256 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR
IDE { |
| 2257 AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(pat
h)); | 2257 AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(pat
h)); |
| 2258 if (NULL == pr) { | 2258 if (NULL == pr) { |
| 2259 return NULL; | 2259 return NULL; |
| 2260 } | 2260 } |
| 2261 return create_from_dataProvider(pr); | 2261 return create_from_dataProvider(pr); |
| 2262 } | 2262 } |
| 2263 | 2263 |
| 2264 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 2264 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
| 2265 unsigned styleBits) const SK_OVER
RIDE { | 2265 unsigned styleBits) const SK_OVER
RIDE { |
| 2266 | 2266 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2287 } | 2287 } |
| 2288 return face; | 2288 return face; |
| 2289 } | 2289 } |
| 2290 }; | 2290 }; |
| 2291 | 2291 |
| 2292 /////////////////////////////////////////////////////////////////////////////// | 2292 /////////////////////////////////////////////////////////////////////////////// |
| 2293 | 2293 |
| 2294 SkFontMgr* SkFontMgr::Factory() { | 2294 SkFontMgr* SkFontMgr::Factory() { |
| 2295 return SkNEW(SkFontMgr_Mac); | 2295 return SkNEW(SkFontMgr_Mac); |
| 2296 } | 2296 } |
| OLD | NEW |