Table of Contents

Class CffFontSubset

Namespace
iTextSharp.text.pdf
Assembly
iTextSharp.LGPLv2.Core.dll
public class CffFontSubset : CffFont
Inheritance
CffFontSubset
Inherited Members

Constructors

CffFontSubset(RandomAccessFileOrArray, INullValueDictionary<int, int[]>)

C'tor for CFFFontSubset

public CffFontSubset(RandomAccessFileOrArray rf, INullValueDictionary<int, int[]> glyphsUsed)

Parameters

rf RandomAccessFileOrArray
  • The font file
glyphsUsed INullValueDictionary<int, int[]>
  • a HashMap that contains the glyph used in the subset

Methods

AssembleIndex(int[], byte[])

Function creates the new index, inserting the count,offsetsize,offset array and object array.

protected static byte[] AssembleIndex(int[] newOffsets, byte[] newObjects)

Parameters

newOffsets int[]

the subsetted offset array

newObjects byte[]

the subsetted object array

Returns

byte[]

the new index created

BuildFdArrayUsed(int)

Function reads the FDSelect and builds the FDArrayUsed HashMap According to the glyphs used

protected void BuildFdArrayUsed(int font)

Parameters

font int

the Number of font being processed

BuildFdSubrsOffsets(int, int)

The function finds for the FD array processed the local subr offset and its offset array.

protected void BuildFdSubrsOffsets(int font, int fd)

Parameters

font int

the font

fd int

The FDARRAY processed

BuildGSubrsUsed(int)

Function scans the Glsubr used ArrayList to find recursive calls to Gsubrs and adds to Hashmap and ArrayList

protected void BuildGSubrsUsed(int font)

Parameters

font int

the font

BuildIndexHeader(int, int, int)

Function Build the header of an index

protected void BuildIndexHeader(int count, int offsize, int first)

Parameters

count int

the count field of the index

offsize int

the offsize field of the index

first int

the first offset of the index

BuildNewCharString(int)

Function uses BuildNewIndex to create the new index of the subset charstrings @throws IOException

protected void BuildNewCharString(int fontIndex)

Parameters

fontIndex int

the font

BuildNewFile(int)

The function builds the new output stream according to the subset process @throws IOException

protected byte[] BuildNewFile(int font)

Parameters

font int

the font

Returns

byte[]

the subseted font stream

BuildNewIndex(int[], INullValueDictionary<int, int[]>, byte)

Function builds the new offset array, object array and assembles the index. used for creating the glyph and subrs subsetted index @throws IOException

protected byte[] BuildNewIndex(int[] offsets, INullValueDictionary<int, int[]> used, byte operatorForUnusedEntries)

Parameters

offsets int[]

the offset array of the original index

used INullValueDictionary<int, int[]>

the hashmap of the used objects

operatorForUnusedEntries byte

the operator inserted into the data stream for unused entries

Returns

byte[]

the new index subset version

BuildNewLgSubrs(int)

Function builds the new local and global subsrs indices. IF CID then All of the FD Array lsubrs will be subsetted. @throws IOException

protected void BuildNewLgSubrs(int font)

Parameters

font int

the font

BuildSubrUsed(int, int, int, int[], INullValueDictionary<int, int[]>, IList<int>)

Function uses ReadAsubr on the glyph used to build the LSubr and Gsubr HashMap. The HashMap (of the lsub only) is then scaned recursivly for Lsubr and Gsubrs calls.

protected void BuildSubrUsed(int font, int fd, int subrOffset, int[] subrsOffsets, INullValueDictionary<int, int[]> hSubr, IList<int> lSubr)

Parameters

font int

the font

fd int

FD array processed. 0 indicates function was called by non CID font

subrOffset int

the offset to the subr index to calc the bias

subrsOffsets int[]

the offset array of the subr index

hSubr INullValueDictionary<int, int[]>

HashMap of the subrs used

lSubr IList<int>

ArrayList of the subrs used

CalcBias(int, int)

Function calcs bias according to the CharString type and the count of the subrs

protected int CalcBias(int offset, int font)

Parameters

offset int

The offset to the relevent subrs index

font int

the font

Returns

int

The calculated Bias

CalcHints(int, int, int, int, int[])

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.

