[
https://issues.apache.org/jira/browse/PDFBOX-691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Leleu updated PDFBOX-691:
------------------------------
Attachment: embedded-font.ttf
PDF_WITH_TRUETYPE_CMAP_FORMAT0.pdf
> 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.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira