Skip to content
pixi-silk
GitHub repository
Function

createCanvasText

import { createCanvasText } from 'pixi-silk/i18n/canvas';
function createCanvasText(options?: CanvasTextOptions): Promise<CanvasTextProvider>;

The canvas path for text slots (brief sec. 6.5). The browser shapes and orders the value with Canvas2D fillText. A distance transform turns it into a single-channel SDF “run sprite”, which a SilkBackend draws as one glyph, so outline, glow and shadow of the slot’s style apply. Colour emoji cannot be distance fields: they are drawn as a bitmap sprite on top, without outline or glow. One style per slot.

Pass the result as dynamicText to Silk.create, or pass { mode: 'canvas' } there to load this module only when a message has a text slot.

Parameters#

ParameterType
optionsCanvasTextOptions

Returns#

Promise<CanvasTextProvider>