parse-bmfont-ascii

    1.0.6 • Public • Published

    parse-bmfont-ascii

    stable

    Parses ASCII (text) BMFont files.

    Takes a string or Buffer:

    var fs = require('fs')
    var parse = require('parse-bmfont-xml')
     
    fs.readFileSync(__dirname+'/Arial.fnt', function(err, data) {
      var result = parse(data)
      console.log(result.info.face)   // "Arial"
      console.log(result.pages)       // [ 'sheet0.png' ]
      console.log(result.chars)       // [ ... char data ... ]
      console.log(result.kernings)    // [ ... kernings data ... ]
    })

    The spec for the returned JSON object is here. The input data should match the spec, see test/Nexa Light-32.fnt for an example.

    See Also

    See text-modules for related modules.

    Usage

    NPM

    result = parse(data)

    Parses data, a string or Buffer that represents ASCII (text) data of an AngelCode BMFont file. The returned result object looks like this:

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

    License

    MIT, see LICENSE.md for details.

    Install

    npm i parse-bmfont-ascii

    DownloadsWeekly Downloads

    1,090,160

    Version

    1.0.6

    License

    MIT

    Last publish

    Collaborators

    • mattdesl