Changeset 191378 in webkit


Ignore:
Timestamp:
Oct 21, 2015 12:05:21 AM (9 years ago)
Author:
fred.wang@free.fr
Message:

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

Reviewed by Martin Robinson.

Source/WebCore:

Test: fonts/use-typo-metrics-1.html

Make the FreeType backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
Similar work should be done for other backends, see bug 131839.

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that's the case.

LayoutTests:

Add a test to verify that the line height of a font is calculated from the typo metrics when the OS/2 USE_TYPO_METRICS flag is set. Currently, the test only passes with the FreeType backend.

  • fonts/lineheight5000-typolineheight2300.woff: Added.
  • fonts/use-typo-metrics-1-expected.html: Added.
  • fonts/use-typo-metrics-1.html: Added.
  • platform/mac/TestExpectations: Mark as failing.
  • platform/win/TestExpectations: Mark as failing.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191376 r191378  
     12015-10-21  Frederic Wang  <fred.wang@free.fr>
     2
     3        [FreeType] Add support for the USE_TYPO_METRICS flag
     4        https://bugs.webkit.org/show_bug.cgi?id=150340
     5
     6        Reviewed by Martin Robinson.
     7
     8        Add a test to verify that the line height of a font is calculated from the typo metrics when the OS/2 USE_TYPO_METRICS flag is set. Currently, the test only passes with the FreeType backend.
     9
     10        * fonts/lineheight5000-typolineheight2300.woff: Added.
     11        * fonts/use-typo-metrics-1-expected.html: Added.
     12        * fonts/use-typo-metrics-1.html: Added.
     13        * platform/mac/TestExpectations: Mark as failing.
     14        * platform/win/TestExpectations: Mark as failing.
     15
    1162015-10-20  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/LayoutTests/platform/mac/TestExpectations

    r191273 r191378  
    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.
     1353webkit.org/b/131839 fonts/use-typo-metrics-1.html [ Failure ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r191217 r191378  
    32653265# The following tests are not relevant on the Windows platform:
    32663266fast/forms/hidpi-textfield-background-bleeding.html [ Skip ]
     3267
     3268# USE_TYPO_METRICS is not implemented on the Windows platform
     3269webkit.org/b/131839 fonts/use-typo-metrics-1.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r191369 r191378  
     12015-10-21  Frederic Wang  <fred.wang@free.fr>
     2
     3        [FreeType] Add support for the USE_TYPO_METRICS flag
     4        https://bugs.webkit.org/show_bug.cgi?id=150340
     5
     6        Reviewed by Martin Robinson.
     7
     8        Test: fonts/use-typo-metrics-1.html
     9
     10        Make the FreeType backend use the typo metrics when the OS/2 USE_TYPO_METRICS flag is set.
     11        Similar work should be done for other backends, see bug 131839.
     12
     13        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     14        (WebCore::Font::platformInit): Verify whether the OS/2 USE_TYPO_METRICS flag is set and use the typo metrics if that's the case.
     15
    1162015-10-20  Hunseop Jeong  <hs85.jeong@samsung.com>
    217
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r188130 r191378  
    6565    float capHeight = narrowPrecisionToFloat(fontExtents.height);
    6666    float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);
     67
     68    // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
     69    FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
     70    if (TT_OS2* OS2Table = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2))) {
     71        const FT_Short kUseTypoMetricsMask = 1 << 7;
     72        if (OS2Table->fsSelection & kUseTypoMetricsMask) {
     73            // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
     74            // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
     75            double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
     76            ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
     77            descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
     78            lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
     79        }
     80    }
     81    cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
    6782
    6883    m_fontMetrics.setAscent(ascent);
Note: See TracChangeset for help on using the changeset viewer.