Skip to content
pixi-silk
GitHub repository
Entry point

pixi-silk/i18n/pixi

Draws baked localized text with PixiJS: Silk (bundles, atlas pages, themes), SilkMessage, and the silkBundleLoader for Assets. WebGL2 and WebGPU.

import { MessageGeometry, PageArraySource, PixiBackend, PixiStyleRows } from 'pixi-silk/i18n/pixi';

Classes#

ClassDescription
MessageGeometryThe geometry of a SilkMessage’s text buffer: one unit quad, and one instance (INSTANCE_FLOATS floats) per glyph or line. PixiBackend owns it. You rarely need it directly.
PageArraySourceEvery atlas page of a bundle in one 2D array texture, layer = page slot, so a bundle can draw from any number of pages in one draw call. Layers are as large as the largest page. Smaller pages sit at the top left of theirs, which the shader allows for (it samples in atlas pixels). Needs WebGL2 or WebGPU, and the uploaders installPageArrays adds to the renderer.
PixiBackendThe PixiJS SilkBackend (brief sec. 2.3): atlas pages as textures, style rows as a data texture, text buffers as instanced geometries, run sprites as one-glyph meshes drawn by the message shader. Silk drives it. The core never touches Pixi.
PixiStyleRowsStyle rows on the GPU: an RGBA32F texture, 8 texels per row and 64 rows per texture row, as packStyle packs them. The writeStyleRows part of SilkBackend, one per theme.
PreparedSetA set of prepared messages.
SilkBaked localized text for Pixi (brief sec. 6.1). Holds the bundles in use, their atlas pages and glyph metrics on the GPU, the inline objects and the dev update events. Create it once.
SilkMessageA prepared message on screen (brief sec. 6.1). Glyphs are instances of one mesh, drawn in one draw call. Updates take the cheapest tier that can serve them (sec. 6.3). set with a number of the same length rewrites only that slot’s glyphs (value-fast). Other values lay out again. A plural change swaps the baked variant. maxWidth, align, size and lineHeight lay out again without shaping. Tag taps on interactive styles arrive as tagtap. accessibleText holds the plain text with values filled in, for Pixi’s accessibility system.
SilkMessageLayerA container that draws the glyphs of its SilkMessage children together: one draw call per bundle and theme, however many messages (brief sec. 7, M6). The merged instances carry each message’s index, and a data texture carries each message’s transform and alpha, so moving a message costs no instance write. Messages stay normal children: position, rotate, scale, hide and tap them as usual. Inline objects and text slots still draw on their own.
SilkThemeA theme bound to its style-row texture. set changes a style at runtime: paint properties (colours, outline, glow, shadow, lines, weight bias) rewrite a few style rows and move no glyph. Shape-relevant properties (weight, size, family, letter spacing, features) cannot change baked text: a dev warning says to run silk compile again.

Interfaces#

InterfaceDescription
DynamicTextModeThe built-in dynamic text modes of SilkOptions.dynamicText.
DynamicTextProviderDraws a text slot’s value (the dynamic path, pixi-silk/i18n/canvas).
InlineObjectAn inline object, as Silk.registerInline takes it.
MessageSpecPer-message options of Silk.prepare.
PageLayerOne layer of a PageArraySource: an atlas page as decoded pixels.
PreparedMessageA message ready to show. Immutable and shared by every SilkMessage made from it.
PrepareOptionsOptions of Silk.prepare.
SilkOptionsOptions of Silk.create.
TagTapEventWhat a tagtap event carries.
TextSlotRenderA text slot to draw, as DynamicTextProvider.draw receives it. Sizes in local pixels.
UpdateEventWhat Silk.on reports for every update.

Type Aliases#

Type AliasDescription
UpdateTierThe update tiers of brief sec. 6.3, cheapest first.

Variables#

VariableDescription
silkBundleLoaderThe Pixi Assets loader for .silk bundles. Register it once with extensions.add(silkBundleLoader). Assets.load('/i18n/ar.silk') then returns a SilkBundle.

Functions#

FunctionDescription
installPageArraysAdds the page array uploaders to a renderer’s texture system. Returns false when the renderer cannot draw array textures (WebGL1), so the caller keeps binding pages one by one.
loadAtlasPageFetches and decodes one atlas page, without premultiplied alpha or colour conversion.