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 SkFontMgr_DEFINED | 8 #ifndef SkFontMgr_DEFINED |
9 #define SkFontMgr_DEFINED | 9 #define SkFontMgr_DEFINED |
10 | 10 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 #include "SkFontStyle.h" | 12 #include "SkFontStyle.h" |
13 | 13 |
14 class SkData; | 14 class SkData; |
| 15 class SkFontData; |
15 class SkStreamAsset; | 16 class SkStreamAsset; |
16 class SkString; | 17 class SkString; |
17 class SkTypeface; | 18 class SkTypeface; |
18 | 19 |
19 class SK_API SkFontStyleSet : public SkRefCnt { | 20 class SK_API SkFontStyleSet : public SkRefCnt { |
20 public: | 21 public: |
21 SK_DECLARE_INST_COUNT(SkFontStyleSet) | 22 SK_DECLARE_INST_COUNT(SkFontStyleSet) |
22 | 23 |
23 virtual int count() = 0; | 24 virtual int count() = 0; |
24 virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0; | 25 virtual void getStyle(int index, SkFontStyle*, SkString* style) = 0; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const; | 89 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const; |
89 | 90 |
90 /** | 91 /** |
91 * Create a typeface for the specified stream and TTC index | 92 * Create a typeface for the specified stream and TTC index |
92 * (pass 0 for none) or NULL if the stream is not recognized. The caller | 93 * (pass 0 for none) or NULL if the stream is not recognized. The caller |
93 * must call unref() on the returned object if it is not null. | 94 * must call unref() on the returned object if it is not null. |
94 */ | 95 */ |
95 SkTypeface* createFromStream(SkStreamAsset*, int ttcIndex = 0) const; | 96 SkTypeface* createFromStream(SkStreamAsset*, int ttcIndex = 0) const; |
96 | 97 |
97 /** | 98 /** |
| 99 * Create a typeface from the specified font data. |
| 100 * Takes ownership of the font data, so the caller should not reference it
again. |
| 101 * Will return NULL if the typeface could not be created. |
| 102 * The caller must call unref() on the returned object if it is not null. |
| 103 */ |
| 104 SkTypeface* createFromFontData(SkFontData*) const; |
| 105 |
| 106 /** |
98 * Create a typeface for the specified fileName and TTC index | 107 * Create a typeface for the specified fileName and TTC index |
99 * (pass 0 for none) or NULL if the file is not found, or its contents are | 108 * (pass 0 for none) or NULL if the file is not found, or its contents are |
100 * not recognized. The caller must call unref() on the returned object | 109 * not recognized. The caller must call unref() on the returned object |
101 * if it is not null. | 110 * if it is not null. |
102 */ | 111 */ |
103 SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const; | 112 SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const; |
104 | 113 |
105 SkTypeface* legacyCreateTypeface(const char familyName[], | 114 SkTypeface* legacyCreateTypeface(const char familyName[], |
106 unsigned typefaceStyleBits) const; | 115 unsigned typefaceStyleBits) const; |
107 | 116 |
(...skipping 14 matching lines...) Expand all Loading... |
122 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 131 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
123 const SkFontStyle&) const = 0; | 132 const SkFontStyle&) const = 0; |
124 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, | 133 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, |
125 const char* bcp47[], int bcp
47Count, | 134 const char* bcp47[], int bcp
47Count, |
126 SkUnichar character) const =
0; | 135 SkUnichar character) const =
0; |
127 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 136 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
128 const SkFontStyle&) const = 0; | 137 const SkFontStyle&) const = 0; |
129 | 138 |
130 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0; | 139 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0; |
131 virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const =
0; | 140 virtual SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const =
0; |
| 141 // TODO: make pure virtual. |
| 142 virtual SkTypeface* onCreateFromFontData(SkFontData*) const; |
132 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
= 0; | 143 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
= 0; |
133 | 144 |
134 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 145 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
135 unsigned styleBits) const = 0; | 146 unsigned styleBits) const = 0; |
136 private: | 147 private: |
137 static SkFontMgr* Factory(); // implemented by porting layer | 148 static SkFontMgr* Factory(); // implemented by porting layer |
138 friend SkFontMgr* sk_fontmgr_create_default(); | 149 friend SkFontMgr* sk_fontmgr_create_default(); |
139 | 150 |
140 typedef SkRefCnt INHERITED; | 151 typedef SkRefCnt INHERITED; |
141 }; | 152 }; |
142 | 153 |
143 #endif | 154 #endif |
OLD | NEW |