protected Chunk getChunk(Map attributes, String text, Locale locale)
{
// underline and strikethrough are set on the chunk below
Font font = getFont(attributes, locale, false);
Chunk chunk = new Chunk(text, font);
if (hasUnderline(attributes))
{
// using the same values as sun.font.Fond2D
chunk.setUnderline(null, 0, 1f / 18, 0, -1f / 12, 0);
}
if (hasStrikethrough(attributes))
{
// using the same thickness as sun.font.Fond2D.
// the position is calculated in Fond2D based on the ascent, defaulting
// to iText default position which depends on the font size
chunk.setUnderline(null, 0, 1f / 18, 0, 1f / 3, 0);
}
Color backcolor = (Color)attributes.get(TextAttribute.BACKGROUND);
if (backcolor != null)
{
chunk.setBackground(backcolor);
}
Object script = attributes.get(TextAttribute.SUPERSCRIPT);
if (script != null)
{
if (TextAttribute.SUPERSCRIPT_SUPER.equals(script))
{
chunk.setTextRise(font.getCalculatedLeading(1f)/2);
}
else if (TextAttribute.SUPERSCRIPT_SUB.equals(script))
{
chunk.setTextRise(-font.getCalculatedLeading(1f)/2);
}
}
if (splitCharacter != null)
{
//TODO use line break offsets if available?
chunk.setSplitCharacter(splitCharacter);
}
return chunk;
}