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.

Reply via email to