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 })).
Example
Section titled “Example”const inter = Font.fromBytes(await (await fetch("/Inter.ttf")).arrayBuffer());surface.text("Hello", { font: inter, size: 12, at: [72, 72] });Properties
Section titled “Properties”
readonlybytes:Uint8Array<ArrayBufferLike> |undefined
The font program, for a font loaded from bytes.
standard
Section titled “standard”
readonlystandard:Standard14|undefined
The PostScript name, for a standard 14 font.
Methods
Section titled “Methods”fromBytes()
Section titled “fromBytes()”
staticfromBytes(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).
Parameters
Section titled “Parameters”ArrayBuffer | Uint8Array<ArrayBufferLike>
Returns
Section titled “Returns”Font
standard()
Section titled “standard()”
staticstandard(name):Font
One of the standard 14 fonts.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Font