Chromium Code Reviews| 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..03dff28c08a954068155dfa89e01c4f341d78ab9 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() |
|
bungeman-skia
2014/02/11 15:42:56
computePaintTextFlags(bool isWebFont)
this is sta
|
| { |
| - 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(); |
| } |
| #endif |