foliojs / fontkit

An advanced font engine for Node and the browser
1.45k stars 213 forks source link

Subset is not working #241

Closed BannerwiseMZL closed 3 years ago

BannerwiseMZL commented 3 years ago

The subsetted file created by fontkit does not include any valid Glyph. I've tried multiple different font files (TTF) and none of them are working properly. Please view the code snippet below. I've also attached a screenshot of the result. Are there any requirements to the TTF format I don't know about? Or ways to debug this? Or anything else?


        const run = font.layout('dDoOuUbBlLeEcCiIkKtT');
        const svg = run.glyphs[0].path.toSVG();
        console.log(svg);
        const subset = font.createSubset();
        run.glyphs.forEach(function (glyph: any) {
            console.log('adding glyph');
            subset.includeGlyph(glyph);
        });
        subset.encodeStream()
            .pipe(fs.createWriteStream('subset.ttf'));```

![image](https://user-images.githubusercontent.com/16005883/92440456-d517d800-f1ac-11ea-8305-74a35cd9bc6b.png)
BannerwiseMZL commented 3 years ago

Didn't see the following comment:

Currently, subsets produce minimal fonts designed for PDF embedding that may not work as standalone files. They have no cmap tables and other essential tables for standalone use. This limitation will be removed in the future.