The shaper path for text slots: kb_text_shape in WebAssembly (62 kB brotli) shapes player names with the font the bundle was baked from, drawn as a distance-field run sprite. TrueType fonts only.
import { KbShaper, ShapedTextProvider, createKbShaper, createShapedText } from 'pixi-silk/i18n/shaper';
Classes#
| Class | Description |
|---|
| KbShaper | 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. |
| ShapedTextProvider | The text slot provider createShapedText returns. |
Interfaces#
Type Aliases#
| Type Alias | Description |
|---|
| Contour | One closed contour as a polyline: quadratic curves are flattened. |
| KbWasmSource | Where the kb_text_shape WebAssembly module comes from: its bytes, a compiled module or a URL. |
Functions#
| Function | Description |
|---|
| createKbShaper | Loads kb_text_shape and a TrueType font into a KbShaper. |
| createShapedText | The shaper path for text slots (brief sec. 6.5, shaper mode). kb_text_shape shapes the value with the font the bundle was baked from, the outlines are filled in JavaScript and a distance transform turns them into a run sprite. Slots then match the baked text in font, shaping and metrics on every platform, with no canvas. Pass the result as dynamicText to Silk.create. |
| fillContours | Fills polygons into a coverage bitmap with exact area anti-aliasing: each edge adds its signed area to an accumulation buffer, and a running sum gives the coverage. Overlapping contours of the same direction (variable fonts) clamp to full coverage. Coordinates are in pixels, y down. |
| readFont | pixi-silk/i18n/shaper: draws text slots (player names) with the font a bundle was baked from. kb_text_shape in WebAssembly shapes the value. The TrueType outlines are filled in JavaScript, and a distance transform turns them into a run sprite. Pass await createShapedText({ font }) as dynamicText to Silk.create. The kb.wasm file is fetched next to this module. |