-
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
PdfBoxGraphics2DFontTextDrawer.getFontMetrics always floors the width #35
Comments
MarkusDLN
changed the title
PdfBoxGraphics2DFontTextDrawer.getFontMetrics always floors the size
PdfBoxGraphics2DFontTextDrawer.getFontMetrics always floors the width
Apr 8, 2022
rototor
added a commit
that referenced
this issue
Apr 12, 2022
I just release version 0.37 with this fix. |
Thank you for your quick response and the new release. Much appreciated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran into an issue with the FontMetrics provided by the PdfBoxGraphics2DFontTextDrawer when using it for the method SwingUtilities.layoutCompoundLabel. The method tries to shorten the given text if necessary and add three dots at the end (...) to indicate that the original string was longer. To do this the method goes character by character until the available width is reached.
The issue now is that the FontMetrics always floors the width so that the sum of the width of the individual characters will always be (significantly) lower than the actual width of the string represented by these characters (for non monospaced fonts).
I think this should be rounded (like sun.font.FontDesignMetrics) by adding 0.5f before casting to an int.
The text was updated successfully, but these errors were encountered: