Small World Engine API Reference - v0.76.20
    Preparing search index...

    Class TextTexture

    Renders text (including variable fonts and canvas-level effects) into a Texture, ready to be assigned as a material's diffuse map on a Plane. Call setText/setOptions to redraw and push the updated pixels to the GPU on the next frame.

    Index
    texture: Texture

    The GPU-facing texture backed by this instance's canvas.

    • get height(): number

      The unscaled (CSS pixel) height of the rendered text texture, useful for sizing a Plane.

      Returns number

    • get width(): number

      The unscaled (CSS pixel) width of the rendered text texture, useful for sizing a Plane.

      Returns number

    • Replaces the displayed text and redraws, marking the texture for GPU re-upload.

      Parameters

      • text: string

        The new text to display.

      Returns void

    • Loads a font file and registers it with document.fonts under the given family name.

      Parameters

      • family: string

        The font family name to register the loaded font under.

      • url: string

        The URL of the font file (e.g. a variable-font .woff2).

      Returns Promise<FontFace>

      A promise that resolves to the loaded FontFace.