Calculate kerning table of a font
npm install detect-kerningjs
const kerning = require('detect-kerning')
let pairs = kerning('Roboto')
/*
{
'A”': -10,
'W.': -5,
'P,': -3,
...
}
*/
// get px kerning for 16px font-size
let px = 16 * pairs['AV'] / 1000
`
$3
Detect kerning pairs for the font family or stack of families and return their kerning in 1000 units/em. Optionally pass specific kerning pairs to check, or a unicode range, by default all printable ASCII character pairs are detected from the [32, 126] range. Alternatively, an options object can define:
* options.pairs - specific pairs to check;
* options.range - unicode range to detect pairs from;
* options.fontSize - base font size to use for check. Can affect performance, by default 16.
* options.threshold` - font size (em) ratio to detect kerning, by default 0.05. Values below that number can bloat kerning table size.