PdfChunk(Chunk chunk, PdfAction action) {
thisChunk[0] = this;
value = chunk.getContent();
Font f = chunk.getFont();
float size = f.getSize();
if (size == Font.UNDEFINED)
size = 12;
baseFont = f.getBaseFont();
int style = f.getStyle();
if (style == Font.UNDEFINED) {
style = Font.NORMAL;
}
if (baseFont == null) {
// translation of the font-family to a PDF font-family
baseFont = f.getCalculatedBaseFont(false);
}
else {
// bold simulation
if ((style & Font.BOLD) != 0)
attributes.put(Chunk.TEXTRENDERMODE, new Object[]{new Integer(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE), new Float(size / 30f), null});
// italic simulation
if ((style & Font.ITALIC) != 0)
attributes.put(Chunk.SKEW, new float[]{0, ITALIC_ANGLE});
}
font = new PdfFont(baseFont, size);
// other style possibilities
HashMap attr = chunk.getAttributes();
if (attr != null) {
for (Iterator i = attr.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
Object name = entry.getKey();
if (keysAttributes.containsKey(name)) {
attributes.put(name, entry.getValue());
}
else if (keysNoStroke.containsKey(name)) {
noStroke.put(name, entry.getValue());
}
}
if ("".equals(attr.get(Chunk.GENERICTAG))) {
attributes.put(Chunk.GENERICTAG, chunk.getContent());
}
}
if (f.isUnderlined()) {
Object obj[] = {null, new float[]{0, 1f / 15, 0, -1f / 3, 0}};
Object unders[][] = Utilities.addToArray((Object[][])attributes.get(Chunk.UNDERLINE), obj);
attributes.put(Chunk.UNDERLINE, unders);
}
if (f.isStrikethru()) {
Object obj[] = {null, new float[]{0, 1f / 15, 0, 1f / 3, 0}};
Object unders[][] = Utilities.addToArray((Object[][])attributes.get(Chunk.UNDERLINE), obj);
attributes.put(Chunk.UNDERLINE, unders);
}
if (action != null)
attributes.put(Chunk.ACTION, action);
// the color can't be stored in a PdfFont
noStroke.put(Chunk.COLOR, f.getColor());
noStroke.put(Chunk.ENCODING, font.getFont().getEncoding());
Object obj[] = (Object[])attributes.get(Chunk.IMAGE);
if (obj == null) {
image = null;
}