|
3 weeks ago | |
---|---|---|
.. | ||
lib | 3 weeks ago | |
node_modules | 3 weeks ago | |
LICENSE.md | 3 weeks ago | |
README.md | 3 weeks ago | |
browser.js | 3 weeks ago | |
index.js | 3 weeks ago | |
json-spec.md | 3 weeks ago | |
package.json | 3 weeks ago | |
test-server.js | 3 weeks ago |
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:
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 URIbinary
boolean, whether the data should be read as binary, default falsefs.readFile
or phinTo 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);
}
);
MIT, see LICENSE.md for details.