@kurot/bitmap-font
v0.1.0
Published
Headless bitmap font data, parsing, validation, serialization and layout for games and editors
Readme
@kurot/bitmap-font
Version 0.1.0. A headless TypeScript bitmap-font kernel for games, font editors and build tools. No runtime dependencies, DOM, Canvas, Core, UI, image decoding or filesystem access. ESM / ES2022.
pnpm add @kurot/bitmap-font@^0.1.0import { parseBitmapFont, layoutBitmapText, serializeBitmapFont } from '@kurot/bitmap-font';
const font = parseBitmapFont(descriptorText);
const preview = layoutBitmapText(font, '1,234.56', { width: 540 });
const exportedJSON = serializeBitmapFont(font);parseBitmapFont(unknown): native version-1 JSON, Egret frames JSON (including JSON.fntfiles), or single-page, unpacked, full-color BMFont text.validateBitmapFont(unknown): validates and copies native data to a deeply frozen snapshot. Editing inputs remain mutable and are never modified.serializeBitmapFont(data): validated, deterministic native JSON.layoutBitmapText(data, text, options?): glyph positions, UTF-16 indices, line metrics and bounds, with kerning, code-point wrapping and alignment.
Exported types: BitmapFontData, BitmapGlyph, BitmapTextLayoutOptions,
BitmapTextLayout, BitmapTextLine, PositionedBitmapGlyph.
See format and layout contract and verification. Importing this package does not load images. The matching Core/UI source adds font resources, BitmapText rendering and BitmapLabel. These integrations are absent from published Core 2.1.1 and UI 3.1.0; their releases follow this package.
A future editor keeps original glyph images, names and editing history in its
own project format. It uses this package for interchange and preview layout,
@kurot/atlas for packing pixels, and optionally Core for actual rendering.
Packing requires mapping each character to its resulting unrotated atlas region;
advances and bearings are font metrics and must survive pixel trimming.
pnpm install
pnpm build
pnpm testTests include the existing number-font descriptor; test resources are excluded from the package. No font-editor application or CLI/KUI catalog adoption is included. Core/UI source integration uses package-local pnpm overrides; publish this package before releasing Core with its registry dependency.
