You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
8 months ago | |
---|---|---|
.. | ||
lib | 8 months ago | |
node_modules | 8 months ago | |
LICENSE.md | 8 months ago | |
README.md | 8 months ago | |
browser.js | 8 months ago | |
index.js | 8 months ago | |
json-spec.md | 8 months ago | |
package.json | 8 months ago |
README.md
load-bmfont
Loads an AngelCode BMFont file in browser (with XHR) and node (with fs and phin), returning a JSON representation.
var load = require('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 Also
See text-modules for related modules.
Usage
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
orurl
the path (in Node) or URIbinary
boolean, whether the data should be read as binary, default false- (in node) options for
fs.readFile
orphin
- (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.
load({
uri: 'fonts/Arial.bin',
binary: true
}, function(err, font) {
console.log(font)
})
License
MIT, see LICENSE.md for details.