1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.fontbox.ttf; 18 19 import java.io.IOException; 20 21 /** 22 * A table in a true type font. 23 * 24 * @author Ben Litchfield (ben@benlitchfield.com) 25 * @version $Revision: 1.1 $ 26 */ 27 public class GlyphTable extends TTFTable 28 { 29 /** 30 * Tag to identify this table. 31 */ 32 public static final String TAG = "glyf"; 33 34 private GlyphData[] glyphs; 35 36 /** 37 * This will read the required data from the stream. 38 * 39 * @param ttf The font that is being read. 40 * @param data The stream to read the data from. 41 * @throws IOException If there is an error reading the data. 42 */ 43 public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException 44 { 45 MaximumProfileTable maxp = ttf.getMaximumProfile(); 46 IndexToLocationTable loc = ttf.getIndexToLocation(); 47 PostScriptTable post = ttf.getPostScript(); 48 long[] offsets = loc.getOffsets(); 49 int numGlyphs = maxp.getNumGlyphs(); 50 glyphs = new GlyphData[numGlyphs]; 51 String[] glyphNames = post.getGlyphNames(); 52 for( int i=0; i<numGlyphs-1; i++ ) 53 { 54 GlyphData glyph = new GlyphData(); 55 data.seek( getOffset() + offsets[i] ); 56 glyph.initData( ttf, data ); 57 glyphs[i] = glyph; 58 } 59 } 60 /** 61 * @return Returns the glyphs. 62 */ 63 public GlyphData[] getGlyphs() 64 { 65 return glyphs; 66 } 67 /** 68 * @param glyphsValue The glyphs to set. 69 */ 70 public void setGlyphs(GlyphData[] glyphsValue) 71 { 72 this.glyphs = glyphsValue; 73 } 74 }