How to automate svg font generation for pdf build pipelines
- Step 1Install opentype.js — npm install opentype.js. Same library powers the browser tool and works identically in Node.
- Step 2Walk fonts directory — For each TTF/OTF in src/fonts/, parse with opentype.parse, iterate the glyph set, emit the <font>/<glyph> XML structure to dist/svg-fonts/<name>.svg.
- Step 3Wire into PDF build — Run before your PDF generation step. The PDF library picks up the SVG fonts via the standard CSS @font-face flow and embeds them in output PDFs.
Frequently asked questions
Is the script the same as the browser tool?+
Yes — opentype.js path extraction works identically in Node. The output bytes match what the browser tool would produce.
Can I cap glyph count per font?+
Yes — the script supports a maxGlyphs option. Useful when source fonts have 5,000+ glyphs but the PDF only renders a small subset.
What about XML escaping?+
Glyph unicode characters that conflict with XML markup (<, >, &) need escaping. The Node implementation uses the same escapeXml helper as the browser tool.
Privacy first
Every JAD Font tool runs entirely in your browser using opentype.js and the wawoff2 WASM Brotli encoder. Your fonts never leave your device — verified by zero outbound network requests during processing.