Package org.apache.fop.fonts.cff
Class CFFDataReader
java.lang.Object
org.apache.fop.fonts.cff.CFFDataReader
A class to read the CFF data from an OTF CFF font file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn object used to hold index data from the CFF dataclassParent class which provides the ability to retrieve byte data from a sub-table.classprivate static classstatic classA class containing data for a dictionary entryclassclassclassclassclassclass -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.fontbox.cff.CFFDataInputprivate CFFDataReader.CFFIndexDataprivate static final intprivate CFFDataReader.CustomEncodingprivate List<CFFDataReader.FontDict> private CFFDataReader.FDSelectprivate CFFDataReader.CFFIndexDataprivate byte[]private CFFDataReader.CFFIndexDataprivate CFFDataReader.CFFIndexDataprivate static final intprivate CFFDataReader.CFFIndexDataprivate LinkedHashMap<String, CFFDataReader.DICTEntry> Commonly used parsed dictionariesprivate CFFDataReader.CFFIndexData -
Constructor Summary
ConstructorsConstructorDescriptionCFFDataReader(byte[] cffDataArray) Constructor for the CFF data reader which accepts the CFF byte data as an argument.CFFDataReader(FontFileReader fontFile) Constructor for the CFF data reader which accepts a FontFileReader object which points to the original font file as an argument. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.fontbox.cff.CFFDataInputprivate byte[]getCFFOffsetBytes(int offset, int length) Retrieves a number of bytes from the CFF data streambyte[]org.apache.fontbox.cff.CFFDataInputgetLocalSubrsForGlyph(int glyph) getPrivateDict(CFFDataReader.DICTEntry privateEntry) byte[]getPrivateDictBytes(CFFDataReader.DICTEntry privateEntry) intgetSIDFromGID(int charsetOffset, int gid) Retrieves the SID for the given GID objectprivate intgetSIDFromGIDFormat(int gid, int format) private StringgetString(int sid) private List<CFFDataReader.FontDict> parseDictData(byte[] dictData) Parses the dictionary data and returns a map of objects for each entryprivate voidParses the char string index from the CFF byte dataprivate CFFDataReader.CustomEncodingprivate CFFDataReader.FDSelectprivate CFFDataReader.Format0EncodingreadFormat0Encoding(int format, int numEntries) private CFFDataReader.Format0FDSelectprivate CFFDataReader.Format1EncodingreadFormat1Encoding(int format, int numEntries) private CFFDataReader.Format3FDSelectprivate byte[]private CFFDataReader.CFFIndexDatareadIndex(int offset) Reads a CFF index object are the specified offset positionreadIndex(org.apache.fontbox.cff.CFFDataInput input) Reads an index from the current position of the CFFDataInput objectprivate CFFDataReader.CFFIndexDataprivate booleanreadNibble(StringBuilder realNumber, int nibble) private CFFDataReader.FontDictsetFDData(CFFDataReader.DICTEntry privateFDEntry, CFFDataReader.FontDict newFontDict)
-
Field Details
-
cffData
private org.apache.fontbox.cff.CFFDataInput cffData -
header
private byte[] header -
nameIndex
-
topDICTIndex
-
stringIndex
-
charStringIndex
-
globalIndexSubr
-
localIndexSubr
-
encoding
-
fdSelect
-
fdFonts
-
DOUBLE_BYTE_OPERATOR
private static final int DOUBLE_BYTE_OPERATOR- See Also:
-
NUM_STANDARD_STRINGS
private static final int NUM_STANDARD_STRINGS- See Also:
-
topDict
Commonly used parsed dictionaries
-
-
Constructor Details
-
CFFDataReader
public CFFDataReader() -
CFFDataReader
Constructor for the CFF data reader which accepts the CFF byte data as an argument.- Parameters:
cffDataArray- A byte array which holds the CFF data- Throws:
IOException
-
CFFDataReader
Constructor for the CFF data reader which accepts a FontFileReader object which points to the original font file as an argument.- Parameters:
fontFile- The font file as represented by a FontFileReader object- Throws:
IOException
-
-
Method Details
-
readCFFData
- Throws:
IOException
-
getPrivateDict
public Map<String,CFFDataReader.DICTEntry> getPrivateDict(CFFDataReader.DICTEntry privateEntry) throws IOException - Throws:
IOException
-
getPrivateDictBytes
- Throws:
IOException
-
getCFFOffsetBytes
Retrieves a number of bytes from the CFF data stream- Parameters:
offset- The offset of the bytes to retrievelength- The number of bytes to retrieve- Returns:
- Returns a byte array of requested bytes
- Throws:
IOException- Throws an IO Exception if an error occurs
-
parseDictData
public LinkedHashMap<String,CFFDataReader.DICTEntry> parseDictData(byte[] dictData) throws IOException Parses the dictionary data and returns a map of objects for each entry- Parameters:
dictData- The data for the dictionary data- Returns:
- Returns a map of type DICTEntry identified by the operand name
- Throws:
IOException- Throws an IO Exception if an error occurs
-
readNibble
-
readHeader
- Throws:
IOException
-
readIndex
Reads a CFF index object are the specified offset position- Parameters:
offset- The position of the index object to read- Returns:
- Returns an object representing the index
- Throws:
IOException- Throws an IO Exception if an error occurs
-
readIndex
- Throws:
IOException
-
readIndex
public CFFDataReader.CFFIndexData readIndex(org.apache.fontbox.cff.CFFDataInput input) throws IOException Reads an index from the current position of the CFFDataInput object- Parameters:
input- The object holding the CFF byte data- Returns:
- Returns an object representing the index
- Throws:
IOException- Throws an IO Exception if an error occurs
-
getSIDFromGID
Retrieves the SID for the given GID object- Parameters:
charsetOffset- The offset of the charset datagid- The GID for which to retrieve the SID- Returns:
- Returns the SID as an integer
- Throws:
IOException
-
getSIDFromGIDFormat
- Throws:
IOException
-
getHeader
public byte[] getHeader() -
getNameIndex
-
getTopDictIndex
-
getTopDictEntries
-
getStringIndex
-
getGlobalIndexSubr
-
getLocalIndexSubr
-
getCharStringIndex
-
getCFFData
public org.apache.fontbox.cff.CFFDataInput getCFFData() -
getEncoding
-
getFDSelect
-
getFDFonts
-
getLocalSubrsForGlyph
- Throws:
IOException
-
readCharStringIndex
Parses the char string index from the CFF byte data- Returns:
- Returns the char string index object
- Throws:
IOException- Throws an IO Exception if an error occurs
-
readEncoding
- Throws:
IOException
-
readFormat0Encoding
private CFFDataReader.Format0Encoding readFormat0Encoding(int format, int numEntries) throws IOException - Throws:
IOException
-
readFormat1Encoding
private CFFDataReader.Format1Encoding readFormat1Encoding(int format, int numEntries) throws IOException - Throws:
IOException
-
readFDSelect
- Throws:
IOException
-
readFormat0FDSelect
- Throws:
IOException
-
readFormat3FDSelect
- Throws:
IOException
-
parseCIDData
- Throws:
IOException
-
setFDData
private CFFDataReader.FontDict setFDData(CFFDataReader.DICTEntry privateFDEntry, CFFDataReader.FontDict newFontDict) throws IOException - Throws:
IOException
-
getString
- Throws:
IOException
-
readLocalIndexSubrs
- Throws:
IOException
-