Chromium Code Reviews| Index: sky/engine/platform/fonts/skia/FontCacheSkia.cpp |
| diff --git a/sky/engine/platform/fonts/skia/FontCacheSkia.cpp b/sky/engine/platform/fonts/skia/FontCacheSkia.cpp |
| index 2654ba85b9ff35453b4a51b0fe81302c096f53aa..b5cec4f182bb93c47233f19476b213bad31ed253 100644 |
| --- a/sky/engine/platform/fonts/skia/FontCacheSkia.cpp |
| +++ b/sky/engine/platform/fonts/skia/FontCacheSkia.cpp |
| @@ -69,6 +69,56 @@ static tmp::StreamType streamForFontconfigInterfaceId(int fontconfigInterfaceId) |
| namespace blink { |
| +static int toSkiaWeight(FontWeight weight) |
| +{ |
| + switch (weight) { |
| + case FontWeight100: |
| + return 100; |
| + case FontWeight200: |
| + return 200; |
| + case FontWeight300: |
| + return 300; |
| + case FontWeight400: |
| + return 400; |
| + case FontWeight500: |
| + return 500; |
| + case FontWeight600: |
| + return 600; |
| + case FontWeight700: |
| + return 700; |
| + case FontWeight800: |
| + return 800; |
| + case FontWeight900: |
| + return 900; |
| + } |
| + ASSERT_NOT_REACHED(); |
| + return 400; |
| +} |
| + |
| +static SkFontStyle::Slant toSkiaSlant(FontStyle style) |
| +{ |
| + switch (style) { |
| + case FontStyleNormal: |
| + return SkFontStyle::kUpright_Slant; |
| + case FontStyleItalic: |
| + return SkFontStyle::kItalic_Slant; |
| + } |
| + ASSERT_NOT_REACHED(); |
| + return SkFontStyle::kUpright_Slant; |
| +} |
| + |
| +static int toSkiaWidth(FontStretch stretch) |
| +{ |
| + return static_cast<int>(stretch); |
|
eseidel
2015/03/16 23:57:54
I still might add a one-line comment.
|
| +} |
| + |
| +static SkFontStyle toSkiaFontStyle(const FontDescription& fontDescription) |
| +{ |
| + return SkFontStyle(toSkiaWeight(fontDescription.weight()), |
| + toSkiaWidth(fontDescription.stretch()), |
| + toSkiaSlant(fontDescription.style())); |
| +} |
| + |
| void FontCache::platformInit() |
| { |
| } |
| @@ -190,15 +240,8 @@ PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc |
| name = family.utf8(); |
| } |
| - int style = SkTypeface::kNormal; |
| - if (fontDescription.weight() >= FontWeight600) |
| - style |= SkTypeface::kBold; |
| - if (fontDescription.style()) |
| - style |= SkTypeface::kItalic; |
| - |
| - // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of |
| - // CreateFromName on all platforms. |
| - return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypeface::Style>(style))); |
| + RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
| + return adoptRef(fm->matchFamilyStyle(name.data(), toSkiaFontStyle(fontDescription))); |
| } |
| #if !OS(WIN) |