text: public void applyFont(int startIndex, int endIndex, short fontIndex) {if (startIndex > endIndex)throw new IllegalArgumentException("Start index must be less than end index.");if (startIndex < 0 || endIndex > length())throw new IllegalArgumentException("Start and end index not in range.");if (startIndex == endIndex)return;short currentFont = NO_FONT;if (endIndex != length()) {currentFont = this.getFontAtIndex(endIndex);}_string = cloneStringIfRequired();Iterator<FormatRun> formatting = _string.formatIterator();if (formatting != null) {while (formatting.hasNext()) {FormatRun r = formatting.next();if ((r.getCharacterPos() >= startIndex) && (r.getCharacterPos() < endIndex))formatting.remove();}}_string.addFormatRun(new FormatRun((short)startIndex, fontIndex));if (endIndex != length())_string.addFormatRun(new FormatRun((short)endIndex, currentFont));addToSSTIfRequired();}