InterfaceRenderTextOptions

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

interface RenderTextOptions {
    color?: number;
    features?: Record<string, number | boolean>;
    font: BinaryData | BinaryData[];
    hinting?: boolean;
    layout?: TextLayoutOptions | TextLayout;
    size: number;
    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: {}

TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every character comes from the first font that has it (e.g. [text, emoji]), the first one sets the line height. Color glyphs (COLR layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any script is shaped like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts, marks)

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

The text layout, as TextLayoutOptions or a TextLayout. Default: the defaults of TextLayout

size: number

Font size in pixels (per em)

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)