Oops,
I must apologize. The problem I was describing is already fixed in the head
revision of fontbox trunk. I was on an older state.
Sorry again,
Petr.
-----Původní zpráva-----
From: Timo Boehme
Sent: Thursday, January 30, 2014 1:26 PM
To: dev@pdfbox.apache.org
Subject: Re: Bug in GlyphTable
Hi Petr,
thank you for finding this problem and providing a solution.
Could you please open a bug report issue for this on
https://issues.apache.org/jira/browse/PDFBOX
and providing information if the issue is in PDFBOX trunk or another
version?
Ideally you could provide your solution as patch against PDFBOX trunk.
Thanks,
Timo
Am 30.01.2014 11:34, schrieb Petr Slabý:
Hi,
according to
https://developer.apple.com/fonts/TTRefMan/RM06/Chap6loca.html, the “loca”
table is supposed to contain glyphcount+1 offset. If an index of a glyph
is the same as the offset of the previous one, the glyph has no data (does
not exist in the font). The code of initData() in GlyphTable expects that
each glyph is defined and with a table of offset such as
[0,86,.....,86,172,172,....172] ends up in nirvana. There is no glyph at
the offset 172 and trying to read it there fails.
The code of initData should therefore be something like:
public void initData( TrueTypeFont ttf, TTFDataStream data ) throws
IOException
{
MaximumProfileTable maxp = ttf.getMaximumProfile();
IndexToLocationTable loc = ttf.getIndexToLocation();
long[] offsets = loc.getOffsets();
int numGlyphs = maxp.getNumGlyphs();
glyphs = new GlyphData[numGlyphs];
GlyphData glyph = null;
for( int i=0; i<numGlyphs-1; i++ )
{
long ofs = offsets[i];
long size = offsets[i+1] - ofs;
if(size > 0) {
glyph = new GlyphData();
data.seek( getOffset() + ofs );
glyph.initData( ttf, data );
glyphs[i] = glyph;
}
else {
glyphs[i] = EMPTY_GLYPH;
}
}
}
EMPTY_GLYPH is a constant initialized with an empty GlyfSimpleDescript.
--
Timo Boehme
OntoChem GmbH
H.-Damerow-Str. 4
06120 Halle/Saale
T: +49 345 4780474
F: +49 345 4780471
timo.boe...@ontochem.com
_____________________________________________________________________
OntoChem GmbH
Geschäftsführer: Dr. Lutz Weber
Sitz: Halle / Saale
Registergericht: Stendal
Registernummer: HRB 215461
_____________________________________________________________________