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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 #define WEIGHT_THRESHOLD ((SkFontStyle::kNormal_Weight + SkFontStyle::kBold_W
eight)/2) | 437 #define WEIGHT_THRESHOLD ((SkFontStyle::kNormal_Weight + SkFontStyle::kBold_W
eight)/2) |
438 | 438 |
439 class SkTypeface_Mac : public SkTypeface { | 439 class SkTypeface_Mac : public SkTypeface { |
440 public: | 440 public: |
441 SkTypeface_Mac(const SkFontStyle& fs, SkFontID fontID, bool isFixedPitch, | 441 SkTypeface_Mac(const SkFontStyle& fs, SkFontID fontID, bool isFixedPitch, |
442 CTFontRef fontRef, const char requestedName[], bool isLocalSt
ream) | 442 CTFontRef fontRef, const char requestedName[], bool isLocalSt
ream) |
443 : SkTypeface(fs, fontID, isFixedPitch) | 443 : SkTypeface(fs, fontID, isFixedPitch) |
444 , fRequestedName(requestedName) | 444 , fRequestedName(requestedName) |
445 , fFontRef(fontRef) // caller has already called CFRetain for us | 445 , fFontRef(fontRef) // caller has already called CFRetain for us |
446 , fIsLocalStream(isLocalStream) | 446 , fIsLocalStream(isLocalStream) |
447 , fHasSbixTable(false) | 447 , fHasColorGlyphs(CTFontGetSymbolicTraits(fFontRef) & kCTFontColorGlyphs
Trait) |
448 { | 448 { |
449 SkASSERT(fontRef); | 449 SkASSERT(fontRef); |
450 | |
451 AutoCFRelease<CFArrayRef> tags(CTFontCopyAvailableTables(fFontRef,kCTFon
tTableOptionNoOptions)); | |
452 if (tags) { | |
453 int count = SkToInt(CFArrayGetCount(tags)); | |
454 for (int i = 0; i < count; ++i) { | |
455 uintptr_t tag = reinterpret_cast<uintptr_t>(CFArrayGetValueAtInd
ex(tags, i)); | |
456 if ('sbix' == tag) { | |
457 fHasSbixTable = true; | |
458 break; | |
459 } | |
460 } | |
461 } | |
462 } | 450 } |
463 | 451 |
464 SkString fRequestedName; | 452 SkString fRequestedName; |
465 AutoCFRelease<CTFontRef> fFontRef; | 453 AutoCFRelease<CTFontRef> fFontRef; |
466 | 454 |
467 protected: | 455 protected: |
468 int onGetUPEM() const SK_OVERRIDE; | 456 int onGetUPEM() const SK_OVERRIDE; |
469 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 457 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
470 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; | 458 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; |
471 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE
; | 459 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE
; |
472 int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 460 int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
473 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 461 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
474 size_t length, void* data) const SK_OVERRIDE; | 462 size_t length, void* data) const SK_OVERRIDE; |
475 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRID
E; | 463 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRID
E; |
476 void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 464 void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
477 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; | 465 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; |
478 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 466 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
479 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 467 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
480 const uint32_t*, uint32_t) const SK_OVERRIDE; | 468 const uint32_t*, uint32_t) const SK_OVERRIDE; |
481 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 469 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
482 int glyphCount) const SK_OVERRIDE; | 470 int glyphCount) const SK_OVERRIDE; |
483 int onCountGlyphs() const SK_OVERRIDE; | 471 int onCountGlyphs() const SK_OVERRIDE; |
484 | 472 |
485 private: | 473 private: |
486 bool fIsLocalStream; | 474 bool fIsLocalStream; |
487 bool fHasSbixTable; | 475 bool fHasColorGlyphs; |
488 | 476 |
489 typedef SkTypeface INHERITED; | 477 typedef SkTypeface INHERITED; |
490 }; | 478 }; |
491 | 479 |
492 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL
ocalStream) { | 480 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool isL
ocalStream) { |
493 SkASSERT(fontRef); | 481 SkASSERT(fontRef); |
494 bool isFixedPitch; | 482 bool isFixedPitch; |
495 SkFontStyle style = SkFontStyle(computeStyleBits(fontRef, &isFixedPitch)); | 483 SkFontStyle style = SkFontStyle(computeStyleBits(fontRef, &isFixedPitch)); |
496 SkFontID fontID = CTFontRef_to_SkFontID(fontRef); | 484 SkFontID fontID = CTFontRef_to_SkFontID(fontRef); |
497 | 485 |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 rec->fMaskFormat = SkMask::kLCD16_Format; | 1878 rec->fMaskFormat = SkMask::kLCD16_Format; |
1891 rec->setHinting(SkPaint::kNormal_Hinting); | 1879 rec->setHinting(SkPaint::kNormal_Hinting); |
1892 } else { | 1880 } else { |
1893 rec->fMaskFormat = SkMask::kA8_Format; | 1881 rec->fMaskFormat = SkMask::kA8_Format; |
1894 } | 1882 } |
1895 } | 1883 } |
1896 | 1884 |
1897 // CoreText provides no information as to whether a glyph will be color or n
ot. | 1885 // CoreText provides no information as to whether a glyph will be color or n
ot. |
1898 // Fonts may mix outlines and bitmaps, so information is needed on a glyph b
y glyph basis. | 1886 // Fonts may mix outlines and bitmaps, so information is needed on a glyph b
y glyph basis. |
1899 // If a font contains an 'sbix' table, consider it to be a color font, and d
isable lcd. | 1887 // If a font contains an 'sbix' table, consider it to be a color font, and d
isable lcd. |
1900 if (fHasSbixTable) { | 1888 if (fHasColorGlyphs) { |
1901 rec->fMaskFormat = SkMask::kARGB32_Format; | 1889 rec->fMaskFormat = SkMask::kARGB32_Format; |
1902 } | 1890 } |
1903 | 1891 |
1904 // Unhinted A8 masks (those not derived from LCD masks) must respect SK_GAMM
A_APPLY_TO_A8. | 1892 // Unhinted A8 masks (those not derived from LCD masks) must respect SK_GAMM
A_APPLY_TO_A8. |
1905 // All other masks can use regular gamma. | 1893 // All other masks can use regular gamma. |
1906 if (SkMask::kA8_Format == rec->fMaskFormat && SkPaint::kNo_Hinting == hintin
g) { | 1894 if (SkMask::kA8_Format == rec->fMaskFormat && SkPaint::kNo_Hinting == hintin
g) { |
1907 #ifndef SK_GAMMA_APPLY_TO_A8 | 1895 #ifndef SK_GAMMA_APPLY_TO_A8 |
1908 rec->ignorePreBlend(); | 1896 rec->ignorePreBlend(); |
1909 #endif | 1897 #endif |
1910 } else { | 1898 } else { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 } | 2272 } |
2285 return face; | 2273 return face; |
2286 } | 2274 } |
2287 }; | 2275 }; |
2288 | 2276 |
2289 /////////////////////////////////////////////////////////////////////////////// | 2277 /////////////////////////////////////////////////////////////////////////////// |
2290 | 2278 |
2291 SkFontMgr* SkFontMgr::Factory() { | 2279 SkFontMgr* SkFontMgr::Factory() { |
2292 return SkNEW(SkFontMgr_Mac); | 2280 return SkNEW(SkFontMgr_Mac); |
2293 } | 2281 } |
OLD | NEW |