summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/mac/SimpleFontDataMac.mm')
-rw-r--r--WebCore/platform/graphics/mac/SimpleFontDataMac.mm31
1 files changed, 27 insertions, 4 deletions
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index fd57630..e1d3f43 100644
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -260,6 +260,24 @@ void SimpleFontData::platformInit()
m_descent = 3;
}
+ if (m_orientation == Vertical) {
+ // Ignore vertical orientation when the font doesn't support vertical metrics.
+ // The check doesn't look neat but this is what AppKit does for vertical writing...
+ RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(m_platformData.ctFont(), kCTFontTableOptionExcludeSynthetic));
+ CFIndex numTables = CFArrayGetCount(tableTags.get());
+ bool found = false;
+ for (CFIndex index = 0; index < numTables; ++index) {
+ CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
+ if (tag == kCTFontTableVhea || tag == kCTFontTableVORG) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found == false)
+ m_orientation = Horizontal;
+ }
+
// 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();
@@ -339,6 +357,11 @@ void SimpleFontData::platformCharWidthInit()
void SimpleFontData::platformDestroy()
{
+ if (m_smallCapsFontData && !isCustomFont()) {
+ fontCache()->releaseFontData(m_smallCapsFontData);
+ m_smallCapsFontData = 0;
+ }
+
#ifdef BUILDING_ON_TIGER
if (m_styleGroup)
wkReleaseStyleGroup(m_styleGroup);
@@ -359,8 +382,8 @@ SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDes
m_smallCapsFontData = new SimpleFontData(smallCapsFontData, true, false);
} else {
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- float size = [m_platformData.font() pointSize] * smallCapsFontSizeMultiplier;
- FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toSize:size]);
+ float size = m_platformData.size() * smallCapsFontSizeMultiplier;
+ FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toSize:size], size);
// AppKit resets the type information (screen/printer) when you convert a font to a different size.
// We have to fix up the font that we're handed back.
@@ -423,7 +446,7 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
FloatRect boundingBox;
#ifndef BUILDING_ON_TIGER
boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(),
- m_platformData.orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
+ orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
boundingBox.setY(-boundingBox.bottom());
#else
// FIXME: Custom fonts don't have NSFonts, so this function doesn't compute correct bounds for these on Tiger.
@@ -441,7 +464,7 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
{
CGSize advance;
- if (m_platformData.orientation() == Horizontal) {
+ if (orientation() == Horizontal || m_isBrokenIdeographFont) {
NSFont* font = platformData().font();
float pointSize = platformData().m_size;
CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);