1 31 package org.pdfbox.ttf; 32 33 import java.io.IOException ; 34 35 41 public class IndexToLocationTable extends TTFTable 42 { 43 private static final short SHORT_OFFSETS = 0; 44 private static final short LONG_OFFSETS = 1; 45 46 49 public static final String TAG = "loca"; 50 51 private long[] offsets; 52 53 60 public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException 61 { 62 HeaderTable head = ttf.getHeader(); 63 MaximumProfileTable maxp = ttf.getMaximumProfile(); 64 int numGlyphs = maxp.getNumGlyphs(); 65 offsets = new long[ numGlyphs +1]; 66 for( int i=0; i<numGlyphs+1; i++ ) 67 { 68 if( head.getIndexToLocFormat() == SHORT_OFFSETS ) 69 { 70 offsets[i] = data.readUnsignedShort() * 2; 71 } 72 else if( head.getIndexToLocFormat() == LONG_OFFSETS ) 73 { 74 offsets[i] = data.readUnsignedInt(); 75 } 76 else 77 { 78 throw new IOException ( "Error:TTF.loca unknown offset format."); 79 } 80 } 81 } 82 85 public long[] getOffsets() 86 { 87 return offsets; 88 } 89 92 public void setOffsets(long[] offsetsValue) 93 { 94 this.offsets = offsetsValue; 95 } 96 } 97 | Popular Tags |