Changeset 221909 in webkit


Ignore:
Timestamp:
Sep 12, 2017 4:21:36 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[Freetype] Doesn't support coloured fonts
https://bugs.webkit.org/show_bug.cgi?id=156579

Source/WebCore:

Patch by Fujii Hironori <Fujii Hironori> on 2017-09-12
Reviewed by Michael Catanzaro.

Covered by existing tests. This needs a large rebaseline that will be done in follow up commits.

  • platform/graphics/FontCascade.h: Enable advance text rendering mode by default.

(WebCore::FontCascade::advancedTextRenderingMode const):
(WebCore::FontCascade::computeRequiresShaping const):

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::Font::platformInit): Do not get metrics from OS/2 table for non-scalable fonts.

  • platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:

(WebCore::harfBuzzGetGlyph): Use U8_APPEND_UNSAFE() instead of converting to a String and then encoding it with
UTF8Encoding().

Tools:

Reviewed by Michael Catanzaro.

Bump webkitgtk-test-fonts to 0.0.6 version that includes the EmijoOne font.

  • gtk/jhbuild.modules:
  • wpe/jhbuild.modules:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221908 r221909  
     12017-09-12  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Freetype] Doesn't support coloured fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=156579
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Covered by existing tests. This needs a large rebaseline that will be done in follow up commits.
     9
     10        * platform/graphics/FontCascade.h: Enable advance text rendering mode by default.
     11        (WebCore::FontCascade::advancedTextRenderingMode const):
     12        (WebCore::FontCascade::computeRequiresShaping const):
     13        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     14        (WebCore::Font::platformInit): Do not get metrics from OS/2 table for non-scalable fonts.
     15        * platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
     16        (WebCore::harfBuzzGetGlyph): Use U8_APPEND_UNSAFE() instead of converting to a String and then encoding it with
     17        UTF8Encoding().
     18
    1192017-09-12  Frederic Wang  <fwang@igalia.com>
    220
  • trunk/Source/WebCore/platform/graphics/FontCascade.h

    r219858 r221909  
    276276        if (textRenderingMode == OptimizeSpeed)
    277277            return false;
    278 #if PLATFORM(COCOA)
     278#if PLATFORM(COCOA) || USE(FREETYPE)
    279279        return true;
    280280#else
     
    295295    bool computeRequiresShaping() const
    296296    {
    297 #if PLATFORM(COCOA)
     297#if PLATFORM(COCOA) || USE(FREETYPE)
    298298        if (!m_fontDescription.variantSettings().isAllNormal())
    299299            return true;
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r221858 r221909  
    9090        // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
    9191        FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
    92         TT_OS2* OS2Table = freeTypeFace ? static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2)) : nullptr;
    93         if (OS2Table) {
    94             const FT_Short kUseTypoMetricsMask = 1 << 7;
    95             if (OS2Table->fsSelection & kUseTypoMetricsMask) {
    96                 // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
    97                 // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
    98                 double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
    99                 ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
    100                 descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
    101                 lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
     92        if (freeTypeFace && freeTypeFace->face_flags & FT_FACE_FLAG_SCALABLE) {
     93            if (auto* OS2Table = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2))) {
     94                const FT_Short kUseTypoMetricsMask = 1 << 7;
     95                if (OS2Table->fsSelection & kUseTypoMetricsMask) {
     96                    // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
     97                    // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
     98                    double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
     99                    ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
     100                    descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
     101                    lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
     102                }
    102103            }
    103104        }
  • trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp

    r200129 r221909  
    100100        cairo_glyph_t* glyphs = 0;
    101101        int numGlyphs = 0;
    102         UChar ch = unicode;
    103         CString utf8Codepoint = UTF8Encoding().encode(StringView(&ch, 1), QuestionMarksForUnencodables);
    104         if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0) != CAIRO_STATUS_SUCCESS)
     102        char buffer[U8_MAX_LENGTH];
     103        size_t bufferLength = 0;
     104        U8_APPEND_UNSAFE(buffer, bufferLength, unicode);
     105        if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, buffer, bufferLength, &glyphs, &numGlyphs, nullptr, nullptr, nullptr) != CAIRO_STATUS_SUCCESS)
    105106            return false;
    106107        if (!numGlyphs)
  • trunk/Tools/ChangeLog

    r221907 r221909  
     12017-09-12  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Freetype] Doesn't support coloured fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=156579
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Bump webkitgtk-test-fonts to 0.0.6 version that includes the EmijoOne font.
     9
     10        * gtk/jhbuild.modules:
     11        * wpe/jhbuild.modules:
     12
    1132017-09-11  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/Tools/gtk/jhbuild.modules

    r221727 r221909  
    111111  <autotools id="fonts" supports-non-srcdir-builds="no"
    112112             skip-autogen="true">
    113     <branch repo="github.com" module="mrobinson/webkitgtk-test-fonts.git" checkoutdir="webkitgtk-test-fonts" tag="0.0.5"/>
     113    <branch repo="github.com" module="WebKitGTK/webkitgtk-test-fonts.git" checkoutdir="webkitgtk-test-fonts" tag="0.0.6"/>
    114114  </autotools>
    115115
  • trunk/Tools/wpe/jhbuild.modules

    r221858 r221909  
    9393  <autotools id="fonts" supports-non-srcdir-builds="no"
    9494             skip-autogen="true">
    95     <branch repo="github.com" module="mrobinson/webkitgtk-test-fonts.git" checkoutdir="webkitgtk-test-fonts" tag="0.0.5"/>
     95    <branch repo="github.com" module="WebKitGTK/webkitgtk-test-fonts.git" checkoutdir="webkitgtk-test-fonts" tag="0.0.6"/>
    9696  </autotools>
    9797
Note: See TracChangeset for help on using the changeset viewer.