// add parameters in case of styled text element
String plainText = styledText.getText();
int runLimit = 0;
AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
while (
runLimit < styledText.length()
&& (runLimit = iterator.getRunLimit()) <= styledText.length()
)
{
Map styledTextAttributes = iterator.getAttributes();
JRFont styleFont = new JRBaseFont(styledTextAttributes);
Color styleForeground = (Color) styledTextAttributes.get(TextAttribute.FOREGROUND);
Color styleBackground = (Color) styledTextAttributes.get(TextAttribute.BACKGROUND);
writer.write("\\f");
writer.write(String.valueOf(getFontIndex(styleFont, getTextLocale(text))));
writer.write("\\fs");
writer.write(String.valueOf(2 * styleFont.getFontSize()));
if (styleFont.isBold())
{
writer.write("\\b");
}
if (styleFont.isItalic())
{
writer.write("\\i");
}
if (styleFont.isUnderline())
{
writer.write("\\ul");
}
if (styleFont.isStrikeThrough())
{
writer.write("\\strike");
}
if (TextAttribute.SUPERSCRIPT_SUPER.equals(styledTextAttributes.get(TextAttribute.SUPERSCRIPT)))
{
writer.write("\\super");
}
else if (TextAttribute.SUPERSCRIPT_SUB.equals(styledTextAttributes.get(TextAttribute.SUPERSCRIPT)))
{
writer.write("\\sub");
}
if(!(null == styleBackground || styleBackground.equals(text.getBackcolor()))){
writer.write("\\highlight");
writer.write(String.valueOf(getColorIndex(styleBackground)));
}
writer.write("\\cf");
writer.write(String.valueOf(getColorIndex(styleForeground)));
writer.write(" ");
writer.write(
handleUnicodeText(
plainText.substring(iterator.getIndex(), runLimit)
)
);
// reset all styles in the paragraph
writer.write("\\plain");
iterator.setIndex(runLimit);
}
// if (startedHyperlink)
// {
// endHyperlink();
// }