Renderer · class

SdfTextLayout

Explained in Hello world.

class SdfTextLayout
import { SdfTextLayout } from '@driftengine/core';

Constructor

new

constructor()

Properties

NameTypeDescription
positionsreadonlyFloat32Array<ArrayBuffer>
uvsreadonlyFloat32Array<ArrayBuffer>
indicesreadonlyUint32Array<ArrayBuffer>
quadCountnumber
widthnumber
heightnumber

Methods

set

set(font: SdfFont, text: string, style: SdfTextStyle): boolean

Lay a string out. Returns whether anything moved, so a caller can skip the upload.

ParameterTypeDescription
fontSdfFont
textstring
styleSdfTextStyle
More

The key covers the style as well as the text, because a size change moves every vertex and a string that only compared its characters would keep the old geometry at the new size -- which reads as the wrong font rather than as a stale buffer.

A piece is one code point, unless the font carries a pre-shaped run that starts here, in which case it is that run and it draws as a single quad. See SdfFont.runs: the engine does no shaping, so a script that joins or reorders its letters has to arrive already shaped, as one cell.