You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2010/05/01 17:25:57 UTC

[jira] Resolved: (PDFBOX-696) PDTrueTypeFont limits number of glyph widths to 256. This can easily be removed.

     [ https://issues.apache.org/jira/browse/PDFBOX-696?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Resolution: Fixed

I've applied the patch with version 940001

Thanks to Michael for the contribution.

> PDTrueTypeFont limits number of glyph widths to 256. This can easily be removed.
> --------------------------------------------------------------------------------
>
>                 Key: PDFBOX-696
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-696
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing
>    Affects Versions: 1.1.0
>         Environment: Ubuntu Karmic
>            Reporter: Michael Berg
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.2.0
>
>
> Currently the support for fonts with exotic glyphs are limited at best. Making PDFBox render chinese characters has proved to be a bit of a pain ... :-)
> One blocker we ran into was the limitation of glyph widths to 256 individual widths. In PDTrueTypeFont.java, we find this in loadDescriptorDictionary():
>             int firstChar = 0;
>             int maxWidths=256;
>             HorizontalMetricsTable hMet = ttf.getHorizontalMetrics();
>             int[] widthValues = hMet.getAdvanceWidth();
>             List widths = new ArrayList(maxWidths);
> The "int maxWidths=256" affects the remaining code so glyph widths for codepoints larger than 256 are ignored. We found that there is no need to impose such a limitation, and that having it makes it impossible to generate a proper /W dictionary when generating a cidfonttype2. Simply replacing the hard coded value 256 with the following seems to be a perfectly usable solution:
>             int firstChar = 0;
>             //int maxWidths=256;  <---- No hard coded value
>             int maxWidths = glyphToCCode.length;            // <---- rather use the counted number of codepoints
>             HorizontalMetricsTable hMet = ttf.getHorizontalMetrics();
>             int[] widthValues = hMet.getAdvanceWidth();
>             List widths = new ArrayList(maxWidths);
>             Integer zero = new Integer( 250 );
> Is it possible to have this change added to 1.2.0?
> Also we would be more than happy to contribute some code that shows how you can use PDFBox to produce PDF's containing special characters (asian, chinese etc) by using codepoint-to-glyph mapping and copy-paste working (/tounicode). The code allows API users to simply use UTF-8 strings and not worry about any of the tricky font handling details.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.