You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Juraj Lonc (JIRA)" <ji...@apache.org> on 2012/09/10 10:38:08 UTC

[jira] [Created] (PDFBOX-1408) Width of space character is calculated wrong

Juraj Lonc created PDFBOX-1408:
----------------------------------

             Summary: Width of space character is calculated wrong
                 Key: PDFBOX-1408
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1408
             Project: PDFBox
          Issue Type: Bug
            Reporter: Juraj Lonc


PDFStreamEngine calculates width of space (line 357):

spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);

In some cases it the result is 0.
Problem is that getFontWidth requires code number of " ".

If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PDFBOX-1408) Width of space character is calculated wrong

Posted by "Juraj Lonc (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juraj Lonc updated PDFBOX-1408:
-------------------------------

    Attachment: PDFBOX-1408_PDFStreamEngine.patch

This is the "fast & ugly" fix.
It's just to show what I mean so the "pretty version" of this fix is up to you :)

Actually I am not sure PDFStreamEngine.java is the best place to put this fix in. Maybe the better place would be PDSimpleFont.getFontWidth
                
> Width of space character is calculated wrong
> --------------------------------------------
>
>                 Key: PDFBOX-1408
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1408
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Juraj Lonc
>         Attachments: makcene-export.pdf, PDFBOX-1408_PDFStreamEngine.patch
>
>
> PDFStreamEngine calculates width of space (line 357):
> spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);
> In some cases the result is 0.
> Problem is that getFontWidth requires code number of " ".
> If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PDFBOX-1408) Width of space character is calculated wrong

Posted by "Juraj Lonc (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juraj Lonc updated PDFBOX-1408:
-------------------------------

    Attachment: makcene-export.pdf

Attached file contains font with ToUnicode mapping.
That results to wrong calculation of space width.
                
> Width of space character is calculated wrong
> --------------------------------------------
>
>                 Key: PDFBOX-1408
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1408
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Juraj Lonc
>         Attachments: makcene-export.pdf
>
>
> PDFStreamEngine calculates width of space (line 357):
> spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);
> In some cases the result is 0.
> Problem is that getFontWidth requires code number of " ".
> If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (PDFBOX-1408) Width of space character is calculated wrong

Posted by "Juraj Lonc (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juraj Lonc updated PDFBOX-1408:
-------------------------------

    Description: 
PDFStreamEngine calculates width of space (line 357):

spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);

In some cases the result is 0.
Problem is that getFontWidth requires code number of " ".

If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

  was:
PDFStreamEngine calculates width of space (line 357):

spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);

In some cases it the result is 0.
Problem is that getFontWidth requires code number of " ".

If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

    
> Width of space character is calculated wrong
> --------------------------------------------
>
>                 Key: PDFBOX-1408
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1408
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Juraj Lonc
>
> PDFStreamEngine calculates width of space (line 357):
> spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);
> In some cases the result is 0.
> Problem is that getFontWidth requires code number of " ".
> If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (PDFBOX-1408) Width of space character is calculated wrong

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-1408.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8.0
         Assignee: Andreas Lehmkühler

I adapted Juraj proposal as follows:

- store the mapping for the space character within the CMap
- implemented a new method PDFont/PDSimpleFont#getSpaceWidth which determines the width using the ToUnicode map if present, otherwise the old method is used
- the average font width is used as fall back value

I added all that stuff in revisions 1398055,1398056 and 1398057

Thanks for the contribution
                
> Width of space character is calculated wrong
> --------------------------------------------
>
>                 Key: PDFBOX-1408
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1408
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Juraj Lonc
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.8.0
>
>         Attachments: makcene-export.pdf, PDFBOX-1408_PDFStreamEngine.patch
>
>
> PDFStreamEngine calculates width of space (line 357):
> spaceWidthText = (font.getFontWidth( SPACE_BYTES, 0, 1 )*glyphSpaceToTextSpaceFactor);
> In some cases the result is 0.
> Problem is that getFontWidth requires code number of " ".
> If there is "ToUnicode" mapping for that font that it is necessary to lookup CMap for code number and NOT to use 0x20 (space) as it is in souce code.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira