Repository navigation
@textmode/document 2.0.0
The package now defines textmode.document@3.1.0, with optional font references on layers and a stable way to identify supported SFNT fonts. Package versions and document format versions are independent.
Highlights
- Adds the format 3.1 specification, JSON Schema, TypeScript declarations, and consumer documentation.
- Adds an optional
fontreference to each layer. The reference stores a normalized font identity and may include a display name. It does not embed font data or require a local font match during decoding. - Adds
identifySfntFont(bytes)from@textmode/document/font. It identifies standalone TTF and OTF data with a full SHA-256 identity. It validates SFNT table bounds and applies size and table-count limits. WOFF decoding is not included. - Keeps decoding support for format 3.0, format 2.0, and
textmode.layer@1.0.0/textmode.layer@1.1.0inputs. Older documents migrate to canonical format 3.1 data and return migration warnings. - Adds the schema package subpath
@textmode/document/schema/3.1. The format 3.0 schema remains unchanged.
Compatibility note
The decoder now returns canonical documents with formatVersion: "3.1.0". If your application checks this value or depends on the exact shape of decoder output, update that code. Format 3.0 input remains supported and is migrated to 3.1. The package does not rewrite files on disk.
The font identity helper is an optional entry point. The root decoder remains independent of font hashing code; importing @textmode/document/font uses the @noble/hashes runtime dependency.
Install
npm install @textmode/document@2.0.0The package requires Node.js 24 or later and uses ESM.