summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-04 01:30:08 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-04 01:30:08 +0000
commit7accba0ab620be684308e40ff342c3a57bbd9241 (patch)
tree0a48a322626f9ff7e1ea304ec69f2baca52b14bf /webkit
parent2ecc3274a76dd709e2aaf74d385f57b499d843b5 (diff)
downloadchromium_src-7accba0ab620be684308e40ff342c3a57bbd9241.zip
chromium_src-7accba0ab620be684308e40ff342c3a57bbd9241.tar.gz
chromium_src-7accba0ab620be684308e40ff342c3a57bbd9241.tar.bz2
Linux: calculate fractional xheight
We need to push the calculation of the x-height into Skia. For one of the layout tests, it assumes that 2.5ex of Ahem is exactly 32px. Previously we calculated the x-height of Ahem to be 13px, so 2.5*13 was 33px. Now we use the 26.6 fixed point number from freetype's hinter and turn that directly into a floating point value (x-height is the only WebKit metric which is a floating point value). This lets us pass LayoutTests/css2.1/t1507-c526-font-sz-02-b-a.html (although the Windows baseline is wrong) Review URL: http://codereview.chromium.org/13112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp
index 2394c5e..433aa69 100644
--- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp
+++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp
@@ -39,24 +39,11 @@ void SimpleFontData::platformInit()
m_descent = SkScalarCeil(metrics.fHeight) - m_ascent;
}
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- if (!glyphPageZero)
- return;
-
- static const UChar32 x_char = 'x';
- const Glyph x_glyph = glyphPageZero->glyphDataForCharacter(x_char).glyph;
-
- if (x_glyph) {
- // If the face includes a glyph for x we measure its height exactly.
- SkRect xbox;
-
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- paint.measureText(&x_glyph, 2, &xbox);
-
- m_xHeight = -xbox.fTop;
+ if (metrics.fXHeight) {
+ m_xHeight = metrics.fXHeight;
} else {
- // hack taken from the Windows port
- m_xHeight = static_cast<float>(m_ascent) * 0.56;
+ // hack taken from the Windows port
+ m_xHeight = static_cast<float>(m_ascent) * 0.56;
}
m_lineGap = SkScalarRound(metrics.fLeading);
@@ -71,10 +58,17 @@ void SimpleFontData::platformInit()
if (metrics.fAvgCharWidth) {
m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth);
} else {
- if (x_glyph) {
- m_avgCharWidth = widthForGlyph(x_glyph);
- } else {
- m_avgCharWidth = m_xHeight;
+ m_avgCharWidth = m_xHeight;
+
+ GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
+
+ if (glyphPageZero) {
+ static const UChar32 x_char = 'x';
+ const Glyph x_glyph = glyphPageZero->glyphDataForCharacter(x_char).glyph;
+
+ if (x_glyph) {
+ m_avgCharWidth = widthForGlyph(x_glyph);
+ }
}
}
}