Title: [191440] trunk
Revision
191440
Author
fred.w...@free.fr
Date
2015-10-21 23:45:21 -0700 (Wed, 21 Oct 2015)

Log Message

[Mac] Add support for the USE_TYPO_METRICS flag
https://bugs.webkit.org/show_bug.cgi?id=150394

Reviewed by Myles C. Maxfield.

Source/WebCore:

Make the Cocoa backend use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set.

No new tests because this is already tested by fonts/use-typo-metrics-1.html

* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that is the case.

LayoutTests:

Update font, reference and Mac expectation for fonts/use-typo-metrics-1.html

* fonts/lineheight5000-typolineheight2300.woff: Add a MATH table.
* platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.
* platform/mac/TestExpectations: Remove Mac failure expectation.
* platform/mac/mathml/opentype/opentype-stretchy-expected.txt: Updated.
* platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191439 => 191440)


--- trunk/LayoutTests/ChangeLog	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/ChangeLog	2015-10-22 06:45:21 UTC (rev 191440)
@@ -1,3 +1,18 @@
+2015-10-21  Frederic Wang  <fred.w...@free.fr>
+
+        [Mac] Add support for the USE_TYPO_METRICS flag
+        https://bugs.webkit.org/show_bug.cgi?id=150394
+
+        Reviewed by Myles C. Maxfield.
+
+        Update font, reference and Mac expectation for fonts/use-typo-metrics-1.html
+
+        * fonts/lineheight5000-typolineheight2300.woff: Add a MATH table.
+        * platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.
+        * platform/mac/TestExpectations: Remove Mac failure expectation.
+        * platform/mac/mathml/opentype/opentype-stretchy-expected.txt: Updated.
+        * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.
+
 2015-10-21  Ryan Haddad  <ryanhad...@apple.com>
 
         Adding http/tests/media/video-load-suspend.html to the list of flaky media tests

Modified: trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff (191439 => 191440)


--- trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/fonts/lineheight5000-typolineheight2300.woff	2015-10-22 06:45:21 UTC (rev 191440)
@@ -1,17 +1,16 @@
-wOFFOTTOT
-CFF \xF4\xDF(\x89\xC9 6FFTM\xD4v\xC5\x86OS/2\xF0D`!\xD5'cmap4EJ\x93\xA9head|06\x8Dh\xB7hhea\xAC$+wOFFOTTO\xB4	CFF `\xDF(\x89\xC9 6FFTM@v\xDANpMATH\K\xF2DOS/2\D`!\xD5'cmapEJ\x93\xA9head06\xA2\xA5\xA1hhea8$ \xAD-\xAFhmtx\xC8
+\xAFhmtx\xA8
 
-\xD0maxp\xD4Pname\xDC]\xE4\xE7}\xAB\xE0post< \xFF\x863x\x9Ccd`aa`ddTO\xCB\xCF+\xD1\xCD\xC9\xCCK\xCDH\xCDL\xCF(1500\xD0-\xA9,\xC8G002102\xE8\xFD\xE0g\xF8!\xCD\xF8C\x86\xE9\x87,\xF3	\x96\xC6\xEE\xDF1\xBFj~na\x95ax\xC8/\xC3\xC0  \xC3\xF0LP\x86\x81O\x86QJ\x88\x81\xA4G\x8D\xC1\x87\xA1\xC89\xBF\xA0\xB2d\x96\x82F\xB2\xA6\x82\x91\x81\xA1\xA9\x82obI\x86\xAF\x8F\x82cqq~rfbIf~q.!ҽ@\xC0\xC8`\xC0\xC0\xCCȨ\xA4\xAC׽\xF7\x87\xEB^ƽ{n\xD9˼W\xEC\x97ď\x95\xFF$\xD8\xF6\xFE)\xFD\xE1\xFAs\xCBWv>\xBE\xDF1,\xBFj~\xD5\xFC\xABa\xE7\xFBU#\xD2-Z>\xFF\xE7\x96n\xB6n.\x8Elc[x\x9Cc```d\x82Kvo\xB8\xC1\xB4\xB3\xD0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B22e\x96\x8Ap\xAA\xC4\\x9CV$
+\xC3@J6\x9D\xBBP\x9B6t.\xF9\xB6\xBA%Z\xE7\xA0-`welҲ\xE2+JS\x979\xE77+\xE3\xBFdx\x9Cc```f\x80`Fp\xF2\xC1|+ \xCD\xA4\x98\xFC\xFF\xFF\xF2\xC1\xF4\xFF\x87\xFF7C\xD5#\x82\x83\x92GL\xA4)x	9x\x9Cc`f\x83\xFF\xCDF@\x8A\x91+(U\xB9x\x9Ccd`aa`ddTO\xCB\xCF+\xD1\xCD\xC9\xCCK\xCDH\xCDL\xCF(1500\xD0-\xA9,\xC8G002102\xE8\xFD\xE0g\xF8!\xCD\xF8C\x86\xE9\x87,\xF3	\x96\xC6\xEE\xDF1\xBFj~na\x95ax\xC8/\xC3\xC0  \xC3\xF0LP\x86\x81O\x86QJ\x88\x81\xA4G\x8D\xC1\x87\xA1\xC89\xBF\xA0\xB2d\x96\x82F\xB2\xA6\x82\x91\x81\xA1\xA9\x82obI\x86\xAF\x8F\x82cqq~rfbIf~q.!ҽ@\xC0\xC8`\xC0\xC0\xCCȨ\xA4\xAC׽\xF7\x87\xEB^ƽ{n\xD9˼W\xEC\x97ď\x95\xFF$\xD8\xF6\xFE)\xFD\xE1\xFAs\xCBWv>\xBE\xDF1,\xBFj~\xD5\xFC\xABa\xE7\xFBU#\xD2-Z>\xFF\xE7\x96n\xB6n.\x8Elc[x\x9Cc```d\x82Kvo\xB8\xC1\xB4\xEFF#+B +x\x9Cc`d``\xE0bx\xC0\xF0\x82!\x80\xC1\x86\xF5&\xE8A0\xA0ɝ\x80ҚX\xF4\xA1\x83i@\xFDqD\xA83\x82\xA8\xD306\x92(\xE2F\xD81\xA3(\xC3߫@\xB6
 +\\xA7\x8C\x8EF+J\xE8\xE8
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac/TestExpectations (191439 => 191440)


--- trunk/LayoutTests/platform/mac/TestExpectations	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2015-10-22 06:45:21 UTC (rev 191440)
@@ -1348,6 +1348,3 @@
 
 # Imported Blink tests which have not been investigated.
 imported/blink/compositing/video/video-controls-layer-creation-squashing.html [ Pass ImageOnlyFailure ]
-
-# USE_TYPO_METRICS is not implemented on mac.
-webkit.org/b/131839 fonts/use-typo-metrics-1.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-expected.txt (191439 => 191440)


--- trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-expected.txt	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-expected.txt	2015-10-22 06:45:21 UTC (rev 191440)
@@ -9,7 +9,7 @@
             RenderMathMLOperator {mo} at (0,0) size 47x11
               RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
                 RenderBlock (anonymous) at (0,0) size 3x3
-                  RenderText at (0,-3) size 3x10
+                  RenderText at (0,-3) size 3x0
                     text run at (0,-3) width 3: "\x{219F}"
         RenderText {#text} at (48,16) size 5x18
           text run at (48,16) width 5: " "
@@ -18,7 +18,7 @@
             RenderMathMLOperator {mo} at (0,0) size 47x21
               RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
                 RenderBlock (anonymous) at (0,0) size 3x3
-                  RenderText at (0,-3) size 3x10
+                  RenderText at (0,-3) size 3x0
                     text run at (0,-3) width 3: "\x{219F}"
         RenderText {#text} at (100,16) size 5x18
           text run at (100,16) width 5: " "
@@ -27,7 +27,7 @@
             RenderMathMLOperator {mo} at (0,0) size 47x31
               RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
                 RenderBlock (anonymous) at (0,0) size 3x3
-                  RenderText at (0,-3) size 3x10
+                  RenderText at (0,-3) size 3x0
                     text run at (0,-3) width 3: "\x{219F}"
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,50) size 784x154
@@ -36,7 +36,7 @@
             RenderMathMLOperator {mo} at (0,0) size 47x150
               RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
                 RenderBlock (anonymous) at (0,0) size 3x3
-                  RenderText at (0,-3) size 3x10
+                  RenderText at (0,-3) size 3x0
                     text run at (0,-3) width 3: "\x{219F}"
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {P} at (0,220) size 784x85
@@ -45,6 +45,6 @@
             RenderMathMLOperator {mo} at (0,0) size 84x82
               RenderMathMLBlock (anonymous, flex) at (0,0) size 83x12
                 RenderBlock (anonymous) at (0,0) size 11x12
-                  RenderText at (0,6) size 11x10
+                  RenderText at (0,6) size 11x0
                     text run at (0,6) width 11: "\x{2A1B}"
         RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt (191439 => 191440)


--- trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt	2015-10-22 06:45:21 UTC (rev 191440)
@@ -10,7 +10,7 @@
               RenderMathMLOperator {mo} at (0,1) size 16x21
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 11x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (4,0) size 8x1
         RenderText {#text} at (0,0) size 0x0
@@ -21,7 +21,7 @@
               RenderMathMLOperator {mo} at (0,1) size 26x21
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (5,0) size 16x1
         RenderText {#text} at (0,0) size 0x0
@@ -32,7 +32,7 @@
               RenderMathMLOperator {mo} at (0,1) size 156x41
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 151x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (2,0) size 151x1
         RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt (191439 => 191440)


--- trunk/LayoutTests/platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/LayoutTests/platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt	2015-10-22 06:45:21 UTC (rev 191440)
@@ -10,7 +10,7 @@
               RenderMathMLOperator {mo} at (0,1) size 16x21
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 11x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (4,0) size 8x1
         RenderText {#text} at (0,0) size 0x0
@@ -21,7 +21,7 @@
               RenderMathMLOperator {mo} at (0,1) size 26x21
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (5,0) size 16x1
         RenderText {#text} at (0,0) size 0x0
@@ -32,7 +32,7 @@
               RenderMathMLOperator {mo} at (0,1) size 156x41
                 RenderMathMLBlock (anonymous, flex) at (2,0) size 151x4
                   RenderBlock (anonymous) at (0,0) size 2x4
-                    RenderText at (0,-3) size 2x10
+                    RenderText at (0,-3) size 2x0
                       text run at (0,-3) width 2: "\x{219C}"
               RenderMathMLSpace {mspace} at (2,0) size 151x1
         RenderText {#text} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (191439 => 191440)


--- trunk/Source/WebCore/ChangeLog	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/Source/WebCore/ChangeLog	2015-10-22 06:45:21 UTC (rev 191440)
@@ -1,3 +1,17 @@
+2015-10-21  Frederic Wang  <fred.w...@free.fr>
+
+        [Mac] Add support for the USE_TYPO_METRICS flag
+        https://bugs.webkit.org/show_bug.cgi?id=150394
+
+        Reviewed by Myles C. Maxfield.
+
+        Make the Cocoa backend use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set.
+
+        No new tests because this is already tested by fonts/use-typo-metrics-1.html
+
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that is the case.
+
 2015-10-21  Zalan Bujtas  <za...@apple.com>
 
         Print out the render tree from command line.

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (191439 => 191440)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-10-22 06:10:53 UTC (rev 191439)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-10-22 06:45:21 UTC (rev 191440)
@@ -57,6 +57,10 @@
 @end
 #endif
 
+#if USE(APPKIT)
+#include "OpenTypeTypes.h"
+#endif
+
 namespace WebCore {
 
 static bool fontHasVerticalGlyphs(CTFontRef ctFont)
@@ -170,6 +174,32 @@
     
     float lineGap = scaleEmToUnits(CGFontGetLeading(m_platformData.cgFont()), unitsPerEm) * pointSize;
 
+    // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
+    // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font."
+    // We only apply this rule in the important case of fonts with a MATH table.
+    CFArrayRef availableTables = CTFontCopyAvailableTables(m_platformData.cgFont(), kCTFontTableOptionNoOptions);
+    if (CFArrayContainsValue(availableTables, CFRangeMake(0, CFArrayGetCount(availableTables)), kCTFontTableMATH)) {
+        if (CFDataRef os2Table = CGFontCopyTableForTag(kCTFontTableOS2)) {
+            // For the structure of the OS/2 table, see
+            // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html
+            const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1;
+            const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2;
+            const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2;
+            const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2;
+            if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) {
+                const UInt8* os2Data = CFDataGetBytePtr(os2Table);
+                const unsigned short useTypoMetricsMask = 1 << 7;
+                if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) {
+                    ascent = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)), unitsPerEm) * pointSize;
+                    descent = -scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)), unitsPerEm) * pointSize;
+                    lineGap = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)), unitsPerEm) * pointSize;
+                }
+            }
+            CFRelease(os2Table);
+        }
+    }
+    CFRelease(availableTables);
+
     // We need to adjust Times, Helvetica, and Courier to closely match the
     // vertical metrics of their Microsoft counterparts that are the de facto
     // web standard. The AppKit adjustment of 20% is too big and is
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to