[FreeType] Add initial implementation of variation fonts
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2018 09:07:19 +0000 (09:07 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2018 09:07:19 +0000 (09:07 +0000)
commitf4a4df4d4d46034c89469a7a868710d8df44861c
tree0ac4eb8aee8a135d474819980f6b363ee1553824
parent1622f33e2e4e46f05cbf090059f26e20060a3fe5
[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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/loader/cache/CachedFont.cpp
Source/WebCore/platform/graphics/FontPlatformData.h
Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.h [new file with mode: 0644]
Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
Source/cmake/OptionsGTK.cmake
Tools/ChangeLog
Tools/gtk/jhbuild.modules
Tools/gtk/patches/cairo-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch [new file with mode: 0644]