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 CmapTable implements Table { 28 29 private int version; 30 private int numTables; 31 private CmapIndexEntry[] entries; 32 private CmapFormat[] formats; 33 34 protected CmapTable(DirectoryEntry de, RandomAccessFile raf) throws IOException { 35 raf.seek(de.getOffset()); 36 long fp = raf.getFilePointer(); 37 version = raf.readUnsignedShort(); 38 numTables = raf.readUnsignedShort(); 39 entries = new CmapIndexEntry[numTables]; 40 formats = new CmapFormat[numTables]; 41 42 for (int i = 0; i < numTables; i++) { 44 entries[i] = new CmapIndexEntry(raf); 45 } 46 47 for (int i = 0; i < numTables; i++) { 49 raf.seek(fp + entries[i].getOffset()); 50 int format = raf.readUnsignedShort(); 51 formats[i] = CmapFormat.create(format, raf); 52 } 53 } 54 55 public CmapFormat getCmapFormat(short platformId, short encodingId) { 56 57 for (int i = 0; i < numTables; i++) { 59 if (entries[i].getPlatformId() == platformId 60 && entries[i].getEncodingId() == encodingId) { 61 return formats[i]; 62 } 63 } 64 return null; 65 } 66 67 public int getType() { 68 return cmap; 69 } 70 71 public String toString() { 72 StringBuffer sb = new StringBuffer ().append("cmap\n"); 73 74 for (int i = 0; i < numTables; i++) { 76 sb.append("\t").append(entries[i].toString()).append("\n"); 77 } 78 79 for (int i = 0; i < numTables; i++) { 81 sb.append("\t").append(formats[i].toString()).append("\n"); 82 } 83 return sb.toString(); 84 } 85 } 86 | Popular Tags |