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/09 17:30:48 UTC

[jira] Resolved: (PDFBOX-691) TrueTypeParser : Error on CMapEntry with the subtype0 ?

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

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

    Resolution: Duplicate

The provided patch is part of PDFBOX-668 and was committed with version 942539

> TrueTypeParser : Error on CMapEntry with the subtype0 ?
> -------------------------------------------------------
>
>                 Key: PDFBOX-691
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-691
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.0.0, 1.1.0
>            Reporter: Eric Leleu
>            Priority: Minor
>         Attachments: embedded-font.ttf, PDF_WITH_TRUETYPE_CMAP_FORMAT0.pdf
>
>
> Hi,
> I'm encountering a problem using the TrueType Font parser.
> I think the glyphIToCharacterCode isn't correctly initialized with a TrueType character mapping table Format 0.
> According to the TrueType specification, the glyphMapping array should be "An array that maps character codes to glyph index values".
> However, the current implementation sees the glyphMapping as an array that maps glyph index values to  character codes.
> Here is the current implementation : 
>     public void initSubtable( TrueTypeFont ttf, TTFDataStream data ) throws IOException
>     {
>         data.seek( ttf.getCMAP().getOffset() + subTableOffset );
>         int subtableFormat = data.readUnsignedShort();
>         int length = data.readUnsignedShort();
>         int version = data.readUnsignedShort();
>         int numGlyphs = ttf.getMaximumProfile().getNumGlyphs();
>         if( subtableFormat == 0 )
>         {
>             byte[] glyphMapping = data.read( 256 );
>             glyphIdToCharacterCode = new int[256];
>             for( int i=0;i < glyphMapping.length; i++ )
>             {
>                 glyphIdToCharacterCode[i]=(glyphMapping[i]+256)%256;
>             }
>         }
> ...
> I think it should be : 
>     public void initSubtable( TrueTypeFont ttf, TTFDataStream data ) throws IOException
>     {
>         data.seek( ttf.getCMAP().getOffset() + subTableOffset );
>         int subtableFormat = data.readUnsignedShort();
>         int length = data.readUnsignedShort();
>         int version = data.readUnsignedShort();
>         int numGlyphs = ttf.getMaximumProfile().getNumGlyphs();
>         if( subtableFormat == 0 )
>         {
>             byte[] glyphMapping = data.read( 256 );
>             glyphIdToCharacterCode = new int[256];
>             for( int i=0;i < glyphMapping.length; i++ )
>             {
>             	int glyphIndex = (glyphMapping[i]+256)%256;
>                 glyphIdToCharacterCode[glyphIndex]=i;
>             }
>         }
> In attachment, you can find a PDF which uses a TrueType font with a character mapping table Format 0 and the Font Program. (it is a subset)
> Regards,
> Eric

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