Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: src/ports/SkFontHost_linux.cpp

Issue 134643028: Make SkFontMgr interface const. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: dw fixes Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/fonts/SkFontMgr_fontconfig.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 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 "SkFontHost.h" 8 #include "SkFontHost.h"
9 #include "SkFontHost_FreeType_common.h" 9 #include "SkFontHost_FreeType_common.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 * one SkFontStyleSet_Custom for each family. This class may be modified 208 * one SkFontStyleSet_Custom for each family. This class may be modified
209 * to load fonts from any source by changing the initialization. 209 * to load fonts from any source by changing the initialization.
210 */ 210 */
211 class SkFontMgr_Custom : public SkFontMgr { 211 class SkFontMgr_Custom : public SkFontMgr {
212 public: 212 public:
213 explicit SkFontMgr_Custom(const char* dir) { 213 explicit SkFontMgr_Custom(const char* dir) {
214 this->load_system_fonts(dir); 214 this->load_system_fonts(dir);
215 } 215 }
216 216
217 protected: 217 protected:
218 virtual int onCountFamilies() SK_OVERRIDE { 218 virtual int onCountFamilies() const SK_OVERRIDE {
219 return fFamilies.count(); 219 return fFamilies.count();
220 } 220 }
221 221
222 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { 222 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR IDE {
223 SkASSERT(index < fFamilies.count()); 223 SkASSERT(index < fFamilies.count());
224 familyName->set(fFamilies[index]->fFamilyName); 224 familyName->set(fFamilies[index]->fFamilyName);
225 } 225 }
226 226
227 virtual SkFontStyleSet_Custom* onCreateStyleSet(int index) SK_OVERRIDE { 227 virtual SkFontStyleSet_Custom* onCreateStyleSet(int index) const SK_OVERRIDE {
228 SkASSERT(index < fFamilies.count()); 228 SkASSERT(index < fFamilies.count());
229 return SkRef(fFamilies[index].get()); 229 return SkRef(fFamilies[index].get());
230 } 230 }
231 231
232 virtual SkFontStyleSet_Custom* onMatchFamily(const char familyName[]) SK_OVE RRIDE { 232 virtual SkFontStyleSet_Custom* onMatchFamily(const char familyName[]) const SK_OVERRIDE {
233 for (int i = 0; i < fFamilies.count(); ++i) { 233 for (int i = 0; i < fFamilies.count(); ++i) {
234 if (fFamilies[i]->fFamilyName.equals(familyName)) { 234 if (fFamilies[i]->fFamilyName.equals(familyName)) {
235 return SkRef(fFamilies[i].get()); 235 return SkRef(fFamilies[i].get());
236 } 236 }
237 } 237 }
238 return NULL; 238 return NULL;
239 } 239 }
240 240
241 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], 241 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
242 const SkFontStyle& fontStyle) SK_OVER RIDE 242 const SkFontStyle& fontStyle) const S K_OVERRIDE
243 { 243 {
244 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); 244 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
245 return sset->matchStyle(fontStyle); 245 return sset->matchStyle(fontStyle);
246 } 246 }
247 247
248 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, 248 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
249 const SkFontStyle& fontStyle) SK_OVERRI DE 249 const SkFontStyle& fontStyle) const SK_ OVERRIDE
250 { 250 {
251 for (int i = 0; i < fFamilies.count(); ++i) { 251 for (int i = 0; i < fFamilies.count(); ++i) {
252 for (int j = 0; j < fFamilies[i]->fStyles.count(); ++j) { 252 for (int j = 0; j < fFamilies[i]->fStyles.count(); ++j) {
253 if (fFamilies[i]->fStyles[j] == familyMember) { 253 if (fFamilies[i]->fStyles[j] == familyMember) {
254 return fFamilies[i]->matchStyle(fontStyle); 254 return fFamilies[i]->matchStyle(fontStyle);
255 } 255 }
256 } 256 }
257 } 257 }
258 return NULL; 258 return NULL;
259 } 259 }
260 260
261 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) SK_OVERRIDE { 261 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV ERRIDE {
262 SkAutoTUnref<SkStream> stream(new SkMemoryStream(data)); 262 SkAutoTUnref<SkStream> stream(new SkMemoryStream(data));
263 return this->createFromStream(stream, ttcIndex); 263 return this->createFromStream(stream, ttcIndex);
264 } 264 }
265 265
266 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) SK_OV ERRIDE { 266 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE {
267 if (NULL == stream || stream->getLength() <= 0) { 267 if (NULL == stream || stream->getLength() <= 0) {
268 SkDELETE(stream); 268 SkDELETE(stream);
269 return NULL; 269 return NULL;
270 } 270 }
271 271
272 bool isFixedPitch; 272 bool isFixedPitch;
273 SkTypeface::Style style; 273 SkTypeface::Style style;
274 SkString name; 274 SkString name;
275 if (find_name_and_attributes(stream, &name, &style, &isFixedPitch)) { 275 if (find_name_and_attributes(stream, &name, &style, &isFixedPitch)) {
276 return SkNEW_ARGS(SkTypeface_Stream, (style, false, stream, isFixedP itch, name)); 276 return SkNEW_ARGS(SkTypeface_Stream, (style, false, stream, isFixedP itch, name));
277 } else { 277 } else {
278 return NULL; 278 return NULL;
279 } 279 }
280 } 280 }
281 281
282 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) SK_OVE RRIDE { 282 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE {
283 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 283 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
284 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; 284 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL;
285 } 285 }
286 286
287 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 287 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
288 unsigned styleBits) SK_OVERRIDE 288 unsigned styleBits) const SK_OVER RIDE
289 { 289 {
290 SkTypeface::Style oldStyle = (SkTypeface::Style)styleBits; 290 SkTypeface::Style oldStyle = (SkTypeface::Style)styleBits;
291 SkFontStyle style = SkFontStyle(oldStyle & SkTypeface::kBold 291 SkFontStyle style = SkFontStyle(oldStyle & SkTypeface::kBold
292 ? SkFontStyle::kBold_Weight 292 ? SkFontStyle::kBold_Weight
293 : SkFontStyle::kNormal_Weight, 293 : SkFontStyle::kNormal_Weight,
294 SkFontStyle::kNormal_Width, 294 SkFontStyle::kNormal_Width,
295 oldStyle & SkTypeface::kItalic 295 oldStyle & SkTypeface::kItalic
296 ? SkFontStyle::kItalic_Slant 296 ? SkFontStyle::kItalic_Slant
297 : SkFontStyle::kUpright_Slant); 297 : SkFontStyle::kUpright_Slant);
298 SkTypeface* tf = NULL; 298 SkTypeface* tf = NULL;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 403 }
404 404
405 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies; 405 SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> fFamilies;
406 SkFontStyleSet_Custom* gDefaultFamily; 406 SkFontStyleSet_Custom* gDefaultFamily;
407 SkTypeface* gDefaultNormal; 407 SkTypeface* gDefaultNormal;
408 }; 408 };
409 409
410 SkFontMgr* SkFontMgr::Factory() { 410 SkFontMgr* SkFontMgr::Factory() {
411 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX); 411 return new SkFontMgr_Custom(SK_FONT_FILE_PREFIX);
412 } 412 }
OLDNEW
« no previous file with comments | « src/fonts/SkFontMgr_fontconfig.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698