| java.lang.Object com.lowagie.text.pdf.CFFFont com.lowagie.text.pdf.CFFFontSubset
CFFFontSubset | public class CFFFontSubset extends CFFFont (Code) | | This Class subsets a CFF Type Font. The subset is preformed for CID fonts and NON CID fonts.
The Charstring is subseted for both types. For CID fonts only the FDArray which are used are embedded.
The Lsubroutines of the FDArrays used are subsetted as well. The Subroutine subset supports both Type1 and Type2
formatting altough only tested on Type2 Format.
For Non CID the Lsubroutines are subsetted. On both types the Gsubroutines is subsetted.
A font which was not of CID type is transformed into CID as a part of the subset process.
The CID synthetic creation was written by Sivan Toledo (sivan@math.tau.ac.il)
author: Oren Manor (manorore@post.tau.ac.il) and Ygal Blum (blumygal@post.tau.ac.il) |
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) | 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) | protected void | BuildIndexHeader(int Count, int Offsize, int First) | protected void | BuildNewCharString(int FontIndex) | protected byte[] | BuildNewFile(int Font) | protected byte[] | BuildNewIndex(int[] Offsets, HashMap Used) Function builds the new offset array, object array and assembles the 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.
The HashMap (of the lsub only) is then scaned recursivly for Lsubr & Gsubrs
calls. | protected int | CalcBias(int Offset, int Font) | 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() | int | CountCharset(int Offset, int NumofGlyphs) | int | CountRange(int NumofGlyphs, int Type) | 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) | protected void | CreateNewStringIndex(int Font) | void | CreateNonCIDPrivate(int Font, OffsetItem Subr) | 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() | protected void | HandelStack() | protected void | PopStack() | public 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() | 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() | protected void | ReadFDArray(int Font) | void | Reconstruct(int Font) | void | ReconstructFDArray(int Font, OffsetItem[] fdPrivate) | void | ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs) | void | ReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs) | protected int | StackOpp() Function checks the key and return the change to the stack after the operator
The change in the stack. | protected int | countEntireIndexRange(int indexOffset) | protected void | readFDSelect(int Font) |
FDArrayUsed | HashMap FDArrayUsed(Code) | | A HashMap for keeping the FDArrays being used by the font
|
GBias | int GBias(Code) | | The bias for the global subroutines
|
GlyphsUsed | HashMap GlyphsUsed(Code) | | A HashMap containing the glyphs used in the text after being converted
to glyph number by the CMap
|
NewCharStringsIndex | byte[] NewCharStringsIndex(Code) | | The new CharString of the font
|
NewGSubrsIndex | byte[] NewGSubrsIndex(Code) | | The new global subroutines index of the font
|
NewLSubrsIndex | byte[][] NewLSubrsIndex(Code) | | An array of the new Indexs for the local Subr. One index for each FontDict
|
NewSubrsIndexNonCID | byte[] NewSubrsIndexNonCID(Code) | | The new subroutines index for a non-cid font
|
NumOfHints | int NumOfHints(Code) | | Number of arguments to the stem operators in a subroutine calculated recursivly
|
OutputList | LinkedList OutputList(Code) | | The linked list for generating the new font stream
|
SubrsEscapeFuncs | final static String SubrsEscapeFuncs(Code) | | The Strings in this array represent Type1/Type2 escape operator names
|
SubrsFunctions | final static String SubrsFunctions(Code) | | The Strings in this array represent Type1/Type2 operator names
|
glyphsInList | ArrayList glyphsInList(Code) | | The GlyphsUsed keys as an ArrayList
|
hGSubrsUsed | HashMap hGSubrsUsed(Code) | | A HashMap for keeping the Global subroutines used in the font
|
hSubrsUsed | HashMap[] hSubrsUsed(Code) | | A HashMaps array for keeping the subroutines used in each FontDict
|
hSubrsUsedNonCID | HashMap hSubrsUsedNonCID(Code) | | A HashMap for keeping the subroutines used in a non-cid font
|
lGSubrsUsed | ArrayList lGSubrsUsed(Code) | | The Global SubroutinesUsed HashMaps as ArrayLists
|
lSubrsUsed | ArrayList[] lSubrsUsed(Code) | | The SubroutinesUsed HashMaps as ArrayLists
|
lSubrsUsedNonCID | ArrayList lSubrsUsedNonCID(Code) | | The SubroutinesUsed HashMap as ArrayList
|
CFFFontSubset | public CFFFontSubset(RandomAccessFileOrArray rf, HashMap GlyphsUsed)(Code) | | C'tor for CFFFontSubset
Parameters: rf - - The font file Parameters: GlyphsUsed - - a HashMap that contains the glyph used in the subset |
AssembleIndex | protected byte[] AssembleIndex(int[] NewOffsets, byte[] NewObjects)(Code) | | Function creates the new index, inserting the count,offsetsize,offset array
and object array.
Parameters: NewOffsets - the subsetted offset array Parameters: NewObjects - the subsetted object array the new index created |
BuildFDArrayUsed | protected void BuildFDArrayUsed(int Font)(Code) | | Function reads the FDSelect and builds the FDArrayUsed HashMap According to the glyphs used
Parameters: Font - the Number of font being processed |
BuildFDSubrsOffsets | protected void BuildFDSubrsOffsets(int Font, int FD)(Code) | | The function finds for the FD array processed the local subr offset and its
offset array.
Parameters: Font - the font Parameters: FD - The FDARRAY processed |
BuildGSubrsUsed | protected void BuildGSubrsUsed(int Font)(Code) | | Function scans the Glsubr used ArrayList to find recursive calls
to Gsubrs and adds to Hashmap & ArrayList
Parameters: Font - the font |
BuildIndexHeader | protected void BuildIndexHeader(int Count, int Offsize, int First)(Code) | | Function Build the header of an index
Parameters: Count - the count field of the index Parameters: Offsize - the offsize field of the index Parameters: First - the first offset of the index |
BuildNewCharString | protected void BuildNewCharString(int FontIndex) throws IOException(Code) | | Function uses BuildNewIndex to create the new index of the subset charstrings
Parameters: FontIndex - the font throws: IOException - |
BuildNewFile | protected byte[] BuildNewFile(int Font)(Code) | | The function builds the new output stream according to the subset process
Parameters: Font - the font the subseted font stream |
BuildNewIndex | protected byte[] BuildNewIndex(int[] Offsets, HashMap Used) throws IOException(Code) | | Function builds the new offset array, object array and assembles the index.
used for creating the glyph and subrs subsetted index
Parameters: Offsets - the offset array of the original index Parameters: Used - the hashmap of the used objects the new index subset version throws: IOException - |
BuildNewLGSubrs | protected void BuildNewLGSubrs(int Font) throws IOException(Code) | | Function builds the new local & global subsrs indices. IF CID then All of
the FD Array lsubrs will be subsetted.
Parameters: Font - the font throws: IOException - |
BuildSubrUsed | protected void BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffsets, HashMap hSubr, ArrayList lSubr)(Code) | | Function uses ReadAsubr on the glyph used to build the LSubr & Gsubr HashMap.
The HashMap (of the lsub only) is then scaned recursivly for Lsubr & Gsubrs
calls.
Parameters: Font - the font Parameters: FD - FD array processed. 0 indicates function was called by non CID font Parameters: SubrOffset - the offset to the subr index to calc the bias Parameters: SubrsOffsets - the offset array of the subr index Parameters: hSubr - HashMap of the subrs used Parameters: lSubr - ArrayList of the subrs used |
CalcBias | protected int CalcBias(int Offset, int Font)(Code) | | Function calcs bias according to the CharString type and the count
of the subrs
Parameters: Offset - The offset to the relevent subrs index Parameters: Font - the font The calculated Bias |
CalcHints | protected int CalcHints(int begin, int end, int LBias, int GBias, int[] LSubrsOffsets)(Code) | | The function reads the subroutine and returns the number of the hint in it.
If a call to another subroutine is found the function calls recursively.
Parameters: begin - the start point of the subr Parameters: end - the end point of the subr Parameters: LBias - the bias of the Local Subrs Parameters: GBias - the bias of the Global Subrs Parameters: LSubrsOffsets - The Offsets array of the subroutines The number of hints in the subroutine read. |
CalcSubrOffsetSize | int CalcSubrOffsetSize(int Offset, int Size)(Code) | | Calculates how many byte it took to write the offset for the subrs in a specific
private dict.
Parameters: Offset - The Offset for the private dict Parameters: Size - The size of the private dict The size of the offset of the subrs in the private dict |
CopyHeader | protected void CopyHeader()(Code) | | Function Copies the header from the original fileto the output list
|
CountCharset | int CountCharset(int Offset, int NumofGlyphs)(Code) | | Calculates the length of the charset according to its format
Parameters: Offset - The Charset Offset Parameters: NumofGlyphs - Number of glyphs in the font the length of the Charset |
CountRange | int CountRange(int NumofGlyphs, int Type)(Code) | | Function calculates the number of ranges in the Charset
Parameters: NumofGlyphs - The number of glyphs in the font Parameters: Type - The format of the Charset The number of ranges in the Charset data structure |
CreateCharset | protected void CreateCharset(OffsetItem charsetRef, int nglyphs)(Code) | | Function creates new CharSet for non-CID fonts.
The CharSet built uses a single range for all glyphs
Parameters: charsetRef - OffsetItem for the CharSet Parameters: nglyphs - the number of glyphs in the font |
CreateFDArray | protected void CreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int Font)(Code) | | Function creates new FDArray for non-CID fonts.
The FDArray built has only the "Private" operator that points to the font's
original private dict
Parameters: fdarrayRef - OffsetItem for the FDArray Parameters: privateRef - OffsetItem for the Private Dict Parameters: Font - the font |
CreateFDSelect | protected void CreateFDSelect(OffsetItem fdselectRef, int nglyphs)(Code) | | Function creates new FDSelect for non-CID fonts.
The FDSelect built uses a single range for all glyphs
Parameters: fdselectRef - OffsetItem for the FDSelect Parameters: nglyphs - the number of glyphs in the font |
CreateKeys | protected void CreateKeys(OffsetItem fdarrayRef, OffsetItem fdselectRef, OffsetItem charsetRef, OffsetItem charstringsRef)(Code) | | Function adds the keys into the TopDict
Parameters: fdarrayRef - OffsetItem for the FDArray Parameters: fdselectRef - OffsetItem for the FDSelect Parameters: charsetRef - OffsetItem for the CharSet Parameters: charstringsRef - OffsetItem for the CharString |
CreateNewStringIndex | protected void CreateNewStringIndex(int Font)(Code) | | Function takes the original string item and adds the new strings
to accomodate the CID rules
Parameters: Font - the font |
CreateNonCIDPrivate | void CreateNonCIDPrivate(int Font, OffsetItem Subr)(Code) | | 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
Parameters: Font - the font Parameters: Subr - The OffsetItem for the subrs of the private |
CreateNonCIDSubrs | void CreateNonCIDSubrs(int Font, IndexBaseItem PrivateBase, OffsetItem Subrs)(Code) | | the function marks the beginning of the subrs index and adds the subsetted subrs
index to the output list.
Parameters: Font - the font Parameters: PrivateBase - IndexBaseItem for the private that's referencing to the subrs Parameters: Subrs - OffsetItem for the subrs |
EmptyStack | protected void EmptyStack()(Code) | | Empty the Type2 Stack
|
HandelStack | protected void HandelStack()(Code) | | Function Checks how the current operator effects the run time stack after being run
An operator may increase or decrease the stack size
|
PopStack | protected void PopStack()(Code) | | Pop one element from the stack
|
Process | public byte[] Process(String fontName) throws IOException(Code) | | The Process function extracts one font out of the CFF file and returns a
subset version of the original.
Parameters: fontName - - The name of the font to be taken out of the CFF The new font stream throws: IOException - |
PushStack | protected void PushStack()(Code) | | Add an item to the stack
|
ReadASubr | protected void ReadASubr(int begin, int end, int GBias, int LBias, HashMap hSubr, ArrayList lSubr, int[] LSubrsOffsets)(Code) | | The function reads a subrs (glyph info) between begin and end.
Adds calls to a Lsubr to the hSubr and lSubrs.
Adds calls to a Gsubr to the hGSubr and lGSubrs.
Parameters: begin - the start point of the subr Parameters: end - the end point of the subr Parameters: GBias - the bias of the Global Subrs Parameters: LBias - the bias of the Local Subrs Parameters: hSubr - the HashMap for the lSubrs Parameters: lSubr - the ArrayList for the lSubrs |
ReadCommand | protected void ReadCommand()(Code) | | The function reads the next command after the file pointer is set
|
ReadFDArray | protected void ReadFDArray(int Font)(Code) | | Read the FDArray count, offsize and Offset array
Parameters: Font - |
Reconstruct | void Reconstruct(int Font)(Code) | | Function reconstructs the FDArray, PrivateDict and LSubr for CID fonts
Parameters: Font - the font |
ReconstructFDArray | void ReconstructFDArray(int Font, OffsetItem[] fdPrivate)(Code) | | Function subsets the FDArray and builds the new one with new offsets
Parameters: Font - The font Parameters: fdPrivate - OffsetItem Array (one for each FDArray) |
ReconstructPrivateDict | void ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)(Code) | | Function Adds the new private dicts (only for the FDs used) to the list
Parameters: Font - the font Parameters: fdPrivate - OffsetItem array one element for each private Parameters: fdPrivateBase - IndexBaseItem array one element for each private Parameters: fdSubrs - OffsetItem array one element for each private |
ReconstructPrivateSubrs | void ReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, OffsetItem[] fdSubrs)(Code) | | Function Adds the new LSubrs dicts (only for the FDs used) to the list
Parameters: Font - The index of the font Parameters: fdPrivateBase - The IndexBaseItem array for the linked list Parameters: fdSubrs - OffsetItem array for the linked list |
StackOpp | protected int StackOpp()(Code) | | Function checks the key and return the change to the stack after the operator
The change in the stack. 2-> flush the stack |
countEntireIndexRange | protected int countEntireIndexRange(int indexOffset)(Code) | | Function computes the size of an index
Parameters: indexOffset - The offset for the computed index The size of the index |
readFDSelect | protected void readFDSelect(int Font)(Code) | | Read the FDSelect of the font and compute the array and its length
Parameters: Font - The index of the font being processed |
|
|