# load-bmfont

> loads a BMFont file in Node and the browser

Latest version **1.4.2** (published 2024-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-bmfont
pnpm add load-bmfont
yarn add load-bmfont
bun add load-bmfont
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.2 |
| Published | 2024-07-09 |
| First published | 2015-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | bmfont, bitmap, font, angel, code, angelcode, parse, ascii, xml, text, json |

## Links

- npm: https://www.npmjs.com/package/load-bmfont
- Repository: https://github.com/Jam3/load-bmfont
- Issues: https://github.com/Jam3/load-bmfont/issues
- npm.io page: https://npm.io/package/load-bmfont

## Dependencies (8)

- [xhr](https://npm.io/package/xhr.md) ^2.0.1
- [mime](https://npm.io/package/mime.md) ^1.3.4
- [phin](https://npm.io/package/phin.md) ^3.7.1
- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [buffer-equal](https://npm.io/package/buffer-equal.md) 0.0.1
- [parse-bmfont-xml](https://npm.io/package/parse-bmfont-xml.md) ^1.1.4
- [parse-bmfont-ascii](https://npm.io/package/parse-bmfont-ascii.md) ^1.0.3
- [parse-bmfont-binary](https://npm.io/package/parse-bmfont-binary.md) ^1.0.5

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.4.2 (latest) — 2024-07-09
- 1.4.1 — 2020-07-02
- 1.4.0 — 2018-09-01
- 1.3.1 — 2018-08-15
- 1.3.0 — 2017-01-27
- 1.2.5 — 2017-01-20
- 1.2.4 — 2016-11-21
- 1.2.3 — 2015-03-15
- 1.2.2 — 2015-03-14
- 1.2.1 — 2015-03-14
- 1.2.0 — 2015-03-14
- 1.1.0 — 2015-03-13
- 1.0.0 — 2015-03-12

## README

# load-bmfont

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Loads an [AngelCode BMFont](http://www.angelcode.com/products/bmfont/) file in browser (with XHR) and node (with fs and [phin](https://github.com/ethanent/phin)), returning a [JSON representation](json-spec.md).

```js
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](https://github.com/mattdesl/text-modules) for related modules.

## Usage

[![NPM](https://nodei.co/npm/load-bmfont.png)](https://www.npmjs.com/package/load-bmfont)

#### `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](https://www.npmjs.com/package/phin)
- (in browser) options for [xhr](https://github.com/Raynos/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);
  }
);
```

## License

MIT, see [LICENSE.md](http://github.com/Jam3/load-bmfont/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/load-bmfont · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
