internal PdfChunk(Chunk chunk, PdfAction action)
{
thisChunk[0] = this;
value = chunk.Content;
Font f = chunk.Font;
float size = f.Size;
if (size == iTextSharp.text.Font.UNDEFINED)
size = 12;
baseFont = f.BaseFont;
BaseFont bf = f.BaseFont;
int style = f.Style;
if (style == iTextSharp.text.Font.UNDEFINED) {
style = iTextSharp.text.Font.NORMAL;
}
if (baseFont == null) {
// translation of the font-family to a PDF font-family
baseFont = f.GetCalculatedBaseFont(false);
}
else{
// bold simulation
if ((style & iTextSharp.text.Font.BOLD) != 0)
attributes[Chunk.TEXTRENDERMODE] = new Object[]{PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null};
// italic simulation
if ((style & iTextSharp.text.Font.ITALIC) != 0)
attributes[Chunk.SKEW] = new float[]{0, ITALIC_ANGLE};
}
font = new PdfFont(baseFont, size);
// other style possibilities
Dictionary<string,object> attr = chunk.Attributes;
if (attr != null) {
foreach (KeyValuePair<string,object> entry in attr) {
string name = entry.Key;
if (keysAttributes.ContainsKey(name)) {
attributes[name] = entry.Value;
}
else if (keysNoStroke.ContainsKey(name)) {
noStroke[name] = entry.Value;
}
}
if (attr.ContainsKey(Chunk.GENERICTAG) && "".Equals(attr[Chunk.GENERICTAG])) {
attributes[Chunk.GENERICTAG] = chunk.Content;
}
}
if (f.IsUnderlined()) {
Object[] obj = {null, new float[]{0, 1f / 15, 0, -1f / 3, 0}};
Object[][] obja = null;
if (attributes.ContainsKey(Chunk.UNDERLINE))
obja = (Object[][])attributes[Chunk.UNDERLINE];
Object[][] unders = Utilities.AddToArray(obja, obj);
attributes[Chunk.UNDERLINE] = unders;
}
if (f.IsStrikethru()) {
Object[] obj = {null, new float[]{0, 1f / 15, 0, 1f / 3, 0}};
Object[][] obja = null;
if (attributes.ContainsKey(Chunk.UNDERLINE))
obja = (Object[][])attributes[Chunk.UNDERLINE];
Object[][] unders = Utilities.AddToArray(obja, obj);
attributes[Chunk.UNDERLINE] = unders;
}
if (action != null)
attributes[Chunk.ACTION] = action;
// the color can't be stored in a PdfFont
noStroke[Chunk.COLOR] = f.Color;
noStroke[Chunk.ENCODING] = font.Font.Encoding;
Object lh;
if (attributes.TryGetValue(Chunk.LINEHEIGHT, out lh)) {
changeLeading = true;
leading = (float)lh;
}
Object[] obj2 = null;
if (attributes.ContainsKey(Chunk.IMAGE))
obj2 = (Object[])attributes[Chunk.IMAGE];
if (obj2 == null)
image = null;
else {
attributes.Remove(Chunk.HSCALE); // images are scaled in other ways
image = (Image)obj2[0];
offsetX = ((float)obj2[1]);
offsetY = ((float)obj2[2]);
changeLeading = (bool)obj2[3];
}
font.Image = image;
object hs;
attributes.TryGetValue(Chunk.HSCALE, out hs);
if (hs != null)
font.HorizontalScaling = (float)hs;
encoding = font.Font.Encoding;
if (noStroke.ContainsKey(Chunk.SPLITCHARACTER))
splitCharacter = (ISplitCharacter)noStroke[Chunk.SPLITCHARACTER];
else
splitCharacter = DefaultSplitCharacter.DEFAULT;
}