Skip to content

webFont

webFont(path, opts?): WebFontHandle

Defined in: packages/renderer/src/assets.ts:167

Create a typed asset handle for a plain web font (a .ttf/.woff/.woff2 loaded for canvas Text, the canvas sibling of bitmapFont). Resolve it through a scene’s preload so the face is registered before the first draw — Pixi caches fallback metrics on first paint otherwise, so a font that loads late never applies.

Pass bitmap to also bake a BitmapText atlas from the same face under the same family, so a single declared font works for both text paths.

class MenuScene extends Scene {
readonly preload = [webFont("fonts/Inter.woff2", { family: "Inter" })];
// …then: new TextComponent({ text: "Play", style: { fontFamily: "Inter" } })
}

string

WebFontOptions

WebFontHandle