protected final boolean checkTTC ( FontFileReader in , String name ) throws IOException { String tag = in . readTTFString ( 4 ) ; if ( "ttcf" . equals ( tag ) ) { // This is a TrueType Collection in . skip ( 4 ) ; // Read directory offsets int numDirectories = ( int ) in . readTTFULong ( ) ; // int numDirectories=in.readTTFUShort(); long [ ] dirOffsets = new long [ numDirectories ] ; for ( int i = 0 ; i < numDirectories ; i ++ ) { dirOffsets [ i ] = in . readTTFULong ( ) ; } log . info ( "This is a TrueType collection file with " + numDirectories + " fonts" ) ; log . info ( "Containing the following fonts: " ) ; // Read all the directories and name tables to check // If the font exists - this is a bit ugly, but... boolean found = false ; // Iterate through all name tables even if font // Is found, just to show all the names long dirTabOffset = 0 ; for ( int i = 0 ; ( i < numDirectories ) ; i ++ ) { in . seekSet ( dirOffsets [ i ] ) ; readDirTabs ( in ) ; readName ( in ) ; if ( fullName . equals ( name ) ) { found = true ; dirTabOffset = dirOffsets [ i ] ; log . info ( fullName + " <-- selected" ) ; } else { log . info ( fullName ) ; } // Reset names notice = "" ; fullName = "" ; familyName = "" ; fontName = "" ; subFamilyName = "" ; } in . seekSet ( dirTabOffset ) ; return found ; } else { in . seekSet ( 0 ) ; return true ; } }
Check if this is a TrueType collection and that the given name exists in the collection . If it does set offset in fontfile to the beginning of the Table Directory for that font .