6.2 KiB
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 — (no submodules)
- 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
PathCommandobjects to the space-separated token string stored in aTypefaceGlyph'sofiel… - reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js
FontLoaderexpects counter-clockwise wind…
- reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js
FontLoaderexpects 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
PathCommandobjects to the space-separated token string stored in aTypefaceGlyph'sofiel… - reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js
FontLoaderexpects 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
PathCommandobjects to the space-separated token string stored in aTypefaceGlyph'sofiel… - reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js
FontLoaderexpects 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
PathCommandobjects to the space-separated token string stored in aTypefaceGlyph'sofiel… - reverse-winding — Reverses the winding order of a typeface.js path command sequence. Three.js
FontLoaderexpects 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 |