Broken spacing/kerning for font `SF Pro` since 1.49.3
For SF Pro
, the main system font on macOS and iOS, letter spacing/kerning is too large when rendered with Pango >= 1.49.3.
Interestingly, this affects both the TrueType and Postscript versions of the font.
Rendering diff
SF Pro Display, 12pt, 96 ppi, Linux Pango 1.49.2 (correct spacing):
SF Pro Display, 12pt, 226 ppi (downscaled), macOS Font Book 10.0 (correct spacing):
SF Pro Display, 12pt, 96 ppi, Linux Pango 1.50.9 (wrong spacing):
Reproduce
This repo contains pango-view
renderings for different pango and font versions.
It also contains all code to create the renderings in a reproducible environment, with zero dependencies besides Nix
Workaround
-
In Pango
The rendering can be fixed by removinghb_font_set_ptem
in pangofc-font.c. This line was introduced in 4e946310. -
In the font
Remove the trak table with fonttools: https://gist.github.com/erikarvstedt/8e1191f69db906b4cef95ab2bb7d466d
Pango revisions
While bisecting between Pango 1.49.2 (which works correctly) and 1.50.9 (latest release as of 2022-09-01), the following revisions produce changes in the renderings:
-
Rev 047bfaf6 (bad1)
Rendering diff: Slight change in image height (irrelevant) -
Rev ccb651dd (bad2)
Rendering diff: Slight increase of spacing
Author: Matthias Clasen mclasen@redhat.com
Date: Fri Nov 5 06:57:44 2021 -0400
Fix advance widths with transforms -
Rev 4e946310 (bad3)
Rendering diff: Huge increase of spacing.
Author: Matthias Clasen mclasen@redhat.com
Date: Mon Nov 8 20:06:47 2021 -0500
Call hb_font_set_ptem when creating fonts -
Rev 303f79e1 (bad4)
Rendering diff: Slight change in image height (irrelevant) -
Rev 22f8df57 (bad5)
Rendering diff: Slight reduction of spacing, because this reverts (bad2)
This rev produces the same output as 1.50.9
Author: Matthias Clasen mclasen@redhat.com
Date: Fri Dec 17 14:24:17 2021 -0500
Revert "Fix advance widths with transforms"
This reverts commit ccb651dd
All these revs are rendered by the repro repo.