1 31 package org.pdfbox.ttf; 32 33 import java.io.IOException ; 34 35 41 public class HorizontalMetricsTable extends TTFTable 42 { 43 46 public static final String TAG = "hmtx"; 47 48 private int[] advanceWidth; 49 private short[] leftSideBearing; 50 private short[] nonHorizontalLeftSideBearing; 51 52 59 public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException 60 { 61 HorizontalHeaderTable hHeader = ttf.getHorizontalHeader(); 62 MaximumProfileTable maxp = ttf.getMaximumProfile(); 63 int numHMetrics = hHeader.getNumberOfHMetrics(); 64 int numGlyphs = maxp.getNumGlyphs(); 65 66 advanceWidth = new int[ numHMetrics ]; 67 leftSideBearing = new short[ numHMetrics ]; 68 for( int i=0; i<numHMetrics; i++ ) 69 { 70 advanceWidth[i] = data.readUnsignedShort(); 71 leftSideBearing[i] = data.readSignedShort(); 72 } 73 74 int numberNonHorizontal = numGlyphs - numHMetrics; 75 nonHorizontalLeftSideBearing = new short[ numberNonHorizontal ]; 76 for( int i=0; i<numberNonHorizontal; i++ ) 77 { 78 nonHorizontalLeftSideBearing[i] = data.readSignedShort(); 79 } 80 } 81 84 public int[] getAdvanceWidth() 85 { 86 return advanceWidth; 87 } 88 91 public void setAdvanceWidth(int[] advanceWidthValue) 92 { 93 this.advanceWidth = advanceWidthValue; 94 } 95 } 96 | Popular Tags |