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#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
font | readonly | FontTables | The font’s tables: outlines and vertical metrics. | packages/pixi-silk/src/i18n/kb/kb.ts:55 |
fontHash | readonly | string | 64-bit FNV-1a hash of the font file, 16 hex digits, as fontHash computes it. | packages/pixi-silk/src/i18n/kb/kb.ts:52 |
unitsPerEm | readonly | number | Units 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#
| Parameter | Type |
|---|---|
text | string |
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 |