1 18 package org.apache.batik.svggen.font.table; 19 20 import java.io.IOException ; 21 import java.io.RandomAccessFile ; 22 23 28 public class ScriptList { 29 30 private int scriptCount = 0; 31 private ScriptRecord[] scriptRecords; 32 private Script[] scripts; 33 34 35 protected ScriptList(RandomAccessFile raf, int offset) throws IOException { 36 raf.seek(offset); 37 scriptCount = raf.readUnsignedShort(); 38 scriptRecords = new ScriptRecord[scriptCount]; 39 scripts = new Script[scriptCount]; 40 for (int i = 0; i < scriptCount; i++) { 41 scriptRecords[i] = new ScriptRecord(raf); 42 } 43 for (int i = 0; i < scriptCount; i++) { 44 scripts[i] = new Script(raf, offset + scriptRecords[i].getOffset()); 45 } 46 } 47 48 public int getScriptCount() { 49 return scriptCount; 50 } 51 52 public ScriptRecord getScriptRecord(int i) { 53 return scriptRecords[i]; 54 } 55 56 public Script findScript(String tag) { 57 if (tag.length() != 4) { 58 return null; 59 } 60 int tagVal = ((tag.charAt(0)<<24) 61 | (tag.charAt(1)<<16) 62 | (tag.charAt(2)<<8) 63 | tag.charAt(3)); 64 for (int i = 0; i < scriptCount; i++) { 65 if (scriptRecords[i].getTag() == tagVal) { 66 return scripts[i]; 67 } 68 } 69 return null; 70 } 71 72 } 73 74 | Popular Tags |