+2015-10-22 Frederic Wang <fred.wang@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-22 Michael Saboff <msaboff@apple.com>
REGRESSION(r191360): Repro Crash: com.apple.WebKit.WebContent at JavaScriptCore:JSC::ExecState::bytecodeOffset + 174
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
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
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
# 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 ]
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: " "
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: " "
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
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
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
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
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
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
+2015-10-22 Frederic Wang <fred.wang@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::fontHasMathTable): Add a function to verify whether a font has a MATH table.
+ (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-22 Wenson Hsieh <wenson_hsieh@apple.com>
Implement touch-action: manipulation; for iOS
@end
#endif
+#if USE(APPKIT)
+#include "OpenTypeTypes.h"
+#endif
+
namespace WebCore {
static bool fontHasVerticalGlyphs(CTFontRef ctFont)
}
#if USE(APPKIT)
+static bool fontHasMathTable(CTFontRef ctFont)
+{
+ RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
+ CFIndex numTables = CFArrayGetCount(tableTags.get());
+ for (CFIndex index = 0; index < numTables; ++index) {
+ CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
+ if (tag == 'MATH')
+ return true;
+ }
+ return false;
+}
+
static NSString *webFallbackFontFamily(void)
{
static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain];
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.
+ if (fontHasMathTable(m_platformData.ctFont())) {
+ if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), 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);
+ }
+ }
+
// 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