Skip to content
Shapemetry

@huukhanhnguyen/geometry / namespaces/Font

namespaces/Font

free

const free: (id) => boolean = wasm.font_free

Drop a registered font. False if the id was not registered.

Parameters

id

number

Returns

boolean


metrics

const metrics: (id) => string = wasm.font_metrics

{ unitsPerEm, ascender, descender, lineGap }, in FONT UNITS.

Parameters

id

number

Returns

string


parse

const parse: (data, index) => number = wasm.font_parse

Parse a font file and register it, returning the id every other text_* export takes. index selects a face inside a collection (.ttc/.otc/.dfont) and is 0 for a plain font. The bytes are copied into the registry, so the caller's buffer is free afterwards.

Parameters

data

Uint8Array

index

number

Returns

number


setVariations

const setVariations: (id, settings_json) => void = wasm.font_set_variations

Pin a variable font's design axes: [{"axis":"wght","value":700}]. An empty list restores the defaults.

Parameters

id

number

settings_json

string

Returns

void

Last updated: 📖 1 min readEdit on GitHub