-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draw Attributed text only supports Font, while Family/Weight/Posture is an alternate way. #51
Comments
Would you mind making a pull request with your changes? Sub- and superscript has likely to be emulated by creating a derived font and then adding some text matrix transformation to it. That could be tricky. As you might need to exit the text mode and enter it again. If you provide a pull request I'll can review this and try to get a release with this fix out soon. Otherwise it can take some time, as I'm rather busy at the moment. |
Looking at your test code, I would refer to the definition of TextAttribute and the use of Font: |
Looking at the images, the culprit seems to be the new function applyTextWidth, which calculates the new position based on the added text. Here I assumed a horizontal text in order to keep the baseline of the text (i.e. the subscript/superscript have an translation to move the text vertically, which is temporary, i.e. does not extend past the superscript text). This of course works fine if there is no other translation or rotation applied. |
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;
The text was updated successfully, but these errors were encountered: