| 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 "SkFontDescriptor.h" | 8 #include "SkFontDescriptor.h" |
| 9 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
| 10 #include "SkLazyPtr.h" | 10 #include "SkLazyPtr.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 SkTypeface* createTypeface(int index) override { | 23 SkTypeface* createTypeface(int index) override { |
| 24 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); | 24 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); |
| 25 return NULL; | 25 return NULL; |
| 26 } | 26 } |
| 27 SkTypeface* matchStyle(const SkFontStyle&) override { | 27 SkTypeface* matchStyle(const SkFontStyle&) override { |
| 28 return NULL; | 28 return NULL; |
| 29 } | 29 } |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { | 32 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { return new SkEmptyFontStyleSet;
} |
| 33 return SkNEW(SkEmptyFontStyleSet); | |
| 34 } | |
| 35 | 33 |
| 36 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
| 37 | 35 |
| 38 class SkEmptyFontMgr : public SkFontMgr { | 36 class SkEmptyFontMgr : public SkFontMgr { |
| 39 protected: | 37 protected: |
| 40 int onCountFamilies() const override { | 38 int onCountFamilies() const override { |
| 41 return 0; | 39 return 0; |
| 42 } | 40 } |
| 43 void onGetFamilyName(int index, SkString* familyName) const override { | 41 void onGetFamilyName(int index, SkString* familyName) const override { |
| 44 SkDEBUGFAIL("onGetFamilyName called with bad index"); | 42 SkDEBUGFAIL("onGetFamilyName called with bad index"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 return NULL; | 61 return NULL; |
| 64 } | 62 } |
| 65 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 63 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 66 const SkFontStyle&) const override { | 64 const SkFontStyle&) const override { |
| 67 return NULL; | 65 return NULL; |
| 68 } | 66 } |
| 69 SkTypeface* onCreateFromData(SkData*, int) const override { | 67 SkTypeface* onCreateFromData(SkData*, int) const override { |
| 70 return NULL; | 68 return NULL; |
| 71 } | 69 } |
| 72 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const override { | 70 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int) const override { |
| 73 SkDELETE(stream); | 71 delete stream; |
| 74 return NULL; | 72 return NULL; |
| 75 } | 73 } |
| 76 SkTypeface* onCreateFromFile(const char[], int) const override { | 74 SkTypeface* onCreateFromFile(const char[], int) const override { |
| 77 return NULL; | 75 return NULL; |
| 78 } | 76 } |
| 79 SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const override { | 77 SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const override { |
| 80 return NULL; | 78 return NULL; |
| 81 } | 79 } |
| 82 }; | 80 }; |
| 83 | 81 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 154 } |
| 157 | 155 |
| 158 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], | 156 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], |
| 159 unsigned styleBits) const { | 157 unsigned styleBits) const { |
| 160 return this->onLegacyCreateTypeface(familyName, styleBits); | 158 return this->onLegacyCreateTypeface(familyName, styleBits); |
| 161 } | 159 } |
| 162 | 160 |
| 163 // As a template argument this must have external linkage. | 161 // As a template argument this must have external linkage. |
| 164 SkFontMgr* sk_fontmgr_create_default() { | 162 SkFontMgr* sk_fontmgr_create_default() { |
| 165 SkFontMgr* fm = SkFontMgr::Factory(); | 163 SkFontMgr* fm = SkFontMgr::Factory(); |
| 166 return fm ? fm : SkNEW(SkEmptyFontMgr); | 164 return fm ? fm : new SkEmptyFontMgr; |
| 167 } | 165 } |
| 168 | 166 |
| 169 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); | 167 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); |
| 170 | 168 |
| 171 SkFontMgr* SkFontMgr::RefDefault() { | 169 SkFontMgr* SkFontMgr::RefDefault() { |
| 172 return SkRef(singleton.get()); | 170 return SkRef(singleton.get()); |
| 173 } | 171 } |
| OLD | NEW |