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.mm114
1 files changed, 20 insertions, 94 deletions
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index 562f56e..7f1a72e 100644
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -45,6 +45,7 @@
#import <wtf/Assertions.h>
#import <wtf/StdLibExtras.h>
#import <wtf/RetainPtr.h>
+#import <wtf/UnusedParam.h>
@interface NSFont (WebAppKitSecretAPI)
- (BOOL)_isFakeFixedPitch;
@@ -407,7 +408,24 @@ void SimpleFontData::determinePitch()
[name caseInsensitiveCompare:@"MonotypeCorsiva"] != NSOrderedSame;
}
-GlyphMetrics SimpleFontData::platformMetricsForGlyph(Glyph glyph, GlyphMetricsMode metricsMode) const
+FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
+{
+ FloatRect boundingBox;
+#ifndef BUILDING_ON_TIGER
+ CGRect box;
+ CGFontGetGlyphBBoxes(platformData().cgFont(), &glyph, 1, &box);
+ 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);
+#endif
+ return boundingBox;
+}
+
+float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
{
NSFont* font = platformData().font();
float pointSize = platformData().m_size;
@@ -417,99 +435,7 @@ GlyphMetrics SimpleFontData::platformMetricsForGlyph(Glyph glyph, GlyphMetricsMo
LOG_ERROR("Unable to cache glyph widths for %@ %f", [font displayName], pointSize);
advance.width = 0;
}
- GlyphMetrics metrics;
- metrics.horizontalAdvance = advance.width + m_syntheticBoldOffset;
- if (metricsMode == GlyphBoundingBox) {
-#ifndef BUILDING_ON_TIGER
- CGRect boundingBox;
- CGFontGetGlyphBBoxes(platformData().cgFont(), &glyph, 1, &boundingBox);
- CGFloat scale = pointSize / unitsPerEm();
- metrics.boundingBox = CGRectApplyAffineTransform(boundingBox, CGAffineTransformMakeScale(scale, -scale));
- if (m_syntheticBoldOffset)
- metrics.boundingBox.setWidth(metrics.boundingBox.width() + m_syntheticBoldOffset);
-#endif
- }
- return metrics;
-}
-
-#if USE(ATSUI)
-void SimpleFontData::checkShapesArabic() const
-{
- ASSERT(!m_checkedShapesArabic);
-
- m_checkedShapesArabic = true;
-
- ATSUFontID fontID = m_platformData.m_atsuFontID;
- if (!fontID) {
- LOG_ERROR("unable to get ATSUFontID for %@", m_platformData.font());
- return;
- }
-
- // This function is called only on fonts that contain Arabic glyphs. Our
- // heuristic is that if such a font has a glyph metamorphosis table, then
- // it includes shaping information for Arabic.
- FourCharCode tables[] = { 'morx', 'mort' };
- for (unsigned i = 0; i < sizeof(tables) / sizeof(tables[0]); ++i) {
- ByteCount tableSize;
- OSStatus status = ATSFontGetTable(fontID, tables[i], 0, 0, 0, &tableSize);
- if (status == noErr) {
- m_shapesArabic = true;
- return;
- }
-
- if (status != kATSInvalidFontTableAccess)
- LOG_ERROR("ATSFontGetTable failed (%d)", status);
- }
-}
-#endif
-
-#if USE(CORE_TEXT)
-CTFontRef SimpleFontData::getCTFont() const
-{
- if (getNSFont())
- return toCTFontRef(getNSFont());
- if (!m_CTFont)
- m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_platformData.cgFont(), m_platformData.size(), NULL, NULL));
- return m_CTFont.get();
-}
-
-CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures) const
-{
- unsigned key = typesettingFeatures + 1;
- pair<HashMap<unsigned, RetainPtr<CFDictionaryRef> >::iterator, bool> addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
- RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.first->second;
- if (!addResult.second)
- return attributesDictionary.get();
-
- bool allowLigatures = platformData().allowsLigatures() || (typesettingFeatures & Ligatures);
-
- static const int ligaturesNotAllowedValue = 0;
- static CFNumberRef ligaturesNotAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesNotAllowedValue);
-
- static const int ligaturesAllowedValue = 1;
- static CFNumberRef ligaturesAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesAllowedValue);
-
- if (!(typesettingFeatures & Kerning)) {
- static const float kerningAdjustmentValue = 0;
- static CFNumberRef kerningAdjustment = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &kerningAdjustmentValue);
- static const void* keysWithKerningDisabled[] = { kCTFontAttributeName, kCTKernAttributeName, kCTLigatureAttributeName };
- const void* valuesWithKerningDisabled[] = { getCTFont(), kerningAdjustment, allowLigatures
- ? ligaturesAllowed : ligaturesNotAllowed };
- attributesDictionary.adoptCF(CFDictionaryCreate(NULL, keysWithKerningDisabled, valuesWithKerningDisabled,
- sizeof(keysWithKerningDisabled) / sizeof(*keysWithKerningDisabled),
- &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- } else {
- // By omitting the kCTKernAttributeName attribute, we get Core Text's standard kerning.
- static const void* keysWithKerningEnabled[] = { kCTFontAttributeName, kCTLigatureAttributeName };
- const void* valuesWithKerningEnabled[] = { getCTFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed };
- attributesDictionary.adoptCF(CFDictionaryCreate(NULL, keysWithKerningEnabled, valuesWithKerningEnabled,
- sizeof(keysWithKerningEnabled) / sizeof(*keysWithKerningEnabled),
- &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- }
-
- return attributesDictionary.get();
+ return advance.width + m_syntheticBoldOffset;
}
-#endif
-
} // namespace WebCore