Skip to content
pixi-silk
GitHub repository
Class

KbShaper

import { KbShaper } from 'pixi-silk/i18n/shaper';

A RuntimeShaper for one TrueType font, backed by kb_text_shape compiled to WebAssembly (62 kB with brotli). It shapes Arabic, Hebrew, Latin and the other scripts kb_text_shape knows, with the bidi algorithm for mixed runs. Each shaper owns one WebAssembly instance and its memory.

Implements#

Properties#

PropertyModifierTypeDescriptionDefined in
fontreadonlyFontTablesThe font’s tables: outlines and vertical metrics.packages/pixi-silk/src/i18n/kb/kb.ts:55
fontHashreadonlystring64-bit FNV-1a hash of the font file, 16 hex digits, as fontHash computes it.packages/pixi-silk/src/i18n/kb/kb.ts:52
unitsPerEmreadonlynumberUnits per em of the font.packages/pixi-silk/src/i18n/kb/kb.ts:53

Methods#

shape()#

shape(text: string, options: {
  direction: "ltr" | "rtl" | "auto";
  features?: string[];
  language?: string;
  script?: string;
}): ShapedGlyphOut[];

Shapes text as one paragraph. Glyphs come in visual order with clusters as UTF-16 offsets. direction sets the paragraph direction. script, language and features are ignored: kb_text_shape picks the script from the text and applies the default features.

Parameters#

ParameterType
textstring
options{ direction: "ltr" | "rtl" | "auto"; features?: string[]; language?: string; script?: string; }
options.direction"ltr" | "rtl" | "auto"
options.features?string[]
options.language?string
options.script?string

Returns#

ShapedGlyphOut[]

Implementation of#

RuntimeShaper.shape