Files
2026-06-09 21:06:27 +01:00

6.2 KiB

@suaveplan/font-convert - Convert TTF/OTF/WOFF/WOFF2 font files to typeface.js JSON format. Defines canonical TypefaceFont, TypefaceGlyph, and PathCommand types used by font-compress and font-decompress.

Summary

Converts TTF/OTF/WOFF/WOFF2 font files to the typeface.js JSON format used by Three.js FontLoader. Also defines the canonical TypefaceFont, TypefaceGlyph, and PathCommand types consumed by @suaveplan/font-compress.

Documentation tree

- [batch-converter](./src/core/batch-converter/batch-converter.md) — _(no submodules)_- [font-converter](./src/core/font-converter/font-converter.md) — _(no submodules)_- [font-converter](./src/core/font-converter/font-converter.md) — _(no submodules)_- [types](./src/types/typeface.md) — _(no submodules)_- [typeface](./src/types/typeface.md) — _(no submodules)_- [outline-to-string](./src/utils/outline-to-string.md) — Serialises an array of `PathCommand` objects to the space-separated token string stored in a `TypefaceGlyph`'s `o` fiel…
  • reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js FontLoader expects counter-clockwise wind…
  • batch-converter — (no submodules)- font-converter — (no submodules)- font-converter — (no submodules)- types — (no submodules)- typeface — (no submodules)- outline-to-string — Serialises an array of PathCommand objects to the space-separated token string stored in a TypefaceGlyph's o fiel…
  • reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js FontLoader expects counter-clockwise wind…
  • batch-converter — (no submodules)- font-converter — (no submodules)- font-converter — (no submodules)- types — (no submodules)- typeface — (no submodules)- outline-to-string — Serialises an array of PathCommand objects to the space-separated token string stored in a TypefaceGlyph's o fiel…
  • reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js FontLoader expects counter-clockwise wind…
  • batch-converter — (no submodules)- font-converter — (no submodules) - font-converter — (no submodules)- types — (no submodules) - typeface — (no submodules)- outline-to-string — Serialises an array of PathCommand objects to the space-separated token string stored in a TypefaceGlyph's o fiel…
  • reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js FontLoader expects counter-clockwise wind…

Packages in the font family

Package Purpose
@suaveplan/font-subset Unicode subset, WOFF2/WOFF encode, hinting strip
@suaveplan/font-convert TTF/OTF → typeface.js JSON (this package)
@suaveplan/font-compress typeface.js JSON → BTF binary pack/unpack

Quick start

import { createFontConverter } from "@suaveplan/font-convert";
import { readFileSync } from "node:fs";

const converter = createFontConverter();
const font = converter.convert(readFileSync("MyFont.ttf"));

console.log(font.familyName);   // "MyFont"
console.log(font.cssFontWeight); // "normal" | "bold"

Modules

Module Description
FontConverter Parse font binary → TypefaceFont
BatchConverter Convert multiple fonts in one call
reverseWinding Reverse glyph winding order
outlineToString Serialise PathCommand[] to outline string
TypefaceFont types Canonical shared types