foliojs / fontkit

An advanced font engine for Node and the browser
1.46k stars 219 forks source link

Subset of woff2 ttf fonts with transformed glyf/loca table does not work #201

Open blikblum opened 5 years ago

blikblum commented 5 years ago

Woff2 fonts can have loca and glyf stored in a specific format which is supposed to be transformed at decode time.

Currently, fontkit transforms the glyf table which is sufficient to read glyph data

But when subsetting, the original untransformed, loca table is used to get the glyf table offset leading to extraneous or empty glyph data

To support such case it is needed to encode the transformed glyf data into a buffer and than use it when subsetting. Just transforming loca table won't work, and is superfluous, because the transformed glyf data is stored as an array objects and not as a buffer

This bug does not affects woff2 otf (with CFF outlines) files