[ 
https://issues.apache.org/jira/browse/PDFBOX-3457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15584645#comment-15584645
 ] 

John Hewson edited comment on PDFBOX-3457 at 10/18/16 6:47 AM:
---------------------------------------------------------------

Ok, so having eliminated the gs-bugzilla693663-p9.pdf file, we're left with two 
PDFs, PDFJS-7523.pdf and PDFJS-5550-2.pdf. I see something in common between 
them: the problematic fonts are both standard 14.

Looking back at PDFBOX-870 and the files which Tilman linked to above, none of 
the fonts which we (correctly) stretch are standard 14. Which makes me think 
that the solution to this issue is to not stretch a font if it is standard 14. 
After all, the PDF spec already defines the AFM widths for these fonts, and 
requires the /Widths in any embedded fonts to match. This change in PageDrawer 
brings the desired effect:

{code}
// stretch non-embedded glyph if it does not match the width contained in the 
PDF
if (!font.isEmbedded() && !font.isStandard14())
{
   ...
{code}

I'll let Tilman try it out on his test suite.


was (Author: jahewson):
Ok, so having eliminated the gs-bugzilla693663-p9.pdf file, we're left with two 
PDFs, PDFJS-7523.pdf and PDFJS-5550-2.pdf. I see something in common between 
them: the problematic fonts are both standard 14.

Looking back at PDFBOX-870 and the files which Tilman linked to above, none of 
the fonts which we stretch are standard 14. Which makes me think that the 
solution to this issue is to not stretch a font if it is standard 14. After 
all, the PDF spec already defines the AFM widths for these fonts, and requires 
the /Widths in any embedded fonts to match. This change in PageDrawer brings 
the desired effect:

{code}
// stretch non-embedded glyph if it does not match the width contained in the 
PDF
if (!font.isEmbedded() && !font.isStandard14())
{
   ...
{code}

I'll let Tilman try it out on his test suite.

> Glyphs rendered in wrong width
> ------------------------------
>
>                 Key: PDFBOX-3457
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3457
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.2, 2.0.3, 2.1.0
>            Reporter: Tilman Hausherr
>         Attachments: PDFJS-5550.pdf, PDFJS-7523.pdf, 
> gs-bugzilla693663-p9.pdf, overlapping.png
>
>
> Fonts rendered in wrong size. The cause is related to wrong values in the 
> /WIDTHS table and this code in PageDrawer:
> {code}
>             // stretch non-embedded glyph if it does not match the width 
> contained in the PDF
>             if (!font.isEmbedded())
>             {
>                 float fontWidth = font.getWidthFromFont(code);
>                 if (fontWidth > 0 && // ignore spaces
>                         Math.abs(fontWidth - displacement.getX() * 1000) > 
> 0.0001)
>                 {
>                     float pdfWidth = displacement.getX() * 1000;
>                     at.scale(pdfWidth / fontWidth, 1);
>                 }
>             }
> {code}
> I suspect that there must be another condition to skip the stretching, but I 
> didn't find out which one.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to