Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Duplicate
-
1.0.0, 1.1.0
-
None
-
None
Description
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++ )
}
...
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++ )
}
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
Attachments
Attachments
Issue Links
- is part of
-
PDFBOX-668 TrueType Font - Feature for CMAPEncodingEntry
- Closed