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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 protected: | 411 protected: |
412 friend class SkFontHost; // to access our protected members for deprecate
d methods | 412 friend class SkFontHost; // to access our protected members for deprecate
d methods |
413 | 413 |
414 virtual int onGetUPEM() const SK_OVERRIDE; | 414 virtual int onGetUPEM() const SK_OVERRIDE; |
415 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 415 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
416 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 416 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
417 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 417 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
418 size_t length, void* data) const SK_OVERRIDE; | 418 size_t length, void* data) const SK_OVERRIDE; |
419 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; | 419 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK
_OVERRIDE; |
420 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 420 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
421 virtual void onGetFontDescriptor(SkFontDescriptor*) const SK_OVERRIDE; | 421 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; |
422 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 422 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
423 SkAdvancedTypefaceMetrics::PerGlyphInfo, | 423 SkAdvancedTypefaceMetrics::PerGlyphInfo, |
424 const uint32_t*, uint32_t) const SK_OVERRIDE; | 424 const uint32_t*, uint32_t) const SK_OVERRIDE; |
425 | 425 |
426 private: | 426 private: |
427 typedef SkTypeface INHERITED; | 427 typedef SkTypeface INHERITED; |
428 }; | 428 }; |
429 | 429 |
430 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[]) { | 430 static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[]) { |
431 SkASSERT(fontRef); | 431 SkASSERT(fontRef); |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 | 1676 |
1677 dataPtr += (tableSize + 3) & ~3; | 1677 dataPtr += (tableSize + 3) & ~3; |
1678 ++entry; | 1678 ++entry; |
1679 } | 1679 } |
1680 | 1680 |
1681 return stream; | 1681 return stream; |
1682 } | 1682 } |
1683 | 1683 |
1684 /////////////////////////////////////////////////////////////////////////////// | 1684 /////////////////////////////////////////////////////////////////////////////// |
1685 | 1685 |
1686 #include "SkStream.h" | |
1687 | |
1688 void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) { | |
1689 SkFontDescriptor desc; | |
1690 face->onGetFontDescriptor(&desc); | |
1691 | |
1692 desc.serialize(stream); | |
1693 | |
1694 // by convention, we also write out the actual sfnt data, preceeded by | |
1695 // a packed-length. For now we skip that, so we just write the zero. | |
1696 stream->writePackedUInt(0); | |
1697 } | |
1698 | |
1699 SkTypeface* SkFontHost::Deserialize(SkStream* stream) { | |
1700 SkFontDescriptor desc(stream); | |
1701 | |
1702 // by convention, Serialize will have also written the actual sfnt data. | |
1703 // for now, we just want to skip it. | |
1704 size_t size = stream->readPackedUInt(); | |
1705 stream->skip(size); | |
1706 | |
1707 return SkFontHost::CreateTypeface(NULL, desc.getFamilyName(), desc.getStyle(
)); | |
1708 } | |
1709 | |
1710 /////////////////////////////////////////////////////////////////////////////// | |
1711 | |
1712 // DEPRECATED | 1686 // DEPRECATED |
1713 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo
ntID) { | 1687 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo
ntID) { |
1714 SkTypeface* face = GetDefaultFace(); | 1688 SkTypeface* face = GetDefaultFace(); |
1715 if (face->uniqueID() == currFontID) { | 1689 if (face->uniqueID() == currFontID) { |
1716 face = NULL; | 1690 face = NULL; |
1717 } | 1691 } |
1718 return SkSafeRef(face); | 1692 return SkSafeRef(face); |
1719 } | 1693 } |
1720 | 1694 |
1721 /////////////////////////////////////////////////////////////////////////////// | 1695 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 } | 1814 } |
1841 } | 1815 } |
1842 | 1816 |
1843 // we take ownership of the ref | 1817 // we take ownership of the ref |
1844 static const char* get_str(CFStringRef ref, SkString* str) { | 1818 static const char* get_str(CFStringRef ref, SkString* str) { |
1845 CFStringToSkString(ref, str); | 1819 CFStringToSkString(ref, str); |
1846 CFSafeRelease(ref); | 1820 CFSafeRelease(ref); |
1847 return str->c_str(); | 1821 return str->c_str(); |
1848 } | 1822 } |
1849 | 1823 |
1850 void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc) const { | 1824 void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc, |
1851 this->INHERITED::onGetFontDescriptor(desc); | 1825 bool* isLocalStream) const { |
1852 SkString tmpStr; | 1826 SkString tmpStr; |
1853 | 1827 |
1854 desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr)); | 1828 desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr)); |
1855 desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr)); | 1829 desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr)); |
1856 desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr)
); | 1830 desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr)
); |
| 1831 // TODO: need to add support for local-streams (here and openStream) |
| 1832 *isLocalStream = false; |
1857 } | 1833 } |
| 1834 |
OLD | NEW |