case ttcfTag:
buffer.getInt(); // skip TTC version ID
directoryCount = buffer.getInt();
if (fIndex >= directoryCount) {
throw new FontFormatException("Bad collection index");
}
fontIndex = fIndex;
buffer = readBlock(TTCHEADERSIZE+4*fIndex, 4);
headerOffset = buffer.getInt();
break;
case v1ttTag:
case trueTag:
case ottoTag:
break;
default:
throw new FontFormatException("Unsupported sfnt " +
getPublicFileName());
}
/* Now have the offset of this TT font (possibly within a TTC)
* After the TT version/scaler type field, is the short
* representing the number of tables in the table directory.
* The table directory begins at 12 bytes after the header.
* Each table entry is 16 bytes long (4 32-bit ints)
*/
buffer = readBlock(headerOffset+4, 2);
numTables = buffer.getShort();
directoryOffset = headerOffset+DIRECTORYHEADERSIZE;
ByteBuffer bbuffer = readBlock(directoryOffset,
numTables*DIRECTORYENTRYSIZE);
IntBuffer ibuffer = bbuffer.asIntBuffer();
DirectoryEntry table;
tableDirectory = new DirectoryEntry[numTables];
for (int i=0; i<numTables;i++) {
tableDirectory[i] = table = new DirectoryEntry();
table.tag = ibuffer.get();
/* checksum */ ibuffer.get();
table.offset = ibuffer.get();
table.length = ibuffer.get();
if (table.offset + table.length > fileSize) {
throw new FontFormatException("bad table, tag="+table.tag);
}
}
initNames();
} catch (Exception e) {
if (FontManager.logging) {
FontManager.logger.severe(e.toString());
}
if (e instanceof FontFormatException) {
throw (FontFormatException)e;
} else {
throw new FontFormatException(e.toString());
}
}
if (familyName == null || fullName == null) {
throw new FontFormatException("Font name not found");
}
/* The os2_Table is needed to gather some info, but we don't
* want to keep it around (as a field) so obtain it once and
* pass it to the code that needs it.
*/