do
{
measuredState = prevMeasuredState.cloneState();
String text = lineText.substring(0, linePosition) + truncateSuffx;
AttributedString attributedText = new AttributedString(text);
//set original attributes for the text part
AttributedCharacterIterator lineAttributes =
new AttributedString(
allParagraphs,
measuredState.textOffset,
measuredState.textOffset + linePosition
).getIterator();
setAttributes(attributedText, lineAttributes, 0);
//set global attributes for the suffix part
setAttributes(
attributedText,
globalAttributes,
text.length() - truncateSuffx.length(),
text.length()
);
AttributedCharacterIterator lineParagraph = attributedText.getIterator();
BreakIterator breakIterator =
isToTruncateAtChar()
? BreakIterator.getCharacterInstance()
: BreakIterator.getLineInstance();