Skip to content

@bendyline/molen-client/text ​

Molen rendering client: three.js wrapper, snapshot sync, interpolation.

ts
import { /* … */ } from '@bendyline/molen-client/text';

Interfaces ​

CompileVectorFontOptions ​

Properties ​

characters? ​
ts
optional characters?: string;

Explicit subset, including ? and space. Default: every character in the typeface.

curveSegments? ​
ts
optional curveSegments?: number;

Segments per outline curve, 2–32; default 6 for medium-fi signage.

id ​
ts
id: string;
kerning? ​
ts
optional kerning?: Record<string, number>;

Optional pair adjustments in em units from the source font's kerning tables.

style? ​
ts
optional style?: "normal" | "italic";
weight? ​
ts
optional weight?: number;

FontLibrary ​

Properties ​

defaultFont ​
ts
defaultFont: string;
fonts ​
ts
fonts: Readonly<Record<string, VectorFont>>;
roles? ​
ts
optional roles?: Readonly<Record<string, string>>;

Semantic roles, e.g. highway, sans, serif and mono. Values are font ids.


TextLayoutOptions ​

Properties ​

align? ​
ts
optional align?: "center" | "left" | "right";
fallbackFonts? ​
ts
optional fallbackFonts?: readonly string[];
font? ​
ts
optional font?: string;

A font id or semantic role in the library.

letterSpacing? ​
ts
optional letterSpacing?: number;

Additional advance in em units.

lineHeight? ​
ts
optional lineHeight?: number;

Baseline spacing in em units, default the face's lineHeight.

maxCharacters? ​
ts
optional maxCharacters?: number;

Bounds CPU/geometry work; default 256, maximum 4096 Unicode characters.

maxHeight? ​
ts
optional maxHeight?: number;
maxWidth? ​
ts
optional maxWidth?: number;
overflow? ​
ts
optional overflow?: "shrink" | "ellipsis";
size? ​
ts
optional size?: number;

Maximum em size in world units (default 1). Fitting never stretches glyphs.

verticalAlign? ​
ts
optional verticalAlign?: "center" | "baseline" | "top";

TextMeshData ​

Properties ​

height ​
ts
height: number;
indices ​
ts
indices: Uint32Array;
missingGlyphs ​
ts
missingGlyphs: string[];
positions ​
ts
positions: Float32Array;
text ​
ts
text: string;

The rendered text after normalization/length limiting/ellipsis.

truncated ​
ts
truncated: boolean;
width ​
ts
width: number;

VectorFont ​

Compiled outlines: fonts remain content supplied by the host, never embedded in library code.

Properties ​

ascent ​
ts
ascent: number;
descent ​
ts
descent: number;
family ​
ts
family: string;
format ​
ts
format: "molen/vector-font@1";
glyphs ​
ts
glyphs: Record<string, VectorGlyph>;
id ​
ts
id: string;
kerning ​
ts
kerning: Record<string, number>;

Keys are pairs of Unicode characters, including supplementary code points.

lineHeight ​
ts
lineHeight: number;
style ​
ts
style: "normal" | "italic";
weight ​
ts
weight: number;

VectorGlyph ​

Glyph coordinates and advance are in em units, Y up. Triangles face +Z.

Properties ​

advance ​
ts
advance: number;
indices ​
ts
indices: number[];
positions ​
ts
positions: number[];

Variables ​

vectorFontSchema ​

ts
const vectorFontSchema: z.ZodType<VectorFont>;

Functions ​

buildTextMesh() ​

ts
function buildTextMesh(
   value, 
   library, 
   options?
): TextMeshData;

Proportional advances, pair kerning, fallback fonts, multiline alignment and uniform fitting.

Parameters ​

value ​

string

library ​

FontLibrary

options? ​

TextLayoutOptions

Returns ​

TextMeshData


compileVectorFont() ​

ts
function compileVectorFont(data, options): VectorFont;

Compile typeface JSON (including TTFLoader output) once, then store the result in a pack. Node and browser compatible; no canvas or OS font dependency. Does not fetch a font.

Parameters ​

data ​

FontData

options ​

CompileVectorFontOptions

Returns ​

VectorFont


createTextGeometry() ​

ts
function createTextGeometry(
   text, 
   fonts, 
   options?
): BufferGeometry;

Caller owns/disposes the geometry and chooses its material, color, transform and batching.

Parameters ​

text ​

string

fonts ​

FontLibrary

options? ​

TextLayoutOptions

Returns ​

BufferGeometry


loadFontLibrary() ​

ts
function loadFontLibrary(catalog, read): Promise<FontLibrary>;

Read catalog-relative font documents through the host's file/pack loader; never fetches URLs.

Parameters ​

catalog ​

unknown

read ​

(path) => Promise&lt;unknown&gt;

Returns ​

Promise&lt;FontLibrary&gt;

50 guides · 44 schema formats · 51 API entry points · 11 samples. API, CLI and schema pages are generated from the shipped build.