How to generate custom .otf font subset file?
Use case:
- There exists gauge .otf font file.
- There exists specific Unicode glyph set (ranges, points).
- Output is new .otf file sufficient for set from point 2.
How do this on .NET or JavaScript?
How to generate custom .otf font subset file?
Use case:
How do this on .NET or JavaScript?
If you are ok with using a package, fontkit is powerful/flexible and supports TTF, OTF, WOFF, WOFF2, TTC, and DFONT. You should consider this if you are looking for more complicated edits. Below is an example sourced from their readme.
// npm install fontkit
var fontkit = require('fontkit');
// open a font synchronously
var font = fontkit.openSync('font.ttf');
// layout a string, using default shaping features.
// returns a GlyphRun, describing glyphs and positions.
var run = font.layout('hello world!');
// create a font subset
var subset = font.createSubset();
run.glyphs.forEach(function(glyph) {
subset.includeGlyph(glyph);
});
let buffer = subset.encode();