About
Constructing shapes from glyphs at runtime for three.js.
Examples
Installation
Via npm: ( npm i ycw/three-font-outliner#v1.0.2
)
import Outliner from "three-font-outliner"
Via cdn:
import Outliner from "https://cdn.jsdelivr.net/gh/ycw/[email protected]/src/index.js"
Usage
Create an outliner.
// From arraybuffer holding the font file.
new Outliner(buffer, THREE.ShapePath);
// From font url. (async)
await Outliner.fromUrl("./roboto.ttf", THREE.ShapePath);
Outline text.
// Outline text with optional options.
outliner.outline("hello", {
size: 100, // Font size. Default 100.
isLTR: true, // Is text written in left-to-right? Default true.
isCCW: false, // Is solid shape using CCW winding? Default false.
});
Consume outline result.
const {
shapes, // Array of THREE.Shape.
h, // Line height.
w, // Advance width.
yMin, // Bottom (negative number).
yMax, // Top.
} = outliner.outline("hello");