Package org.apache.fop.fonts.cff
Class CFFDataReader
- java.lang.Object
-
- org.apache.fop.fonts.cff.CFFDataReader
-
public class CFFDataReader extends java.lang.Object
A class to read the CFF data from an OTF CFF font file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CFFDataReader.CFFIndexData
An object used to hold index data from the CFF dataclass
CFFDataReader.CFFSubTable
Parent class which provides the ability to retrieve byte data from a sub-table.class
CFFDataReader.CustomEncoding
private static class
CFFDataReader.DataLocation
static class
CFFDataReader.DICTEntry
A class containing data for a dictionary entryclass
CFFDataReader.FDSelect
class
CFFDataReader.FontDict
class
CFFDataReader.Format0Encoding
class
CFFDataReader.Format0FDSelect
class
CFFDataReader.Format1Encoding
class
CFFDataReader.Format3FDSelect
-
Field Summary
Fields Modifier and Type Field Description private org.apache.fontbox.cff.CFFDataInput
cffData
private CFFDataReader.CFFIndexData
charStringIndex
private static int
DOUBLE_BYTE_OPERATOR
private CFFDataReader.CustomEncoding
encoding
private java.util.List<CFFDataReader.FontDict>
fdFonts
private CFFDataReader.FDSelect
fdSelect
private CFFDataReader.CFFIndexData
globalIndexSubr
private byte[]
header
private CFFDataReader.CFFIndexData
localIndexSubr
private CFFDataReader.CFFIndexData
nameIndex
private static int
NUM_STANDARD_STRINGS
private CFFDataReader.CFFIndexData
stringIndex
private java.util.LinkedHashMap<java.lang.String,CFFDataReader.DICTEntry>
topDict
Commonly used parsed dictionariesprivate CFFDataReader.CFFIndexData
topDICTIndex
-
Constructor Summary
Constructors Constructor Description CFFDataReader()
CFFDataReader(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
-
-
-
Field Detail
-
cffData
private org.apache.fontbox.cff.CFFDataInput cffData
-
header
private byte[] header
-
nameIndex
private CFFDataReader.CFFIndexData nameIndex
-
topDICTIndex
private CFFDataReader.CFFIndexData topDICTIndex
-
stringIndex
private CFFDataReader.CFFIndexData stringIndex
-
charStringIndex
private CFFDataReader.CFFIndexData charStringIndex
-
globalIndexSubr
private CFFDataReader.CFFIndexData globalIndexSubr
-
localIndexSubr
private CFFDataReader.CFFIndexData localIndexSubr
-
encoding
private CFFDataReader.CustomEncoding encoding
-
fdSelect
private CFFDataReader.FDSelect fdSelect
-
fdFonts
private java.util.List<CFFDataReader.FontDict> fdFonts
-
DOUBLE_BYTE_OPERATOR
private static final int DOUBLE_BYTE_OPERATOR
- See Also:
- Constant Field Values
-
NUM_STANDARD_STRINGS
private static final int NUM_STANDARD_STRINGS
- See Also:
- Constant Field Values
-
topDict
private java.util.LinkedHashMap<java.lang.String,CFFDataReader.DICTEntry> topDict
Commonly used parsed dictionaries
-
-
Constructor Detail
-
CFFDataReader
public CFFDataReader()
-
CFFDataReader
public CFFDataReader(byte[] cffDataArray) throws java.io.IOException
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:
java.io.IOException
-
CFFDataReader
public CFFDataReader(FontFileReader fontFile) throws java.io.IOException
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:
java.io.IOException
-
-
Method Detail
-
readCFFData
private void readCFFData() throws java.io.IOException
- Throws:
java.io.IOException
-
getPrivateDict
public java.util.Map<java.lang.String,CFFDataReader.DICTEntry> getPrivateDict(CFFDataReader.DICTEntry privateEntry) throws java.io.IOException
- Throws:
java.io.IOException
-
getPrivateDictBytes
public byte[] getPrivateDictBytes(CFFDataReader.DICTEntry privateEntry) throws java.io.IOException
- Throws:
java.io.IOException
-
getCFFOffsetBytes
private byte[] getCFFOffsetBytes(int offset, int length) throws java.io.IOException
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:
java.io.IOException
- Throws an IO Exception if an error occurs
-
parseDictData
public java.util.LinkedHashMap<java.lang.String,CFFDataReader.DICTEntry> parseDictData(byte[] dictData) throws java.io.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:
java.io.IOException
- Throws an IO Exception if an error occurs
-
readNibble
private boolean readNibble(java.lang.StringBuilder realNumber, int nibble)
-
readHeader
private byte[] readHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
readIndex
public CFFDataReader.CFFIndexData readIndex(int offset) throws java.io.IOException
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:
java.io.IOException
- Throws an IO Exception if an error occurs
-
readIndex
private CFFDataReader.CFFIndexData readIndex() throws java.io.IOException
- Throws:
java.io.IOException
-
readIndex
public CFFDataReader.CFFIndexData readIndex(org.apache.fontbox.cff.CFFDataInput input) throws java.io.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:
java.io.IOException
- Throws an IO Exception if an error occurs
-
getSIDFromGID
public int getSIDFromGID(int charsetOffset, int gid) throws java.io.IOException
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:
java.io.IOException
-
getSIDFromGIDFormat
private int getSIDFromGIDFormat(int gid, int format) throws java.io.IOException
- Throws:
java.io.IOException
-
getHeader
public byte[] getHeader()
-
getNameIndex
public CFFDataReader.CFFIndexData getNameIndex()
-
getTopDictIndex
public CFFDataReader.CFFIndexData getTopDictIndex()
-
getTopDictEntries
public java.util.LinkedHashMap<java.lang.String,CFFDataReader.DICTEntry> getTopDictEntries()
-
getStringIndex
public CFFDataReader.CFFIndexData getStringIndex()
-
getGlobalIndexSubr
public CFFDataReader.CFFIndexData getGlobalIndexSubr()
-
getLocalIndexSubr
public CFFDataReader.CFFIndexData getLocalIndexSubr()
-
getCharStringIndex
public CFFDataReader.CFFIndexData getCharStringIndex()
-
getCFFData
public org.apache.fontbox.cff.CFFDataInput getCFFData()
-
getEncoding
public CFFDataReader.CustomEncoding getEncoding()
-
getFDSelect
public CFFDataReader.FDSelect getFDSelect()
-
getFDFonts
public java.util.List<CFFDataReader.FontDict> getFDFonts()
-
getLocalSubrsForGlyph
public org.apache.fontbox.cff.CFFDataInput getLocalSubrsForGlyph(int glyph) throws java.io.IOException
- Throws:
java.io.IOException
-
readCharStringIndex
public CFFDataReader.CFFIndexData readCharStringIndex() throws java.io.IOException
Parses the char string index from the CFF byte data- Returns:
- Returns the char string index object
- Throws:
java.io.IOException
- Throws an IO Exception if an error occurs
-
readEncoding
private CFFDataReader.CustomEncoding readEncoding() throws java.io.IOException
- Throws:
java.io.IOException
-
readFormat0Encoding
private CFFDataReader.Format0Encoding readFormat0Encoding(int format, int numEntries) throws java.io.IOException
- Throws:
java.io.IOException
-
readFormat1Encoding
private CFFDataReader.Format1Encoding readFormat1Encoding(int format, int numEntries) throws java.io.IOException
- Throws:
java.io.IOException
-
readFDSelect
private CFFDataReader.FDSelect readFDSelect() throws java.io.IOException
- Throws:
java.io.IOException
-
readFormat0FDSelect
private CFFDataReader.Format0FDSelect readFormat0FDSelect() throws java.io.IOException
- Throws:
java.io.IOException
-
readFormat3FDSelect
private CFFDataReader.Format3FDSelect readFormat3FDSelect() throws java.io.IOException
- Throws:
java.io.IOException
-
parseCIDData
private java.util.List<CFFDataReader.FontDict> parseCIDData() throws java.io.IOException
- Throws:
java.io.IOException
-
setFDData
private CFFDataReader.FontDict setFDData(CFFDataReader.DICTEntry privateFDEntry, CFFDataReader.FontDict newFontDict) throws java.io.IOException
- Throws:
java.io.IOException
-
getString
private java.lang.String getString(int sid) throws java.io.IOException
- Throws:
java.io.IOException
-
readLocalIndexSubrs
private CFFDataReader.CFFIndexData readLocalIndexSubrs() throws java.io.IOException
- Throws:
java.io.IOException
-
-