Package org.apache.fontbox.cff
Class CFFParser
java.lang.Object
org.apache.fontbox.cff.CFFParser
This class represents a parser for a CFF font.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSource from which bytes may be read in the future.(package private) static classInner class representing a font's built-in CFF encoding.private static classAllows bytes to be re-read later by CFFParser.private static classInner class holding the DictData of a CFF font.private static classAn empty charset in a malformed CID font.private static classAn empty charset in a malformed Type1 font.private static classInner class representing a Format0 charset.private static classInner class representing a Format0 encoding.private static classFormat 0 FDSelect.private static classInner class representing a Format1 charset.private static classInner class representing a Format1 encoding.private static classInner class representing a Format2 charset.private static final classFormat 3 FDSelect data.private static classInner class holding the header of a CFF font.private static final classStructure of a Range3 element.private static final classInner class representing a rang mapping for a CID charset. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidconcatenateMatrix(List<Number> matrixDest, List<Number> matrixConcat) private DataInputprivate StringgetString(CFFParser.DictData dict, String name) parse(byte[] bytes, CFFParser.ByteSource source) Parse CFF font using byte array, also passing in a byte source for future use.Parse CFF font using a DataInput as input.parse(RandomAccessRead randomAccessRead) Parse CFF font using a RandomAccessRead as input.private voidparseCIDFontDicts(DataInput input, CFFParser.DictData topDict, CFFCIDFont font, int nrOfcharStrings) Parse dictionaries specific to a CIDFont.voidparseFirstSubFontROS(RandomAccessRead randomAccessRead, FontHeaders outHeaders) Extract "Registry", "Ordering" and "Supplement" properties from the first CFF subfont.private CFFFontprivate CFFCIDFontparseROS(CFFParser.DictData topDict) Extracts Registry, Ordering and Supplement fromtopDict["ROS"].private voidparseType1Dicts(DataInput input, CFFParser.DictData topDict, CFFType1Font font, CFFCharset charset) Parse dictionaries specific to a Type 1-equivalent font.private CFFCharsetreadCharset(DataInput dataInput, int nGlyphs, boolean isCIDFont) private static CFFParser.DictDatareadDictData(DataInput input) private static CFFParser.DictDatareadDictData(DataInput input, int offset, int dictSize) private CFFEncodingreadEncoding(DataInput dataInput, CFFCharset charset) private static CFFParser.DictData.Entryprivate static FDSelectreadFDSelect(DataInput dataInput, int nGlyphs) Read the FDSelect Data according to the format.private CFFParser.Format0CharsetreadFormat0Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) private CFFParser.Format0EncodingreadFormat0Encoding(DataInput dataInput, CFFCharset charset, int format) private static CFFParser.Format0FDSelectreadFormat0FDSelect(DataInput dataInput, int nGlyphs) Read the Format 0 of the FDSelect data structure.private CFFParser.Format1CharsetreadFormat1Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) private CFFParser.Format1EncodingreadFormat1Encoding(DataInput dataInput, CFFCharset charset, int format) private CFFParser.Format2CharsetreadFormat2Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) private static CFFParser.Format3FDSelectreadFormat3FDSelect(DataInput dataInput) Read the Format 3 of the FDSelect data structure.private static CFFParser.HeaderreadHeader(DataInput input) private static byte[][]readIndexData(DataInput input) private static int[]readIndexDataOffsets(DataInput input) private static IntegerreadIntegerNumber(DataInput input, int b0) private static longprivate static intreadOffSize(DataInput input) private static StringreadOperator(DataInput input, int b0) readPrivateDict(CFFParser.DictData privateDict) private static DoublereadRealNumber(DataInput input) private StringreadString(int index) private static String[]readStringIndexData(DataInput input) private voidreadSupplement(DataInput dataInput, CFFParser.CFFBuiltInEncoding encoding) private static StringreadTagName(DataInput input) private DataInputskipHeader(DataInput input) toString()
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOGLog instance. -
TAG_OTTO
- See Also:
-
TAG_TTCF
- See Also:
-
TAG_TTFONLY
- See Also:
-
stringIndex
-
source
-
debugFontName
-
-
Constructor Details
-
CFFParser
public CFFParser()
-
-
Method Details
-
parse
Parse CFF font using byte array, also passing in a byte source for future use.- Parameters:
bytes- source bytessource- source to re-read bytes from in the future- Returns:
- the parsed CFF fonts
- Throws:
IOException- If there is an error reading from the stream
-
parse
Parse CFF font using a RandomAccessRead as input.- Parameters:
randomAccessRead- the source to be parsed- Returns:
- the parsed CFF fonts
- Throws:
IOException- If there is an error reading from the stream
-
parseFirstSubFontROS
public void parseFirstSubFontROS(RandomAccessRead randomAccessRead, FontHeaders outHeaders) throws IOException Extract "Registry", "Ordering" and "Supplement" properties from the first CFF subfont.- Parameters:
randomAccessRead- the source to be parsedoutHeaders- where to put results- Throws:
IOException- If there is an error reading from the stream
-
skipHeader
- Throws:
IOException
-
parse
Parse CFF font using a DataInput as input.- Parameters:
input- the source to be parsed- Throws:
IOException- If there is an error reading from the stream
-
createTaggedCFFDataInput
- Throws:
IOException
-
readTagName
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readOffSize
- Throws:
IOException
-
readHeader
- Throws:
IOException
-
readIndexDataOffsets
- Throws:
IOException
-
readIndexData
- Throws:
IOException
-
readStringIndexData
- Throws:
IOException
-
readDictData
- Throws:
IOException
-
readDictData
private static CFFParser.DictData readDictData(DataInput input, int offset, int dictSize) throws IOException - Throws:
IOException
-
readEntry
- Throws:
IOException
-
readOperator
- Throws:
IOException
-
readIntegerNumber
- Throws:
IOException
-
readRealNumber
- Throws:
IOException
-
parseROS
Extracts Registry, Ordering and Supplement fromtopDict["ROS"].- Throws:
IOException
-
parseFont
- Throws:
IOException
-
concatenateMatrix
-
parseCIDFontDicts
private void parseCIDFontDicts(DataInput input, CFFParser.DictData topDict, CFFCIDFont font, int nrOfcharStrings) throws IOException Parse dictionaries specific to a CIDFont.- Throws:
IOException
-
readPrivateDict
-
parseType1Dicts
private void parseType1Dicts(DataInput input, CFFParser.DictData topDict, CFFType1Font font, CFFCharset charset) throws IOException Parse dictionaries specific to a Type 1-equivalent font.- Throws:
IOException
-
readString
- Throws:
IOException
-
getString
- Throws:
IOException
-
readEncoding
- Throws:
IOException
-
readFormat0Encoding
private CFFParser.Format0Encoding readFormat0Encoding(DataInput dataInput, CFFCharset charset, int format) throws IOException - Throws:
IOException
-
readFormat1Encoding
private CFFParser.Format1Encoding readFormat1Encoding(DataInput dataInput, CFFCharset charset, int format) throws IOException - Throws:
IOException
-
readSupplement
private void readSupplement(DataInput dataInput, CFFParser.CFFBuiltInEncoding encoding) throws IOException - Throws:
IOException
-
readFDSelect
Read the FDSelect Data according to the format.- Parameters:
dataInput-nGlyphs-- Returns:
- the FDSelect data
- Throws:
IOException
-
readFormat0FDSelect
private static CFFParser.Format0FDSelect readFormat0FDSelect(DataInput dataInput, int nGlyphs) throws IOException Read the Format 0 of the FDSelect data structure.- Parameters:
dataInput-nGlyphs-- Returns:
- the Format 0 of the FDSelect data
- Throws:
IOException
-
readFormat3FDSelect
private static CFFParser.Format3FDSelect readFormat3FDSelect(DataInput dataInput) throws IOException Read the Format 3 of the FDSelect data structure.- Parameters:
dataInput-- Returns:
- the Format 3 of the FDSelect data
- Throws:
IOException
-
readCharset
private CFFCharset readCharset(DataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat0Charset
private CFFParser.Format0Charset readFormat0Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat1Charset
private CFFParser.Format1Charset readFormat1Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat2Charset
private CFFParser.Format2Charset readFormat2Charset(DataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
toString
-