Singleton class for rendering text using signed distance fields.

SdfTextRenderer supports both single-channel and multi-channel signed distance fields.

Hierarchy

  • TextRenderer<SdfTextRendererState>
    • SdfTextRenderer

Constructors

Properties

set: Readonly<TrPropSetters<SdfTextRendererState>>
stage: Stage
type: "canvas" | "sdf" = 'sdf'

Methods

  • Destroy/Clean up the state object

    Parameters

    • state: SdfTextRendererState

    Returns void

    Opposite of createState(). Frees any event listeners / resources held by the state that may not reliably get garbage collected.

  • Schedule a state update via queueMicrotask

    Parameters

    • state: SdfTextRendererState

    Returns void

    This method is used to schedule a state update via queueMicrotask. This method should be called whenever a state update is needed, and it will ensure that the state is only updated once per microtask.

  • Parameters

    • state: SdfTextRendererState
    • status:
          | "loaded"
          | "failed"
          | "loading"
          | "initialState"
          | "destroyed"
    • Optionalerror: Error

    Returns void