OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkFontConfigInterface_DEFINED | 8 #ifndef SkFontConfigInterface_DEFINED |
9 #define SkFontConfigInterface_DEFINED | 9 #define SkFontConfigInterface_DEFINED |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 * if the FontRef's data is not available. The caller is responsible for | 90 * if the FontRef's data is not available. The caller is responsible for |
91 * deleting the stream when it is done accessing the data. | 91 * deleting the stream when it is done accessing the data. |
92 */ | 92 */ |
93 virtual SkStreamAsset* openStream(const FontIdentity&) = 0; | 93 virtual SkStreamAsset* openStream(const FontIdentity&) = 0; |
94 | 94 |
95 /** | 95 /** |
96 * Return an SkTypeface for the given FontIdentity. | 96 * Return an SkTypeface for the given FontIdentity. |
97 * | 97 * |
98 * The default implementation simply returns a new typeface built using dat
a obtained from | 98 * The default implementation simply returns a new typeface built using dat
a obtained from |
99 * openStream(), but derived classes may implement more complex caching sch
emes. | 99 * openStream(), but derived classes may implement more complex caching sch
emes. |
100 * | |
101 * Callers are responsible for unref-ing the result. | |
102 */ | 100 */ |
| 101 virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity) { |
| 102 return SkTypeface::MakeFromStream(this->openStream(identity), identity.f
TTCIndex); |
| 103 } |
| 104 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
103 virtual SkTypeface* createTypeface(const FontIdentity& identity) { | 105 virtual SkTypeface* createTypeface(const FontIdentity& identity) { |
104 return SkTypeface::CreateFromStream(this->openStream(identity), identity
.fTTCIndex); | 106 return this->makeTypeface(identity).release(); |
105 } | 107 } |
| 108 #endif |
106 | 109 |
107 /** | 110 /** |
108 * Return a singleton instance of a direct subclass that calls into | 111 * Return a singleton instance of a direct subclass that calls into |
109 * libfontconfig. This does not affect the refcnt of the returned instance. | 112 * libfontconfig. This does not affect the refcnt of the returned instance. |
110 * The mutex may be used to guarantee the singleton is only constructed onc
e. | 113 * The mutex may be used to guarantee the singleton is only constructed onc
e. |
111 */ | 114 */ |
112 static SkFontConfigInterface* GetSingletonDirectInterface(); | 115 static SkFontConfigInterface* GetSingletonDirectInterface(); |
113 | 116 |
114 // New APIS, which have default impls for now (which do nothing) | 117 // New APIS, which have default impls for now (which do nothing) |
115 | 118 |
116 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); } | 119 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); } |
117 typedef SkRefCnt INHERITED; | 120 typedef SkRefCnt INHERITED; |
118 }; | 121 }; |
119 | 122 |
120 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */ | 123 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */ |
121 SK_API SkFontMgr* SkFontMgr_New_FCI(SkFontConfigInterface* fci); | 124 SK_API SkFontMgr* SkFontMgr_New_FCI(SkFontConfigInterface* fci); |
122 | 125 |
123 #endif | 126 #endif |
OLD | NEW |