public void initData(TrueTypeFont ttf,
TTFDataStream data) throws IOException {
int formatSelector = data.readUnsignedShort();
int numberOfNameRecords = data.readUnsignedShort();
int offsetToStartOfStringStorage = data.readUnsignedShort();
for( int i=0; i< numberOfNameRecords; i++ )
{
NameRecord nr = new NameRecord();
nr.initData( ttf, data );
nameRecords.add( nr );
}
for( int i=0; i< numberOfNameRecords; i++ )
{
NameRecord nr = nameRecords.get( i );
data.seek( getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset() );
int platform = nr.getPlatformId();
int encoding = nr.getPlatformEncodingId();
String charset = "ISO-8859-1";
if( platform == 3 && encoding == 1 )
{
charset = "UTF-16";
}
else if( platform == 2 )
{
if( encoding == 0 )
{
charset = "US-ASCII";
}
else if( encoding == 1 )
{
//not sure is this is correct??
charset = "ISO-10646-1";
}
else if( encoding == 2 )
{
charset = "ISO-8859-1";
}
}
String string = data.readString( nr.getStringLength(), charset );
nr.setString( string );
}
}
This will read the required data from the stream. |