1 18 package org.apache.batik.svggen.font.table; 19 20 import java.io.ByteArrayInputStream ; 21 import java.io.IOException ; 22 import java.io.RandomAccessFile ; 23 24 28 public class GlyfTable implements Table { 29 30 private byte[] buf = null; 31 private GlyfDescript[] descript; 32 33 protected GlyfTable(DirectoryEntry de, RandomAccessFile raf) throws IOException { 34 raf.seek(de.getOffset()); 35 buf = new byte[de.getLength()]; 36 raf.read(buf); 37 67 } 68 69 public void init(int numGlyphs, LocaTable loca) { 70 if (buf == null) { 71 return; 72 } 73 descript = new GlyfDescript[numGlyphs]; 74 ByteArrayInputStream bais = new ByteArrayInputStream (buf); 75 for (int i = 0; i < numGlyphs; i++) { 76 int len = loca.getOffset((short)(i + 1)) - loca.getOffset(i); 77 if (len > 0) { 78 bais.reset(); 79 bais.skip(loca.getOffset(i)); 80 short numberOfContours = (short)(bais.read()<<8 | bais.read()); 81 if (numberOfContours >= 0) { 82 descript[i] = new GlyfSimpleDescript(this, numberOfContours, bais); 83 } 84 } else { 85 descript[i] = null; 86 } 87 } 88 89 for (int i = 0; i < numGlyphs; i++) { 90 int len = loca.getOffset((short)(i + 1)) - loca.getOffset(i); 91 if (len > 0) { 92 bais.reset(); 93 bais.skip(loca.getOffset(i)); 94 short numberOfContours = (short)(bais.read()<<8 | bais.read()); 95 if (numberOfContours < 0) { 96 descript[i] = new GlyfCompositeDescript(this, bais); 97 } 98 } 99 } 100 buf = null; 101 } 102 103 public GlyfDescript getDescription(int i) { 104 return descript[i]; 105 } 106 107 public int getType() { 108 return glyf; 109 } 110 } 111 | Popular Tags |