char textChr[] = text.toCharArray();
int nextEnd = f.canDisplayUpTo(textChr, start, end);
boolean isNextValid = nextEnd == start;
for (int last = start; nextEnd != -1 && nextEnd <= end; ) {
if (isNextValid) {
nextEnd = f.canDisplayUpTo(textChr, nextEnd, end);
isNextValid = false;
} else {
if (nextEnd >= end || f.canDisplay(Character.codePointAt(textChr, nextEnd, end)) ) {
at.addAttribute(TextAttribute.FAMILY, fallbackFont, last, Math.min(nextEnd,end));
if (nextEnd >= end) break;