Please autocompute exact face width
For a long time it was not possible to expose exact face width to apps, because the OpenType spec only provided a fixed list of widths in the OS/2 width table
That changed with the introduction of variable fonts: they can now expose their real width value via the variable width axis
That change also applies to non variable fonts. As noted by the spec authors:
The Width axis can be used as a variation axis within a variable font. It can also be used within a STAT table in non-variable fonts within a family that has width variants to provide a complete characterization of a font in relation to its family within the STAT table.
Unfortunately font makers are not using this facility for non variable fonts. That introduces width discrepancies between the variable and non variable variants of the same font family, with potential breakage if apps trust the width fontconfig derived from from the OS/2 scale (issue #213).
Since width is no longer limited to a set of values (as per spec), and font maker metadata is garbage (as usual), fontconfig should autocompute the real width of faces and use this real value in the info it returns to software.
Algorithm:
- if a font family contains a Regular face
- and some faces differ on the width axis (while Regular on weight and slant), for any reason (oS/2 metadata, keyword in style name, whatever)
- compute the em of those faces (width of
m
) and use the ratio with Regular em as width - propagate on the wight and slant axis (use the width of
SemiCondensed
as the width ofSemiCondensed Bold
, etc) - If the faces to not contain a
m
, use another glyph present in all faces as scale check
If this is too expensive to do at initial indexing, do it as a background second stage, as long as no app requests the width value for a particular face