Index: third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp |
diff --git a/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp b/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp |
index 5ad1346766c4fe1af86bfd1490e90f6a37ac2342..134c7a443630a465a014b8dda0e22bb8434a9023 100644 |
--- a/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp |
@@ -154,6 +154,23 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri |
return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); |
} |
+static inline SkFontStyle fontStyle(const FontDescription& fontDescription) |
bungeman-skia
2016/04/25 14:58:00
Looks like this moved over to FontDescription::ski
Tom (Use chromium acct)
2016/04/25 19:02:21
Done.
|
+{ |
+ int width = static_cast<int>(fontDescription.stretch()); |
+ int weight = (fontDescription.weight() - FontWeight100 + 1) * 100; |
+ SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic |
+ ? SkFontStyle::kItalic_Slant |
+ : SkFontStyle::kUpright_Slant; |
+ return SkFontStyle(weight, width, slant); |
+} |
+ |
+static_assert(static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontStyle::kUltraCondensed_Width), |
+ "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
+static_assert(static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNormal_Width), |
+ "FontStretchNormal should map to kNormal_Width"); |
+static_assert(static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontStyle::kUltaExpanded_Width), |
+ "FontStretchUltraExpanded should map to kUltaExpanded_Width"); |
+ |
PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name) |
{ |
#if !OS(WIN) && !OS(ANDROID) |
@@ -197,14 +214,11 @@ PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc |
return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescription.skiaFontStyle())); |
#endif |
- // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of |
- // CreateFromName on all platforms. |
- int style = SkTypeface::kNormal; |
- if (fontDescription.weight() >= FontWeight600) |
- style |= SkTypeface::kBold; |
- if (fontDescription.style()) |
- style |= SkTypeface::kItalic; |
- return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypeface::Style>(style))); |
+ // FIXME: Use m_fontManager, matchFamilyStyle instead of |
+ // legacyCreateTypeface on all platforms. |
+ RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
+ return adoptRef(fm->legacyCreateTypeface(name.data(), |
+ fontStyle(fontDescription))); |
bungeman-skia
2016/04/25 14:58:00
fontDescription.skiaFontStyle() instead of fontSty
Tom (Use chromium acct)
2016/04/25 19:02:21
Done.
|
} |
#if !OS(WIN) |