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 the position immediately
before B
, then HarfBuzz merges the
B
, C
, and
D
clusters — all the clusters between
the final position of the reordered glyph and its original
position. This means that we get:
A,D,B,C,E 0,1,1,1,4
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.