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

Unified Diff: Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp

Issue 23454039: detect web-fonts, and force gray-antialiasing for them, regardless of the system's FONTSMOOTHING se… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
diff --git a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
index 04eccf698564dda76778cf0fd3b3e090843707ab..30f96c67ca626dc6fb0f209be72d796cdf567fe7 100644
--- a/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
+++ b/Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
@@ -35,6 +35,7 @@
#include <windows.h>
#include <mlang.h>
#include <objidl.h>
+#include "core/platform/LayoutTestSupport.h"
#include "core/platform/SharedBuffer.h"
#include "core/platform/graphics/FontCache.h"
#include "core/platform/graphics/skia/SkiaFontWin.h"
@@ -82,6 +83,14 @@ static uint32_t getDefaultGDITextFlags()
return gFlags;
}
+static bool isWebFont(const LOGFONT& lf)
+{
+ // web-fonts have artifical names constructed to always be
+ // 1. 24 characters, followed by a '\0'
+ // 2. the last two characters are '=='
f(malita) 2013/09/13 15:28:02 Don't know much about LOGFONT, but I assume lfFace
+ return '=' == lf.lfFaceName[22] && '=' == lf.lfFaceName[23] && '\0' == lf.lfFaceName[24];
+}
+
static int computePaintTextFlags(const LOGFONT& lf)
{
int textFlags = 0;
@@ -101,7 +110,21 @@ static int computePaintTextFlags(const LOGFONT& lf)
}
// only allow features that SystemParametersInfo allows
- return textFlags & getDefaultGDITextFlags();
+ textFlags &= getDefaultGDITextFlags();
+
+ /*
+ * FontPlatformData(...) will read our logfont, and try to honor the the lfQuality
+ * setting (computing the corresponding SkPaint flags for AA and LCD). However, it
+ * will limit the quality based on its query of SPI_GETFONTSMOOTHING. This could mean
+ * we end up drawing the text in BW, even though our lfQuality requested antialiasing.
+ *
+ * Many web-fonts are so poorly hinted that they are terrible to read when drawn in BW.
+ * In these cases, we have decided to FORCE these fonts to be drawn with at least grayscale AA,
+ * even when the System (getDefaultGDITextFlags) tells us to draw only in BW.
+ */
+ if (isWebFont(lf) && !isRunningLayoutTest())
+ textFlags |= SkPaint::kAntiAlias_Flag;
+ return textFlags;
}
PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size, int* paintTextFlags)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698