Skip to content
pixi-silk
GitHub repository
Function

clusters

import { clusters } from 'pixi-silk/text';
function clusters(text: string, wordBreak?: WordBreak): Cluster[];

Splits a paragraph into the clusters layoutText measures and draws, in reading order.

  • Plain text (Latin, Greek, Cyrillic, Chinese, Japanese, Korean) is one cluster per code point.
  • A character with its marks, an emoji with its modifiers and joiners, and a flag are one cluster.
  • Letters of a cursive script (Arabic, Syriac) stay together while they join, so Canvas shapes the run. A run breaks after a letter that does not join forward.
  • A word of a script that needs shaping (Burmese, Thai, Khmer, Lao, Tibetan, the Indic scripts and Sinhala) is one cluster. Vowels written before their consonant and stacked consonants then come out right.

breakBefore marks where a line may break without a space. That is between Chinese and Japanese characters and Korean syllables unless wordBreak is keep-all, never before closing punctuation or small kana, never after opening brackets. It is also between words of Thai, Lao, Khmer and Burmese.

Parameters#

ParameterTypeDefault value
textstringundefined
wordBreakWordBreak'normal'

Returns#

Cluster[]