Skip to content

Font

A font to draw text with: TrueType or OpenType bytes (subset to the glyphs drawn and embedded) or one of the standard 14. Needs the text module (init({ text: true })).

const inter = Font.fromBytes(await (await fetch("/Inter.ttf")).arrayBuffer());
surface.text("Hello", { font: inter, size: 12, at: [72, 72] });

readonly bytes: Uint8Array<ArrayBufferLike> | undefined

The font program, for a font loaded from bytes.


readonly standard: Standard14 | undefined

The PostScript name, for a standard 14 font.

static fromBytes(bytes): Font

A font from its bytes (TrueType or OpenType/CFF). The bytes are checked when a builder first uses the font (invalid-font, font-not-embeddable).

ArrayBuffer | Uint8Array<ArrayBufferLike>

Font


static standard(name): Font

One of the standard 14 fonts.

Standard14

Font