tagStatus = TagStatus.NONE;
// interpret tag:
// BOLD
if ("b".equalsIgnoreCase(currTagText)) {
// start a new bold span
buildingSpans.add(new StyleSpan(StyleConstants.KEY_BOLD, Boolean.TRUE, index, 0));
} else if ("/b".equalsIgnoreCase(currTagText)) {
// find last BOLD entry and add length
endSpan(StyleConstants.KEY_BOLD, store, index, buildingSpans);
}
// ITALICS
else if ("i".equalsIgnoreCase(currTagText)) {
// start a new italics span
buildingSpans.add(new StyleSpan(StyleConstants.KEY_ITALICS, Boolean.TRUE, index, 0));
} else if ("/i".equalsIgnoreCase(currTagText)) {
// find last ITALICS entry and add length
endSpan(StyleConstants.KEY_ITALICS, store, index, buildingSpans);
}
// COLOR
else if (currTagText.toLowerCase().startsWith("c=")) {
// start a new color span
try {
// parse a color
final String c = currTagText.substring(2);
buildingSpans.add(new StyleSpan(StyleConstants.KEY_COLOR, ColorRGBA.parseColor(c, null), index,
0));
} catch (final Exception e) {
e.printStackTrace();
}
} else if ("/c".equalsIgnoreCase(currTagText)) {
// find last BOLD entry and add length
endSpan(StyleConstants.KEY_COLOR, store, index, buildingSpans);
}
// SIZE
else if (currTagText.toLowerCase().startsWith("size=")) {
// start a new size span
try {
// parse a size
final int i = Integer.parseInt(currTagText.substring(5));
buildingSpans.add(new StyleSpan(StyleConstants.KEY_SIZE, i, index, 0));
} catch (final Exception e) {
e.printStackTrace();
}
} else if ("/size".equalsIgnoreCase(currTagText)) {
// find last SIZE entry and add length
endSpan(StyleConstants.KEY_SIZE, store, index, buildingSpans);
}
// FAMILY
else if (currTagText.toLowerCase().startsWith("f=")) {
// start a new family span
final String family = currTagText.substring(2);
buildingSpans.add(new StyleSpan(StyleConstants.KEY_FAMILY, family, index, 0));
} else if ("/f".equalsIgnoreCase(currTagText)) {
// find last FAMILY entry and add length
endSpan(StyleConstants.KEY_FAMILY, store, index, buildingSpans);
} else {
// not really a tag, so put it back.
rVal.append('[');
rVal.append(currTagText);
rVal.append(']');
tagStatus = TagStatus.NONE;
}
currTagText = "";
continue;
}
// anything else
rVal.append(token);
index += token.length();
}
// close any remaining open tags
while (!buildingSpans.isEmpty()) {
final StyleSpan span = buildingSpans.getLast();
endSpan(span.getStyle(), store, index, buildingSpans);
}
// return plain text
return rVal.toString();
}