protected int CalcHints(int begin, int end, int lBias, int gBias, int[] lSubrsOffsets)

Parameters

begin int

the start point of the subr

end int

the end point of the subr

lBias int

the bias of the Local Subrs

gBias int

the bias of the Global Subrs

lSubrsOffsets int[]

The Offsets array of the subroutines

Returns

int

The number of hints in the subroutine read.

CopyHeader()

Function Copies the header from the original fileto the output list

protected void CopyHeader()

CountEntireIndexRange(int)

Function computes the size of an index

protected int CountEntireIndexRange(int indexOffset)

Parameters

indexOffset int

The offset for the computed index

Returns

int

The size of the index

CreateCharset(OffsetItem, int)

Function creates new CharSet for non-CID fonts. The CharSet built uses a single range for all glyphs

protected void CreateCharset(CffFont.OffsetItem charsetRef, int nglyphs)

Parameters

charsetRef CffFont.OffsetItem

OffsetItem for the CharSet

nglyphs int

the number of glyphs in the font

CreateFdArray(OffsetItem, OffsetItem, int)

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

protected void CreateFdArray(CffFont.OffsetItem fdarrayRef, CffFont.OffsetItem privateRef, int font)

Parameters

fdarrayRef CffFont.OffsetItem

OffsetItem for the FDArray

privateRef CffFont.OffsetItem

OffsetItem for the Private Dict

font int

the font

CreateFdSelect(OffsetItem, int)

Function creates new FDSelect for non-CID fonts. The FDSelect built uses a single range for all glyphs

protected void CreateFdSelect(CffFont.OffsetItem fdselectRef, int nglyphs)

Parameters

fdselectRef CffFont.OffsetItem

OffsetItem for the FDSelect

nglyphs int

the number of glyphs in the font

CreateKeys(OffsetItem, OffsetItem, OffsetItem, OffsetItem)

Function adds the keys into the TopDict

protected void CreateKeys(CffFont.OffsetItem fdarrayRef, CffFont.OffsetItem fdselectRef, CffFont.OffsetItem charsetRef, CffFont.OffsetItem charstringsRef)

Parameters

fdarrayRef CffFont.OffsetItem

OffsetItem for the FDArray

fdselectRef CffFont.OffsetItem

OffsetItem for the FDSelect

charsetRef CffFont.OffsetItem

OffsetItem for the CharSet

charstringsRef CffFont.OffsetItem

OffsetItem for the CharString

CreateNewStringIndex(int)

Function takes the original string item and adds the new strings to accomodate the CID rules

protected void CreateNewStringIndex(int font)

Parameters

font int

the font

EmptyStack()

Empty the Type2 Stack

protected void EmptyStack()

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 HandelStack()

PopStack()

Pop one element from the stack

protected void PopStack()

Process(string)

The Process function extracts one font out of the CFF file and returns a subset version of the original. @throws IOException

public byte[] Process(string fontName)

Parameters

fontName string
  • The name of the font to be taken out of the CFF

Returns

byte[]

The new font stream

PushStack()

Add an item to the stack

protected void PushStack()

ReadASubr(int, int, int, int, INullValueDictionary<int, int[]>, IList<int>, int[])

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.

protected void ReadASubr(int begin, int end, int gBias, int lBias, INullValueDictionary<int, int[]> hSubr, IList<int> lSubr, int[] lSubrsOffsets)

Parameters

begin int

the start point of the subr

end int

the end point of the subr

gBias int

the bias of the Global Subrs

lBias int

the bias of the Local Subrs

hSubr INullValueDictionary<int, int[]>

the HashMap for the lSubrs

lSubr IList<int>
lSubrsOffsets int[]

the ArrayList for the lSubrs

ReadCommand()

The function reads the next command after the file pointer is set

protected void ReadCommand()

ReadFdArray(int)

Read the FDArray count, offsize and Offset array

protected void ReadFdArray(int font)

Parameters

font int

ReadFdSelect(int)

Read the FDSelect of the font and compute the array and its length

protected void ReadFdSelect(int font)

Parameters

font int

The index of the font being processed

StackOpp()

Function checks the key and return the change to the stack after the operator

protected int StackOpp()

Returns

int

The change in the stack. 2-> flush the stack