diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-19 20:23:04 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-19 20:23:04 +0000 |
commit | 990000e307fe52b5a27f9a93dcab89f8b449beec (patch) | |
tree | 796c4c80555dcdcc1359b52b2785525c8ef3934d /webkit/port/platform/graphics | |
parent | a883abac6b4ef01883f84ca839c7d2dce7fd45cd (diff) | |
download | chromium_src-990000e307fe52b5a27f9a93dcab89f8b449beec.zip chromium_src-990000e307fe52b5a27f9a93dcab89f8b449beec.tar.gz chromium_src-990000e307fe52b5a27f9a93dcab89f8b449beec.tar.bz2 |
Match Windows font metrics on Linux.
With this change, many layout tests involving text match render trees
exactly. By turning off anti-aliasing we also almost match pixel
exact. There are a couple of single-pixel differences between Win32 font
rendering and FreeType however (see the bottom left pixel of an 'a'
glyph for example), so we aren't quite pixel-for-pixel yet.
Mike Reed expects to redo much of the font configuration code in Skia to
cope with complex text and subpixel text so, for now, I'm not going to
have anti-aliasing be a command line flag etc.
Review URL: http://codereview.chromium.org/11284
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform/graphics')
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp index b047cb334..a3d9dd0 100644 --- a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -58,7 +58,7 @@ void FontPlatformData::setupPaint(SkPaint* paint) const { const float ts = m_textSize > 0 ? m_textSize : 12; - paint->setAntiAlias(true); + paint->setAntiAlias(false); paint->setSubpixelText(false); paint->setTextSize(SkFloatToScalar(ts)); paint->setTypeface(m_typeface); diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp index 7371275..29b5d74 100644 --- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -29,17 +29,13 @@ void SimpleFontData::platformInit() m_font.setupPaint(&paint); paint.getFontMetrics(&metrics); - // use ceil instead of round to favor descent, given a lot of accidental - // clipping of descenders (e.g. 14pt 'g') in textedit fields - const int descent = SkScalarCeil(metrics.fDescent); - const int span = SkScalarRound(metrics.fDescent - metrics.fAscent); - const int ascent = span - descent; - - m_ascent = ascent; - m_descent = descent; + // Beware those who step here: This code is designed to match Win32 font + // metrics *exactly*. + m_ascent = SkScalarCeil(-metrics.fAscent); + m_descent = SkScalarCeil(metrics.fDescent); m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the Windows port - m_lineSpacing = ascent + descent; - m_lineGap = SkScalarRound(metrics.fLeading); + m_lineGap = SkScalarCeil(metrics.fLeading); + m_lineSpacing = m_ascent + m_descent + m_lineGap; // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is // calculated for us, but we need to calculate m_maxCharWidth and |