diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 01:48:23 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 01:48:23 +0000 |
commit | d792583fa4a7436f78356c7c608b6f2ed52cccb4 (patch) | |
tree | 6cc2ff393d6b7daf611c1aaa04cdfc7c6b9fcf45 /webkit | |
parent | 5855df7de77eee7ad51cdac73f7d294525d75faf (diff) | |
download | chromium_src-d792583fa4a7436f78356c7c608b6f2ed52cccb4.zip chromium_src-d792583fa4a7436f78356c7c608b6f2ed52cccb4.tar.gz chromium_src-d792583fa4a7436f78356c7c608b6f2ed52cccb4.tar.bz2 |
Linux: calculate x-height from the outline of the glyph.
This allows us to pass css1/font_properties/font_size.html
Review URL: http://codereview.chromium.org/13076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp | 33 | ||||
-rw-r--r-- | webkit/tools/layout_tests/test_lists/tests_fixable.txt | 1 |
2 files changed, 25 insertions, 9 deletions
diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp index c5080c9..2394c5e 100644 --- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -39,26 +39,43 @@ void SimpleFontData::platformInit() m_descent = SkScalarCeil(metrics.fHeight) - m_ascent; } - m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the Windows port + 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; + } else { + // hack taken from the Windows port + m_xHeight = static_cast<float>(m_ascent) * 0.56; + } + m_lineGap = SkScalarRound(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 // m_avgCharWidth in order for text entry widgets to be sized correctly. - // Skia doesn't expose either of these so we calculate them ourselves - - GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); - if (!glyphPageZero) - return; m_maxCharWidth = SkScalarRound(metrics.fXRange * SkScalarRound(m_font.size())); if (metrics.fAvgCharWidth) { m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth); } else { - static const UChar32 x_char = 'x'; - m_avgCharWidth = widthForGlyph(glyphPageZero->glyphDataForCharacter(x_char).glyph); + if (x_glyph) { + m_avgCharWidth = widthForGlyph(x_glyph); + } else { + m_avgCharWidth = m_xHeight; + } } } diff --git a/webkit/tools/layout_tests/test_lists/tests_fixable.txt b/webkit/tools/layout_tests/test_lists/tests_fixable.txt index f6b812e..542a7ba 100644 --- a/webkit/tools/layout_tests/test_lists/tests_fixable.txt +++ b/webkit/tools/layout_tests/test_lists/tests_fixable.txt @@ -784,7 +784,6 @@ LayoutTests/http/tests/plugins/geturlnotify-from-npp-destroystream.html = FAIL P DEBUG : LayoutTests/svg/W3C-SVG-1.1/interact-dom-01-b.svg = CRASH // Tests that fail on linux but pass on windows. -LINUX : LayoutTests/css1/font_properties/font_size.html = FAIL LINUX : LayoutTests/css1/pseudo/multiple_pseudo_elements.html = FAIL LINUX : LayoutTests/css1/text_properties/line_height.html = FAIL LINUX : LayoutTests/css1/text_properties/text_indent.html = FAIL |