Commit 73af4646 authored by hyatt@apple.com's avatar hyatt@apple.com

Make the same change to xheight on Windows for CG.

Reviewed by Adam Roben.

* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::SimpleFontData::platformInit):



git-svn-id: svn://svn.chromium.org/blink/trunk@80764 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3d1121d9
2011-03-10 David Hyatt <hyatt@apple.com>
Reviewed by Adam Roben.
Make the same change to xheight on Windows for CG.
* platform/graphics/win/SimpleFontDataCGWin.cpp:
(WebCore::SimpleFontData::platformInit):
2011-03-10 David Hyatt <hyatt@apple.com>
Reviewed by Simon Fraser.
......
......@@ -97,18 +97,14 @@ void SimpleFontData::platformInit()
m_fontMetrics.setLineGap(fLineGap);
m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap));
// Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font.
// Unfortunately, NSFont will round this for us so we don't quite get the right value.
GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
Glyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0;
if (xGlyph) {
// Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
// reported x-height to only include the portion of the glyph that is above the baseline.
CGRect xBox;
CGFontGetGlyphBBoxes(font, &xGlyph, 1, &xBox);
// Use the maximum of either width or height because "x" is nearly square
// and web pages that foolishly use this metric for width will be laid out
// poorly if we return an accurate height. Classic case is Times 13 point,
// which has an "x" that is 7x6 pixels.
m_fontMetrics.setXHeight(scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), unitsPerEm) * pointSize);
m_fontMetrics.setXHeight(scaleEmToUnits(CGRectGetMaxY(xBox), unitsPerEm) * pointSize);
} else {
int iXHeight = CGFontGetXHeight(font);
m_fontMetrics.setXHeight(scaleEmToUnits(iXHeight, unitsPerEm) * pointSize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment