[FreeType] Add initial implementation of variation fonts
https://bugs.webkit.org/show_bug.cgi?id=192151
Reviewed by Michael Catanzaro.
.:
Enable variation fonts in GTK+ port when required dependencies are available.
- Source/cmake/OptionsGTK.cmake:
Source/WebCore:
- css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::font): Remove platform ifdefs.
- loader/cache/CachedFont.cpp:
(WebCore::CachedFont::platformDataFromCustomData): Ditto.
- platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::isFixedWidth const):
- platform/graphics/cairo/FontCustomPlatformData.h: Use RefPtr for cairo_font_face_t.
- platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::getFontPropertiesFromPattern): Helper function to get several font properties from the fontconfig
pattern.
(WebCore::FontCache::systemFallbackForCharacters): Use getFontPropertiesFromPattern().
(WebCore::FontCache::createFontPlatformData): Pass FC_VARIABLE to the pattern and call buildVariationSettings()
before creating the FontPlatformData to set FC_FONT_VARIATIONS on the pattern.
(WebCore::defaultVariationValues): Parse font variations table.
(WebCore::buildVariationSettings): Build a font variations string from the settings that can be passed to cairo.
- platform/graphics/freetype/FontCacheFreeType.h: Added.
- platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::FontCustomPlatformData::FontCustomPlatformData): Use RefPtr and make freeTypeFaceKey global.
(WebCore::FontCustomPlatformData::~FontCustomPlatformData): Remove explicit destroy.
(WebCore::defaultFontconfigOptions): Moved here from FontCacheFreeType.
(WebCore::FontCustomPlatformData::fontPlatformData): Call buildVariationSettings() before creating the
FontPlatformData to set FC_FONT_VARIATIONS on the pattern.
(WebCore::FontCustomPlatformData::supportsFormat): Add variation formats.
- platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::setCairoFontOptionsFromFontConfigPattern): Call cairo_font_options_set_variations() with the
FC_FONT_VARIATIONS value from the pattern.
(WebCore::FontPlatformData::FontPlatformData): Use a single constructor that always receives a valid fontconfig
pattern.
(WebCore::FontPlatformData::fcPattern const): Return the fontconfig pattern.
(WebCore::FontPlatformData::platformIsEqual const): Update the condition now that m_pattern can't be nullptr.
(WebCore::FontPlatformData::buildScaledFont): Use m_pattern unconditionally.
- platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::Font::platformCreateScaledFont const): Update it to use the new FontPlatformData constructor.
- platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp:
(WebCore::HarfBuzzFace::createFont): Pass variations to HarfBuzz.
- platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
- platform/graphics/win/FontCustomPlatformData.h:
Tools:
Add cairo patch to avoid crashes.
- gtk/jhbuild.modules:
- gtk/patches/cairo-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch: Added.
LayoutTests:
Unskip variation fonts tests that are now passing in GTK+ port.
- platform/gtk/TestExpectations: