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.Object
TrueType font file parser.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isEmbedded
private boolean
parseOnDemandOnly
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
allowCFF()
(package private) TrueTypeFont
newFont(TTFDataStream raf)
TrueTypeFont
parse(java.io.File ttfFile)
Parse a file and return a TrueType font.TrueTypeFont
parse(java.io.InputStream inputStream)
Parse an input stream and return a TrueType font.TrueTypeFont
parse(java.lang.String ttfFile)
Parse a file and return a TrueType font.(package private) TrueTypeFont
parse(TTFDataStream raf)
Parse a file and get a true type font.TrueTypeFont
parseEmbedded(java.io.InputStream inputStream)
Parse an input stream and return a TrueType font that is to be embedded.private void
parseTables(TrueTypeFont font)
Parse all tables and check if all needed tables are present.protected TTFTable
readTable(TrueTypeFont font, java.lang.String tag)
private TTFTable
readTableDirectory(TrueTypeFont font, TTFDataStream raf)
-
-
-
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 PDFparseOnDemand
- true if the tables of the font should be parsed on demand
-
-
Method Detail
-
parse
public TrueTypeFont parse(java.lang.String ttfFile) throws java.io.IOException
Parse a file and return a TrueType font.- Parameters:
ttfFile
- The TrueType font filename.- Returns:
- A TrueType font.
- Throws:
java.io.IOException
- If there is an error parsing the TrueType font.
-
parse
public TrueTypeFont parse(java.io.File ttfFile) throws java.io.IOException
Parse a file and return a TrueType font.- Parameters:
ttfFile
- The TrueType font file.- Returns:
- A TrueType font.
- Throws:
java.io.IOException
- If there is an error parsing the TrueType font.
-
parse
public TrueTypeFont parse(java.io.InputStream inputStream) throws java.io.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:
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.
-
parse
TrueTypeFont parse(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.
-
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.
-
allowCFF
protected boolean allowCFF()
-
readTableDirectory
private TTFTable readTableDirectory(TrueTypeFont font, TTFDataStream raf) throws java.io.IOException
- Throws:
java.io.IOException
-
readTable
protected TTFTable readTable(TrueTypeFont font, java.lang.String tag)
-
-