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

Unified Diff: Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 470443004: Implement support for numeric font-weights on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: w/expectations Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/text/font-weight.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/skia/FontCacheSkia.cpp
diff --git a/Source/platform/fonts/skia/FontCacheSkia.cpp b/Source/platform/fonts/skia/FontCacheSkia.cpp
index 4fa74dfc0aae7de3a94626c87fbe75e0a369b8df..c7c6af9c3ab945b35d8f73b450707d5f80b81c2e 100644
--- a/Source/platform/fonts/skia/FontCacheSkia.cpp
+++ b/Source/platform/fonts/skia/FontCacheSkia.cpp
@@ -164,6 +164,18 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
}
+#if OS(WIN)
+static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
+{
+ int width = SkFontStyle::kNormal_Width;
+ int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
+ SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
+ ? SkFontStyle::kItalic_Slant
+ : SkFontStyle::kUpright_Slant;
+ return SkFontStyle(weight, width, slant);
+}
+#endif
+
PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDescription, const FontFaceCreationParams& creationParams, CString& name)
{
#if !OS(WIN) && !OS(ANDROID)
@@ -199,16 +211,22 @@ PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc
#if OS(WIN)
if (s_sideloadedFonts) {
- HashMap<String, SkTypeface*>::iterator sideloadedFont = s_sideloadedFonts->find(name.data());
- if (sideloadedFont != s_sideloadedFonts->end()) {
+ HashMap<String, SkTypeface*>::iterator sideloadedFont =
+ s_sideloadedFonts->find(name.data());
+ if (sideloadedFont != s_sideloadedFonts->end())
return adoptRef(sideloadedFont->value);
- }
}
- // FIXME: Use SkFontStyle and matchFamilyStyle instead of legacyCreateTypeface.
- if (m_fontManager)
- return adoptRef(m_fontManager->legacyCreateTypeface(name.data(), style));
+
+ if (m_fontManager) {
+ return adoptRef(useDirectWrite()
+ ? m_fontManager->matchFamilyStyle(name.data(), fontStyle(fontDescription))
+ : m_fontManager->legacyCreateTypeface(name.data(), style)
+ );
+ }
#endif
+ // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of
+ // CreateFromName on all platforms.
return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypeface::Style>(style)));
}
« no previous file with comments | « LayoutTests/fast/text/font-weight.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698