go-text / typesetting

High quality text shaping in pure Go.
Other
88 stars 11 forks source link

Add support for the CFF2 Opentype table #120

Closed benoitkugler closed 6 months ago

benoitkugler commented 6 months ago

This PR adds support for the 'CFF2' Opentype table (required by #118).

It is larger than expected since I had to fix variation handling : we were previously using float32 to store a coordinate, but the Opentype spec uses a fixed 2.14 storage. The difference was significant enough to have a off-by-one difference with Harfbuzz when computing glyph extents (with variations). It seems simpler and better to just follow the spec (and Harfbuzz).

Also, I had to tweak the Postscript interpreter implementation to use float64 instead of int32, so that we properly handle the non integer point coordinates arising when using variations.