@mocanvas/mocanvas · function
declare function preloadFont(id: string, font: TLTypeFace, targetDocument?: Document): Promise<FontFace>Load a font into a document and register it under id.
Resolves once the file is available for layout, so a caller can render text knowing it will not reflow underneath. Where the CSS Font Loading API is missing — a server render, a test environment — it rejects rather than pretending: a caller that wants "load if you can" should catch, and one that is measuring text needs to know it did not happen.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.