Devanagari Universal Shaping Engine (USE) Syllable Reordering

Each character's Unicode Indic_Syllabic_Category/Indic_Positional_Category drives syllable classification and glyph reordering - the same shaping a browser applies, ported from HarfBuzz's own Universal Shaping Engine.

Pre-base vowel sign (matra) reordering

कि ("ki") - the vowel sign I is a pre-base matra: in the source text it follows the consonant it belongs to, but a real font expects it drawn before the consonant, so the shaped glyph list is reordered accordingly:

कि

Conjunct formation (cjct) with a pre-base matra

क्षि ("kṣi") - the two-consonant conjunct क्ष (KA+VIRAMA+SSA) fuses into a single glyph via the font's own cjct feature, and the following vowel sign still reorders to before the whole fused conjunct:

क्षि

Reph formation (rphf) and repositioning

र्कि ("rki") - a word-initial रँ (RA+VIRAMA) forms a reph via the font's own rphf feature, which the shaping engine then moves forward past the base consonant to sit beside the pre-base vowel sign - the font's own pres feature then fuses the repositioned reph with the vowel sign into one combined presentation glyph:

र्कि

Vowel modifiers (anusvara, visarga) - not reordered

कं (anusvara) and कः (visarga) attach after the base without any glyph reordering - only pre-base vowel signs move:

AnusvaraVisargaPost-base vowel (contrast)
कंकःका