Move code to discover if a CTFont has vertical glyphs out of SimpleFontData::platform...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 21:01:47 +0000 (21:01 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2011 21:01:47 +0000 (21:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=61392

Reviewed by Dave Hyatt.

* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::fontHasVerticalGlyphs): Moved code here...
(WebCore::SimpleFontData::platformInit): ...from here.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87201 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

index 76e5466..1083b0e 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-24  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        Move code to discover if a CTFont has vertical glyphs out of SimpleFontData::platformInit()
+        https://bugs.webkit.org/show_bug.cgi?id=61392
+
+        * platform/graphics/mac/SimpleFontDataMac.mm:
+        (WebCore::fontHasVerticalGlyphs): Moved code here...
+        (WebCore::SimpleFontData::platformInit): ...from here.
+
 2011-05-24  Kenneth Russell  <kbr@google.com>
 
         Reviewed by James Robinson.
index 8930117..d968cb0 100644 (file)
@@ -58,6 +58,19 @@ namespace WebCore {
 const float smallCapsFontSizeMultiplier = 0.7f;
 static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x / unitsPerEm; }
 
+static bool fontHasVerticalGlyphs(CTFontRef ctFont)
+{
+    // The check doesn't look neat but this is what AppKit does for vertical writing...
+    RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(ctFont, kCTFontTableOptionExcludeSynthetic));
+    CFIndex numTables = CFArrayGetCount(tableTags.get());
+    for (CFIndex index = 0; index < numTables; ++index) {
+        CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
+        if (tag == kCTFontTableVhea || tag == kCTFontTableVORG)
+            return true;
+    }
+    return false;
+}
+
 static bool initFontData(SimpleFontData* fontData)
 {
     if (!fontData->platformData().cgFont())
@@ -212,18 +225,8 @@ void SimpleFontData::platformInit()
         descent = 3;
     }
     
-    if (platformData().orientation() == Vertical && !isTextOrientationFallback()) {
-        // 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());
-        for (CFIndex index = 0; index < numTables; ++index) {
-            CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
-            if (tag == kCTFontTableVhea || tag == kCTFontTableVORG) {
-                m_hasVerticalGlyphs = true;
-                break;
-            }
-        }
-    }
+    if (platformData().orientation() == Vertical && !isTextOrientationFallback())
+        m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
 
     float xHeight;