{"id":14797,"library":"parse-bmfont-ascii","title":"BMFont ASCII File Parser","description":"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.","status":"abandoned","version":"1.0.6","language":"javascript","source_language":"en","source_url":"git://github.com/mattdesl/parse-bmfont-ascii","tags":["javascript","ascii","parse","convert","bmfont","bm","bitmap","font","bitmaps"],"install":[{"cmd":"npm install parse-bmfont-ascii","lang":"bash","label":"npm"},{"cmd":"yarn add parse-bmfont-ascii","lang":"bash","label":"yarn"},{"cmd":"pnpm add parse-bmfont-ascii","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module. Direct ESM `import` is not supported without a transpiler or wrapper. The function is the default export.","wrong":"import parse from 'parse-bmfont-ascii'","symbol":"parse","correct":"const parse = require('parse-bmfont-ascii')"}],"quickstart":{"code":"const parse = require('parse-bmfont-ascii');\n\n// Example BMFont ASCII data (simplified Arial.fnt structure)\nconst 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\ncommon lineHeight=32 base=26 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0\npage id=0 file=\"sheet0.png\"\nchars count=3\nchar id=65 x=1 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15\nchar id=66 x=22 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15\nchar id=67 x=43 y=1 width=20 height=20 xoffset=0 yoffset=4 xadvance=20 page=0 chnl=15\nkernings count=1\nkerning first=65 second=66 amount=-2`;\n\ntry {\n  const result = parse(bmfontData);\n\n  console.log('Font Face:', result.info.face); // Expected: Arial\n  console.log('Pages:', result.pages);         // Expected: [ 'sheet0.png' ]\n  console.log('Number of chars:', result.chars.length); // Expected: 3\n  console.log('First char ID:', result.chars[0].id);   // Expected: 65 (A)\n  console.log('First kerning amount:', result.kernings[0].amount); // Expected: -2\n} catch (error) {\n  console.error('Failed to parse BMFont data:', error);\n}","lang":"javascript","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Evaluate actively maintained alternatives like `load-bmfont` or specific BMFont parsers designed for modern environments, or fork the repository and maintain it yourself.","message":"The 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.","severity":"deprecated","affected_versions":">=1.0.6"},{"fix":"Always use `require('parse-bmfont-ascii')` to correctly import this specific package.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create a `parse-bmfont-ascii.d.ts` file with type definitions or use `@ts-ignore` for imports.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: parse is not a function"},{"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.","cause":"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.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported"},{"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; }`.","cause":"This TypeScript error occurs because `parse-bmfont-ascii` does not provide its own type declarations (`.d.ts` files).","error":"Cannot find name 'parse'."}],"ecosystem":"npm"}