arcade2d
Interface

TextOptions

graphics/text.types.ts:19

Construction-time configuration for a Text. Extends the shared TexturedGraphicsOptions (anchor, tint, alpha, visible) with the typographic settings. Note fill is the glyph colour, while the inherited tint multiplies on top of it. Every field is optional; an omitted field takes the documented default.

Properties

readonly #
align?: TextAlign

Horizontal alignment of lines within a multi-line Text. Defaults to 'left'. Ignored for single-line text — to position a single line, set its host's position or its anchor.

readonly #
alpha?: number

Opacity in the range 0 (fully transparent) to 1 (fully opaque). Defaults to 1.

readonly #
anchor?: number | PointPrimitive

The anchor point — the spot on the graphic that sits on the host WorldObject's position — as a fraction of the graphic's size in each axis. 0 is the left/top edge, 1 the right/bottom, 0.5 the centre. Pass a single number to use it for both axes, or a PointPrimitive for independent values.

Defaults to 0.5 (centred), which differs from the renderer's own top-left default. Centring matches arcade2d's convention that a WorldObject's position is its visual origin.

readonly #
fill?: string | number

Fill colour of the glyphs. Either a 24-bit RGB integer (0xff0000 for red) or a CSS colour string ('#ff0000', 'red'). Defaults to 0xffffff (white).

readonly #
fontFamily?: string | FontAsset

Font family the text is drawn in. Accepts either a FontAsset — preloaded via AssetLibrary.load — whose FontAsset.family is read, or a raw CSS family string for system fonts ('monospace', 'Arial, sans-serif').

Defaults to 'sans-serif', which is the platform's default proportional family. Prefer passing a loaded FontAsset for any production text so the rendered output is deterministic across machines.

readonly #
fontSize?: number

Font size in pixels. Defaults to 16.

Note that this is the typographic size, not a width/height — scaling a Text by setting host.scale will resample the underlying texture and look soft. Choose a fontSize close to the size you actually want on screen, and leave the host's scale at (1, 1).

readonly #
layer?: Layer

The render layer this graphic draws in, as a Layer token from the world's LayerSet (e.g. layers.get('characters')).

Layers are opt-in per world. If the world was created with layers, this is required — omitting it throws ErrorCode.LAYER_UNSPECIFIED, since a layered world has no implicit default band. If the world has no layer set, this must be omitted — passing it throws ErrorCode.LAYER_SET_ABSENT. Change it later with AbstractGraphics.layer to move the graphic between bands.

readonly #
tint?: number

Multiplicative tint as a 24-bit RGB integer (e.g. 0xff0000 for red). 0xffffff (white) leaves colours unchanged. For Text this multiplies on top of the glyph TextOptions.fill. Defaults to 0xffffff.

readonly #
visible?: boolean

Whether the graphic is drawn at all. A hidden graphic still ticks and keeps its transform in sync; it is simply skipped by the renderer. Defaults to true.

ESC