[ https://issues.apache.org/jira/browse/PDFBOX-5784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17825928#comment-17825928 ]
Tilman Hausherr edited comment on PDFBOX-5784 at 3/13/24 7:44 AM: ------------------------------------------------------------------ What I meant is that even if we replace FONTSCALE with the actual value, i.e. 2048 here, the result is still wrong in this code line: {code:java} float currCharWidth = font.getStringWidth(combString) / FONTSCALE * fontSize/2; {code} Here replacing it would be almost as if dividing by 2 once more, however the SO person removed "/2" i.e. multiplied by 2. Maybe we need to do similar, i.e. multiplying by (UnitsPerEm / FONTSCALE). {{getStringWidth}} uses 1000, I couldn't find in the code that it does any adjustment, which means that its value would be too small. was (Author: tilman): What I meant is that even if we replace FONTSCALE with the actual value, i.e. 2048 here, the result is still wrong in this code line: {code:java} float currCharWidth = font.getStringWidth(combString) / FONTSCALE * fontSize/2; {code} Here replacing it would be almost as if dividing by 2 once more, however the SO person removed "/2" i.e. multiplied by 2. Maybe we need to do the opposite, i.e. multiplying by (UnitsPerEm / FONTSCALE). {{getStringWidth}} uses 1000, I couldn't find in the code that it does any adjustment, which means that its value would be too small. > AppearanceGeneratorHelper assumes fontscale 1000 > ------------------------------------------------ > > Key: PDFBOX-5784 > URL: https://issues.apache.org/jira/browse/PDFBOX-5784 > Project: PDFBox > Issue Type: Bug > Components: AcroForm > Reporter: Tilman Hausherr > Assignee: Maruan Sahyoun > Priority: Major > Attachments: screenshot-1.png, with_dividing_by_2.pdf, > without_dividing.pdf > > > The user in the attached SO question noticed that the comb adjustment needed > a factor of 2 to work correctly. A look at the font shows UnitsPerEm = 2048. > Sample code: > {code:java} > doc.getDocumentCatalog().getAcroForm().getField("field1").setValue("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"); > doc.getDocumentCatalog().getAcroForm().getField("field2").setValue("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"); > {code} > !screenshot-1.png! -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org