org.apache.fop.fonts
Class TTFFile

java.lang.Object
  extended by org.apache.fop.fonts.TTFFile
Direct Known Subclasses:
TTFSubSetFile

public class TTFFile
extends Object

Reads a TrueType file or a TrueType Collection. The TrueType spec can be found at the Microsoft Typography site: http://www.microsoft.com/truetype/


Constructor Summary
TTFFile()
           
 
Method Summary
protected  boolean checkTTC(FontFileReader in, String name, boolean verbose)
          Check if this is a TrueType collection and that the given name exists in the collection.
 HashMap getAnsiKerning()
           
 int getCapHeight()
           
 String getCharSetName()
           
 int getCharWidth(int idx)
           
 ArrayList getCMaps()
          Return a ArrayList with TTFCmapEntry
 String getFamilyName()
           
 short getFirstChar()
           
 int getFlags()
           
 int[] getFontBBox()
           
 String getItalicAngle()
           
 HashMap getKerning()
           
 short getLastChar()
           
 int getLowerCaseAscent()
           
 int getLowerCaseDescent()
           
protected  void getNumGlyphs(FontFileReader in)
          Read the number of glyphs from the "maxp" table
 String getPostscriptName()
           
 String getStemV()
           
 int[] getWidths()
           
 String getWindowsName()
           
 int getXHeight()
           
 boolean isEmbeddable()
           
static void main(String[] args)
           
 void printStuff()
           
protected  void readDirTabs(FontFileReader in)
          Read Table Directory from the current position in the FontFileReader and fill the global HashMap dirTabs with the table name (String) as key and a TTFDirTabEntry as value.
 void readFont(FontFileReader in)
           
 void readFont(FontFileReader in, String name)
          Read the font data If the fontfile is a TrueType Collection (.ttc file) The name of the font to read data for must be supplied, else the name is ignored
protected  void readFontHeader(FontFileReader in)
          Read the "head" table, this reads the bounding box and sets the upem (unitsPerEM) variable
protected  void readHorizontalHeader(FontFileReader in)
          Read the "hhea" table to find the ascender and descender and size of "hmtx" table, i.e.
protected  void readHorizontalMetrics(FontFileReader in)
          Read "hmtx" table and put the horizontal metrics in the mtx_tab array.
protected  void readIndexToLocation(FontFileReader in)
          Read the "loca" table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TTFFile

public TTFFile()
Method Detail

readFont

public void readFont(FontFileReader in)
              throws IOException
Throws:
IOException

readFont

public void readFont(FontFileReader in,
                     String name)
              throws IOException
Read the font data If the fontfile is a TrueType Collection (.ttc file) The name of the font to read data for must be supplied, else the name is ignored

Throws:
IOException

printStuff

public void printStuff()

main

public static void main(String[] args)

getWindowsName

public String getWindowsName()

getPostscriptName

public String getPostscriptName()

getFamilyName

public String getFamilyName()

getCharSetName

public String getCharSetName()

getCapHeight

public int getCapHeight()

getXHeight

public int getXHeight()

getFlags

public int getFlags()

getStemV

public String getStemV()

getItalicAngle

public String getItalicAngle()

getFontBBox

public int[] getFontBBox()

getLowerCaseAscent

public int getLowerCaseAscent()

getLowerCaseDescent

public int getLowerCaseDescent()

getLastChar

public short getLastChar()

getFirstChar

public short getFirstChar()

getWidths

public int[] getWidths()

getCharWidth

public int getCharWidth(int idx)

getKerning

public HashMap getKerning()

getAnsiKerning

public HashMap getAnsiKerning()

isEmbeddable

public boolean isEmbeddable()

readDirTabs

protected void readDirTabs(FontFileReader in)
                    throws IOException
Read Table Directory from the current position in the FontFileReader and fill the global HashMap dirTabs with the table name (String) as key and a TTFDirTabEntry as value.

Throws:
IOException

readFontHeader

protected void readFontHeader(FontFileReader in)
                       throws IOException
Read the "head" table, this reads the bounding box and sets the upem (unitsPerEM) variable

Throws:
IOException

getNumGlyphs

protected void getNumGlyphs(FontFileReader in)
                     throws IOException
Read the number of glyphs from the "maxp" table

Throws:
IOException

readHorizontalHeader

protected void readHorizontalHeader(FontFileReader in)
                             throws IOException
Read the "hhea" table to find the ascender and descender and size of "hmtx" table, i.e. a fixed size font might have only one width

Throws:
IOException

readHorizontalMetrics

protected void readHorizontalMetrics(FontFileReader in)
                              throws IOException
Read "hmtx" table and put the horizontal metrics in the mtx_tab array. If the number of metrics is less than the number of glyphs (eg fixed size fonts), extend the mtx_tab array and fill in the missing widths

Throws:
IOException

readIndexToLocation

protected final void readIndexToLocation(FontFileReader in)
                                  throws IOException
Read the "loca" table

Throws:
IOException

getCMaps

public ArrayList getCMaps()
Return a ArrayList with TTFCmapEntry


checkTTC

protected final boolean checkTTC(FontFileReader in,
                                 String name,
                                 boolean verbose)
                          throws IOException
Check if this is a TrueType collection and that the given name exists in the collection. If it does, set offset in fontfile to the beginning of the Table Directory for that font

Returns:
true if not collection or font name present, false otherwise
Throws:
IOException


Copyright ? 1999-2003 Apache Software Foundation. All Rights Reserved.