Skip to content
pixi-silk
GitHub repository
Entry point

pixi-silk/text/bidi

The Unicode Bidirectional Algorithm (UAX #9) without Pixi: bidi classes, embedding levels and visual order.

import { bidiClass, hasRtl, mirror, paragraphLevel } from 'pixi-silk/text/bidi';

Type Aliases#

Type AliasDescription
BidiClassBidi character types used here (UAX #9 table 4, minus the explicit formatting types).
TextDirectionBase direction of a paragraph. auto takes it from the first strong character, left to right when there is none.

Functions#

FunctionDescription
bidiClassThe bidi type of one code point. Covers the common scripts. Anything unlisted is L, or ON for punctuation and symbols.
hasRtlTrue when the text holds a right-to-left character or a bidi control, so it needs the bidi pass.
mirrorL4: the mirrored form of a character drawn right to left, such as ) for (, or the character itself.
paragraphLevelParagraph level from the first strong type (P2, P3): 1 for R or AL, 0 for L or none. Text inside isolates is skipped.
resetWhitespaceL1 for one line: whitespace and isolate controls at the end of the line, and before tabs, fall back to the paragraph level. types are the original types of the line’s units. Changes levels in place.
resolveLevelsEmbedding levels of one paragraph, one per unit, in logical order (UAX #9 rules X1 to X10, W1 to W7, N0 to N2, I1 and I2). types are the original types. chars are the units’ text, used to pair brackets (N0). Even levels run left to right, odd ones right to left. Embedding controls and boundary neutrals take the level of the unit before them.
visualOrderL2: the visual order of a line as indices into levels, left to right.