0.1.9 • Published 9 years ago

bmfont2json v0.1.9

Weekly downloads
386
License
MIT
Repository
github
Last release
9 years ago

Parses BMFont files (XML/TXT) to JSON objects, with a command-line tool for easy conversion.

example

var fs = require('fs');
var bmfont2json = require('bmfont2json');

//grab the Buffer or a string of our data
var data = fs.readFileSync(__dirname + '/myfile.fnt');

//the bitmap font data as an object
var obj = bmfont2json(data);

//we can stringify it if we want...
var json = JSON.stingify( obj );

The function parses a string (or Node Buffer) that is either XML data (with a root element), or TXT data (following Bitmap Font spec).

The output looks something like the following JSON. It tries to stay true to the BMFont spec.

{
     pages: [
         "sheet_0.png", 
         "sheet_1.png"
     ],
     chars: [
         { chnl, height, id, page, width, x, y, xoffset, yoffset, xadvance },
         ...
     ],
     info: { ... },
     common: { ... },
     kernings: [
         { first, second, amount }
     ]
}

Related modules:

spec

See here for a more complete JSON output.

command-line tool

Converts a single file. If no output is provided, it prints to stdout.

Install
    npm install bmfont2json -g

Usage:
    bmfont2json file [options]

Options:
    -o, --ouput the output path
    -p, --pretty pretty print the JSON output
0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago