https://github.com/dy/detect-kerning
Calculate kerning pairs for a font
https://github.com/dy/detect-kerning
Last synced: 9 months ago
JSON representation
Calculate kerning pairs for a font
- Host: GitHub
- URL: https://github.com/dy/detect-kerning
- Owner: dy
- Created: 2018-06-09T04:30:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-20T23:02:50.000Z (almost 8 years ago)
- Last Synced: 2025-08-15T07:33:53.478Z (10 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# detect-kerning [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/detect-kerning)
Calculate kerning pairs for a font.
[](https://npmjs.org/package/detect-kerning/)
```js
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
```
### `pairs = kerning(family|familyList, pairs|range|options?)`
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.
## Related
* [css-font](https://npmjs.org/css-font) for parsing font-family from css font string.
## License
© 2018 Dmitry Yv. MIT License