Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
parse-bmfont-xml
Advanced tools
Readme
Parses XML 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 ... ]
})
Also works in the browser, for example using XHR:
var parse = require('parse-bmfont-xml')
var xhr = require('xhr')
xhr({ uri: 'fonts/NexaLight32.xml' }, function(err, res, body) {
if (err)
throw err
var result = parse(body)
console.log(result.info.face)
})
The spec for the returned JSON object is here. The input XML should match the spec with a <font>
root element, see [test/Nexa Light-32.fnt](test/Nexa Light-32.fnt) for an example.
See text-modules for related modules.
result = parse(data)
Parses data
, a string or Buffer that represents XML 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 }
]
}
If the data is malformed, an error will be thrown.
The browser implementation relies on xml-parse-from-string, which may not work in environments without valid DOM APIs (like CocoonJS).
MIT, see LICENSE.md for details.
FAQs
parses XML BMFont files into a JavaScript object
The npm package parse-bmfont-xml receives a total of 879,866 weekly downloads. As such, parse-bmfont-xml popularity was classified as popular.
We found that parse-bmfont-xml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.