1 31 package org.pdfbox.ttf; 32 33 import java.io.IOException ; 34 35 import java.util.ArrayList ; 36 import java.util.List ; 37 38 44 public class NamingTable extends TTFTable 45 { 46 49 public static final String TAG = "name"; 50 51 private List nameRecords = new ArrayList (); 52 53 60 public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException 61 { 62 int formatSelector = data.readUnsignedShort(); 63 int numberOfNameRecords = data.readUnsignedShort(); 64 int offsetToStartOfStringStorage = data.readUnsignedShort(); 65 for( int i=0; i< numberOfNameRecords; i++ ) 66 { 67 NameRecord nr = new NameRecord(); 68 nr.initData( ttf, data ); 69 nameRecords.add( nr ); 70 } 71 for( int i=0; i<numberOfNameRecords; i++ ) 72 { 73 NameRecord nr = (NameRecord)nameRecords.get( i ); 74 data.seek( getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset() ); 75 int platform = nr.getPlatformId(); 76 int encoding = nr.getPlatformEncodingId(); 77 String charset = "ISO-8859-1"; 78 if( platform == 3 && encoding == 1 ) 79 { 80 charset = "UTF-16"; 81 } 82 else if( platform == 2 ) 83 { 84 if( encoding == 0 ) 85 { 86 charset = "US-ASCII"; 87 } 88 else if( encoding == 1 ) 89 { 90 charset = "ISO-10646-1"; 92 } 93 else if( encoding == 2 ) 94 { 95 charset = "ISO-8859-1"; 96 } 97 } 98 String string = data.readString( nr.getStringLength(), charset ); 99 nr.setString( string ); 100 } 101 } 102 103 108 public List getNameRecords() 109 { 110 return nameRecords; 111 } 112 } 113 | Popular Tags |