Top Description Fields Constructors Methods
org.apache.fontbox.ttf

public Class TTFParser

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.fontbox.ttf.OTFParser
Imports
java.io.IOException, .InputStream, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.io.RandomAccessRead

TrueType font file parser.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
private boolean
private static final Log

Constructor Summary

AccessConstructor and Description
public
TTFParser()

Constructor.

public
TTFParser(boolean
true if the font is embedded in PDF
isEmbedded
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected boolean
private TrueTypeFont

Returns:

A TrueType font.
createFontWithTables
(TTFDataStream
The TTF file.
raf
)

Parse a file and get a true type font.

pack-priv TrueTypeFont
public TrueTypeFont

Returns:

A TrueType font.
parse
(RandomAccessRead
The RandomAccessREad to be read from. It will be closed before returning.
randomAccessRead
)

Parse a RandomAccessRead and return a TrueType font.

pack-priv TrueTypeFont
public TrueTypeFont

Returns:

A TrueType font.
parseEmbedded
(InputStream
The TTF data stream to parse from. It will be closed before returning.
inputStream
)

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

public FontHeaders

Returns:

TrueType font headers.
parseTableHeaders
(RandomAccessRead
The RandomAccessREad to be read from. It will be closed before returning.
randomAccessRead
)

Parse a RandomAccessRead and return a TrueType font.

pack-priv FontHeaders
private void
parseTables(TrueTypeFont
the TrueTypeFont instance holding the parsed data.
font
)

Parse all tables and check if all needed tables are present.

protected TTFTable
private TTFTable
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isEmbeddedback to summary
private boolean isEmbedded
LOGback to summary
private static final Log LOG

Constructor Detail

TTFParserback to summary
public TTFParser()

Constructor.

TTFParserback to summary
public TTFParser(boolean isEmbedded)

Constructor.

Parameters
isEmbedded:boolean

true if the font is embedded in PDF

Method Detail

allowCFFback to summary
protected boolean allowCFF()
createFontWithTablesback to summary
private TrueTypeFont createFontWithTables(TTFDataStream raf) throws IOException

Parse a file and get a true type font.

Parameters
raf:TTFDataStream

The TTF file.

Returns:TrueTypeFont

A TrueType font.

Exceptions
IOException:
If there is an error parsing the TrueType font.
newFontback to summary
pack-priv TrueTypeFont newFont(TTFDataStream raf)
parseback to summary
public TrueTypeFont parse(RandomAccessRead randomAccessRead) throws IOException

Parse a RandomAccessRead and return a TrueType font.

Parameters
randomAccessRead:RandomAccessRead

The RandomAccessREad to be read from. It will be closed before returning.

Returns:TrueTypeFont

A TrueType font.

Exceptions
IOException:
If there is an error parsing the TrueType font.
parseback to summary
pack-priv TrueTypeFont parse(TTFDataStream raf) throws IOException
parseEmbeddedback to summary
public TrueTypeFont parseEmbedded(InputStream inputStream) throws IOException

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

Parameters
inputStream:InputStream

The TTF data stream to parse from. It will be closed before returning.

Returns:TrueTypeFont

A TrueType font.

Exceptions
IOException:
If there is an error parsing the TrueType font.
parseTableHeadersback to summary
public FontHeaders parseTableHeaders(RandomAccessRead randomAccessRead) throws IOException

Parse a RandomAccessRead and return a TrueType font.

Parameters
randomAccessRead:RandomAccessRead

The RandomAccessREad to be read from. It will be closed before returning.

Returns:FontHeaders

TrueType font headers.

Exceptions
IOException:
If there is an error parsing the TrueType font.
parseTableHeadersback to summary
pack-priv FontHeaders parseTableHeaders(TTFDataStream raf) throws IOException

Based on parseTables(). Parse all table headers and check if all needed tables are present. This method can be optimized further by skipping unused portions inside each individual table parser

Exceptions
IOException:
If there is an error parsing the TrueType font.
parseTablesback to summary
private void parseTables(TrueTypeFont font) throws IOException

Parse all tables and check if all needed tables are present.

Parameters
font:TrueTypeFont

the TrueTypeFont instance holding the parsed data.

Exceptions
IOException:
If there is an error parsing the TrueType font.
readTableback to summary
protected TTFTable readTable(String tag)
readTableDirectoryback to summary
private TTFTable readTableDirectory(TTFDataStream raf) throws IOException