Bug 215214

Summary: REGRESSION(r254506): [Freetype] Spektra variable font does not work properly
Product: WebKit Reporter: Adrian Perez <aperez>
Component: TextAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cgarcia, clopez, mmaxfield, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://v-fonts.com/fonts/spektra
Attachments:
Description Flags
Side by side comparison of Epiphany (WebKitGTK) and Firefox
none
Patch aperez: review+

Description Adrian Perez 2020-08-06 06:07:20 PDT
The following font changes it slant (backwards to forwards) depending
on a variable parameter: https://v-fonts.com/fonts/spektra

With a current WebKitGTK build from “trunk” the slant is always backwards.
Comment 1 Adrian Perez 2020-08-06 06:13:45 PDT
Created attachment 406082 [details]
Side by side comparison of Epiphany (WebKitGTK) and Firefox

Screenshot showing Epiphany (left, with a WebKitGTK build from trunk)
and Firefox (right) with the test URL loaded and the “Italic” parameter
set to +20 in both cases.
Comment 2 Adrian Perez 2020-08-06 06:16:39 PDT
WebKitGTK 2.28.4 (the most recent stable release at the moment) also
shows this issue, so it does not seem to be a recent regression.
Comment 3 Radar WebKit Bug Importer 2020-08-13 06:08:21 PDT
<rdar://problem/66984524>
Comment 4 Carlos Garcia Campos 2020-08-13 06:56:00 PDT
It turns out the problem is not the spektra font, not even the font variation implementation, it's the webkit-font-smoothing cairo implementation that breaks font variations. So, what's different in https://v-fonts.com/fonts/spektra is that webkit-font-smoothing is used. This regressed in r254506, when a font smoothing mode is passed to drawGlyphsToContext() a new cairo font options is set, using the default font options and changing the antialiasing. This means the font options from the font (the ones containing the variation settings), set in the context by cairo_set_scaled_font() are lost. We should copy the scaled font options instead, then set the antialiasing and apply them. I'll prepare a patch and try to add a test.
Comment 5 Carlos Garcia Campos 2020-08-13 08:25:00 PDT
Created attachment 406518 [details]
Patch
Comment 6 Adrian Perez 2020-08-13 15:32:05 PDT
Tested patch locally as well, worked like a charm!
Comment 7 Carlos Garcia Campos 2020-08-13 22:59:28 PDT
Committed r265648: <https://trac.webkit.org/changeset/265648>