Guidelines for AI coding assistants working on this repository.
This is a CLI tool that generates fonts.json metadata for Nutrient PDF SDK font bundles.
nutrient-font-tool/
├── bin/cli.js # CLI entry point
├── lib/
│ ├── bundle.js # Main logic: scan fonts, generate JSON
│ └── wasm-loader.js # Loads and interfaces with WASM module
├── wasm/
│ ├── FontToolWASM.js # Emscripten-generated JS loader
│ └── FontToolWASM.wasm # Compiled WebAssembly binary
└── test/
└── bundle.test.js # Vitest tests
The wasm/ directory contains pre-compiled binaries. The source code is not in this repository.
- Do NOT attempt to modify, regenerate, or reverse-engineer the WASM files
- Do NOT ask users for the WASM source code
- The WASM binary is built from private source code and distributed in compiled form
- Treat
wasm/FontToolWASM.jsandwasm/FontToolWASM.wasmas opaque dependencies
The WASM module exports:
allocateMemory(size)→MemoryHandle- Allocate memory for font dataprocessFont(memoryHandle, filename)→string- Process font, returns JSON string
The MemoryHandle object has:
.view- Uint8Array view into WASM memory (copy data here).delete()- Free the memory (always call when done)
bin/cli.js- CLI argument parsing, user interactionlib/bundle.js- File scanning, JSON generation, output handlinglib/wasm-loader.js- How we call into WASM (but not the WASM itself)test/- Tests- Documentation, CI workflows, package.json
wasm/FontToolWASM.js- Generated file, do not editwasm/FontToolWASM.wasm- Binary, cannot edit
npm test # Run tests once
npm run test:watch # Watch modeTests use a small fixture font (test/fixtures/Anton-Regular.ttf).
- ES modules (
import/export) - Node.js 18+ features are OK
- Keep dependencies minimal
- Async/await for file operations