diff options
Diffstat (limited to 'WebCore/platform/graphics/mac/SimpleFontDataMac.mm')
-rw-r--r-- | WebCore/platform/graphics/mac/SimpleFontDataMac.mm | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm index 7f1a72e..04badbe 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm +++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm @@ -265,14 +265,19 @@ void SimpleFontData::platformInit() GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); NSGlyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0; if (xGlyph) { - NSRect xBox = [m_platformData.font() boundingRectForGlyph:xGlyph]; + CGRect xBox = platformBoundsForGlyph(xGlyph); // 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_xHeight = max(NSMaxX(xBox), NSMaxY(xBox)); - } else - m_xHeight = [m_platformData.font() xHeight]; + m_xHeight = static_cast<float>(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox))); + } else { +#ifndef BUILDING_ON_TIGER + m_xHeight = static_cast<float>(CGFontGetXHeight(m_platformData.cgFont())) / m_unitsPerEm; +#else + m_xHeight = m_platformData.font() ? [m_platformData.font() xHeight] : 0; +#endif + } } static CFDataRef copyFontTableForTag(FontPlatformData platformData, FourCharCode tableName) @@ -417,11 +422,15 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const float pointSize = platformData().m_size; CGFloat scale = pointSize / unitsPerEm(); boundingBox = CGRectApplyAffineTransform(box, CGAffineTransformMakeScale(scale, -scale)); - if (m_syntheticBoldOffset) - boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset); #else - UNUSED_PARAM(glyph); + // FIXME: Custom fonts don't have NSFonts, so this function doesn't compute correct bounds for these on Tiger. + if (!m_platformData.font()) + return boundingBox; + boundingBox = [m_platformData.font() boundingRectForGlyph:glyph]; #endif + if (m_syntheticBoldOffset) + boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset); + return boundingBox; } |