Package org.apache.fontbox.ttf
Class TTFParser
- java.lang.Object
-
- org.apache.fontbox.ttf.TTFParser
-
- Direct Known Subclasses:
OTFParser
public class TTFParser extends java.lang.ObjectTrueType font file parser.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisEmbeddedprivate static org.apache.commons.logging.LogLOG
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanallowCFF()private TrueTypeFontcreateFontWithTables(TTFDataStream raf)Parse a file and get a true type font.(package private) TrueTypeFontnewFont(TTFDataStream raf)(package private) TrueTypeFontparse(TTFDataStream raf)TrueTypeFontparse(RandomAccessRead randomAccessRead)Parse a RandomAccessRead and return a TrueType font.TrueTypeFontparseEmbedded(java.io.InputStream inputStream)Parse an input stream and return a TrueType font that is to be embedded.(package private) FontHeadersparseTableHeaders(TTFDataStream raf)Based on#parseTables().FontHeadersparseTableHeaders(RandomAccessRead randomAccessRead)Parse a RandomAccessRead and return a TrueType font.private voidparseTables(TrueTypeFont font)Parse all tables and check if all needed tables are present.protected TTFTablereadTable(java.lang.String tag)private TTFTablereadTableDirectory(TTFDataStream raf)
-
-
-
Method Detail
-
parse
public TrueTypeFont parse(RandomAccessRead randomAccessRead) throws java.io.IOException
Parse a RandomAccessRead and return a TrueType font.- Parameters:
randomAccessRead- The RandomAccessREad to be read from. It will be closed before returning.- Returns:
- A TrueType font.
- Throws:
java.io.IOException- If there is an error parsing the TrueType font.
-
parseEmbedded
public TrueTypeFont parseEmbedded(java.io.InputStream inputStream) throws java.io.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:
java.io.IOException- If there is an error parsing the TrueType font.
-
parseTableHeaders
public FontHeaders parseTableHeaders(RandomAccessRead randomAccessRead) throws java.io.IOException
Parse a RandomAccessRead and return a TrueType font.- Parameters:
randomAccessRead- The RandomAccessREad to be read from. It will be closed before returning.- Returns:
- TrueType font headers.
- Throws:
java.io.IOException- If there is an error parsing the TrueType font.
-
createFontWithTables
private TrueTypeFont createFontWithTables(TTFDataStream raf) throws java.io.IOException
Parse a file and get a true type font.- Parameters:
raf- The TTF file.- Returns:
- A TrueType font.
- Throws:
java.io.IOException- If there is an error parsing the TrueType font.
-
parse
TrueTypeFont parse(TTFDataStream raf) throws java.io.IOException
- Throws:
java.io.IOException
-
newFont
TrueTypeFont newFont(TTFDataStream raf)
-
parseTables
private void parseTables(TrueTypeFont font) throws java.io.IOException
Parse all tables and check if all needed tables are present.- Parameters:
font- the TrueTypeFont instance holding the parsed data.- Throws:
java.io.IOException- If there is an error parsing the TrueType font.
-
parseTableHeaders
FontHeaders parseTableHeaders(TTFDataStream raf) throws java.io.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- Parameters:
font- the TrueTypeFont instance holding the parsed data.- Throws:
java.io.IOException- If there is an error parsing the TrueType font.
-
allowCFF
protected boolean allowCFF()
-
readTableDirectory
private TTFTable readTableDirectory(TTFDataStream raf) throws java.io.IOException
- Throws:
java.io.IOException
-
readTable
protected TTFTable readTable(java.lang.String tag)
-
-