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 interface
Source from which bytes may be read in the future.(package private) static class
Inner class representing a font's built-in CFF encoding.private static class
Inner class holding the DictData of a CFF font.(package private) static class
Inner class representing an embedded CFF charset.private static class
An empty charset in a malformed CID font.private static class
Inner class representing a Format0 charset.private static class
Inner class representing a Format0 encoding.private static class
Format 0 FDSelect.private static class
Inner class representing a Format1 charset.private static class
Inner class representing a Format1 encoding.private static class
Inner class representing a Format2 charset.private static final class
Format 3 FDSelect data.private static class
Inner class holding the header of a CFF font.private static final class
Structure of a Range3 element.private static final class
Inner class representing a rang mapping for a CID charset. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
concatenateMatrix
(List<Number> matrixDest, List<Number> matrixConcat) private CFFDataInput
createTaggedCFFDataInput
(CFFDataInput input, byte[] bytes) private String
getString
(CFFParser.DictData dict, String name) parse
(byte[] bytes) Parse CFF font using a byte array as input.parse
(byte[] bytes, CFFParser.ByteSource source) Parse CFF font using byte array, also passing in a byte source for future use.private void
parseCIDFontDicts
(CFFDataInput input, CFFParser.DictData topDict, CFFCIDFont font, int nrOfcharStrings) Parse dictionaries specific to a CIDFont.private CFFFont
parseFont
(CFFDataInput input, String name, byte[] topDictIndex) private void
parseType1Dicts
(CFFDataInput input, CFFParser.DictData topDict, CFFType1Font font, CFFCharset charset) Parse dictionaries specific to a Type 1-equivalent font.private CFFCharset
readCharset
(CFFDataInput dataInput, int nGlyphs, boolean isCIDFont) private static CFFParser.DictData
readDictData
(CFFDataInput input) private static CFFParser.DictData
readDictData
(CFFDataInput input, int dictSize) private CFFEncoding
readEncoding
(CFFDataInput dataInput, CFFCharset charset) private static CFFParser.DictData.Entry
readEntry
(CFFDataInput input) private static FDSelect
readFDSelect
(CFFDataInput dataInput, int nGlyphs, CFFCIDFont ros) Read the FDSelect Data according to the format.private CFFParser.Format0Charset
readFormat0Charset
(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) private CFFParser.Format0Encoding
readFormat0Encoding
(CFFDataInput dataInput, CFFCharset charset, int format) private static CFFParser.Format0FDSelect
readFormat0FDSelect
(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) Read the Format 0 of the FDSelect data structure.private CFFParser.Format1Charset
readFormat1Charset
(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) private CFFParser.Format1Encoding
readFormat1Encoding
(CFFDataInput dataInput, CFFCharset charset, int format) private CFFParser.Format2Charset
readFormat2Charset
(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) private static CFFParser.Format3FDSelect
readFormat3FDSelect
(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) Read the Format 3 of the FDSelect data structure.private static CFFParser.Header
readHeader
(CFFDataInput input) private static byte[][]
readIndexData
(CFFDataInput input) private static int[]
readIndexDataOffsets
(CFFDataInput input) private static Integer
readIntegerNumber
(CFFDataInput input, int b0) private static long
readLong
(CFFDataInput input) private static CFFOperator
readOperator
(CFFDataInput input, int b0) private static CFFOperator.Key
readOperatorKey
(CFFDataInput input, int b0) readPrivateDict
(CFFParser.DictData privateDict) private static Double
readRealNumber
(CFFDataInput input) private String
readString
(int index) private static String[]
readStringIndexData
(CFFDataInput input) private void
readSupplement
(CFFDataInput dataInput, CFFParser.CFFBuiltInEncoding encoding) private static String
readTagName
(CFFDataInput 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 byte array as input.- Parameters:
bytes
- the given byte array- Returns:
- the parsed CFF fonts
- Throws:
IOException
- If there is an error reading from the stream
-
createTaggedCFFDataInput
- Throws:
IOException
-
readTagName
- Throws:
IOException
-
readLong
- Throws:
IOException
-
readHeader
- Throws:
IOException
-
readIndexDataOffsets
- Throws:
IOException
-
readIndexData
- Throws:
IOException
-
readStringIndexData
- Throws:
IOException
-
readDictData
- Throws:
IOException
-
readDictData
- Throws:
IOException
-
readEntry
- Throws:
IOException
-
readOperator
- Throws:
IOException
-
readOperatorKey
- Throws:
IOException
-
readIntegerNumber
- Throws:
IOException
-
readRealNumber
- Throws:
IOException
-
parseFont
- Throws:
IOException
-
concatenateMatrix
-
parseCIDFontDicts
private void parseCIDFontDicts(CFFDataInput input, CFFParser.DictData topDict, CFFCIDFont font, int nrOfcharStrings) throws IOException Parse dictionaries specific to a CIDFont.- Throws:
IOException
-
readPrivateDict
-
parseType1Dicts
private void parseType1Dicts(CFFDataInput 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(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException - Throws:
IOException
-
readFormat1Encoding
private CFFParser.Format1Encoding readFormat1Encoding(CFFDataInput dataInput, CFFCharset charset, int format) throws IOException - Throws:
IOException
-
readSupplement
private void readSupplement(CFFDataInput dataInput, CFFParser.CFFBuiltInEncoding encoding) throws IOException - Throws:
IOException
-
readFDSelect
private static FDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFCIDFont ros) throws IOException Read the FDSelect Data according to the format.- Parameters:
dataInput
-nGlyphs
-ros
-- Returns:
- the FDSelect data
- Throws:
IOException
-
readFormat0FDSelect
private static CFFParser.Format0FDSelect readFormat0FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) throws IOException Read the Format 0 of the FDSelect data structure.- Parameters:
dataInput
-format
-nGlyphs
-ros
-- Returns:
- the Format 0 of the FDSelect data
- Throws:
IOException
-
readFormat3FDSelect
private static CFFParser.Format3FDSelect readFormat3FDSelect(CFFDataInput dataInput, int format, int nGlyphs, CFFCIDFont ros) throws IOException Read the Format 3 of the FDSelect data structure.- Parameters:
dataInput
-format
-nGlyphs
-ros
-- Returns:
- the Format 3 of the FDSelect data
- Throws:
IOException
-
readCharset
private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat0Charset
private CFFParser.Format0Charset readFormat0Charset(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat1Charset
private CFFParser.Format1Charset readFormat1Charset(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
readFormat2Charset
private CFFParser.Format2Charset readFormat2Charset(CFFDataInput dataInput, int format, int nGlyphs, boolean isCIDFont) throws IOException - Throws:
IOException
-
toString
-