| 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 | 9 |
| 10 static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHoriz
ontal_LCDOrientation; | 10 static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHoriz
ontal_LCDOrientation; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return (SkFontHost::LCDOrder)SkFontLCDConfig::GetSubpixelOrder(); | 43 return (SkFontHost::LCDOrder)SkFontLCDConfig::GetSubpixelOrder(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void SkFontHost::SetSubpixelOrder(LCDOrder order) { | 46 void SkFontHost::SetSubpixelOrder(LCDOrder order) { |
| 47 SkFontLCDConfig::SetSubpixelOrder((SkFontLCDConfig::LCDOrder)order); | 47 SkFontLCDConfig::SetSubpixelOrder((SkFontLCDConfig::LCDOrder)order); |
| 48 } | 48 } |
| 49 | 49 |
| 50 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
| 51 /////////////////////////////////////////////////////////////////////////////// | 51 /////////////////////////////////////////////////////////////////////////////// |
| 52 | 52 |
| 53 #include "SkFontStyle.h" |
| 54 |
| 55 SkFontStyle::SkFontStyle() { |
| 56 fUnion.fU32 = 0; |
| 57 fUnion.fR.fWeight = kNormal_Weight; |
| 58 fUnion.fR.fWidth = kNormal_Width; |
| 59 fUnion.fR.fSlant = kUpright_Slant; |
| 60 } |
| 61 |
| 62 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) { |
| 63 fUnion.fU32 = 0; |
| 64 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight); |
| 65 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width
); |
| 66 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant); |
| 67 } |
| 68 |
| 53 #include "SkFontMgr.h" | 69 #include "SkFontMgr.h" |
| 54 | 70 |
| 71 class SkEmptyFontStyleSet : public SkFontStyleSet { |
| 72 public: |
| 73 virtual int count() SK_OVERRIDE { return 0; } |
| 74 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { |
| 75 SkASSERT(!"SkFontStyleSet::getStyle called on empty set"); |
| 76 } |
| 77 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { |
| 78 SkASSERT(!"SkFontStyleSet::createTypeface called on empty set"); |
| 79 return NULL; |
| 80 } |
| 81 virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE { |
| 82 return NULL; |
| 83 } |
| 84 }; |
| 85 |
| 86 SkFontStyleSet* SkFontStyleSet::CreateEmpty() { |
| 87 return SkNEW(SkEmptyFontStyleSet); |
| 88 } |
| 89 |
| 90 /////////////////////////////////////////////////////////////////////////////// |
| 91 |
| 55 class SkEmptyFontMgr : public SkFontMgr { | 92 class SkEmptyFontMgr : public SkFontMgr { |
| 56 protected: | 93 protected: |
| 57 virtual int onCountFamilies() SK_OVERRIDE { | 94 virtual int onCountFamilies() SK_OVERRIDE { |
| 58 return 0; | 95 return 0; |
| 59 } | 96 } |
| 60 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { | 97 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { |
| 61 SkASSERT(!"onGetFamilyName called with bad index"); | 98 SkASSERT(!"onGetFamilyName called with bad index"); |
| 62 } | 99 } |
| 63 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE { | 100 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE { |
| 64 SkASSERT(!"onCreateStyleSet called with bad index"); | 101 SkASSERT(!"onCreateStyleSet called with bad index"); |
| 65 return NULL; | 102 return NULL; |
| 66 } | 103 } |
| 104 virtual SkFontStyleSet* onMatchFamily(const char[]) SK_OVERRIDE { |
| 105 return SkFontStyleSet::CreateEmpty(); |
| 106 } |
| 107 |
| 67 virtual SkTypeface* onMatchFamilyStyle(const char[], | 108 virtual SkTypeface* onMatchFamilyStyle(const char[], |
| 68 const SkFontStyle&) SK_OVERRIDE { | 109 const SkFontStyle&) SK_OVERRIDE { |
| 69 return NULL; | 110 return NULL; |
| 70 } | 111 } |
| 71 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 112 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 72 const SkFontStyle&) SK_OVERRIDE { | 113 const SkFontStyle&) SK_OVERRIDE { |
| 73 return NULL; | 114 return NULL; |
| 74 } | 115 } |
| 75 virtual SkTypeface* onCreateFromData(SkData*, int) SK_OVERRIDE { | 116 virtual SkTypeface* onCreateFromData(SkData*, int) SK_OVERRIDE { |
| 76 return NULL; | 117 return NULL; |
| 77 } | 118 } |
| 78 virtual SkTypeface* onCreateFromStream(SkStream*, int) SK_OVERRIDE { | 119 virtual SkTypeface* onCreateFromStream(SkStream*, int) SK_OVERRIDE { |
| 79 return NULL; | 120 return NULL; |
| 80 } | 121 } |
| 81 virtual SkTypeface* onCreateFromFile(const char[], int) SK_OVERRIDE { | 122 virtual SkTypeface* onCreateFromFile(const char[], int) SK_OVERRIDE { |
| 82 return NULL; | 123 return NULL; |
| 83 } | 124 } |
| 84 }; | 125 }; |
| 85 | 126 |
| 86 SkFontStyle::SkFontStyle() { | |
| 87 fUnion.fU32 = 0; | |
| 88 fUnion.fR.fWeight = kNormal_Weight; | |
| 89 fUnion.fR.fWidth = kNormal_Width; | |
| 90 fUnion.fR.fSlant = kUpright_Slant; | |
| 91 } | |
| 92 | |
| 93 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) { | |
| 94 fUnion.fU32 = 0; | |
| 95 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight); | |
| 96 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width
); | |
| 97 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant); | |
| 98 } | |
| 99 | |
| 100 int SkFontMgr::countFamilies() { | 127 int SkFontMgr::countFamilies() { |
| 101 return this->onCountFamilies(); | 128 return this->onCountFamilies(); |
| 102 } | 129 } |
| 103 | 130 |
| 104 void SkFontMgr::getFamilyName(int index, SkString* familyName) { | 131 void SkFontMgr::getFamilyName(int index, SkString* familyName) { |
| 105 this->onGetFamilyName(index, familyName); | 132 this->onGetFamilyName(index, familyName); |
| 106 } | 133 } |
| 107 | 134 |
| 108 SkFontStyleSet* SkFontMgr::createStyleSet(int index) { | 135 SkFontStyleSet* SkFontMgr::createStyleSet(int index) { |
| 109 return this->onCreateStyleSet(index); | 136 return this->onCreateStyleSet(index); |
| 110 } | 137 } |
| 111 | 138 |
| 139 SkFontStyleSet* SkFontMgr::matchFamily(const char familyName[]) { |
| 140 return this->onMatchFamily(familyName); |
| 141 } |
| 142 |
| 112 SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[], | 143 SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[], |
| 113 const SkFontStyle& fs) { | 144 const SkFontStyle& fs) { |
| 114 return this->onMatchFamilyStyle(familyName, fs); | 145 return this->onMatchFamilyStyle(familyName, fs); |
| 115 } | 146 } |
| 116 | 147 |
| 117 SkTypeface* SkFontMgr::matchFaceStyle(const SkTypeface* face, | 148 SkTypeface* SkFontMgr::matchFaceStyle(const SkTypeface* face, |
| 118 const SkFontStyle& fs) { | 149 const SkFontStyle& fs) { |
| 119 return this->onMatchFaceStyle(face, fs); | 150 return this->onMatchFaceStyle(face, fs); |
| 120 } | 151 } |
| 121 | 152 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 static SkFontMgr* gFM; | 166 static SkFontMgr* gFM; |
| 136 if (NULL == gFM) { | 167 if (NULL == gFM) { |
| 137 gFM = SkFontMgr::Factory(); | 168 gFM = SkFontMgr::Factory(); |
| 138 // we never want to return NULL | 169 // we never want to return NULL |
| 139 if (NULL == gFM) { | 170 if (NULL == gFM) { |
| 140 gFM = SkNEW(SkEmptyFontMgr); | 171 gFM = SkNEW(SkEmptyFontMgr); |
| 141 } | 172 } |
| 142 } | 173 } |
| 143 return SkRef(gFM); | 174 return SkRef(gFM); |
| 144 } | 175 } |
| OLD | NEW |