public void initData(TrueTypeFont ttf,
TTFDataStream data) throws IOException {
HeaderTable head = ttf.getHeader();
MaximumProfileTable maxp = ttf.getMaximumProfile();
int numGlyphs = maxp.getNumGlyphs();
offsets = new long[ numGlyphs +1];
for( int i=0; i< numGlyphs+1; i++ )
{
if( head.getIndexToLocFormat() == SHORT_OFFSETS )
{
offsets[i] = data.readUnsignedShort() * 2;
}
else if( head.getIndexToLocFormat() == LONG_OFFSETS )
{
offsets[i] = data.readUnsignedInt();
}
else
{
throw new IOException( "Error:TTF.loca unknown offset format.");
}
}
}
This will read the required data from the stream. |