| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkFontMgr.h" | 8 #include "SkFontMgr.h" |
| 9 #include "SkLazyPtr.h" | 9 #include "SkLazyPtr.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 | 12 |
| 13 class SkFontStyle; | 13 class SkFontStyle; |
| 14 class SkTypeface; | 14 class SkTypeface; |
| 15 | 15 |
| 16 class SkEmptyFontStyleSet : public SkFontStyleSet { | 16 class SkEmptyFontStyleSet : public SkFontStyleSet { |
| 17 public: | 17 public: |
| 18 int count() SK_OVERRIDE { return 0; } | 18 int count() override { return 0; } |
| 19 void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { | 19 void getStyle(int, SkFontStyle*, SkString*) override { |
| 20 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set"); | 20 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set"); |
| 21 } | 21 } |
| 22 SkTypeface* createTypeface(int index) SK_OVERRIDE { | 22 SkTypeface* createTypeface(int index) override { |
| 23 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); | 23 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); |
| 24 return NULL; | 24 return NULL; |
| 25 } | 25 } |
| 26 SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE { | 26 SkTypeface* matchStyle(const SkFontStyle&) override { |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { | 31 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { |
| 32 return SkNEW(SkEmptyFontStyleSet); | 32 return SkNEW(SkEmptyFontStyleSet); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 36 | 36 |
| 37 class SkEmptyFontMgr : public SkFontMgr { | 37 class SkEmptyFontMgr : public SkFontMgr { |
| 38 protected: | 38 protected: |
| 39 int onCountFamilies() const SK_OVERRIDE { | 39 int onCountFamilies() const override { |
| 40 return 0; | 40 return 0; |
| 41 } | 41 } |
| 42 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE { | 42 void onGetFamilyName(int index, SkString* familyName) const override { |
| 43 SkDEBUGFAIL("onGetFamilyName called with bad index"); | 43 SkDEBUGFAIL("onGetFamilyName called with bad index"); |
| 44 } | 44 } |
| 45 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { | 45 SkFontStyleSet* onCreateStyleSet(int index) const override { |
| 46 SkDEBUGFAIL("onCreateStyleSet called with bad index"); | 46 SkDEBUGFAIL("onCreateStyleSet called with bad index"); |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| 49 SkFontStyleSet* onMatchFamily(const char[]) const SK_OVERRIDE { | 49 SkFontStyleSet* onMatchFamily(const char[]) const override { |
| 50 return SkFontStyleSet::CreateEmpty(); | 50 return SkFontStyleSet::CreateEmpty(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual SkTypeface* onMatchFamilyStyle(const char[], | 53 virtual SkTypeface* onMatchFamilyStyle(const char[], |
| 54 const SkFontStyle&) const SK_OVERRIDE
{ | 54 const SkFontStyle&) const override { |
| 55 return NULL; | 55 return NULL; |
| 56 } | 56 } |
| 57 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], | 57 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
| 58 const SkFontStyle& style, | 58 const SkFontStyle& style, |
| 59 const char* bcp47[], | 59 const char* bcp47[], |
| 60 int bcp47Count, | 60 int bcp47Count, |
| 61 SkUnichar character) const S
K_OVERRIDE { | 61 SkUnichar character) const o
verride { |
| 62 return NULL; | 62 return NULL; |
| 63 } | 63 } |
| 64 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 64 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 65 const SkFontStyle&) const SK_OVERRIDE { | 65 const SkFontStyle&) const override { |
| 66 return NULL; | 66 return NULL; |
| 67 } | 67 } |
| 68 SkTypeface* onCreateFromData(SkData*, int) const SK_OVERRIDE { | 68 SkTypeface* onCreateFromData(SkData*, int) const override { |
| 69 return NULL; | 69 return NULL; |
| 70 } | 70 } |
| 71 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const SK_OVERRIDE
{ | 71 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const override { |
| 72 SkDELETE(stream); | 72 SkDELETE(stream); |
| 73 return NULL; | 73 return NULL; |
| 74 } | 74 } |
| 75 SkTypeface* onCreateFromFile(const char[], int) const SK_OVERRIDE { | 75 SkTypeface* onCreateFromFile(const char[], int) const override { |
| 76 return NULL; | 76 return NULL; |
| 77 } | 77 } |
| 78 SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const SK_OVERRID
E { | 78 SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const override { |
| 79 return NULL; | 79 return NULL; |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { | 83 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { |
| 84 if (NULL == fsset) { | 84 if (NULL == fsset) { |
| 85 fsset = SkFontStyleSet::CreateEmpty(); | 85 fsset = SkFontStyleSet::CreateEmpty(); |
| 86 } | 86 } |
| 87 return fsset; | 87 return fsset; |
| 88 } | 88 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 SkFontMgr* sk_fontmgr_create_default() { | 149 SkFontMgr* sk_fontmgr_create_default() { |
| 150 SkFontMgr* fm = SkFontMgr::Factory(); | 150 SkFontMgr* fm = SkFontMgr::Factory(); |
| 151 return fm ? fm : SkNEW(SkEmptyFontMgr); | 151 return fm ? fm : SkNEW(SkEmptyFontMgr); |
| 152 } | 152 } |
| 153 | 153 |
| 154 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); | 154 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); |
| 155 | 155 |
| 156 SkFontMgr* SkFontMgr::RefDefault() { | 156 SkFontMgr* SkFontMgr::RefDefault() { |
| 157 return SkRef(singleton.get()); | 157 return SkRef(singleton.get()); |
| 158 } | 158 } |
| OLD | NEW |