| 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 "SkLazyPtr.h" | 9 #include "SkLazyPtr.h" |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 : SkFontStyle::kNormal_We
ight; | 73 : SkFontStyle::kNormal_We
ight; |
| 74 fUnion.fR.fWidth = SkFontStyle::kNormal_Width; | 74 fUnion.fR.fWidth = SkFontStyle::kNormal_Width; |
| 75 fUnion.fR.fSlant = (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_S
lant | 75 fUnion.fR.fSlant = (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_S
lant |
| 76 : SkFontStyle::kUpright_
Slant; | 76 : SkFontStyle::kUpright_
Slant; |
| 77 } | 77 } |
| 78 | 78 |
| 79 #include "SkFontMgr.h" | 79 #include "SkFontMgr.h" |
| 80 | 80 |
| 81 class SkEmptyFontStyleSet : public SkFontStyleSet { | 81 class SkEmptyFontStyleSet : public SkFontStyleSet { |
| 82 public: | 82 public: |
| 83 virtual int count() SK_OVERRIDE { return 0; } | 83 int count() SK_OVERRIDE { return 0; } |
| 84 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { | 84 void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { |
| 85 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set"); | 85 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set"); |
| 86 } | 86 } |
| 87 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { | 87 SkTypeface* createTypeface(int index) SK_OVERRIDE { |
| 88 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); | 88 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); |
| 89 return NULL; | 89 return NULL; |
| 90 } | 90 } |
| 91 virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE { | 91 SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE { |
| 92 return NULL; | 92 return NULL; |
| 93 } | 93 } |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { | 96 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { |
| 97 return SkNEW(SkEmptyFontStyleSet); | 97 return SkNEW(SkEmptyFontStyleSet); |
| 98 } | 98 } |
| 99 | 99 |
| 100 /////////////////////////////////////////////////////////////////////////////// | 100 /////////////////////////////////////////////////////////////////////////////// |
| 101 | 101 |
| 102 class SkEmptyFontMgr : public SkFontMgr { | 102 class SkEmptyFontMgr : public SkFontMgr { |
| 103 protected: | 103 protected: |
| 104 virtual int onCountFamilies() const SK_OVERRIDE { | 104 int onCountFamilies() const SK_OVERRIDE { |
| 105 return 0; | 105 return 0; |
| 106 } | 106 } |
| 107 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR
IDE { | 107 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE { |
| 108 SkDEBUGFAIL("onGetFamilyName called with bad index"); | 108 SkDEBUGFAIL("onGetFamilyName called with bad index"); |
| 109 } | 109 } |
| 110 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { | 110 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { |
| 111 SkDEBUGFAIL("onCreateStyleSet called with bad index"); | 111 SkDEBUGFAIL("onCreateStyleSet called with bad index"); |
| 112 return NULL; | 112 return NULL; |
| 113 } | 113 } |
| 114 virtual SkFontStyleSet* onMatchFamily(const char[]) const SK_OVERRIDE { | 114 SkFontStyleSet* onMatchFamily(const char[]) const SK_OVERRIDE { |
| 115 return SkFontStyleSet::CreateEmpty(); | 115 return SkFontStyleSet::CreateEmpty(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual SkTypeface* onMatchFamilyStyle(const char[], | 118 virtual SkTypeface* onMatchFamilyStyle(const char[], |
| 119 const SkFontStyle&) const SK_OVERRIDE
{ | 119 const SkFontStyle&) const SK_OVERRIDE
{ |
| 120 return NULL; | 120 return NULL; |
| 121 } | 121 } |
| 122 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], | 122 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
| 123 const SkFontStyle& style, | 123 const SkFontStyle& style, |
| 124 const char* bcp47[], | 124 const char* bcp47[], |
| 125 int bcp47Count, | 125 int bcp47Count, |
| 126 SkUnichar character) const S
K_OVERRIDE { | 126 SkUnichar character) const S
K_OVERRIDE { |
| 127 return NULL; | 127 return NULL; |
| 128 } | 128 } |
| 129 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 129 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 130 const SkFontStyle&) const SK_OVERRIDE { | 130 const SkFontStyle&) const SK_OVERRIDE { |
| 131 return NULL; | 131 return NULL; |
| 132 } | 132 } |
| 133 virtual SkTypeface* onCreateFromData(SkData*, int) const SK_OVERRIDE { | 133 SkTypeface* onCreateFromData(SkData*, int) const SK_OVERRIDE { |
| 134 return NULL; | 134 return NULL; |
| 135 } | 135 } |
| 136 virtual SkTypeface* onCreateFromStream(SkStream*, int) const SK_OVERRIDE { | 136 SkTypeface* onCreateFromStream(SkStream*, int) const SK_OVERRIDE { |
| 137 return NULL; | 137 return NULL; |
| 138 } | 138 } |
| 139 virtual SkTypeface* onCreateFromFile(const char[], int) const SK_OVERRIDE { | 139 SkTypeface* onCreateFromFile(const char[], int) const SK_OVERRIDE { |
| 140 return NULL; | 140 return NULL; |
| 141 } | 141 } |
| 142 virtual SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const SK
_OVERRIDE { | 142 SkTypeface* onLegacyCreateTypeface(const char [], unsigned) const SK_OVERRID
E { |
| 143 return NULL; | 143 return NULL; |
| 144 } | 144 } |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { | 147 static SkFontStyleSet* emptyOnNull(SkFontStyleSet* fsset) { |
| 148 if (NULL == fsset) { | 148 if (NULL == fsset) { |
| 149 fsset = SkFontStyleSet::CreateEmpty(); | 149 fsset = SkFontStyleSet::CreateEmpty(); |
| 150 } | 150 } |
| 151 return fsset; | 151 return fsset; |
| 152 } | 152 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 SkFontMgr* sk_fontmgr_create_default() { | 213 SkFontMgr* sk_fontmgr_create_default() { |
| 214 SkFontMgr* fm = SkFontMgr::Factory(); | 214 SkFontMgr* fm = SkFontMgr::Factory(); |
| 215 return fm ? fm : SkNEW(SkEmptyFontMgr); | 215 return fm ? fm : SkNEW(SkEmptyFontMgr); |
| 216 } | 216 } |
| 217 | 217 |
| 218 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); | 218 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); |
| 219 | 219 |
| 220 SkFontMgr* SkFontMgr::RefDefault() { | 220 SkFontMgr* SkFontMgr::RefDefault() { |
| 221 return SkRef(singleton.get()); | 221 return SkRef(singleton.get()); |
| 222 } | 222 } |
| OLD | NEW |