| Index: Source/platform/fonts/win/FontPlatformDataWin.cpp
|
| diff --git a/Source/platform/fonts/win/FontPlatformDataWin.cpp b/Source/platform/fonts/win/FontPlatformDataWin.cpp
|
| index 222753cb48fa51c312b8f23556935d834878bae5..ebccad5436be1918c865ab351b5bfee6d51339c9 100644
|
| --- a/Source/platform/fonts/win/FontPlatformDataWin.cpp
|
| +++ b/Source/platform/fonts/win/FontPlatformDataWin.cpp
|
| @@ -85,7 +85,7 @@ void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons
|
| // Lookup the current system settings for font smoothing.
|
| // We cache these values for performance, but if the browser has a way to be
|
| // notified when these change, we could re-query them at that time.
|
| -static uint32_t getDefaultGDITextFlags()
|
| +static uint32_t getSystemTextFlags()
|
| {
|
| static bool gInited;
|
| static uint32_t gFlags;
|
| @@ -106,52 +106,29 @@ static uint32_t getDefaultGDITextFlags()
|
| return gFlags;
|
| }
|
|
|
| -static bool isWebFont(const LOGFONT& lf)
|
| +static bool isWebFont(const String& familyName)
|
| {
|
| - // web-fonts have artifical names constructed to always be
|
| + // Web-fonts have artifical names constructed to always be:
|
| // 1. 24 characters, followed by a '\0'
|
| // 2. the last two characters are '=='
|
| - return '=' == lf.lfFaceName[22] && '=' == lf.lfFaceName[23] && '\0' == lf.lfFaceName[24];
|
| + return familyName.length() == 24
|
| + && '=' == familyName[22] && '=' == familyName[23];
|
| }
|
|
|
| -static int computePaintTextFlags(const LOGFONT& lf)
|
| +static int computePaintTextFlags(String fontFamilyName)
|
| {
|
| - int textFlags = 0;
|
| - switch (lf.lfQuality) {
|
| - case NONANTIALIASED_QUALITY:
|
| - textFlags = 0;
|
| - break;
|
| - case ANTIALIASED_QUALITY:
|
| - textFlags = SkPaint::kAntiAlias_Flag;
|
| - break;
|
| - case CLEARTYPE_QUALITY:
|
| - textFlags = (SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag);
|
| - break;
|
| - default:
|
| - textFlags = getDefaultGDITextFlags();
|
| - break;
|
| - }
|
| + int textFlags = getSystemTextFlags();
|
|
|
| - // only allow features that SystemParametersInfo allows
|
| - 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())
|
| + // 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 (getSystemTextFlags) tells us to draw only in BW.
|
| + if (isWebFont(fontFamilyName) && !isRunningLayoutTest())
|
| textFlags |= SkPaint::kAntiAlias_Flag;
|
| return textFlags;
|
| }
|
|
|
| #if !USE(HARFBUZZ)
|
| -PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size, int* paintTextFlags)
|
| +PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size)
|
| {
|
| LOGFONT info;
|
| GetObject(hfont, sizeof(info), &info);
|
| @@ -161,8 +138,6 @@ PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT hfont, int* size, int* pain
|
| height = -height;
|
| *size = height;
|
| }
|
| - if (paintTextFlags)
|
| - *paintTextFlags = computePaintTextFlags(info);
|
| return adoptRef(SkCreateTypefaceFromLOGFONT(info));
|
| }
|
| #endif
|
| @@ -207,10 +182,11 @@ FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien
|
| , m_syntheticItalic(false)
|
| , m_orientation(orientation)
|
| , m_scriptCache(0)
|
| - , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags))
|
| + , m_typeface(CreateTypefaceFromHFont(font, 0))
|
| , m_isHashTableDeletedValue(false)
|
| , m_useSubpixelPositioning(false)
|
| {
|
| + m_paintTextFlags = computePaintTextFlags(fontFamilyName());
|
| }
|
| #endif
|
|
|
| @@ -274,14 +250,13 @@ FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
|
| , m_isHashTableDeletedValue(false)
|
| , m_useSubpixelPositioning(useSubpixelPositioning)
|
| {
|
| + m_paintTextFlags = computePaintTextFlags(fontFamilyName());
|
| +#if !USE(HARFBUZZ)
|
| // FIXME: This can be removed together with m_font once the last few
|
| // uses of hfont() has been eliminated.
|
| LOGFONT logFont;
|
| SkLOGFONTFromTypeface(m_typeface.get(), &logFont);
|
| logFont.lfHeight = -textSize;
|
| - m_paintTextFlags = computePaintTextFlags(logFont);
|
| -
|
| -#if !USE(HARFBUZZ)
|
| HFONT hFont = CreateFontIndirect(&logFont);
|
| m_font = hFont ? RefCountedHFONT::create(hFont) : 0;
|
| m_scriptCache = 0;
|
|
|