OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The Android Open Source Project | 2 * Copyright 2009 The Android Open Source Project |
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 #include "SkFontLCDConfig.h" | 8 #include "SkFontLCDConfig.h" |
9 #include "SkOnce.h" | 9 #include "SkOnce.h" |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 }; | 85 }; |
86 | 86 |
87 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { | 87 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { |
88 return SkNEW(SkEmptyFontStyleSet); | 88 return SkNEW(SkEmptyFontStyleSet); |
89 } | 89 } |
90 | 90 |
91 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
92 | 92 |
93 class SkEmptyFontMgr : public SkFontMgr { | 93 class SkEmptyFontMgr : public SkFontMgr { |
94 protected: | 94 protected: |
95 virtual int onCountFamilies() SK_OVERRIDE { | 95 virtual int onCountFamilies() const SK_OVERRIDE { |
96 return 0; | 96 return 0; |
97 } | 97 } |
98 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { | 98 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR
IDE { |
99 SkDEBUGFAIL("onGetFamilyName called with bad index"); | 99 SkDEBUGFAIL("onGetFamilyName called with bad index"); |
100 } | 100 } |
101 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE { | 101 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { |
102 SkDEBUGFAIL("onCreateStyleSet called with bad index"); | 102 SkDEBUGFAIL("onCreateStyleSet called with bad index"); |
103 return NULL; | 103 return NULL; |
104 } | 104 } |
105 virtual SkFontStyleSet* onMatchFamily(const char[]) SK_OVERRIDE { | 105 virtual SkFontStyleSet* onMatchFamily(const char[]) const SK_OVERRIDE { |
106 return SkFontStyleSet::CreateEmpty(); | 106 return SkFontStyleSet::CreateEmpty(); |
107 } | 107 } |
108 | 108 |
109 virtual SkTypeface* onMatchFamilyStyle(const char[], | 109 virtual SkTypeface* onMatchFamilyStyle(const char[], |
110 const SkFontStyle&) SK_OVERRIDE { | 110 const SkFontStyle&) const SK_OVERRIDE
{ |
111 return NULL; | 111 return NULL; |
112 } | 112 } |
113 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 113 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
114 const SkFontStyle&) SK_OVERRIDE { | 114 const SkFontStyle&) const SK_OVERRIDE { |
115 return NULL; | 115 return NULL; |
116 } | 116 } |
117 virtual SkTypeface* onCreateFromData(SkData*, int) SK_OVERRIDE { | 117 virtual SkTypeface* onCreateFromData(SkData*, int) const SK_OVERRIDE { |
118 return NULL; | 118 return NULL; |
119 } | 119 } |
120 virtual SkTypeface* onCreateFromStream(SkStream*, int) SK_OVERRIDE { | 120 virtual SkTypeface* onCreateFromStream(SkStream*, int) const SK_OVERRIDE { |
121 return NULL; | 121 return NULL; |
122 } | 122 } |
123 virtual SkTypeface* onCreateFromFile(const char[], int) SK_OVERRIDE { | 123 virtual SkTypeface* onCreateFromFile(const char[], int) const SK_OVERRIDE { |
124 return NULL; | 124 return NULL; |
125 } | 125 } |
126 virtual SkTypeface* onLegacyCreateTypeface(const char [], unsigned) SK_OVERR
IDE { | 126 virtual SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const SK
_OVERRIDE { |
127 return NULL; | 127 return NULL; |
128 } | 128 } |
129 }; | 129 }; |
130 | 130 |
131 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { | 131 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { |
132 if (NULL == fsset) { | 132 if (NULL == fsset) { |
133 fsset = SkFontStyleSet::CreateEmpty(); | 133 fsset = SkFontStyleSet::CreateEmpty(); |
134 } | 134 } |
135 return fsset; | 135 return fsset; |
136 } | 136 } |
137 | 137 |
138 int SkFontMgr::countFamilies() { | 138 int SkFontMgr::countFamilies() const { |
139 return this->onCountFamilies(); | 139 return this->onCountFamilies(); |
140 } | 140 } |
141 | 141 |
142 void SkFontMgr::getFamilyName(int index, SkString* familyName) { | 142 void SkFontMgr::getFamilyName(int index, SkString* familyName) const { |
143 this->onGetFamilyName(index, familyName); | 143 this->onGetFamilyName(index, familyName); |
144 } | 144 } |
145 | 145 |
146 SkFontStyleSet* SkFontMgr::createStyleSet(int index) { | 146 SkFontStyleSet* SkFontMgr::createStyleSet(int index) const { |
147 return emptyOnNull(this->onCreateStyleSet(index)); | 147 return emptyOnNull(this->onCreateStyleSet(index)); |
148 } | 148 } |
149 | 149 |
150 SkFontStyleSet* SkFontMgr::matchFamily(const char familyName[]) { | 150 SkFontStyleSet* SkFontMgr::matchFamily(const char familyName[]) const { |
151 return emptyOnNull(this->onMatchFamily(familyName)); | 151 return emptyOnNull(this->onMatchFamily(familyName)); |
152 } | 152 } |
153 | 153 |
154 SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[], | 154 SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[], |
155 const SkFontStyle& fs) { | 155 const SkFontStyle& fs) const { |
156 return this->onMatchFamilyStyle(familyName, fs); | 156 return this->onMatchFamilyStyle(familyName, fs); |
157 } | 157 } |
158 | 158 |
159 SkTypeface* SkFontMgr::matchFaceStyle(const SkTypeface* face, | 159 SkTypeface* SkFontMgr::matchFaceStyle(const SkTypeface* face, |
160 const SkFontStyle& fs) { | 160 const SkFontStyle& fs) const { |
161 return this->onMatchFaceStyle(face, fs); | 161 return this->onMatchFaceStyle(face, fs); |
162 } | 162 } |
163 | 163 |
164 SkTypeface* SkFontMgr::createFromData(SkData* data, int ttcIndex) { | 164 SkTypeface* SkFontMgr::createFromData(SkData* data, int ttcIndex) const { |
165 if (NULL == data) { | 165 if (NULL == data) { |
166 return NULL; | 166 return NULL; |
167 } | 167 } |
168 return this->onCreateFromData(data, ttcIndex); | 168 return this->onCreateFromData(data, ttcIndex); |
169 } | 169 } |
170 | 170 |
171 SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) { | 171 SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) const { |
172 if (NULL == stream) { | 172 if (NULL == stream) { |
173 return NULL; | 173 return NULL; |
174 } | 174 } |
175 return this->onCreateFromStream(stream, ttcIndex); | 175 return this->onCreateFromStream(stream, ttcIndex); |
176 } | 176 } |
177 | 177 |
178 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) { | 178 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) const { |
179 if (NULL == path) { | 179 if (NULL == path) { |
180 return NULL; | 180 return NULL; |
181 } | 181 } |
182 return this->onCreateFromFile(path, ttcIndex); | 182 return this->onCreateFromFile(path, ttcIndex); |
183 } | 183 } |
184 | 184 |
185 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], | 185 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], |
186 unsigned styleBits) { | 186 unsigned styleBits) const { |
187 return this->onLegacyCreateTypeface(familyName, styleBits); | 187 return this->onLegacyCreateTypeface(familyName, styleBits); |
188 } | 188 } |
189 | 189 |
190 void set_up_default(SkFontMgr** singleton) { | 190 void set_up_default(SkFontMgr** singleton) { |
191 *singleton = SkFontMgr::Factory(); | 191 *singleton = SkFontMgr::Factory(); |
192 // we never want to return NULL | 192 // we never want to return NULL |
193 if (NULL == *singleton) { | 193 if (NULL == *singleton) { |
194 *singleton = SkNEW(SkEmptyFontMgr); | 194 *singleton = SkNEW(SkEmptyFontMgr); |
195 } | 195 } |
196 } | 196 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 241 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
242 return fm->createFromFile(path); | 242 return fm->createFromFile(path); |
243 } | 243 } |
244 | 244 |
245 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | 245 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
246 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 246 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
247 return fm->createFromStream(stream); | 247 return fm->createFromStream(stream); |
248 } | 248 } |
249 | 249 |
250 #endif | 250 #endif |
OLD | NEW |