com.lowagie.text.pdf
public class CFFFontSubset extends CFFFont
Field Summary | |
---|---|
static byte | ENDCHAR_OP
Operator codes for unused CharStrings and unused local and global Subrs |
HashMap | FDArrayUsed
A HashMap for keeping the FDArrays being used by the font |
ArrayList | glyphsInList
The GlyphsUsed keys as an ArrayList |
int | GBias
The bias for the global subroutines |
HashMap | GlyphsUsed
A HashMap containing the glyphs used in the text after being converted
to glyph number by the CMap |
HashMap | hGSubrsUsed
A HashMap for keeping the Global subroutines used in the font |
HashMap[] | hSubrsUsed
A HashMaps array for keeping the subroutines used in each FontDict |
HashMap | hSubrsUsedNonCID
A HashMap for keeping the subroutines used in a non-cid font |
ArrayList | lGSubrsUsed
The Global SubroutinesUsed HashMaps as ArrayLists |
ArrayList[] | lSubrsUsed
The SubroutinesUsed HashMaps as ArrayLists |
ArrayList | lSubrsUsedNonCID
The SubroutinesUsed HashMap as ArrayList |
byte[] | NewCharStringsIndex
The new CharString of the font |
byte[] | NewGSubrsIndex
The new global subroutines index of the font |
byte[][] | NewLSubrsIndex
An array of the new Indexes for the local Subr. |
byte[] | NewSubrsIndexNonCID
The new subroutines index for a non-cid font |
int | NumOfHints
Number of arguments to the stem operators in a subroutine calculated recursively |
LinkedList | OutputList
The linked list for generating the new font stream |
static byte | RETURN_OP |
static String[] | SubrsEscapeFuncs
The Strings in this array represent Type1/Type2 escape operator names |
static String[] | SubrsFunctions
The Strings in this array represent Type1/Type2 operator names |
Constructor Summary | |
---|---|
CFFFontSubset(RandomAccessFileOrArray rf, HashMap GlyphsUsed)
C'tor for CFFFontSubset |
Method Summary | |
---|---|
protected byte[] | AssembleIndex(int[] NewOffsets, byte[] NewObjects)
Function creates the new index, inserting the count,offsetsize,offset array
and object array. |
protected void | BuildFDArrayUsed(int Font)
Function reads the FDSelect and builds the FDArrayUsed HashMap According to the glyphs used |
protected void | BuildFDSubrsOffsets(int Font, int FD)
The function finds for the FD array processed the local subr offset and its
offset array. |
protected void | BuildGSubrsUsed(int Font)
Function scans the Glsubr used ArrayList to find recursive calls
to Gsubrs and adds to Hashmap & ArrayList |
protected void | BuildIndexHeader(int Count, int Offsize, int First)
Function Build the header of an index |
protected void | BuildNewCharString(int FontIndex)
Function uses BuildNewIndex to create the new index of the subset charstrings |
protected byte[] | BuildNewFile(int Font)
The function builds the new output stream according to the subset process |
protected byte[] | BuildNewIndex(int[] Offsets, HashMap Used, byte OperatorForUnusedEntries)
Function builds the new offset array, object array and assembles the index.
used for creating the glyph and subrs subsetted index |
protected void | BuildNewLGSubrs(int Font)
Function builds the new local & global subsrs indices. |
protected void | BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffsets, HashMap hSubr, ArrayList lSubr)
Function uses ReadAsubr on the glyph used to build the LSubr & Gsubr HashMap.
|
protected int | countEntireIndexRange(int indexOffset)
Function computes the size of an index |
protected int | CalcBias(int Offset, int Font)
Function calcs bias according to the CharString type and the count
of the subrs |
protected int | CalcHints(int begin, int end, int LBias, int GBias, int[] LSubrsOffsets)
The function reads the subroutine and returns the number of the hint in it.
|
int | CalcSubrOffsetSize(int Offset, int Size)
Calculates how many byte it took to write the offset for the subrs in a specific
private dict. |
protected void | CopyHeader()
Function Copies the header from the original fileto the output list |
int | CountCharset(int Offset, int NumofGlyphs)
Calculates the length of the charset according to its format |
int | CountRange(int NumofGlyphs, int Type)
Function calculates the number of ranges in the Charset |
protected void | CreateCharset(OffsetItem charsetRef, int nglyphs)
Function creates new CharSet for non-CID fonts.
|
protected void | CreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int Font)
Function creates new FDArray for non-CID fonts.
|
protected void | CreateFDSelect(OffsetItem fdselectRef, int nglyphs)
Function creates new FDSelect for non-CID fonts.
|
protected void | CreateKeys(OffsetItem fdarrayRef, OffsetItem fdselectRef, OffsetItem charsetRef, OffsetItem charstringsRef)
Function adds the keys into the TopDict |
protected void | CreateNewStringIndex(int Font)
Function takes the original string item and adds the new strings
to accommodate the CID rules |
void | CreateNonCIDPrivate(int Font, OffsetItem Subr)
The function creates a private dict for a font that was not CID
All the keys are copied as is except for the subrs key |
void | CreateNonCIDSubrs(int Font, IndexBaseItem PrivateBase, OffsetItem Subrs)
the function marks the beginning of the subrs index and adds the subsetted subrs
index to the output list. |
protected void | EmptyStack()
Empty the Type2 Stack
|
protected void | HandelStack()
Function Checks how the current operator effects the run time stack after being run
An operator may increase or decrease the stack size |
protected void | PopStack()
Pop one element from the stack
|
byte[] | Process(String fontName)
The Process function extracts one font out of the CFF file and returns a
subset version of the original. |
protected void | PushStack()
Add an item to the stack
|
protected void | readFDSelect(int Font)
Read the FDSelect of the font and compute the array and its length |
protected void | ReadASubr(int begin, int end, int GBias, int LBias, HashMap hSubr, ArrayList lSubr, int[] LSubrsOffsets)
The function reads a subrs (glyph info) between begin and end.
|
protected void | ReadCommand()
The function reads the next command after the file pointer is set |
protected void | ReadFDArray(int Font)
Read the FDArray count, offsize and Offset array |
void | Reconstruct(int Font)
Function reconstructs the FDArray, PrivateDict and LSubr for CID fonts |
void | ReconstructFDArray(int Font, OffsetItem[] fdPrivate)
Function subsets the FDArray and builds the new one with new offsets |
void | ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)
Function Adds the new private dicts (only for the FDs used) to the list |
void | ReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)
Function Adds the new LSubrs dicts (only for the FDs used) to the list |
protected int | StackOpp()
Function checks the key and return the change to the stack after the operator |
Parameters: rf - The font file GlyphsUsed - a HashMap that contains the glyph used in the subset
Parameters: NewOffsets the subsetted offset array NewObjects the subsetted object array
Returns: the new index created
Parameters: Font the Number of font being processed
Parameters: Font the font FD The FDARRAY processed
Parameters: Font the font
Parameters: Count the count field of the index Offsize the offsize field of the index First the first offset of the index
Parameters: FontIndex the font
Throws: IOException
Parameters: Font the font
Returns: the subsetted font stream
Parameters: Offsets the offset array of the original index Used the hashmap of the used objects OperatorForUnusedEntries the operator inserted into the data stream for unused entries
Returns: the new index subset version
Throws: IOException
Parameters: Font the font
Throws: IOException
Parameters: Font the font FD FD array processed. 0 indicates function was called by non CID font SubrOffset the offset to the subr index to calc the bias SubrsOffsets the offset array of the subr index hSubr HashMap of the subrs used lSubr ArrayList of the subrs used
Parameters: indexOffset The offset for the computed index
Returns: The size of the index
Parameters: Offset The offset to the relevant subrs index Font the font
Returns: The calculated Bias
Parameters: begin the start point of the subr end the end point of the subr LBias the bias of the Local Subrs GBias the bias of the Global Subrs LSubrsOffsets The Offsets array of the subroutines
Returns: The number of hints in the subroutine read.
Parameters: Offset The Offset for the private dict Size The size of the private dict
Returns: The size of the offset of the subrs in the private dict
Parameters: Offset The Charset Offset NumofGlyphs Number of glyphs in the font
Returns: the length of the Charset
Parameters: NumofGlyphs The number of glyphs in the font Type The format of the Charset
Returns: The number of ranges in the Charset data structure
Parameters: charsetRef OffsetItem for the CharSet nglyphs the number of glyphs in the font
Parameters: fdarrayRef OffsetItem for the FDArray privateRef OffsetItem for the Private Dict Font the font
Parameters: fdselectRef OffsetItem for the FDSelect nglyphs the number of glyphs in the font
Parameters: fdarrayRef OffsetItem for the FDArray fdselectRef OffsetItem for the FDSelect charsetRef OffsetItem for the CharSet charstringsRef OffsetItem for the CharString
Parameters: Font the font
Parameters: Font the font Subr The OffsetItem for the subrs of the private
Parameters: Font the font PrivateBase IndexBaseItem for the private that's referencing to the subrs Subrs OffsetItem for the subrs
Parameters: fontName - The name of the font to be taken out of the CFF
Returns: The new font stream
Throws: IOException
Parameters: Font The index of the font being processed
Parameters: begin the start point of the subr end the end point of the subr GBias the bias of the Global Subrs LBias the bias of the Local Subrs hSubr the HashMap for the lSubrs lSubr the ArrayList for the lSubrs
Parameters: Font
Parameters: Font the font
Parameters: Font The font fdPrivate OffsetItem Array (one for each FDArray)
Parameters: Font the font fdPrivate OffsetItem array one element for each private fdPrivateBase IndexBaseItem array one element for each private fdSubrs OffsetItem array one element for each private
Parameters: Font The index of the font fdPrivateBase The IndexBaseItem array for the linked list fdSubrs OffsetItem array for the linked list
Returns: The change in the stack. 2-> flush the stack