org.apache.fop.fonts
Class TTFFile

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

public class TTFFile
extends java.lang.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, java.lang.String name, boolean verbose)
          Check if this is a TrueType collection and that the given name exists in the collection.
 java.util.HashMap getAnsiKerning()
           
 int getCapHeight()
           
 java.lang.String getCharSetName()
           
 int getCharWidth(int idx)
           
 java.util.ArrayList getCMaps()
          Return a ArrayList with TTFCmapEntry
 java.lang.String getFamilyName()
           
 short getFirstChar()
           
 int getFlags()
           
 int[] getFontBBox()
           
 java.lang.String getItalicAngle()
           
 java.util.HashMap getKerning()
           
 short getLastChar()
           
 int getLowerCaseAscent()
           
 int getLowerCaseDescent()
           
protected  void getNumGlyphs(FontFileReader in)
          Read the number of glyphs from the "maxp" table
 java.lang.String getPostscriptName()
           
 java.lang.String getStemV()
           
 int[] getWidths()
           
 java.lang.String getWindowsName()
           
 int getXHeight()
           
 boolean isEmbeddable()
           
static void main(java.lang.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, java.lang.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 java.io.IOException
Throws:
java.io.IOException

readFont

public void readFont(FontFileReader in,
                     java.lang.String name)
              throws java.io.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:
java.io.IOException

printStuff

public void printStuff()

main

public static void main(java.lang.String[] args)

getWindowsName

public java.lang.String getWindowsName()

getPostscriptName

public java.lang.String getPostscriptName()

getFamilyName

public java.lang.String getFamilyName()

getCharSetName

public java.lang.String getCharSetName()

getCapHeight

public int getCapHeight()

getXHeight

public int getXHeight()

getFlags

public int getFlags()

getStemV

public java.lang.String getStemV()

getItalicAngle

public java.lang.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 java.util.HashMap getKerning()

getAnsiKerning

public java.util.HashMap getAnsiKerning()

isEmbeddable

public boolean isEmbeddable()

readDirTabs

protected void readDirTabs(FontFileReader in)
                    throws java.io.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:
java.io.IOException

readFontHeader

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

Throws:
java.io.IOException

getNumGlyphs

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

Throws:
java.io.IOException

readHorizontalHeader

protected void readHorizontalHeader(FontFileReader in)
                             throws java.io.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:
java.io.IOException

readHorizontalMetrics

protected void readHorizontalMetrics(FontFileReader in)
                              throws java.io.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:
java.io.IOException

readIndexToLocation

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

Throws:
java.io.IOException

getCMaps

public java.util.ArrayList getCMaps()
Return a ArrayList with TTFCmapEntry


checkTTC

protected final boolean checkTTC(FontFileReader in,
                                 java.lang.String name,
                                 boolean verbose)
                          throws java.io.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:
java.io.IOException


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