|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.pdf.CFFFont
com.lowagie.text.pdf.CFFFontSubset
public class CFFFontSubset
This Class subsets a CFF Type Font. The subset is preformed for CID fonts and NON CID fonts. The Charstring is subsetted 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 although 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)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.lowagie.text.pdf.CFFFont |
---|
CFFFont.DictNumberItem, CFFFont.DictOffsetItem, CFFFont.Font, CFFFont.IndexBaseItem, CFFFont.IndexMarkerItem, CFFFont.IndexOffsetItem, CFFFont.Item, CFFFont.MarkerItem, CFFFont.OffsetItem, CFFFont.RangeItem, CFFFont.StringItem, CFFFont.SubrMarkerItem, CFFFont.UInt16Item, CFFFont.UInt24Item, CFFFont.UInt32Item, CFFFont.UInt8Item |
Field Summary | |
---|---|
(package private) static byte |
ENDCHAR_OP
Operator codes for unused CharStrings and unused local and global Subrs |
(package private) HashMap |
FDArrayUsed
A HashMap for keeping the FDArrays being used by the font |
(package private) int |
GBias
The bias for the global subroutines |
(package private) ArrayList |
glyphsInList
The GlyphsUsed keys as an ArrayList |
(package private) HashMap |
GlyphsUsed
A HashMap containing the glyphs used in the text after being converted to glyph number by the CMap |
(package private) HashMap |
hGSubrsUsed
A HashMap for keeping the Global subroutines used in the font |
(package private) HashMap[] |
hSubrsUsed
A HashMaps array for keeping the subroutines used in each FontDict |
(package private) HashMap |
hSubrsUsedNonCID
A HashMap for keeping the subroutines used in a non-cid font |
(package private) ArrayList |
lGSubrsUsed
The Global SubroutinesUsed HashMaps as ArrayLists |
(package private) ArrayList[] |
lSubrsUsed
The SubroutinesUsed HashMaps as ArrayLists |
(package private) ArrayList |
lSubrsUsedNonCID
The SubroutinesUsed HashMap as ArrayList |
(package private) byte[] |
NewCharStringsIndex
The new CharString of the font |
(package private) byte[] |
NewGSubrsIndex
The new global subroutines index of the font |
(package private) byte[][] |
NewLSubrsIndex
An array of the new Indexes for the local Subr. |
(package private) byte[] |
NewSubrsIndexNonCID
The new subroutines index for a non-cid font |
(package private) int |
NumOfHints
Number of arguments to the stem operators in a subroutine calculated recursively |
(package private) LinkedList |
OutputList
The linked list for generating the new font stream |
(package private) static byte |
RETURN_OP
|
(package private) static String[] |
SubrsEscapeFuncs
The Strings in this array represent Type1/Type2 escape operator names |
(package private) static String[] |
SubrsFunctions
The Strings in this array represent Type1/Type2 operator names |
Fields inherited from class com.lowagie.text.pdf.CFFFont |
---|
arg_count, args, buf, fonts, gsubrIndexOffset, gsubrOffsets, key, nameIndexOffset, nameOffsets, nextIndexOffset, operatorNames, standardStrings, stringIndexOffset, stringOffsets, topdictIndexOffset, topdictOffsets |
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. |
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 |
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. |
(package private) 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 |
(package private) int |
CountCharset(int Offset,
int NumofGlyphs)
Calculates the length of the charset according to its format |
protected int |
countEntireIndexRange(int indexOffset)
Function computes the size of an index |
(package private) int |
CountRange(int NumofGlyphs,
int Type)
Function calculates the number of ranges in the Charset |
protected void |
CreateCharset(CFFFont.OffsetItem charsetRef,
int nglyphs)
Function creates new CharSet for non-CID fonts. |
protected void |
CreateFDArray(CFFFont.OffsetItem fdarrayRef,
CFFFont.OffsetItem privateRef,
int Font)
Function creates new FDArray for non-CID fonts. |
protected void |
CreateFDSelect(CFFFont.OffsetItem fdselectRef,
int nglyphs)
Function creates new FDSelect for non-CID fonts. |
protected void |
CreateKeys(CFFFont.OffsetItem fdarrayRef,
CFFFont.OffsetItem fdselectRef,
CFFFont.OffsetItem charsetRef,
CFFFont.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 |
(package private) void |
CreateNonCIDPrivate(int Font,
CFFFont.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 |
(package private) void |
CreateNonCIDSubrs(int Font,
CFFFont.IndexBaseItem PrivateBase,
CFFFont.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 |
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 |
protected void |
readFDSelect(int Font)
Read the FDSelect of the font and compute the array and its length |
(package private) void |
Reconstruct(int Font)
Function reconstructs the FDArray, PrivateDict and LSubr for CID fonts |
(package private) void |
ReconstructFDArray(int Font,
CFFFont.OffsetItem[] fdPrivate)
Function subsets the FDArray and builds the new one with new offsets |
(package private) void |
ReconstructPrivateDict(int Font,
CFFFont.OffsetItem[] fdPrivate,
CFFFont.IndexBaseItem[] fdPrivateBase,
CFFFont.OffsetItem[] fdSubrs)
Function Adds the new private dicts (only for the FDs used) to the list |
(package private) void |
ReconstructPrivateSubrs(int Font,
CFFFont.IndexBaseItem[] fdPrivateBase,
CFFFont.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 |
Methods inherited from class com.lowagie.text.pdf.CFFFont |
---|
exists, getCard16, getCard8, getCID, getDictItem, getEntireIndexRange, getIndex, getInt, getNames, getOffset, getPosition, getShort, getString, isCID, ReadEncoding, seek |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final String[] SubrsFunctions
static final String[] SubrsEscapeFuncs
static final byte ENDCHAR_OP
static final byte RETURN_OP
HashMap GlyphsUsed
ArrayList glyphsInList
HashMap FDArrayUsed
HashMap[] hSubrsUsed
ArrayList[] lSubrsUsed
HashMap hGSubrsUsed
ArrayList lGSubrsUsed
HashMap hSubrsUsedNonCID
ArrayList lSubrsUsedNonCID
byte[][] NewLSubrsIndex
byte[] NewSubrsIndexNonCID
byte[] NewGSubrsIndex
byte[] NewCharStringsIndex
int GBias
LinkedList OutputList
int NumOfHints
Constructor Detail |
---|
public CFFFontSubset(RandomAccessFileOrArray rf, HashMap GlyphsUsed)
rf
- - The font fileGlyphsUsed
- - a HashMap that contains the glyph used in the subsetMethod Detail |
---|
int CountCharset(int Offset, int NumofGlyphs)
Offset
- The Charset OffsetNumofGlyphs
- Number of glyphs in the font
int CountRange(int NumofGlyphs, int Type)
NumofGlyphs
- The number of glyphs in the fontType
- The format of the Charset
protected void readFDSelect(int Font)
Font
- The index of the font being processedprotected void BuildFDArrayUsed(int Font)
Font
- the Number of font being processedprotected void ReadFDArray(int Font)
Font
- public byte[] Process(String fontName) throws IOException
fontName
- - The name of the font to be taken out of the CFF
IOException
protected int CalcBias(int Offset, int Font)
Offset
- The offset to the relevant subrs indexFont
- the font
protected void BuildNewCharString(int FontIndex) throws IOException
FontIndex
- the font
IOException
protected void BuildNewLGSubrs(int Font) throws IOException
Font
- the font
IOException
protected void BuildFDSubrsOffsets(int Font, int FD)
Font
- the fontFD
- The FDARRAY processedprotected void BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffsets, HashMap hSubr, ArrayList lSubr)
Font
- the fontFD
- FD array processed. 0 indicates function was called by non CID fontSubrOffset
- the offset to the subr index to calc the biasSubrsOffsets
- the offset array of the subr indexhSubr
- HashMap of the subrs usedlSubr
- ArrayList of the subrs usedprotected void BuildGSubrsUsed(int Font)
Font
- the fontprotected void ReadASubr(int begin, int end, int GBias, int LBias, HashMap hSubr, ArrayList lSubr, int[] LSubrsOffsets)
begin
- the start point of the subrend
- the end point of the subrGBias
- the bias of the Global SubrsLBias
- the bias of the Local SubrshSubr
- the HashMap for the lSubrslSubr
- the ArrayList for the lSubrsprotected void HandelStack()
protected int StackOpp()
protected void EmptyStack()
protected void PopStack()
protected void PushStack()
protected void ReadCommand()
protected int CalcHints(int begin, int end, int LBias, int GBias, int[] LSubrsOffsets)
begin
- the start point of the subrend
- the end point of the subrLBias
- the bias of the Local SubrsGBias
- the bias of the Global SubrsLSubrsOffsets
- The Offsets array of the subroutines
protected byte[] BuildNewIndex(int[] Offsets, HashMap Used, byte OperatorForUnusedEntries) throws IOException
Offsets
- the offset array of the original indexUsed
- the hashmap of the used objectsOperatorForUnusedEntries
- the operator inserted into the data stream for unused entries
IOException
protected byte[] AssembleIndex(int[] NewOffsets, byte[] NewObjects)
NewOffsets
- the subsetted offset arrayNewObjects
- the subsetted object array
protected byte[] BuildNewFile(int Font)
Font
- the font
protected void CopyHeader()
protected void BuildIndexHeader(int Count, int Offsize, int First)
Count
- the count field of the indexOffsize
- the offsize field of the indexFirst
- the first offset of the indexprotected void CreateKeys(CFFFont.OffsetItem fdarrayRef, CFFFont.OffsetItem fdselectRef, CFFFont.OffsetItem charsetRef, CFFFont.OffsetItem charstringsRef)
fdarrayRef
- OffsetItem for the FDArrayfdselectRef
- OffsetItem for the FDSelectcharsetRef
- OffsetItem for the CharSetcharstringsRef
- OffsetItem for the CharStringprotected void CreateNewStringIndex(int Font)
Font
- the fontprotected void CreateFDSelect(CFFFont.OffsetItem fdselectRef, int nglyphs)
fdselectRef
- OffsetItem for the FDSelectnglyphs
- the number of glyphs in the fontprotected void CreateCharset(CFFFont.OffsetItem charsetRef, int nglyphs)
charsetRef
- OffsetItem for the CharSetnglyphs
- the number of glyphs in the fontprotected void CreateFDArray(CFFFont.OffsetItem fdarrayRef, CFFFont.OffsetItem privateRef, int Font)
fdarrayRef
- OffsetItem for the FDArrayprivateRef
- OffsetItem for the Private DictFont
- the fontvoid Reconstruct(int Font)
Font
- the fontvoid ReconstructFDArray(int Font, CFFFont.OffsetItem[] fdPrivate)
Font
- The fontfdPrivate
- OffsetItem Array (one for each FDArray)void ReconstructPrivateDict(int Font, CFFFont.OffsetItem[] fdPrivate, CFFFont.IndexBaseItem[] fdPrivateBase, CFFFont.OffsetItem[] fdSubrs)
Font
- the fontfdPrivate
- OffsetItem array one element for each privatefdPrivateBase
- IndexBaseItem array one element for each privatefdSubrs
- OffsetItem array one element for each privatevoid ReconstructPrivateSubrs(int Font, CFFFont.IndexBaseItem[] fdPrivateBase, CFFFont.OffsetItem[] fdSubrs)
Font
- The index of the fontfdPrivateBase
- The IndexBaseItem array for the linked listfdSubrs
- OffsetItem array for the linked listint CalcSubrOffsetSize(int Offset, int Size)
Offset
- The Offset for the private dictSize
- The size of the private dict
protected int countEntireIndexRange(int indexOffset)
indexOffset
- The offset for the computed index
void CreateNonCIDPrivate(int Font, CFFFont.OffsetItem Subr)
Font
- the fontSubr
- The OffsetItem for the subrs of the privatevoid CreateNonCIDSubrs(int Font, CFFFont.IndexBaseItem PrivateBase, CFFFont.OffsetItem Subrs)
Font
- the fontPrivateBase
- IndexBaseItem for the private that's referencing to the subrsSubrs
- OffsetItem for the subrs
|
Hosted by Hostbasket | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |