Skip to content

vyaz-monorepo / renderers/src / registerFont

Function: registerFont()

registerFont(family, source, opts?): Promise<RegisterFontResult>

Defined in: renderers/src/register-font.ts:49

Register one font face with the layout engine and (in a browser) with document.fonts, from a single ArrayBuffer / Uint8Array or a URL.

Parameters

family

string

source

string | ArrayBuffer | Uint8Array<ArrayBufferLike>

opts?

RegisterFontOptions = {}

Returns

Promise<RegisterFontResult>

Example

ts
await registerFont('Inter', '/fonts/Inter.woff2', { weight: 400 })
await registerFont('Inter', bytes, { weight: 700, variation: { wght: 700 } })

Released under the MIT License.