Changeset 191440 in webkit


Ignore:
Timestamp:
Oct 21, 2015 11:45:21 PM (8 years ago)
Author:
fred.wang@free.fr
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.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191431 r191440  
     12015-10-21  Frederic Wang  <fred.wang@free.fr>
     2
     3        [Mac] Add support for the USE_TYPO_METRICS flag
     4        https://bugs.webkit.org/show_bug.cgi?id=150394
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Update font, reference and Mac expectation for fonts/use-typo-metrics-1.html
     9
     10        * fonts/lineheight5000-typolineheight2300.woff: Add a MATH table.
     11        * platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.
     12        * platform/mac/TestExpectations: Remove Mac failure expectation.
     13        * platform/mac/mathml/opentype/opentype-stretchy-expected.txt: Updated.
     14        * platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Updated.
     15
    1162015-10-21  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/LayoutTests/platform/mac-mavericks/mathml/opentype/opentype-stretchy-horizontal-expected.txt

    r174585 r191440  
    1111                RenderMathMLBlock (anonymous, flex) at (2,0) size 11x4
    1212                  RenderBlock (anonymous) at (0,0) size 2x4
    13                     RenderText at (0,-3) size 2x10
     13                    RenderText at (0,-3) size 2x0
    1414                      text run at (0,-3) width 2: "\x{219C}"
    1515              RenderMathMLSpace {mspace} at (4,0) size 8x1
     
    2222                RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
    2323                  RenderBlock (anonymous) at (0,0) size 2x4
    24                     RenderText at (0,-3) size 2x10
     24                    RenderText at (0,-3) size 2x0
    2525                      text run at (0,-3) width 2: "\x{219C}"
    2626              RenderMathMLSpace {mspace} at (5,0) size 16x1
     
    3333                RenderMathMLBlock (anonymous, flex) at (2,0) size 151x4
    3434                  RenderBlock (anonymous) at (0,0) size 2x4
    35                     RenderText at (0,-3) size 2x10
     35                    RenderText at (0,-3) size 2x0
    3636                      text run at (0,-3) width 2: "\x{219C}"
    3737              RenderMathMLSpace {mspace} at (2,0) size 151x1
  • trunk/LayoutTests/platform/mac/TestExpectations

    r191431 r191440  
    13491349# Imported Blink tests which have not been investigated.
    13501350imported/blink/compositing/video/video-controls-layer-creation-squashing.html [ Pass ImageOnlyFailure ]
    1351 
    1352 # USE_TYPO_METRICS is not implemented on mac.
    1353 webkit.org/b/131839 fonts/use-typo-metrics-1.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-expected.txt

    r170699 r191440  
    1010              RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
    1111                RenderBlock (anonymous) at (0,0) size 3x3
    12                   RenderText at (0,-3) size 3x10
     12                  RenderText at (0,-3) size 3x0
    1313                    text run at (0,-3) width 3: "\x{219F}"
    1414        RenderText {#text} at (48,16) size 5x18
     
    1919              RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
    2020                RenderBlock (anonymous) at (0,0) size 3x3
    21                   RenderText at (0,-3) size 3x10
     21                  RenderText at (0,-3) size 3x0
    2222                    text run at (0,-3) width 3: "\x{219F}"
    2323        RenderText {#text} at (100,16) size 5x18
     
    2828              RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
    2929                RenderBlock (anonymous) at (0,0) size 3x3
    30                   RenderText at (0,-3) size 3x10
     30                  RenderText at (0,-3) size 3x0
    3131                    text run at (0,-3) width 3: "\x{219F}"
    3232        RenderText {#text} at (0,0) size 0x0
     
    3737              RenderMathMLBlock (anonymous, flex) at (2,0) size 42x3
    3838                RenderBlock (anonymous) at (0,0) size 3x3
    39                   RenderText at (0,-3) size 3x10
     39                  RenderText at (0,-3) size 3x0
    4040                    text run at (0,-3) width 3: "\x{219F}"
    4141        RenderText {#text} at (0,0) size 0x0
     
    4646              RenderMathMLBlock (anonymous, flex) at (0,0) size 83x12
    4747                RenderBlock (anonymous) at (0,0) size 11x12
    48                   RenderText at (0,6) size 11x10
     48                  RenderText at (0,6) size 11x0
    4949                    text run at (0,6) width 11: "\x{2A1B}"
    5050        RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-horizontal-expected.txt

    r175173 r191440  
    1111                RenderMathMLBlock (anonymous, flex) at (2,0) size 11x4
    1212                  RenderBlock (anonymous) at (0,0) size 2x4
    13                     RenderText at (0,-3) size 2x10
     13                    RenderText at (0,-3) size 2x0
    1414                      text run at (0,-3) width 2: "\x{219C}"
    1515              RenderMathMLSpace {mspace} at (4,0) size 8x1
     
    2222                RenderMathMLBlock (anonymous, flex) at (2,0) size 22x4
    2323                  RenderBlock (anonymous) at (0,0) size 2x4
    24                     RenderText at (0,-3) size 2x10
     24                    RenderText at (0,-3) size 2x0
    2525                      text run at (0,-3) width 2: "\x{219C}"
    2626              RenderMathMLSpace {mspace} at (5,0) size 16x1
     
    3333                RenderMathMLBlock (anonymous, flex) at (2,0) size 151x4
    3434                  RenderBlock (anonymous) at (0,0) size 2x4
    35                     RenderText at (0,-3) size 2x10
     35                    RenderText at (0,-3) size 2x0
    3636                      text run at (0,-3) width 2: "\x{219C}"
    3737              RenderMathMLSpace {mspace} at (2,0) size 151x1
  • trunk/Source/WebCore/ChangeLog

    r191439 r191440  
     12015-10-21  Frederic Wang  <fred.wang@free.fr>
     2
     3        [Mac] Add support for the USE_TYPO_METRICS flag
     4        https://bugs.webkit.org/show_bug.cgi?id=150394
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Make the Cocoa backend use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set.
     9
     10        No new tests because this is already tested by fonts/use-typo-metrics-1.html
     11
     12        * platform/graphics/cocoa/FontCocoa.mm:
     13        (WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that is the case.
     14
    1152015-10-21  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm

    r191331 r191440  
    5858#endif
    5959
     60#if USE(APPKIT)
     61#include "OpenTypeTypes.h"
     62#endif
     63
    6064namespace WebCore {
    6165
     
    171175    float lineGap = scaleEmToUnits(CGFontGetLeading(m_platformData.cgFont()), unitsPerEm) * pointSize;
    172176
     177    // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows:
     178    // "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."
     179    // We only apply this rule in the important case of fonts with a MATH table.
     180    CFArrayRef availableTables = CTFontCopyAvailableTables(m_platformData.cgFont(), kCTFontTableOptionNoOptions);
     181    if (CFArrayContainsValue(availableTables, CFRangeMake(0, CFArrayGetCount(availableTables)), kCTFontTableMATH)) {
     182        if (CFDataRef os2Table = CGFontCopyTableForTag(kCTFontTableOS2)) {
     183            // For the structure of the OS/2 table, see
     184            // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html
     185            const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1;
     186            const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2;
     187            const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2;
     188            const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2;
     189            if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) {
     190                const UInt8* os2Data = CFDataGetBytePtr(os2Table);
     191                const unsigned short useTypoMetricsMask = 1 << 7;
     192                if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) {
     193                    ascent = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)), unitsPerEm) * pointSize;
     194                    descent = -scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)), unitsPerEm) * pointSize;
     195                    lineGap = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)), unitsPerEm) * pointSize;
     196                }
     197            }
     198            CFRelease(os2Table);
     199        }
     200    }
     201    CFRelease(availableTables);
     202
    173203    // We need to adjust Times, Helvetica, and Courier to closely match the
    174204    // vertical metrics of their Microsoft counterparts that are the de facto
Note: See TracChangeset for help on using the changeset viewer.