Reordering in levels 0 and 1: HarfBuzz Manual

## Reordering in levels 0 and 1

Another common operation in the more complex shapers is glyph reordering. In order to maintain a monotonic cluster sequence when glyph reordering takes place, HarfBuzz merges the clusters of everything in the reordering sequence.

For example, let us again start with the character sequence (top row) and initial cluster values (bottom row):

          A,B,C,D,E
          0,1,2,3,4

If `D` is reordered to before `B`, then HarfBuzz merges the `B`, `C`, and `D` clusters, and we get:

          A,D,B,C,E
          0,1,1,1,4

This is clearly not ideal, but it is the only sensible way to maintain a monotonic sequence of cluster values and retain the true relationship between glyphs and characters.