-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Alternate code in PdfBoxGraphics2DFontTextDrawer.java, start line 314.
If FONT attribute is provided that overrides,
otherwise use FAMILY/WEIGHT/POSTURE to create a Font if provided.
```
boolean wasAttributeFont = true;
Font attributeFont = (Font) iterator.getAttribute(TextAttribute.FONT);
if (attributeFont == null) {
attributeFont = env.getFont();
String family = (String) iterator.getAttribute(TextAttribute.FAMILY);
if (family != null) {
int defSize = attributeFont.getSize();
int style = Font.PLAIN;
Number fontSize = ((Number) iterator.getAttribute(TextAttribute.SIZE));
if (fontSize != null) {
defSize = (int)fontSize.floatValue();
}
Float weight = (Float) iterator.getAttribute(TextAttribute.WEIGHT);
if (weight != null && weight > 1.5) {
// weight can have many values, TextAttribute.WEIGHT_BOLD = 2.0
// There may be fonts where the font itself expresses weight
style |=Font.BOLD;
}
Float posture = (Float) iterator.getAttribute(TextAttribute.POSTURE);
if (posture != null && TextAttribute.POSTURE_OBLIQUE.equals(posture)) {
style |= Font.ITALIC;
}
attributeFont = new Font(family, style, defSize);
} else {
wasAttributeFont = false;
}
}
PDFont font = applyFont(attributeFont, env);
Metadata
Metadata
Assignees
Labels
No labels