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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 SkTypeface::Style* outStyle) = 0; | 88 SkTypeface::Style* outStyle) = 0; |
89 | 89 |
90 /** | 90 /** |
91 * Given a FontRef, open a stream to access its data, or return null | 91 * Given a FontRef, open a stream to access its data, or return null |
92 * if the FontRef's data is not available. The caller is responsible for | 92 * if the FontRef's data is not available. The caller is responsible for |
93 * deleting the stream when it is done accessing the data. | 93 * deleting the stream when it is done accessing the data. |
94 */ | 94 */ |
95 virtual SkStreamAsset* openStream(const FontIdentity&) = 0; | 95 virtual SkStreamAsset* openStream(const FontIdentity&) = 0; |
96 | 96 |
97 /** | 97 /** |
| 98 * Return an SkTypeface for the given FontIdentity. |
| 99 * |
| 100 * The default implementation simply returns a new typeface built using dat
a obtained from |
| 101 * openStream(), but derived classes may implement more complex caching sch
emes. |
| 102 * |
| 103 * Callers are responsible for unref-ing the result. |
| 104 */ |
| 105 virtual SkTypeface* createTypeface(const FontIdentity& identity) { |
| 106 return SkTypeface::CreateFromStream(this->openStream(identity), identity
.fTTCIndex); |
| 107 } |
| 108 |
| 109 /** |
98 * Return a singleton instance of a direct subclass that calls into | 110 * Return a singleton instance of a direct subclass that calls into |
99 * libfontconfig. This does not affect the refcnt of the returned instance. | 111 * libfontconfig. This does not affect the refcnt of the returned instance. |
100 * The mutex may be used to guarantee the singleton is only constructed onc
e. | 112 * The mutex may be used to guarantee the singleton is only constructed onc
e. |
101 */ | 113 */ |
102 static SkFontConfigInterface* GetSingletonDirectInterface(SkBaseMutex* mutex
= NULL); | 114 static SkFontConfigInterface* GetSingletonDirectInterface(SkBaseMutex* mutex
= NULL); |
103 | 115 |
104 // New APIS, which have default impls for now (which do nothing) | 116 // New APIS, which have default impls for now (which do nothing) |
105 | 117 |
106 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); } | 118 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); } |
107 virtual bool matchFamilySet(const char[] /*inFamilyName*/, | 119 virtual bool matchFamilySet(const char[] /*inFamilyName*/, |
108 SkString* /*outFamilyName*/, | 120 SkString* /*outFamilyName*/, |
109 SkTArray<FontIdentity>*) { | 121 SkTArray<FontIdentity>*) { |
110 return false; | 122 return false; |
111 } | 123 } |
112 typedef SkRefCnt INHERITED; | 124 typedef SkRefCnt INHERITED; |
113 }; | 125 }; |
114 | 126 |
115 #endif | 127 #endif |
OLD | NEW |