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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | |
OLD | NEW |