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 <vector> | 9 #include <vector> |
10 #ifdef SK_BUILD_FOR_MAC | 10 #ifdef SK_BUILD_FOR_MAC |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 NameFontStyleRec rec; | 2100 NameFontStyleRec rec; |
2101 CFStringToSkString(cfFamilyName, &rec.fFamilyName); | 2101 CFStringToSkString(cfFamilyName, &rec.fFamilyName); |
2102 rec.fFontStyle = desc2fontstyle(desc); | 2102 rec.fFontStyle = desc2fontstyle(desc); |
2103 | 2103 |
2104 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(nameFontStyleProc, | 2104 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(nameFontStyleProc, |
2105 &rec); | 2105 &rec); |
2106 if (face) { | 2106 if (face) { |
2107 return face; | 2107 return face; |
2108 } | 2108 } |
2109 | 2109 |
2110 AutoCFRelease<CFDictionaryRef> fontFamilyNameDictionary( | 2110 AutoCFRelease<CTFontRef> ctNamed(CTFontCreateWithName(cfFamilyName, 1, NULL)
); |
2111 CFDictionaryCreate(kCFAllocatorDefault, | |
2112 (const void**)&kCTFontFamilyNameAttribute, (const voi
d**)&cfFamilyName, | |
2113 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionary
ValueCallBacks)); | |
2114 AutoCFRelease<CTFontDescriptorRef> fontDescriptor( | |
2115 CTFontDescriptorCreateWithAttributes(fontFamilyNameDictionary)); | |
2116 AutoCFRelease<CTFontRef> ctNamed(CTFontCreateWithFontDescriptor(fontDescript
or, 0, NULL)); | |
2117 CTFontRef ctFont = CTFontCreateCopyWithAttributes(ctNamed, 1, NULL, desc); | 2111 CTFontRef ctFont = CTFontCreateCopyWithAttributes(ctNamed, 1, NULL, desc); |
2118 if (NULL == ctFont) { | 2112 if (NULL == ctFont) { |
2119 return NULL; | 2113 return NULL; |
2120 } | 2114 } |
2121 | 2115 |
2122 SkString str; | 2116 SkString str; |
2123 CFStringToSkString(cfFamilyName, &str); | 2117 CFStringToSkString(cfFamilyName, &str); |
2124 | 2118 |
2125 bool isFixedPitch; | 2119 bool isFixedPitch; |
2126 (void)computeStyleBits(ctFont, &isFixedPitch); | 2120 (void)computeStyleBits(ctFont, &isFixedPitch); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2307 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
2314 } | 2308 } |
2315 }; | 2309 }; |
2316 | 2310 |
2317 /////////////////////////////////////////////////////////////////////////////// | 2311 /////////////////////////////////////////////////////////////////////////////// |
2318 | 2312 |
2319 SkFontMgr* SkFontMgr::Factory() { | 2313 SkFontMgr* SkFontMgr::Factory() { |
2320 return SkNEW(SkFontMgr_Mac); | 2314 return SkNEW(SkFontMgr_Mac); |
2321 } | 2315 } |
2322 #endif | 2316 #endif |
OLD | NEW |