private float addToCache (CharSequence str, float x, float y, int start, int end) {
float startX = x;
BitmapFont font = this.font;
Glyph lastGlyph = null;
BitmapFontData data = font.data;
if (data.scaleX == 1 && data.scaleY == 1) {
while (start < end) {
char ch = str.charAt(start++);
if (ch == '[' && font.markupEnabled) {
if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
start += parseAndSetColor(str, start, end) + 1;
continue;
}
start++;
}
lastGlyph = data.getGlyph(ch);
if (lastGlyph != null) {
addGlyph(lastGlyph, x + lastGlyph.xoffset, y + lastGlyph.yoffset, lastGlyph.width, lastGlyph.height);
x += lastGlyph.xadvance;
break;
}
}
while (start < end) {
char ch = str.charAt(start++);
if (ch == '[' && font.markupEnabled) {
if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
start += parseAndSetColor(str, start, end) + 1;
continue;
}
start++;
}
Glyph g = data.getGlyph(ch);
if (g != null) {
x += lastGlyph.getKerning(ch);
lastGlyph = g;
addGlyph(lastGlyph, x + g.xoffset, y + g.yoffset, g.width, g.height);
x += g.xadvance;
}
}
} else {
float scaleX = data.scaleX, scaleY = data.scaleY;
while (start < end) {
char ch = str.charAt(start++);
if (ch == '[' && font.markupEnabled) {
if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
start += parseAndSetColor(str, start, end) + 1;
continue;
}
start++;
}
lastGlyph = data.getGlyph(ch);
if (lastGlyph != null) {
addGlyph(lastGlyph, //
x + lastGlyph.xoffset * scaleX, //
y + lastGlyph.yoffset * scaleY, //
lastGlyph.width * scaleX, //
lastGlyph.height * scaleY);
x += lastGlyph.xadvance * scaleX;
break;
}
}
while (start < end) {
char ch = str.charAt(start++);
if (ch == '[' && font.markupEnabled) {
if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
start += parseAndSetColor(str, start, end) + 1;
continue;
}
start++;
}
Glyph g = data.getGlyph(ch);
if (g != null) {
x += lastGlyph.getKerning(ch) * scaleX;
lastGlyph = g;
addGlyph(lastGlyph, //
x + g.xoffset * scaleX, //