Interface TextOptions

Options of Image.renderText: the text color and layout, and its style (see TextStyle)

interface TextOptions {
    color?: number;
    features?: Record<string, number | boolean>;
    hinting?: boolean;
    layout?: TextLayout;
    strokeColor?: number;
    strokeWidth?: number;
    variations?: Record<string, number | boolean>;
}

Hierarchy (View Summary)

Properties

color?: number

The text color. Default: 0xffffffff

features?: Record<string, number | boolean>

OpenType features by their tags, for the whole text: true turns one on (like tnum for tabular numbers, smcp for small caps, ss01 for a stylistic set), false off (also the ones on by default, like liga or kern), a number picks an alternate (salt: 2). Fonts without a feature ignore it. Default: {}

hinting?: boolean

Whether to run the hinting instructions of TrueType fonts, which align stems and edges with the pixel grid for crisper text at small sizes (like Windows renders text); the glyphs of hinted fonts are then placed on whole pixels. Fonts without instructions (and CFF/OpenType outlines) aren't affected. Default: true

layout?: TextLayout

The text layout. Default: new TextLayout()

strokeColor?: number

Color of the outline. Default: 0x000000ff

strokeWidth?: number

Width of an outline around the glyphs in pixels. Default: 0

variations?: Record<string, number | boolean>

The instance of variable fonts, by their axes: weight (1-1000, like CSS's font-weight: 400 regular, 700 bold), width (percent of the normal width: 75 condensed, 125 expanded), slant (degrees, negative leans right), italic (true/false), opticalSize (the size the glyphs are designed for, in pixels; default: the font size, like browsers' font-optical-sizing: auto), and other axes by their 4-character tag (like Roboto Flex's GRAD: 50). Values outside an axis's range are clamped, axes a font doesn't have are ignored, fonts without axes aren't affected. Default: {} (the fonts' default instances)