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):
D is reordered to the position immediately
B, then HarfBuzz merges the
D clusters — all the clusters between
the final position of the reordered glyph and its original
position. This means that we get:
as the final cluster sequence.
Merging this many clusters is not ideal, but it is the only sensible way for HarfBuzz to maintain the guarantee that the sequence of cluster values remains monotonic and to retain the true relationship between glyphs and characters.