loads a BMFont file in Node and the browser
npm install @codelenny/load-bmfont
!stable



Loads an AngelCode BMFont file from XHR (in browser) and fs (in Node), returning a JSON representation.
``js
var load = require('@codelenny/load-bmfont')
load('fonts/Arial-32.fnt', function(err, font) {
if (err)
throw err
//The BMFont spec in JSON form
console.log(font.common.lineHeight)
console.log(font.info)
console.log(font.chars)
console.log(font.kernings)
})
`
Currently supported BMFont formats:
- ASCII (text)
- JSON
- XML
- binary
See text-modules for related modules.

#### load(opt, cb)
Loads a BMFont file with the opt settings and fires the callback with (err, font) params once finished. If opt is a string, it is used as the URI. Otherwise the options can be:
- uri or url the path (in Node) or URI (in the browser)binary
- boolean, whether the data should be read as binary, default falsefs.readFile
- (in node) options for
- (in browser) options for xhr
To support binary files in the browser and Node, you should use binary: true. Otherwise the XHR request might come in the form of a UTF8 string, which will not work with binary files. This also sets up the XHR object to override mime type in older browsers.
`js``
load({
uri: 'fonts/Arial.bin',
binary: true
}, function(err, font) {
console.log(font)
})
MIT, see LICENSE.md for details.