org.apache.fontbox.ttf

## Class TTFParser

- java.lang.Object
- - org.apache.fontbox.ttf.TTFParser

Direct Known Subclasses:
  OTFParser

    public class TTFParser
    extends Object

TrueType font file parser.

Author:
  Ben Litchfield

### Constructor Summary

Constructors
Constructor and Description
`TTFParser()` Constructor.
`TTFParser(boolean isEmbedded)` Constructor.
`TTFParser(boolean isEmbedded, boolean parseOnDemand)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected boolean` `allowCFF()`
`TrueTypeFont` `parse(File ttfFile)` Parse a file and return a TrueType font.
`TrueTypeFont` `parse(InputStream inputStream)` Parse an input stream and return a TrueType font.
`TrueTypeFont` `parse(String ttfFile)` Parse a file and return a TrueType font.
`TrueTypeFont` `parseEmbedded(InputStream inputStream)` Parse an input stream and return a TrueType font that is to be embedded.
`protected TTFTable` `readTable(TrueTypeFont font, String tag)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TTFParser

    public TTFParser()

Constructor.

#### TTFParser

    public TTFParser(boolean isEmbedded)

Constructor.

Parameters:
  `isEmbedded` - true if the font is embedded in PDF

#### TTFParser

    public TTFParser(boolean isEmbedded,
                     boolean parseOnDemand)

Constructor.

Parameters:
  `isEmbedded` - true if the font is embedded in PDF
  `parseOnDemand` - true if the tables of the font should be parsed on demand

### Method Detail

#### parse

    public TrueTypeFont parse(String ttfFile)
                       throws IOException

Parse a file and return a TrueType font.

Parameters:
  `ttfFile` - The TrueType font filename.
Returns:
  A TrueType font.
Throws:
  `IOException` - If there is an error parsing the TrueType font.

#### parse

    public TrueTypeFont parse(File ttfFile)
                       throws IOException

Parse a file and return a TrueType font.

Parameters:
  `ttfFile` - The TrueType font file.
Returns:
  A TrueType font.
Throws:
  `IOException` - If there is an error parsing the TrueType font.

#### parse

    public TrueTypeFont parse(InputStream inputStream)
                       throws IOException

Parse an input stream and return a TrueType font.

Parameters:
  `inputStream` - The TTF data stream to parse from. It will be closed before returning.
Returns:
  A TrueType font.
Throws:
  `IOException` - If there is an error parsing the TrueType font.

#### parseEmbedded

    public TrueTypeFont parseEmbedded(InputStream inputStream)
                               throws IOException

Parse an input stream and return a TrueType font that is to be embedded.

Parameters:
  `inputStream` - The TTF data stream to parse from. It will be closed before returning.
Returns:
  A TrueType font.
Throws:
  `IOException` - If there is an error parsing the TrueType font.

#### allowCFF

    protected boolean allowCFF()

#### readTable

    protected TTFTable readTable(TrueTypeFont font,
                                 String tag)