load-bmfont
loads a BMFont file in Node and the browser
Last updated 2 years ago by mattdesl .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install load-bmfont 
SYNC missed versions from official npm registry.

load-bmfont

stable

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

NPM

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
  • binary boolean, whether the data should be read as binary, default false
  • (in node) options for fs.readFile or phin
  • (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.

Current Tags

  • 1.4.2                                ...           latest (2 years ago)

13 Versions

  • 1.4.2                                ...           2 years ago
  • 1.4.1                                ...           6 years ago
  • 1.4.0                                ...           8 years ago
  • 1.3.1                                ...           8 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.5                                ...           9 years ago
  • 1.2.4                                ...           9 years ago
  • 1.2.3                                ...           11 years ago
  • 1.2.2                                ...           11 years ago
  • 1.2.1                                ...           11 years ago
  • 1.2.0                                ...           11 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 1
Dependencies (8)
Dev Dependencies (4)

Copyright 2013 - present © cnpmjs.org | Home |