Registry / serialization / parse-bmfont-ascii

parse-bmfont-ascii

JSON →
library1.0.6jsnpmunverified

The `parse-bmfont-ascii` library is designed to parse ASCII-formatted BMFont (Bitmap Font) files into a structured JavaScript object. It specifically handles the human-readable text-based `.fnt` files generated by tools like AngelCode BMFont. This package, currently at version 1.0.6, was last published 11 years ago, indicating it is no longer actively maintained. It accepts either a string or a Node.js `Buffer` containing the BMFont data and returns a JavaScript object detailing font metadata (`info`, `common`), individual character properties (`chars`), kerning pairs (`kernings`), and referenced page textures (`pages`). Its primary function is to provide a lightweight, dedicated parser for this specific text-based bitmap font format, distinct from XML or binary BMFont variants. Given its age, it relies on CommonJS module patterns and does not inherently support ESM or TypeScript type definitions.

npm install parse-bmfont-ascii
INSTALL
IMPORT
SIG · PARSE-BMFONT-ASCII
P
parse-bmfont-ascii
serializationjavascriptv1.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
const parse = require('parse-bmfont-ascii')
import parse from 'parse-bmfont-ascii'
This package is a CommonJS module. Direct ESM `import` is not supported without a transpiler or wrapper. The function is the default export.

This quickstart demonstrates how to use `parse-bmfont-ascii` to parse a string containing BMFont ASCII data, then log key properties of the resulting JavaScript object.

const parse = require('parse-bmfont-ascii'); // Example BMFont ASCII data (simplified Arial.fnt structure) const bmfontData = `info face="Arial" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=0,0 outline=0 common lineHeight=32 base=26 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0 page id=0 file="sheet0.png" chars count=3 char id=65 x=1 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15 char id=66 x=22 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15 char id=67 x=43 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15 kernings count=1 kerning first=65 second=66 amount=-2`; try { const result = parse(bmfontData); console.log('Font Face:', result.info.face); // Expected: Arial console.log('Pages:', result.pages); // Expected: [ 'sheet0.png' ] console.log('Number of chars:', result.chars.length); // Expected: 3 console.log('First char ID:', result.chars[0].id); // Expected: 65 (A) console.log('First kerning amount:', result.kernings[0].amount); // Expected: -2 } catch (error) { console.error('Failed to parse BMFont data:', error); }
Debug
Known issues
breakingThis package is an old CommonJS module and does not natively support ES Modules (ESM). Attempting to `import` it in a pure ESM project will result in an error without a CJS-to-ESM wrapper or bundler configuration.
fix
Use `const parse = require('parse-bmfont-ascii')` in CommonJS environments. For ESM, you might need dynamic import `import('parse-bmfont-ascii').then(mod => mod.default)` or a build step to transpile.
affects: >=1.0.0
deprecatedThe package `parse-bmfont-ascii` is abandoned, with its last release over a decade ago. It receives no active maintenance, meaning bug fixes, security updates, or new features are highly unlikely. Consider alternatives for new projects or if robust maintenance is critical.
fix
Evaluate actively maintained alternatives like `load-bmfont` or specific BMFont parsers designed for modern environments, or fork the repository and maintain it yourself.
affects: >=1.0.6
gotchaThe README's example code incorrectly uses `require('parse-bmfont-xml')` when demonstrating the usage of `parse-bmfont-ascii`. Users should ensure they are importing `parse-bmfont-ascii` if they intend to parse ASCII BMFont files.
fix
Always use `require('parse-bmfont-ascii')` to correctly import this specific package.
affects: >=1.0.0
gotchaThis package does not ship with TypeScript declaration files (`.d.ts`). Using it in a TypeScript project will result in type errors unless custom declarations are provided or the import is ignored.
fix
Create a `parse-bmfont-ascii.d.ts` file with type definitions or use `@ts-ignore` for imports.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: parse is not a function
Attempting to use `parse` as a function after an incorrect `require` statement, or when a bundler fails to correctly resolve the CommonJS default export in an ESM context.
fix
Ensure you are using `const parse = require('parse-bmfont-ascii')` and that your build tools correctly handle CommonJS modules, especially if in an ESM project.
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported
Attempting to `require` a pure ESM module from a CommonJS context, or more commonly, trying to `import` this (CommonJS) package directly in a pure ESM Node.js environment without proper configuration.
fix
This package is CJS. In an ESM project, use dynamic import `import('parse-bmfont-ascii').then(mod => mod.default)`. Alternatively, ensure your bundler (e.g., Webpack, Rollup) is configured to handle CJS modules.
Cannot find name 'parse'.
This TypeScript error occurs because `parse-bmfont-ascii` does not provide its own type declarations (`.d.ts` files).
fix
Create a declaration file (e.g., `types/parse-bmfont-ascii.d.ts`) that defines the module's exports, or use `// @ts-ignore` above the import statement as a temporary workaround. A basic declaration could be `declare module 'parse-bmfont-ascii' { function parse(data: string | Buffer): any; export = parse; }`.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
parse-bmfont-ascii — npm install parse-bmfont-ascii · libregistry