autokerning
Version:
autokerning computes suggested kerning values for glyph pairs from TrueType/OpenType fonts by rendering glyph bitmaps, applying a small Gaussian blur, and measuring pixel overlap across horizontal offsets. It can be used programmatically (as an imported E
36 lines (23 loc) • 881 B
Markdown
autokerning computes suggested kerning values for glyph pairs from TrueType/OpenType fonts by rendering glyph bitmaps, applying a small Gaussian blur, and measuring pixel overlap across horizontal offsets. It can be used programmatically (as an imported ESM module) or via the included CLI.
## Programmatic usage
**Get kerning table (no file):**
```js
const kerning = await getKerningTable('./fonts/Roboto-Black.ttf', ['AV', 'To', 'Wa']);
```
**Generate and save JSON:**
```js
const myPairs = ['AV', 'To', 'Wa']
const { outputPath } = await generateKerningTable('./fonts/Roboto-Black.ttf', {
outputfile: 'Roboto-Black.json',
pairs: myPairs,
writeFile: true,
});
```
```powershell
autokerning Roboto-Black.ttf AV WA To Ta ox
autokerning Roboto-Black.ttf --output kerning.json
```