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

Side by Side Diff: src/core/SkFontHost.cpp

Issue 21149008: refactoring for SK_FONTHOST_USES_FONTMGR option (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/core/SkTypeface.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 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) { 62 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
63 fUnion.fU32 = 0; 63 fUnion.fU32 = 0;
64 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight); 64 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
65 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width ); 65 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width );
66 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant); 66 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
67 } 67 }
68 68
69 #include "SkFontMgr.h" 69 #include "SkFontMgr.h"
70 70
71
72 SK_DEFINE_INST_COUNT(SkFontStyleSet) 71 SK_DEFINE_INST_COUNT(SkFontStyleSet)
73 72
74 class SkEmptyFontStyleSet : public SkFontStyleSet { 73 class SkEmptyFontStyleSet : public SkFontStyleSet {
75 public: 74 public:
76 virtual int count() SK_OVERRIDE { return 0; } 75 virtual int count() SK_OVERRIDE { return 0; }
77 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { 76 virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE {
78 SkASSERT(!"SkFontStyleSet::getStyle called on empty set"); 77 SkASSERT(!"SkFontStyleSet::getStyle called on empty set");
79 } 78 }
80 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { 79 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE {
81 SkASSERT(!"SkFontStyleSet::createTypeface called on empty set"); 80 SkASSERT(!"SkFontStyleSet::createTypeface called on empty set");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 166 }
168 167
169 SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) { 168 SkTypeface* SkFontMgr::createFromStream(SkStream* stream, int ttcIndex) {
170 return this->onCreateFromStream(stream, ttcIndex); 169 return this->onCreateFromStream(stream, ttcIndex);
171 } 170 }
172 171
173 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) { 172 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) {
174 return this->onCreateFromFile(path, ttcIndex); 173 return this->onCreateFromFile(path, ttcIndex);
175 } 174 }
176 175
176 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[],
177 unsigned styleBits) {
178 return this->onLegacyCreateTypeface(familyName, styleBits);
179 }
180
181 SkTypeface* SkFontMgr::onLegacyCreateTypeface(const char familyName[],
182 unsigned styleBits) {
183 SkASSERT(!"unimplemented");
184 return NULL;
185 }
186
177 SkFontMgr* SkFontMgr::RefDefault() { 187 SkFontMgr* SkFontMgr::RefDefault() {
178 static SkFontMgr* gFM; 188 static SkFontMgr* gFM;
179 if (NULL == gFM) { 189 if (NULL == gFM) {
180 gFM = SkFontMgr::Factory(); 190 gFM = SkFontMgr::Factory();
181 // we never want to return NULL 191 // we never want to return NULL
182 if (NULL == gFM) { 192 if (NULL == gFM) {
183 gFM = SkNEW(SkEmptyFontMgr); 193 gFM = SkNEW(SkEmptyFontMgr);
184 } 194 }
185 } 195 }
186 return SkRef(gFM); 196 return SkRef(gFM);
187 } 197 }
198
199 //////////////////////////////////////////////////////////////////////////
200
201 #ifdef SK_FONTHOST_USES_FONTMGR
202
203 #if 0
204 static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) {
205 SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ?
206 SkFontStyle::kBold_Weight :
207 SkFontStyle::kNormal_Weight;
208 SkFontStyle::Width width = SkFontStyle::kNormal_Width;
209 SkFontStyle::Slant slant = (styleBits & SkTypeface::kItalic) ?
210 SkFontStyle::kUpright_Slant :
211 SkFontStyle::kItalic_Slant;
212 return SkFontStyle(weight, width, slant);
213 }
214 #endif
215
216 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
217 const char familyName[],
218 SkTypeface::Style style) {
219 if (familyFace) {
220 return familyFace->refMatchingStyle(style);
221 } else {
222 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
223 return fm->legacyCreateTypeface(familyName, style);
224 }
225 }
226
227 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
228 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
229 return fm->createFromFile(path);
230 }
231
232 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
233 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
234 return fm->createFromStream(stream);
235 }
236
237 #endif
OLDNEW
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698