sdf-bitmap-glyphs
Extract SDF bitmap tiles from font files. This is a thin wrapper around node-fontnik.
var fs = var path = var extract = var file = pathvar font = fs
Each glyph is stored by its code point and looks like this:
{
id: 65, //codepoint
advance: 16, //amount for x-advance
width: 17, //glyph width
height: 17, //glyph height
left: 0, //horizontal bearing
top: -9, //vertical bearing
bitmap: Buffer, //a single channel uint8 bitmap
shape: [23, 23] //the [width, height] of bitmap tile
}
See test/demo.js for an example of rendering a bitmap tile like this:
Usage
extract(font, [opt], cb)
Extracts SDF glyphs from the given font
Buffer. If opt
is not defined, it will only extract ASCII glyphs (0-255). Returns the cb
with (err, data)
results.
Options:
start
the start code point to look for, default 0end
the end code point to look for, default 255
License
MIT, see LICENSE.md for details.