Skip to content

vyaz-monorepo / core/src / shapeRun

Function: shapeRun() ​

shapeRun(font, text, opts?): ShapedRun

Defined in: core/src/measure/FontEngine.ts:239

Shape text through fontkit's OpenType layout engine — the same GPOS kerning and GSUB substitutions (liga, clig, calt, ccmp) a browser applies by default. Use this instead of summing getGlyphAdvance when the measured width has to line up with what the browser will actually paint.

Widths are in font units; multiply by fontSize / unitsPerEm.

Parameters ​

font ​

FontFace

text ​

string

opts? ​

features? ​

Record<string, boolean>

OpenType feature overrides, e.g. { liga: false } to emulate text-rendering: optimizeSpeed. Omit for browser-default behaviour.

language? ​

string

script? ​

string

Returns ​

ShapedRun

Released under the MIT License.