1 18 package org.apache.batik.svggen.font.table; 19 20 import java.io.IOException ; 21 import java.io.RandomAccessFile ; 22 23 27 public class NameRecord { 28 29 private short platformId; 30 private short encodingId; 31 private short languageId; 32 private short nameId; 33 private short stringLength; 34 private short stringOffset; 35 private String record; 36 37 protected NameRecord(RandomAccessFile raf) throws IOException { 38 platformId = raf.readShort(); 39 encodingId = raf.readShort(); 40 languageId = raf.readShort(); 41 nameId = raf.readShort(); 42 stringLength = raf.readShort(); 43 stringOffset = raf.readShort(); 44 } 45 46 public short getEncodingId() { 47 return encodingId; 48 } 49 50 public short getLanguageId() { 51 return languageId; 52 } 53 54 public short getNameId() { 55 return nameId; 56 } 57 58 public short getPlatformId() { 59 return platformId; 60 } 61 62 public String getRecordString() { 63 return record; 64 } 65 66 protected void loadString(RandomAccessFile raf, int stringStorageOffset) throws IOException { 67 StringBuffer sb = new StringBuffer (); 68 raf.seek(stringStorageOffset + stringOffset); 69 if (platformId == Table.platformAppleUnicode) { 70 71 for (int i = 0; i < stringLength/2; i++) { 73 sb.append(raf.readChar()); 74 } 75 } else if (platformId == Table.platformMacintosh) { 76 77 for (int i = 0; i < stringLength; i++) { 79 sb.append((char) raf.readByte()); 80 } 81 } else if (platformId == Table.platformISO) { 82 83 for (int i = 0; i < stringLength; i++) { 85 sb.append((char) raf.readByte()); 86 } 87 } else if (platformId == Table.platformMicrosoft) { 88 89 char c; 91 for (int i = 0; i < stringLength/2; i++) { 92 c = raf.readChar(); 93 sb.append(c); 94 } 95 } 96 record = sb.toString(); 97 } 98 } 99 | Popular Tags |