Changeset 239122 in webkit


Ignore:
Timestamp:
Dec 12, 2018 11:02:53 AM (5 years ago)
Author:
Michael Catanzaro
Message:

Unreviewed manual rollout of r239100-r239102 and r239114
https://bugs.webkit.org/show_bug.cgi?id=192151
<rdar://problem/46655586>

.:

  • Source/cmake/OptionsGTK.cmake:

Source/WebCore:

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::font):

  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::platformDataFromCustomData):

  • platform/FreeType.cmake:
  • platform/graphics/FontPlatformData.h:

(WebCore::FontPlatformData::isFixedWidth const): Deleted.

  • platform/graphics/cairo/FontCustomPlatformData.h:
  • platform/graphics/freetype/FontCacheFreeType.cpp:

(WebCore::FontCache::systemFallbackForCharacters):
(WebCore::FontCache::createFontPlatformData):
(WebCore::getFontPropertiesFromPattern): Deleted.
(WebCore::defaultVariationValues): Deleted.
(WebCore::buildVariationSettings): Deleted.

  • platform/graphics/freetype/FontCacheFreeType.h: Removed.
  • platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:

(WebCore::FontCustomPlatformData::FontCustomPlatformData):
(WebCore::FontCustomPlatformData::~FontCustomPlatformData):
(WebCore::FontCustomPlatformData::fontPlatformData):
(WebCore::FontCustomPlatformData::supportsFormat):
(WebCore::defaultFontconfigOptions): Deleted.

  • platform/graphics/freetype/FontPlatformDataFreeType.cpp:

(WebCore::setCairoFontOptionsFromFontConfigPattern):
(WebCore::getDefaultFontconfigOptions):
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::harfBuzzFace const):
(WebCore::FontPlatformData::platformIsEqual const):
(WebCore::FontPlatformData::buildScaledFont):
(WebCore::FontPlatformData::fcPattern const): Deleted.
(WebCore::FontPlatformData::createOpenTypeMathHarfBuzzFont const): Deleted.

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::Font::platformCreateScaledFont const):

  • platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:

(WebCore::fontFeatures):
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
(WebCore::floatToHarfBuzzPosition): Deleted.
(WebCore::doubleToHarfBuzzPosition): Deleted.
(WebCore::harfBuzzFontFunctions): Deleted.
(WebCore::findScriptForVerticalGlyphSubstitution): Deleted.

  • platform/graphics/harfbuzz/HarfBuzzFace.cpp: Added.

(WebCore::HarfBuzzFace::CacheEntry::CacheEntry):
(WebCore::HarfBuzzFace::CacheEntry::~CacheEntry):
(WebCore::HarfBuzzFace::cache):
(WebCore::HarfBuzzFace::HarfBuzzFace):
(WebCore::HarfBuzzFace::~HarfBuzzFace):
(WebCore::findScriptForVerticalGlyphSubstitution):
(WebCore::HarfBuzzFace::setScriptForVerticalGlyphSubstitution):

  • platform/graphics/harfbuzz/HarfBuzzFace.h: Added.

(WebCore::HarfBuzzFace::CacheEntry::create):
(WebCore::HarfBuzzFace::CacheEntry::face):
(WebCore::HarfBuzzFace::CacheEntry::glyphCache):

  • platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp: Added.

(WebCore::floatToHarfBuzzPosition):
(WebCore::doubleToHarfBuzzPosition):
(WebCore::CairoGetGlyphWidthAndExtents):
(WebCore::harfBuzzGetGlyph):
(WebCore::harfBuzzGetGlyphHorizontalAdvance):
(WebCore::harfBuzzGetGlyphHorizontalOrigin):
(WebCore::harfBuzzGetGlyphExtents):
(WebCore::harfBuzzCairoTextGetFontFuncs):
(WebCore::harfBuzzCairoGetTable):
(WebCore::HarfBuzzFace::createFace):
(WebCore::HarfBuzzFace::createFont):

  • platform/graphics/harfbuzz/HbUniquePtr.h:

(WebCore::HbPtrDeleter<hb_face_t>::operator() const): Deleted.

  • platform/graphics/opentype/OpenTypeMathData.cpp:

(WebCore::OpenTypeMathData::OpenTypeMathData):

  • platform/graphics/win/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • platform/graphics/win/FontCustomPlatformData.h:
  • platform/graphics/win/FontCustomPlatformDataCairo.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

Tools:

  • gtk/jhbuild.modules:
  • gtk/patches/cairo-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch: Removed.

LayoutTests:

  • platform/gtk/TestExpectations:
  • platform/gtk/mathml/opentype/opentype-stretchy-expected.png:
  • platform/gtk/mathml/opentype/opentype-stretchy-expected.txt:
Location:
trunk
Files:
3 added
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r239100 r239122  
     12018-12-12  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        Unreviewed manual rollout of r239100-r239102 and r239114
     4        https://bugs.webkit.org/show_bug.cgi?id=192151
     5        <rdar://problem/46655586>
     6
     7        * Source/cmake/OptionsGTK.cmake:
     8
    192018-12-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    210
  • trunk/LayoutTests/ChangeLog

    r239101 r239122  
     12018-12-12  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        Unreviewed manual rollout of r239100-r239102 and r239114
     4        https://bugs.webkit.org/show_bug.cgi?id=192151
     5        <rdar://problem/46655586>
     6
     7        * platform/gtk/TestExpectations:
     8        * platform/gtk/mathml/opentype/opentype-stretchy-expected.png:
     9        * platform/gtk/mathml/opentype/opentype-stretchy-expected.txt:
     10
    1112018-12-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    212
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r239100 r239122  
    10471047webkit.org/b/161962 fast/forms/implicit-submission.html [ Failure ]
    10481048
     1049# Font variations build flag is turned off
     1050webkit.org/b/162815 fast/text/variations/ [ Skip ]
     1051webkit.org/b/162815 animations/font-variations/ [ Skip ]
     1052webkit.org/b/162815 legacy-animation-engine/animations/font-variations/ [ Skip ]
     1053
    10491054webkit.org/b/169531 fast/text/font-selection-font-face-parse.html [ Skip ]
    10501055
     
    36383643webkit.org/b/192435 fast/css-custom-paint/leaks.html [ Failure ]
    36393644
    3640 webkit.org/b/162815 fast/text/variations/font-face-clamp.html [ ImageOnlyFailure ]
    3641 webkit.org/b/162815 fast/text/variations/font-selection-properties.html [ ImageOnlyFailure ]
    3642 webkit.org/b/162815 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ]
    3643 
    36443645#////////////////////////////////////////////////////////////////////////////////////////
    36453646# End of non-crashing, non-flaky tests failing
  • trunk/LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.txt

    r239101 r239122  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x350
    4   RenderBlock {HTML} at (0,0) size 800x350
    5     RenderBody {BODY} at (8,16) size 784x318
     3layer at (0,0) size 800x339
     4  RenderBlock {HTML} at (0,0) size 800x339
     5    RenderBody {BODY} at (8,16) size 784x307
    66      RenderBlock {P} at (0,0) size 784x35
    77        RenderMathMLMath {math} at (0,20) size 26x11
     
    3636                  text run at (0,-3) width 2: "\x{219F}"
    3737        RenderText {#text} at (0,0) size 0x0
    38       RenderBlock {P} at (0,221) size 784x97
    39         RenderMathMLMath {math} at (0,0) size 94x93
    40           RenderMathMLRow {mrow} at (0,0) size 94x93
    41             RenderMathMLOperator {mo} at (0,0) size 94x93
     38      RenderBlock {P} at (0,221) size 784x86
     39        RenderMathMLMath {math} at (0,0) size 84x82
     40          RenderMathMLRow {mrow} at (0,0) size 84x82
     41            RenderMathMLOperator {mo} at (0,0) size 84x82
    4242              RenderBlock (anonymous) at (0,0) size 10x12
    4343                RenderText {#text} at (0,6) size 10x0
  • trunk/Source/WebCore/ChangeLog

    r239116 r239122  
     12018-12-12  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        Unreviewed manual rollout of r239100-r239102 and r239114
     4        https://bugs.webkit.org/show_bug.cgi?id=192151
     5        <rdar://problem/46655586>
     6
     7        * css/CSSFontFaceSource.cpp:
     8        (WebCore::CSSFontFaceSource::font):
     9        * loader/cache/CachedFont.cpp:
     10        (WebCore::CachedFont::platformDataFromCustomData):
     11        * platform/FreeType.cmake:
     12        * platform/graphics/FontPlatformData.h:
     13        (WebCore::FontPlatformData::isFixedWidth const): Deleted.
     14        * platform/graphics/cairo/FontCustomPlatformData.h:
     15        * platform/graphics/freetype/FontCacheFreeType.cpp:
     16        (WebCore::FontCache::systemFallbackForCharacters):
     17        (WebCore::FontCache::createFontPlatformData):
     18        (WebCore::getFontPropertiesFromPattern): Deleted.
     19        (WebCore::defaultVariationValues): Deleted.
     20        (WebCore::buildVariationSettings): Deleted.
     21        * platform/graphics/freetype/FontCacheFreeType.h: Removed.
     22        * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
     23        (WebCore::FontCustomPlatformData::FontCustomPlatformData):
     24        (WebCore::FontCustomPlatformData::~FontCustomPlatformData):
     25        (WebCore::FontCustomPlatformData::fontPlatformData):
     26        (WebCore::FontCustomPlatformData::supportsFormat):
     27        (WebCore::defaultFontconfigOptions): Deleted.
     28        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
     29        (WebCore::setCairoFontOptionsFromFontConfigPattern):
     30        (WebCore::getDefaultFontconfigOptions):
     31        (WebCore::FontPlatformData::FontPlatformData):
     32        (WebCore::FontPlatformData::operator=):
     33        (WebCore::FontPlatformData::harfBuzzFace const):
     34        (WebCore::FontPlatformData::platformIsEqual const):
     35        (WebCore::FontPlatformData::buildScaledFont):
     36        (WebCore::FontPlatformData::fcPattern const): Deleted.
     37        (WebCore::FontPlatformData::createOpenTypeMathHarfBuzzFont const): Deleted.
     38        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     39        (WebCore::Font::platformCreateScaledFont const):
     40        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
     41        (WebCore::fontFeatures):
     42        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
     43        (WebCore::floatToHarfBuzzPosition): Deleted.
     44        (WebCore::doubleToHarfBuzzPosition): Deleted.
     45        (WebCore::harfBuzzFontFunctions): Deleted.
     46        (WebCore::findScriptForVerticalGlyphSubstitution): Deleted.
     47        * platform/graphics/harfbuzz/HarfBuzzFace.cpp: Added.
     48        (WebCore::HarfBuzzFace::CacheEntry::CacheEntry):
     49        (WebCore::HarfBuzzFace::CacheEntry::~CacheEntry):
     50        (WebCore::HarfBuzzFace::cache):
     51        (WebCore::HarfBuzzFace::HarfBuzzFace):
     52        (WebCore::HarfBuzzFace::~HarfBuzzFace):
     53        (WebCore::findScriptForVerticalGlyphSubstitution):
     54        (WebCore::HarfBuzzFace::setScriptForVerticalGlyphSubstitution):
     55        * platform/graphics/harfbuzz/HarfBuzzFace.h: Added.
     56        (WebCore::HarfBuzzFace::CacheEntry::create):
     57        (WebCore::HarfBuzzFace::CacheEntry::face):
     58        (WebCore::HarfBuzzFace::CacheEntry::glyphCache):
     59        * platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp: Added.
     60        (WebCore::floatToHarfBuzzPosition):
     61        (WebCore::doubleToHarfBuzzPosition):
     62        (WebCore::CairoGetGlyphWidthAndExtents):
     63        (WebCore::harfBuzzGetGlyph):
     64        (WebCore::harfBuzzGetGlyphHorizontalAdvance):
     65        (WebCore::harfBuzzGetGlyphHorizontalOrigin):
     66        (WebCore::harfBuzzGetGlyphExtents):
     67        (WebCore::harfBuzzCairoTextGetFontFuncs):
     68        (WebCore::harfBuzzCairoGetTable):
     69        (WebCore::HarfBuzzFace::createFace):
     70        (WebCore::HarfBuzzFace::createFont):
     71        * platform/graphics/harfbuzz/HbUniquePtr.h:
     72        (WebCore::HbPtrDeleter<hb_face_t>::operator() const): Deleted.
     73        * platform/graphics/opentype/OpenTypeMathData.cpp:
     74        (WebCore::OpenTypeMathData::OpenTypeMathData):
     75        * platform/graphics/win/FontCustomPlatformData.cpp:
     76        (WebCore::FontCustomPlatformData::fontPlatformData):
     77        * platform/graphics/win/FontCustomPlatformData.h:
     78        * platform/graphics/win/FontCustomPlatformDataCairo.cpp:
     79        (WebCore::FontCustomPlatformData::fontPlatformData):
     80
    1812018-12-12  Chris Dumez  <cdumez@apple.com>
    282
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r239100 r239122  
    233233    if (!m_inDocumentCustomPlatformData)
    234234        return nullptr;
     235#if PLATFORM(COCOA)
    235236    return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), Font::Origin::Remote);
     237#else
     238    return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), Font::Origin::Remote);
     239#endif
    236240#endif
    237241
  • trunk/Source/WebCore/loader/cache/CachedFont.cpp

    r239100 r239122  
    142142FontPlatformData CachedFont::platformDataFromCustomData(FontCustomPlatformData& fontCustomPlatformData, const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
    143143{
     144#if PLATFORM(COCOA)
    144145    return fontCustomPlatformData.fontPlatformData(fontDescription, bold, italic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities);
     146#else
     147    UNUSED_PARAM(fontFaceFeatures);
     148    UNUSED_PARAM(fontFaceVariantSettings);
     149    UNUSED_PARAM(fontFaceCapabilities);
     150    return fontCustomPlatformData.fontPlatformData(fontDescription, bold, italic);
     151#endif
    145152}
    146153
  • trunk/Source/WebCore/platform/FreeType.cmake

    r239101 r239122  
    1212
    1313    platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
     14    platform/graphics/harfbuzz/HarfBuzzFace.cpp
    1415)
    1516
     
    2728    list(APPEND WebCore_SOURCES
    2829        platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
     30
     31        platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
    2932    )
    3033endif ()
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r239101 r239122  
    4141#if USE(FREETYPE)
    4242#include "FcUniquePtr.h"
    43 #include "HbUniquePtr.h"
     43#include "HarfBuzzFace.h"
    4444#include "RefPtrFontconfig.h"
    4545#include <memory>
     
    113113
    114114#if USE(FREETYPE)
    115     FontPlatformData(cairo_font_face_t*, FcPattern*, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation);
     115    FontPlatformData(FcPattern*, const FontDescription&);
     116    FontPlatformData(cairo_font_face_t*, const FontDescription&, bool syntheticBold, bool syntheticOblique);
    116117    FontPlatformData(const FontPlatformData&);
    117118    FontPlatformData(FontPlatformData&&) = default;
     
    169170
    170171#if USE(FREETYPE)
    171     HbUniquePtr<hb_font_t> createOpenTypeMathHarfBuzzFont() const;
     172    HarfBuzzFace& harfBuzzFace() const;
    172173    bool hasCompatibleCharmap() const;
    173     FcPattern* fcPattern() const;
    174     bool isFixedWidth() const { return m_fixedWidth; }
    175174#endif
    176175
     
    250249#if USE(FREETYPE)
    251250    RefPtr<FcPattern> m_pattern;
     251    mutable std::unique_ptr<HarfBuzzFace> m_harfBuzzFace;
    252252#endif
    253253
  • trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h

    r239100 r239122  
    2020 */
    2121
    22 #pragma once
     22#ifndef FontCustomPlatformData_h
     23#define FontCustomPlatformData_h
    2324
    2425#if USE(CAIRO)
    2526
    26 #include "RefPtrCairo.h"
    2727#include <wtf/Forward.h>
    2828#include <wtf/Noncopyable.h>
    2929
    3030typedef struct FT_FaceRec_*  FT_Face;
     31typedef struct _cairo_font_face cairo_font_face_t;
    3132
    3233namespace WebCore {
     
    3536class FontPlatformData;
    3637class SharedBuffer;
    37 struct FontSelectionSpecifiedCapabilities;
    38 struct FontVariantSettings;
    39 
    40 template <typename T> class FontTaggedSettings;
    41 typedef FontTaggedSettings<int> FontFeatureSettings;
    4238
    4339struct FontCustomPlatformData {
     
    4541public:
    4642    FontCustomPlatformData(FT_Face, SharedBuffer&);
    47     ~FontCustomPlatformData() = default;
    48     FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&, FontSelectionSpecifiedCapabilities);
     43    ~FontCustomPlatformData();
     44    FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic);
    4945    static bool supportsFormat(const String&);
    5046
    5147private:
    52     RefPtr<cairo_font_face_t> m_fontFace;
     48    cairo_font_face_t* m_fontFace;
    5349};
    5450
     
    5854
    5955#endif // USE(CAIRO)
     56
     57#endif // FontCustomPlatformData_h
  • trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp

    r239100 r239122  
    2323#include "FontCache.h"
    2424
    25 #include "CairoUniquePtr.h"
    2625#include "CairoUtilities.h"
    2726#include "FcUniquePtr.h"
    28 #include "FloatConversion.h"
    2927#include "Font.h"
    30 #include "FontDescription.h"
    31 #include "FontCacheFreeType.h"
    3228#include "RefPtrCairo.h"
    3329#include "RefPtrFontconfig.h"
     
    4137#if PLATFORM(GTK)
    4238#include "GtkUtilities.h"
    43 #endif
    44 
    45 #if ENABLE(VARIATION_FONTS)
    46 #include FT_MULTIPLE_MASTERS_H
    4739#endif
    4840
     
    8880}
    8981
    90 static void getFontPropertiesFromPattern(FcPattern* pattern, const FontDescription& fontDescription, bool& fixedWidth, bool& syntheticBold, bool& syntheticOblique)
    91 {
    92     fixedWidth = false;
    93     int spacing;
    94     if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) == FcResultMatch && spacing == FC_MONO)
    95         fixedWidth = true;
    96 
    97     syntheticBold = false;
    98     bool descriptionAllowsSyntheticBold = fontDescription.fontSynthesis() & FontSynthesisWeight;
    99     if (descriptionAllowsSyntheticBold && isFontWeightBold(fontDescription.weight())) {
    100         // The FC_EMBOLDEN property instructs us to fake the boldness of the font.
    101         FcBool fontConfigEmbolden = FcFalse;
    102         if (FcPatternGetBool(pattern, FC_EMBOLDEN, 0, &fontConfigEmbolden) == FcResultMatch)
    103             syntheticBold = fontConfigEmbolden;
    104 
    105         // Fallback fonts may not have FC_EMBOLDEN activated even though it's necessary.
    106         int weight = 0;
    107         if (!syntheticBold && FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) == FcResultMatch)
    108             syntheticBold = syntheticBold || weight < FC_WEIGHT_DEMIBOLD;
    109     }
    110 
    111     // We requested an italic font, but Fontconfig gave us one that was neither oblique nor italic.
    112     syntheticOblique = false;
    113     int actualFontSlant;
    114     bool descriptionAllowsSyntheticOblique = fontDescription.fontSynthesis() & FontSynthesisStyle;
    115     if (descriptionAllowsSyntheticOblique && fontDescription.italic()
    116         && FcPatternGetInteger(pattern, FC_SLANT, 0, &actualFontSlant) == FcResultMatch) {
    117         syntheticOblique = actualFontSlant == FC_SLANT_ROMAN;
    118     }
    119 }
    120 
    12182RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font*, bool, const UChar* characters, unsigned length)
    12283{
     
    146107        return nullptr;
    147108
    148     bool fixedWidth, syntheticBold, syntheticOblique;
    149     getFontPropertiesFromPattern(resultPattern.get(), description, fixedWidth, syntheticBold, syntheticOblique);
    150 
    151     RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(resultPattern.get()));
    152     FontPlatformData alternateFontData(fontFace.get(), resultPattern.get(), description.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, description.orientation());
     109    FontPlatformData alternateFontData(resultPattern.get(), description);
    153110    return fontForPlatformData(alternateFontData);
    154111}
     
    376333    // Never choose unscalable fonts, as they pixelate when displayed at different sizes.
    377334    FcPatternAddBool(pattern.get(), FC_SCALABLE, FcTrue);
    378 #if ENABLE(VARIATION_FONTS)
    379     FcPatternAddBool(pattern.get(), FC_VARIABLE, FcDontCare);
    380 #endif
    381335    String familyNameString(getFamilyNameStringFromFamily(family));
    382336    if (!FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(familyNameString.utf8().data())))
     
    429383        return nullptr;
    430384
    431     bool fixedWidth, syntheticBold, syntheticOblique;
    432     getFontPropertiesFromPattern(pattern.get(), fontDescription, fixedWidth, syntheticBold, syntheticOblique);
    433 
    434     RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(resultPattern.get()));
    435 #if ENABLE(VARIATION_FONTS)
    436     // Cairo doesn't have API to get the FT_Face of an unscaled font, so we need to
    437     // create a temporary scaled font to get the FT_Face.
    438     CairoUniquePtr<cairo_font_options_t> options(cairo_font_options_copy(getDefaultCairoFontOptions()));
    439     cairo_matrix_t matrix;
    440     cairo_matrix_init_identity(&matrix);
    441     RefPtr<cairo_scaled_font_t> scaledFont = adoptRef(cairo_scaled_font_create(fontFace.get(), &matrix, &matrix, options.get()));
    442     CairoFtFaceLocker cairoFtFaceLocker(scaledFont.get());
    443     if (FT_Face freeTypeFace = cairoFtFaceLocker.ftFace()) {
    444         auto variants = buildVariationSettings(freeTypeFace, fontDescription);
    445         if (!variants.isEmpty())
    446             FcPatternAddString(resultPattern.get(), FC_FONT_VARIATIONS, reinterpret_cast<const FcChar8*>(variants.utf8().data()));
    447     }
    448 #endif
    449     auto platformData = std::make_unique<FontPlatformData>(fontFace.get(), resultPattern.get(), fontDescription.computedPixelSize(), fixedWidth, syntheticBold, syntheticOblique, fontDescription.orientation());
    450385    // Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
    451386    // supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
    452387    // If this font doesn't have one of these three encodings, don't select it.
     388    auto platformData = std::make_unique<FontPlatformData>(resultPattern.get(), fontDescription);
    453389    if (!platformData->hasCompatibleCharmap())
    454390        return nullptr;
     
    462398}
    463399
    464 #if ENABLE(VARIATION_FONTS)
    465 struct VariationDefaults {
    466     float defaultValue;
    467     float minimumValue;
    468     float maximumValue;
    469 };
    470 
    471 typedef HashMap<FontTag, VariationDefaults, FourCharacterTagHash, FourCharacterTagHashTraits> VariationDefaultsMap;
    472 typedef HashMap<FontTag, float, FourCharacterTagHash, FourCharacterTagHashTraits> VariationsMap;
    473 
    474 static VariationDefaultsMap defaultVariationValues(FT_Face face)
    475 {
    476     VariationDefaultsMap result;
    477     FT_MM_Var* ftMMVar;
    478     if (FT_Get_MM_Var(face, &ftMMVar))
    479         return result;
    480 
    481     for (unsigned i = 0; i < ftMMVar->num_axis; ++i) {
    482         auto tag = ftMMVar->axis[i].tag;
    483         auto b1 = 0xFF & (tag >> 24);
    484         auto b2 = 0xFF & (tag >> 16);
    485         auto b3 = 0xFF & (tag >> 8);
    486         auto b4 = 0xFF & (tag >> 0);
    487         FontTag resultKey = {{ static_cast<char>(b1), static_cast<char>(b2), static_cast<char>(b3), static_cast<char>(b4) }};
    488         VariationDefaults resultValues = { narrowPrecisionToFloat(ftMMVar->axis[i].def / 65536.), narrowPrecisionToFloat(ftMMVar->axis[i].minimum / 65536.), narrowPrecisionToFloat(ftMMVar->axis[i].maximum / 65536.) };
    489         result.set(resultKey, resultValues);
    490     }
    491     FT_Done_MM_Var(face->glyph->library, ftMMVar);
    492     return result;
    493 }
    494 
    495 String buildVariationSettings(FT_Face face, const FontDescription& fontDescription)
    496 {
    497     auto defaultValues = defaultVariationValues(face);
    498     const auto& variations = fontDescription.variationSettings();
    499 
    500     VariationsMap variationsToBeApplied;
    501     auto applyVariation = [&](const FontTag& tag, float value) {
    502         auto iterator = defaultValues.find(tag);
    503         if (iterator == defaultValues.end())
    504             return;
    505         float valueToApply = clampTo(value, iterator->value.minimumValue, iterator->value.maximumValue);
    506         variationsToBeApplied.set(tag, valueToApply);
    507     };
    508 
    509     for (auto& variation : variations)
    510         applyVariation(variation.tag(), variation.value());
    511 
    512     StringBuilder builder;
    513     for (auto& variation : variationsToBeApplied) {
    514         if (!builder.isEmpty())
    515             builder.append(',');
    516         builder.append(variation.key[0]);
    517         builder.append(variation.key[1]);
    518         builder.append(variation.key[2]);
    519         builder.append(variation.key[3]);
    520         builder.append('=');
    521         builder.appendNumber(variation.value);
    522     }
    523     return builder.toString();
    524 }
    525 #endif // ENABLE(VARIATION_FONTS)
    526 
    527 }
     400}
  • trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp

    r239101 r239122  
    2323#include "FontCustomPlatformData.h"
    2424
    25 #include "CairoUtilities.h"
    26 #include "FontCacheFreeType.h"
    27 #include "FontDescription.h"
    2825#include "FontPlatformData.h"
    2926#include "SharedBuffer.h"
     
    3229#include <ft2build.h>
    3330#include FT_MODULE_H
    34 #include <mutex>
    3531
    3632namespace WebCore {
     
    4137}
    4238
    43 static cairo_user_data_key_t freeTypeFaceKey;
    44 
    4539FontCustomPlatformData::FontCustomPlatformData(FT_Face freeTypeFace, SharedBuffer& buffer)
    46     : m_fontFace(adoptRef(cairo_ft_font_face_create_for_ft_face(freeTypeFace, FT_LOAD_DEFAULT)))
     40    : m_fontFace(cairo_ft_font_face_create_for_ft_face(freeTypeFace, FT_LOAD_DEFAULT))
    4741{
    4842    buffer.ref(); // This is balanced by the buffer->deref() in releaseCustomFontData.
    4943    static cairo_user_data_key_t bufferKey;
    50     cairo_font_face_set_user_data(m_fontFace.get(), &bufferKey, &buffer,
     44    cairo_font_face_set_user_data(m_fontFace, &bufferKey, &buffer,
    5145         static_cast<cairo_destroy_func_t>(releaseCustomFontData));
    5246
    5347    // Cairo doesn't do FreeType reference counting, so we need to ensure that when
    5448    // this cairo_font_face_t is destroyed, it cleans up the FreeType face as well.
    55     cairo_font_face_set_user_data(m_fontFace.get(), &freeTypeFaceKey, freeTypeFace,
     49    static cairo_user_data_key_t freeTypeFaceKey;
     50    cairo_font_face_set_user_data(m_fontFace, &freeTypeFaceKey, freeTypeFace,
    5651        reinterpret_cast<cairo_destroy_func_t>(reinterpret_cast<void(*)(void)>(FT_Done_Face)));
    5752}
    5853
    59 static FcPattern* defaultFontconfigOptions()
     54FontCustomPlatformData::~FontCustomPlatformData()
    6055{
    61     // Get some generic default settings from fontconfig for web fonts. Strategy
    62     // from Behdad Esfahbod in https://code.google.com/p/chromium/issues/detail?id=173207#c35
    63     // For web fonts, the hint style is overridden in FontCustomPlatformData::FontCustomPlatformData
    64     // so Fontconfig will not affect the hint style, but it may disable hinting completely.
    65     static FcPattern* pattern = nullptr;
    66     static std::once_flag flag;
    67     std::call_once(flag, [](FcPattern*) {
    68         pattern = FcPatternCreate();
    69         FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
    70         cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern);
    71         FcDefaultSubstitute(pattern);
    72         FcPatternDel(pattern, FC_FAMILY);
    73         FcConfigSubstitute(nullptr, pattern, FcMatchFont);
    74     }, pattern);
    75     return pattern;
     56    cairo_font_face_destroy(m_fontFace);
    7657}
    7758
    78 FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&, FontSelectionSpecifiedCapabilities)
     59FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic)
    7960{
    80     auto* freeTypeFace = static_cast<FT_Face>(cairo_font_face_get_user_data(m_fontFace.get(), &freeTypeFaceKey));
    81     ASSERT(freeTypeFace);
    82     RefPtr<FcPattern> pattern = defaultFontconfigOptions();
    83 #if ENABLE(VARIATION_FONTS)
    84     auto variants = buildVariationSettings(freeTypeFace, description);
    85     if (!variants.isEmpty()) {
    86         pattern = adoptRef(FcPatternDuplicate(pattern.get()));
    87         FcPatternAddString(pattern.get(), FC_FONT_VARIATIONS, reinterpret_cast<const FcChar8*>(variants.utf8().data()));
    88     }
    89 #endif
    90     return FontPlatformData(m_fontFace.get(), pattern.get(), description.computedPixelSize(), freeTypeFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH, bold, italic, description.orientation());
     61    return FontPlatformData(m_fontFace, description, bold, italic);
    9162}
    9263
     
    140111#if USE(WOFF2)
    141112        || equalLettersIgnoringASCIICase(format, "woff2")
    142 #if ENABLE(VARIATION_FONTS)
    143         || equalLettersIgnoringASCIICase(format, "woff2-variations")
    144 #endif
    145 #endif
    146 #if ENABLE(VARIATION_FONTS)
    147         || equalLettersIgnoringASCIICase(format, "woff-variations")
    148         || equalLettersIgnoringASCIICase(format, "truetype-variations")
    149         || equalLettersIgnoringASCIICase(format, "opentype-variations")
    150113#endif
    151114        || equalLettersIgnoringASCIICase(format, "woff");
  • trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp

    r239101 r239122  
    2929#include "CairoUtilities.h"
    3030#include "FontCache.h"
     31#include "FontDescription.h"
    3132#include "SharedBuffer.h"
    3233#include <cairo-ft.h>
     
    3435#include <ft2build.h>
    3536#include FT_TRUETYPE_TABLES_H
    36 #include <hb-ft.h>
    37 #include <hb-ot.h>
    3837#include <wtf/MathExtras.h>
    3938#include <wtf/text/WTFString.h>
     
    102101    if (FcPatternGetBool(pattern, FC_HINTING, 0, &booleanResult) == FcResultMatch && !booleanResult)
    103102        cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
    104 
    105 #if ENABLE(VARIATION_FONTS)
    106     FcChar8* variations;
    107     if (FcPatternGetString(pattern, FC_FONT_VARIATIONS, 0, &variations) == FcResultMatch) {
    108         cairo_font_options_set_variations(options, reinterpret_cast<char*>(variations));
    109     }
    110 #endif
    111 }
    112 
    113 FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, FcPattern* pattern, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation orientation)
    114     : FontPlatformData(size, syntheticBold, syntheticOblique, orientation)
    115 {
    116     m_pattern = pattern;
    117     m_fixedWidth = fixedWidth;
    118 
     103}
     104
     105static FcPattern* getDefaultFontconfigOptions()
     106{
     107    // Get some generic default settings from fontconfig for web fonts. Strategy
     108    // from Behdad Esfahbod in https://code.google.com/p/chromium/issues/detail?id=173207#c35
     109    // For web fonts, the hint style is overridden in FontCustomPlatformData::FontCustomPlatformData
     110    // so Fontconfig will not affect the hint style, but it may disable hinting completely.
     111    static FcPattern* pattern = nullptr;
     112    static std::once_flag flag;
     113    std::call_once(flag, [](FcPattern*) {
     114        pattern = FcPatternCreate();
     115        FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
     116        cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern);
     117        FcDefaultSubstitute(pattern);
     118        FcPatternDel(pattern, FC_FAMILY);
     119        FcConfigSubstitute(nullptr, pattern, FcMatchFont);
     120    }, pattern);
     121    return pattern;
     122}
     123
     124FontPlatformData::FontPlatformData(FcPattern* pattern, const FontDescription& fontDescription)
     125    : m_pattern(pattern)
     126    , m_size(fontDescription.computedPixelSize())
     127    , m_orientation(fontDescription.orientation())
     128{
     129    ASSERT(m_pattern);
     130    RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));
     131
     132    int spacing;
     133    if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) == FcResultMatch && spacing == FC_MONO)
     134        m_fixedWidth = true;
     135
     136    bool descriptionAllowsSyntheticBold = fontDescription.fontSynthesis() & FontSynthesisWeight;
     137    if (descriptionAllowsSyntheticBold && isFontWeightBold(fontDescription.weight())) {
     138        // The FC_EMBOLDEN property instructs us to fake the boldness of the font.
     139        FcBool fontConfigEmbolden = FcFalse;
     140        if (FcPatternGetBool(pattern, FC_EMBOLDEN, 0, &fontConfigEmbolden) == FcResultMatch)
     141            m_syntheticBold = fontConfigEmbolden;
     142
     143        // Fallback fonts may not have FC_EMBOLDEN activated even though it's necessary.
     144        int weight = 0;
     145        if (!m_syntheticBold && FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) == FcResultMatch)
     146            m_syntheticBold = m_syntheticBold || weight < FC_WEIGHT_DEMIBOLD;
     147    }
     148
     149    // We requested an italic font, but Fontconfig gave us one that was neither oblique nor italic.
     150    int actualFontSlant;
     151    bool descriptionAllowsSyntheticOblique = fontDescription.fontSynthesis() & FontSynthesisStyle;
     152    if (descriptionAllowsSyntheticOblique && fontDescription.italic()
     153        && FcPatternGetInteger(pattern, FC_SLANT, 0, &actualFontSlant) == FcResultMatch) {
     154        m_syntheticOblique = actualFontSlant == FC_SLANT_ROMAN;
     155    }
     156
     157    buildScaledFont(fontFace.get());
     158}
     159
     160FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, const FontDescription& description, bool bold, bool italic)
     161    : m_size(description.computedPixelSize())
     162    , m_orientation(description.orientation())
     163    , m_syntheticBold(bold)
     164    , m_syntheticOblique(italic)
     165{
    119166    buildScaledFont(fontFace);
     167
     168    CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get());
     169    if (FT_Face fontConfigFace = cairoFtFaceLocker.ftFace())
     170        m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH;
    120171}
    121172
     
    146197
    147198    m_scaledFont = other.m_scaledFont;
     199
     200    // This will be re-created on demand.
     201    m_harfBuzzFace = nullptr;
    148202
    149203    return *this;
     
    184238}
    185239
    186 FcPattern* FontPlatformData::fcPattern() const
    187 {
    188     return m_pattern.get();
     240HarfBuzzFace& FontPlatformData::harfBuzzFace() const
     241{
     242    if (!m_harfBuzzFace)
     243        m_harfBuzzFace = std::make_unique<HarfBuzzFace>(const_cast<FontPlatformData&>(*this), hash());
     244    return *m_harfBuzzFace;
    189245}
    190246
     
    201257bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
    202258{
    203     if (m_pattern != other.m_pattern && !FcPatternEqual(m_pattern.get(), other.m_pattern.get()))
     259    // FcPatternEqual does not support null pointers as arguments.
     260    if ((m_pattern && !other.m_pattern)
     261        || (!m_pattern && other.m_pattern)
     262        || (m_pattern != other.m_pattern && !FcPatternEqual(m_pattern.get(), other.m_pattern.get())))
    204263        return false;
    205264
     
    216275void FontPlatformData::buildScaledFont(cairo_font_face_t* fontFace)
    217276{
    218     ASSERT(m_pattern);
    219277    CairoUniquePtr<cairo_font_options_t> options(cairo_font_options_copy(getDefaultCairoFontOptions()));
    220     setCairoFontOptionsFromFontConfigPattern(options.get(), m_pattern.get());
     278    FcPattern* optionsPattern = m_pattern ? m_pattern.get() : getDefaultFontconfigOptions();
     279    setCairoFontOptionsFromFontConfigPattern(options.get(), optionsPattern);
    221280
    222281    cairo_matrix_t ctm;
     
    230289
    231290    // These matrices may be stacked in the pattern, so it's our job to get them all and multiply them.
    232     for (int i = 0; FcPatternGetMatrix(m_pattern.get(), FC_MATRIX, i, &tempFontConfigMatrix) == FcResultMatch; i++)
     291    for (int i = 0; FcPatternGetMatrix(optionsPattern, FC_MATRIX, i, &tempFontConfigMatrix) == FcResultMatch; i++)
    233292        FcMatrixMultiply(&fontConfigMatrix, &fontConfigMatrix, tempFontConfigMatrix);
    234293
     
    294353}
    295354
    296 HbUniquePtr<hb_font_t> FontPlatformData::createOpenTypeMathHarfBuzzFont() const
    297 {
    298     CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get());
    299     FT_Face ftFace = cairoFtFaceLocker.ftFace();
    300     if (!ftFace)
    301         return nullptr;
    302 
    303     HbUniquePtr<hb_face_t> face(hb_ft_face_create_cached(ftFace));
    304     if (!hb_ot_math_has_data(face.get()))
    305         return nullptr;
    306 
    307     return HbUniquePtr<hb_font_t>(hb_font_create(face.get()));
    308 }
    309 
    310355} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r239100 r239122  
    144144{
    145145    ASSERT(m_platformData.scaledFont());
     146    FontDescription scaledFontDescription = fontDescription;
     147    scaledFontDescription.setComputedSize(scaleFactor * fontDescription.computedSize());
    146148    return Font::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
    147         m_platformData.fcPattern(),
    148         scaleFactor * fontDescription.computedSize(),
    149         m_platformData.isFixedWidth(),
     149        scaledFontDescription,
    150150        m_platformData.syntheticBold(),
    151         m_platformData.syntheticOblique(),
    152         fontDescription.orientation()),
     151        m_platformData.syntheticOblique()),
    153152        origin(), Interstitial::No);
    154153}
  • trunk/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp

    r239102 r239122  
    2727#include "ComplexTextController.h"
    2828
    29 #include "CairoUtilities.h"
    3029#include "FontCascade.h"
    3130#include "HbUniquePtr.h"
    3231#include "SurrogatePairAwareTextIterator.h"
    33 #include <hb-ft.h>
    3432#include <hb-icu.h>
    35 #include <hb-ot.h>
    36 
    37 #if ENABLE(VARIATION_FONTS)
    38 #include FT_MULTIPLE_MASTERS_H
    39 #endif
    4033
    4134namespace WebCore {
     
    4437{
    4538    return static_cast<float>(value) / (1 << 16);
    46 }
    47 
    48 static inline hb_position_t floatToHarfBuzzPosition(float value)
    49 {
    50     return static_cast<hb_position_t>(value * (1 << 16));
    51 }
    52 
    53 static inline hb_position_t doubleToHarfBuzzPosition(double value)
    54 {
    55     return static_cast<hb_position_t>(value * (1 << 16));
    56 }
    57 
    58 static hb_font_funcs_t* harfBuzzFontFunctions()
    59 {
    60     static hb_font_funcs_t* fontFunctions = nullptr;
    61 
    62     // We don't set callback functions which we can't support.
    63     // Harfbuzz will use the fallback implementation if they aren't set.
    64     if (!fontFunctions) {
    65         fontFunctions = hb_font_funcs_create();
    66 #if HB_VERSION_ATLEAST(1, 2, 3)
    67         hb_font_funcs_set_nominal_glyph_func(fontFunctions, [](hb_font_t*, void* context, hb_codepoint_t unicode, hb_codepoint_t* glyph, void*) -> hb_bool_t {
    68             auto& font = *static_cast<Font*>(context);
    69             *glyph = font.glyphForCharacter(unicode);
    70             return !!*glyph;
    71         }, nullptr, nullptr);
    72 
    73         hb_font_funcs_set_variation_glyph_func(fontFunctions, [](hb_font_t*, void* context, hb_codepoint_t unicode, hb_codepoint_t variation, hb_codepoint_t* glyph, void*) -> hb_bool_t {
    74             auto& font = *static_cast<Font*>(context);
    75             auto* scaledFont = font.platformData().scaledFont();
    76             ASSERT(scaledFont);
    77 
    78             CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
    79             if (FT_Face ftFace = cairoFtFaceLocker.ftFace()) {
    80                 *glyph = FT_Face_GetCharVariantIndex(ftFace, unicode, variation);
    81                 return true;
    82             }
    83             return false;
    84             }, nullptr, nullptr);
    85 #else
    86         hb_font_funcs_set_glyph_func(fontFunctions, [](hb_font_t*, void* context, hb_codepoint_t unicode, hb_codepoint_t, hb_codepoint_t* glyph, void*) -> hb_bool_t {
    87             auto& font = *static_cast<Font*>(context);
    88             *glyph = font.glyphForCharacter(unicode);
    89             return !!*glyph;
    90         }, nullptr, nullptr);
    91 #endif
    92         hb_font_funcs_set_glyph_h_advance_func(fontFunctions, [](hb_font_t*, void* context, hb_codepoint_t point, void*) -> hb_bool_t {
    93             auto& font = *static_cast<Font*>(context);
    94             auto* scaledFont = font.platformData().scaledFont();
    95             ASSERT(scaledFont);
    96 
    97             cairo_text_extents_t glyphExtents;
    98             cairo_glyph_t glyph = { point, 0, 0 };
    99             cairo_scaled_font_glyph_extents(scaledFont, &glyph, 1, &glyphExtents);
    100 
    101             bool hasVerticalGlyphs = glyphExtents.y_advance;
    102             return doubleToHarfBuzzPosition(hasVerticalGlyphs ? -glyphExtents.y_advance : glyphExtents.x_advance);
    103         }, nullptr, nullptr);
    104 
    105         hb_font_funcs_set_glyph_h_origin_func(fontFunctions, [](hb_font_t*, void*, hb_codepoint_t, hb_position_t*, hb_position_t*, void*) -> hb_bool_t {
    106             // Just return true, following the way that Harfbuzz-FreeType implementation does.
    107             return true;
    108         }, nullptr, nullptr);
    109 
    110         hb_font_funcs_set_glyph_extents_func(fontFunctions, [](hb_font_t*, void* context, hb_codepoint_t point, hb_glyph_extents_t* extents, void*) -> hb_bool_t {
    111             auto& font = *static_cast<Font*>(context);
    112             auto* scaledFont = font.platformData().scaledFont();
    113             ASSERT(scaledFont);
    114 
    115             cairo_text_extents_t glyphExtents;
    116             cairo_glyph_t glyph = { point, 0, 0 };
    117             cairo_scaled_font_glyph_extents(scaledFont, &glyph, 1, &glyphExtents);
    118 
    119             bool hasVerticalGlyphs = glyphExtents.y_advance;
    120             extents->x_bearing = doubleToHarfBuzzPosition(glyphExtents.x_bearing);
    121             extents->y_bearing = doubleToHarfBuzzPosition(hasVerticalGlyphs ? -glyphExtents.y_bearing : glyphExtents.y_bearing);
    122             extents->width = doubleToHarfBuzzPosition(hasVerticalGlyphs ? -glyphExtents.height : glyphExtents.width);
    123             extents->height = doubleToHarfBuzzPosition(hasVerticalGlyphs ? glyphExtents.width : glyphExtents.height);
    124             return true;
    125         }, nullptr, nullptr);
    126 
    127         hb_font_funcs_make_immutable(fontFunctions);
    128     }
    129     return fontFunctions;
    13039}
    13140
     
    17584}
    17685
    177 static const hb_tag_t s_vertTag = HB_TAG('v', 'e', 'r', 't');
    178 static const hb_tag_t s_vrt2Tag = HB_TAG('v', 'r', 't', '2');
    179 static const hb_tag_t s_kernTag = HB_TAG('k', 'e', 'r', 'n');
    180 static const unsigned s_hbEnd = static_cast<unsigned>(-1);
     86static const unsigned hbEnd = static_cast<unsigned>(-1);
    18187
    18288static Vector<hb_feature_t, 4> fontFeatures(const FontCascade& font, FontOrientation orientation)
     
    18591
    18692    if (orientation == FontOrientation::Vertical) {
    187         features.append({ s_vertTag, 1, 0, s_hbEnd });
    188         features.append({ s_vrt2Tag, 1, 0, s_hbEnd });
    189     }
    190 
    191     hb_feature_t kerning = { s_kernTag, 0, 0, s_hbEnd };
     93        features.append({ HarfBuzzFace::vertTag, 1, 0, hbEnd });
     94        features.append({ HarfBuzzFace::vrt2Tag, 1, 0, hbEnd });
     95    }
     96
     97    hb_feature_t kerning = { HarfBuzzFace::kernTag, 0, 0, hbEnd };
    19298    if (font.enableKerning())
    19399        kerning.value = 1;
     
    196102    for (auto& feature : font.fontDescription().featureSettings()) {
    197103        auto& tag = feature.tag();
    198         features.append({ HB_TAG(tag[0], tag[1], tag[2], tag[3]), static_cast<uint32_t>(feature.value()), 0, s_hbEnd });
     104        features.append({ HB_TAG(tag[0], tag[1], tag[2], tag[3]), static_cast<uint32_t>(feature.value()), 0, hbEnd });
    199105    }
    200106
     
    263169}
    264170
    265 static hb_script_t findScriptForVerticalGlyphSubstitution(hb_face_t* face)
    266 {
    267     static const unsigned maxCount = 32;
    268 
    269     unsigned scriptCount = maxCount;
    270     hb_tag_t scriptTags[maxCount];
    271     hb_ot_layout_table_get_script_tags(face, HB_OT_TAG_GSUB, 0, &scriptCount, scriptTags);
    272     for (unsigned scriptIndex = 0; scriptIndex < scriptCount; ++scriptIndex) {
    273         unsigned languageCount = maxCount;
    274         hb_tag_t languageTags[maxCount];
    275         hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, scriptIndex, 0, &languageCount, languageTags);
    276         for (unsigned languageIndex = 0; languageIndex < languageCount; ++languageIndex) {
    277             unsigned featureIndex;
    278             if (hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, s_vertTag, &featureIndex)
    279                 || hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, s_vrt2Tag, &featureIndex))
    280                 return hb_ot_tag_to_script(scriptTags[scriptIndex]);
    281         }
    282     }
    283     return HB_SCRIPT_INVALID;
    284 }
    285 
    286171void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* characters, unsigned length, unsigned stringLocation, const Font* font)
    287172{
     
    307192
    308193    const auto& fontPlatformData = font->platformData();
    309     auto* scaledFont = fontPlatformData.scaledFont();
    310     CairoFtFaceLocker cairoFtFaceLocker(scaledFont);
    311     FT_Face ftFace = cairoFtFaceLocker.ftFace();
    312     if (!ftFace)
    313         return;
    314 
    315     HbUniquePtr<hb_face_t> face(hb_ft_face_create_cached(ftFace));
    316     HbUniquePtr<hb_font_t> harfBuzzFont(hb_font_create(face.get()));
    317     hb_font_set_funcs(harfBuzzFont.get(), harfBuzzFontFunctions(), const_cast<Font*>(font), nullptr);
    318     const float size = fontPlatformData.size();
    319     if (floorf(size) == size)
    320         hb_font_set_ppem(harfBuzzFont.get(), size, size);
    321     int scale = floatToHarfBuzzPosition(size);
    322     hb_font_set_scale(harfBuzzFont.get(), scale, scale);
    323 
    324 #if ENABLE(VARIATION_FONTS)
    325     FT_MM_Var* ftMMVar;
    326     if (!FT_Get_MM_Var(ftFace, &ftMMVar)) {
    327         Vector<FT_Fixed, 4> coords;
    328         coords.resize(ftMMVar->num_axis);
    329         if (!FT_Get_Var_Design_Coordinates(ftFace, coords.size(), coords.data())) {
    330             Vector<hb_variation_t, 4> variations(coords.size());
    331             for (FT_UInt i = 0; i < ftMMVar->num_axis; ++i) {
    332                 variations[i].tag = ftMMVar->axis[i].tag;
    333                 variations[i].value = coords[i] / 65536.0;
    334             }
    335             hb_font_set_variations(harfBuzzFont.get(), variations.data(), variations.size());
    336         }
    337         FT_Done_MM_Var(ftFace->glyph->library, ftMMVar);
    338     }
    339 #endif
    340 
    341     hb_font_make_immutable(harfBuzzFont.get());
    342 
    343194    auto features = fontFeatures(m_font, fontPlatformData.orientation());
    344195    HbUniquePtr<hb_buffer_t> buffer(hb_buffer_create());
    345     if (fontPlatformData.orientation() == FontOrientation::Vertical)
    346         hb_buffer_set_script(buffer.get(), findScriptForVerticalGlyphSubstitution(face.get()));
    347196
    348197    for (unsigned i = 0; i < runCount; ++i) {
    349198        auto& run = runList[m_run.rtl() ? runCount - i - 1 : i];
    350199
    351         if (fontPlatformData.orientation() != FontOrientation::Vertical)
    352             hb_buffer_set_script(buffer.get(), hb_icu_script_to_script(run.script));
     200        hb_buffer_set_script(buffer.get(), hb_icu_script_to_script(run.script));
    353201        if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride())
    354202            hb_buffer_set_direction(buffer.get(), m_run.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
     
    359207        hb_buffer_add_utf16(buffer.get(), reinterpret_cast<const uint16_t*>(characters), length, run.startIndex, run.endIndex - run.startIndex);
    360208
     209        auto& face = fontPlatformData.harfBuzzFace();
     210        if (fontPlatformData.orientation() == FontOrientation::Vertical)
     211            face.setScriptForVerticalGlyphSubstitution(buffer.get());
     212
     213        HbUniquePtr<hb_font_t> harfBuzzFont(face.createFont());
    361214        hb_shape(harfBuzzFont.get(), buffer.get(), features.isEmpty() ? nullptr : features.data(), features.size());
    362215        m_complexTextRuns.append(ComplexTextRun::create(buffer.get(), *font, characters, stringLocation, length, run.startIndex, run.endIndex));
  • trunk/Source/WebCore/platform/graphics/harfbuzz/HbUniquePtr.h

    r239101 r239122  
    5353};
    5454
    55 template<> struct HbPtrDeleter<hb_face_t> {
    56     void operator()(hb_face_t* ptr) const
    57     {
    58         hb_face_destroy(ptr);
    59     }
    60 };
    61 
    6255} // namespace WebCore
    6356
  • trunk/Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp

    r239101 r239122  
    3535#include "SharedBuffer.h"
    3636
     37
    3738namespace WebCore {
    3839using namespace std;
     
    257258#elif USE(HARFBUZZ)
    258259OpenTypeMathData::OpenTypeMathData(const FontPlatformData& font)
    259     : m_mathFont(font.createOpenTypeMathHarfBuzzFont())
    260 {
     260    : m_mathFont(font.harfBuzzFace().createFont())
     261{
     262    if (!hb_ot_math_has_data(hb_font_get_face(m_mathFont.get())))
     263        m_mathFont = nullptr;
    261264}
    262265#elif USE(DIRECT2D)
     
    294297    return value * font.sizePerUnit();
    295298#elif USE(HARFBUZZ)
    296 float OpenTypeMathData::getMathConstant(const Font& font, MathConstant constant) const
     299float OpenTypeMathData::getMathConstant(const Font&, MathConstant constant) const
    297300{
    298301    hb_position_t value = hb_ot_math_get_constant(m_mathFont.get(), static_cast<hb_ot_math_constant_t>(constant));
     
    300303        return value / 100.0;
    301304
    302     return value * font.sizePerUnit();
     305    return value / 65536.0;
    303306#else
    304307float OpenTypeMathData::getMathConstant(const Font&, MathConstant) const
     
    324327    return mathItalicsCorrectionInfo->getItalicCorrection(*m_mathBuffer, glyph) * font.sizePerUnit();
    325328#elif USE(HARFBUZZ)
    326 float OpenTypeMathData::getItalicCorrection(const Font& font, Glyph glyph) const
    327 {
    328     return hb_ot_math_get_glyph_italics_correction(m_mathFont.get(), glyph) * font.sizePerUnit();
     329float OpenTypeMathData::getItalicCorrection(const Font&, Glyph glyph) const
     330{
     331    return hb_ot_math_get_glyph_italics_correction(m_mathFont.get(), glyph) / 65536.0;
    329332#else
    330333float OpenTypeMathData::getItalicCorrection(const Font&, Glyph) const
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp

    r239100 r239122  
    4747}
    4848
    49 FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&, FontSelectionSpecifiedCapabilities)
     49FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic)
    5050{
    5151    int size = fontDescription.computedPixelSize();
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h

    r239100 r239122  
    3535class FontPlatformData;
    3636class SharedBuffer;
    37 struct FontSelectionSpecifiedCapabilities;
    38 struct FontVariantSettings;
    39 
    40 template <typename T> class FontTaggedSettings;
    41 typedef FontTaggedSettings<int> FontFeatureSettings;
    4237
    4338struct FontCustomPlatformData {
     
    5247    ~FontCustomPlatformData();
    5348
    54     FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&, FontSelectionSpecifiedCapabilities);
     49    FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic);
    5550
    5651    static bool supportsFormat(const String&);
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp

    r239116 r239122  
    4141}
    4242
    43 FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings&, const FontVariantSettings&, FontSelectionSpecifiedCapabilities)
     43FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic)
    4444{
    4545    int size = fontDescription.computedPixelSize();
  • trunk/Source/cmake/OptionsGTK.cmake

    r239100 r239122  
    126126endif ()
    127127
    128 # Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
    129 if ("${PC_CAIRO_VERSION}" VERSION_GREATER_EQUAL "1.16.0"
    130     AND "${PC_FONTCONFIG_VERSION}" VERSION_GREATER_EQUAL "2.13.0"
    131     AND "${FREETYPE_VERSION_STRING}" VERSION_GREATER_EQUAL "2.9.0"
    132     AND "${PC_HARFBUZZ_VERSION}" VERSION_GREATER_EQUAL "1.4.2")
    133     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE ON)
    134 endif ()
    135 
    136128# Public options shared with other WebKit ports. Do not add any options here
    137129# without approval from a GTK+ reviewer. There must be strong reason to support
  • trunk/Tools/ChangeLog

    r239105 r239122  
     12018-12-12  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        Unreviewed manual rollout of r239100-r239102 and r239114
     4        https://bugs.webkit.org/show_bug.cgi?id=192151
     5        <rdar://problem/46655586>
     6
     7        * gtk/jhbuild.modules:
     8        * gtk/patches/cairo-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch: Removed.
     9
    1102018-12-12  Commit Queue  <commit-queue@webkit.org>
    211
  • trunk/Tools/gtk/jhbuild.modules

    r239100 r239122  
    108108    <branch module="releases/cairo-1.16.0.tar.xz" version="1.16.0"
    109109            repo="cairographics.org"
    110             hash="sha1:00e81842ae5e81bb0343108884eb5205be0eac14">
    111       <!-- See https://gitlab.freedesktop.org/cairo/cairo/merge_requests/5 -->
    112       <patch file="cairo-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch" strip="1"/>
    113     </branch>
     110            hash="sha1:00e81842ae5e81bb0343108884eb5205be0eac14"/>
    114111  </autotools>
    115112
Note: See TracChangeset for help on using the changeset viewer.