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

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

Issue 105223006: Remove a layer of indirection and code from SkFontHost. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Rebase, should now work due to Android changes. Created 6 years, 3 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/core/SkFontHost.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 #include "SkLazyPtr.h" 9 #include "SkLazyPtr.h"
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 SkFontMgr* SkFontMgr::CreateDefault() { 201 SkFontMgr* SkFontMgr::CreateDefault() {
202 SkFontMgr* fm = SkFontMgr::Factory(); 202 SkFontMgr* fm = SkFontMgr::Factory();
203 return fm ? fm : SkNEW(SkEmptyFontMgr); 203 return fm ? fm : SkNEW(SkEmptyFontMgr);
204 } 204 }
205 205
206 SkFontMgr* SkFontMgr::RefDefault() { 206 SkFontMgr* SkFontMgr::RefDefault() {
207 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, CreateDefault); 207 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, CreateDefault);
208 return SkRef(singleton.get()); 208 return SkRef(singleton.get());
209 } 209 }
210
211 //////////////////////////////////////////////////////////////////////////
212
213 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
214 const char familyName[],
215 SkTypeface::Style style) {
216 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
217 if (familyFace) {
218 bool bold = style & SkTypeface::kBold;
219 bool italic = style & SkTypeface::kItalic;
220 SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight
221 : SkFontStyle::kNormal_Weight,
222 SkFontStyle::kNormal_Width,
223 italic ? SkFontStyle::kItalic_Slant
224 : SkFontStyle::kUpright_Slant) ;
225 return fm->matchFaceStyle(familyFace, newStyle);
226 } else {
227 return fm->legacyCreateTypeface(familyName, style);
228 }
229 }
230
231 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
232 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
233 return fm->createFromFile(path);
234 }
235
236 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
237 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
238 return fm->createFromStream(stream);
239 }
OLDNEW
« no previous file with comments | « include/core/SkFontHost.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698