// construct the reordered ACI
AttributedCharacterIterator aci = as.getIterator();
int numChars = aci.getEndIndex() - aci.getBeginIndex();
int[] charOrder = null;
if (numChars >= 3) {
char prevChar = aci.first();
char c = aci.next();
int i = 1;
for (char nextChar = aci.next();
nextChar != AttributedCharacterIterator.DONE;
prevChar = c, c = nextChar, nextChar = aci.next(), i++) {