| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 210 |
| 211 ////////////////////////////////////////////////////////////////////////// | 211 ////////////////////////////////////////////////////////////////////////// |
| 212 | 212 |
| 213 #ifndef SK_FONTHOST_DOES_NOT_USE_FONTMGR | |
| 214 | |
| 215 #if 0 | |
| 216 static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) { | |
| 217 SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ? | |
| 218 SkFontStyle::kBold_Weight : | |
| 219 SkFontStyle::kNormal_Weight; | |
| 220 SkFontStyle::Width width = SkFontStyle::kNormal_Width; | |
| 221 SkFontStyle::Slant slant = (styleBits & SkTypeface::kItalic) ? | |
| 222 SkFontStyle::kUpright_Slant : | |
| 223 SkFontStyle::kItalic_Slant; | |
| 224 return SkFontStyle(weight, width, slant); | |
| 225 } | |
| 226 #endif | |
| 227 | |
| 228 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, | 213 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, |
| 229 const char familyName[], | 214 const char familyName[], |
| 230 SkTypeface::Style style) { | 215 SkTypeface::Style style) { |
| 231 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 216 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 232 if (familyFace) { | 217 if (familyFace) { |
| 233 bool bold = style & SkTypeface::kBold; | 218 bool bold = style & SkTypeface::kBold; |
| 234 bool italic = style & SkTypeface::kItalic; | 219 bool italic = style & SkTypeface::kItalic; |
| 235 SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight | 220 SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight |
| 236 : SkFontStyle::kNormal_Weight, | 221 : SkFontStyle::kNormal_Weight, |
| 237 SkFontStyle::kNormal_Width, | 222 SkFontStyle::kNormal_Width, |
| 238 italic ? SkFontStyle::kItalic_Slant | 223 italic ? SkFontStyle::kItalic_Slant |
| 239 : SkFontStyle::kUpright_Slant)
; | 224 : SkFontStyle::kUpright_Slant)
; |
| 240 return fm->matchFaceStyle(familyFace, newStyle); | 225 return fm->matchFaceStyle(familyFace, newStyle); |
| 241 } else { | 226 } else { |
| 242 return fm->legacyCreateTypeface(familyName, style); | 227 return fm->legacyCreateTypeface(familyName, style); |
| 243 } | 228 } |
| 244 } | 229 } |
| 245 | 230 |
| 246 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { | 231 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |
| 247 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 232 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 248 return fm->createFromFile(path); | 233 return fm->createFromFile(path); |
| 249 } | 234 } |
| 250 | 235 |
| 251 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | 236 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
| 252 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); | 237 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 253 return fm->createFromStream(stream); | 238 return fm->createFromStream(stream); |
| 254 } | 239 } |
| 255 | |
| 256 #endif | |
| OLD | NEW |