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

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

Issue 135903012: Fix synthetic bold/italic for webfonts on windows (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/webfont-synthetic-bold.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/FontCustomPlatformDataSkia.cpp
diff --git a/Source/platform/fonts/skia/FontCustomPlatformDataSkia.cpp b/Source/platform/fonts/skia/FontCustomPlatformDataSkia.cpp
index b175fc0885265e3a3a8735565e1cdc75bf28a60e..ecf42ef0664ed88c7ffd2acb51f92f9dfa5d5056 100644
--- a/Source/platform/fonts/skia/FontCustomPlatformDataSkia.cpp
+++ b/Source/platform/fonts/skia/FontCustomPlatformDataSkia.cpp
@@ -56,6 +56,29 @@ FontCustomPlatformData::~FontCustomPlatformData()
FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant)
{
ASSERT(m_typeface);
+#if OS(WIN)
+ // FIXME: Skia currently renders synthetic bold and italics with hinting and without
+ // linear metrics on windows. Using CreateFromName and specifying the bold/italics
+ // style allows for proper rendering of synthetic style. Once Skia has been updated
+ // this workaround will no longer be needed. crbug.com/332958
+ bool syntheticBold = bold && !m_typeface->isBold();
+ bool syntheticItalic = italic && !m_typeface->isItalic();
+ if (syntheticBold || syntheticItalic) {
+ SkString name;
+ m_typeface->getFamilyName(&name);
+
+ int style = SkTypeface::kNormal;
+ if (syntheticBold)
+ style |= SkTypeface::kBold;
+ if (syntheticItalic)
+ style |= SkTypeface::kItalic;
+
+ RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromName(name.c_str(), static_cast<SkTypeface::Style>(style)));
+ syntheticBold = false;
+ syntheticItalic = false;
+ return FontPlatformData(typeface.release(), "", size, syntheticBold, syntheticItalic, orientation);
+ }
+#endif
return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isBold(), italic && !m_typeface->isItalic(), orientation);
}
« no previous file with comments | « LayoutTests/fast/text/webfont-synthetic-bold.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698