Make GL-ready pbfs and metadata for usage in fontstack API.


2600.3.02 years ago5 years agoMinified + gzip package size for @mapbox/fontmachine in KB



Build Status codecov

Make GL-ready pbfs and metadata for usage in fontstack API.

makeGlyphs(opts, opts.font, opts.filetype, [opts.concurrency], callback)

Make all metadata (codepoints) and SDF PBFs necessary for Mapbox GL fontstacks.


parameter type description
opts Object Options object with required font and filetype properties, and any optional parameters.
opts.font Buffer The font file as a Buffer.
opts.filetype string Type of font (e.g. '.ttf' or '.otf').
[opts.concurrency] number optional: Concurrency to use when processing font into PBFs. If undefined, concurrency is unbounded.
callback function(err, result) Callback takes arguments (error, result).

Callback result

property type description
name string The name of this font (concatenated family_name + style_name).
stack Array<{name: string, data: Buffer}> An array of 256 {name: filename, data: buffer} objects with SDF PBFs covering points 0-65535.
metadata {family_name: string, style_name: string} Metadata about the font.
codepoints Array<int> Array of codepoints covered by the font.
original {name: string, data: Buffer} An object containing the original font file (named 'original<filetype>')


Requires nodejs.

$ npm install @mapbox/fontmachine


$ npm test

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.