iText 8.0.5 API
iText.IO.Font.CFFFontSubset Class Reference

This Class subsets a CFF Type Font. More...

Inheritance diagram for iText.IO.Font.CFFFontSubset:
iText.IO.Font.CFFFont

Public Member Functions

  CFFFontSubset (byte[] cff, ICollection< int > GlyphsUsed)
 
virtual byte[]  Process (String fontName)
  The Process function extracts one font out of the CFF file and returns a subset version of the original. More...
 
virtual byte[]  Process ()
  The Process function extracts one font out of the CFF file and returns a subset version of the original with the first name. More...
 
- Public Member Functions inherited from iText.IO.Font.CFFFont
virtual String  GetString (char sid)
 
virtual byte[]  GetCID (String fontName)
  get a single CID font. More...
 
virtual bool  IsCID ()
 
virtual bool  IsCID (String fontName)
 
virtual bool  Exists (String fontName)
 
virtual String[]  GetNames ()
 
  CFFFont (byte[] cff)
 

Package Functions

virtual void  ReadFDSelect (int Font)
  Read the FDSelect of the font and compute the array and its length More...
 
virtual void  BuildFDArrayUsed (int Font)
  Function reads the FDSelect and builds the FDArrayUsed Map According to the glyphs used More...
 
virtual void  ReadFDArray (int Font)
  Read the FDArray count, offsize and Offset array More...
 
virtual int  CalcBias (int Offset, int Font)
  Function calcs bias according to the CharString type and the count of the subrs More...
 
virtual void  BuildNewCharString (int FontIndex)
  Function uses BuildNewIndex to create the new index of the subset charstrings. More...
 
virtual void  BuildNewLGSubrs (int Font)
  Function builds the new local and global subsrs indices. More...
 
virtual void  BuildFDSubrsOffsets (int Font, int FD)
  The function finds for the FD array processed the local subr offset and its offset array. More...
 
virtual void  BuildSubrUsed (int Font, int FD, int SubrOffset, int[] SubrsOffsets, ICollection< int > hSubr, IList< int > lSubr)
  Function uses ReadAsubr on the glyph used to build the LSubr and Gsubr Map. More...
 
virtual void  BuildGSubrsUsed (int Font)
  Function scans the Glsubr used list to find recursive calls to Gsubrs and adds to Map and list More...
 
virtual void  ReadASubr (int begin, int end, int GBias, int LBias, ICollection< int > hSubr, IList< int > lSubr, int[] LSubrsOffsets)
  The function reads a subrs (glyph info) between begin and end. More...
 
virtual 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 More...
 
virtual int  StackOpp ()
  Function checks the key and return the change to the stack after the operator More...
 
virtual void  EmptyStack ()
  Empty the Type2 Stack More...
 
virtual void  PopStack ()
  Pop one element from the stack More...
 
virtual void  PushStack ()
  Add an item to the stack More...
 
virtual void  ReadCommand ()
  The function reads the next command after the file pointer is set More...
 
virtual 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. More...
 
virtual byte[]  BuildNewIndex (int[] Offsets, ICollection< int > Used, byte OperatorForUnusedEntries)
  Function builds the new offset array, object array and assembles the index. More...
 
virtual byte[]  BuildNewIndexAndCopyAllGSubrs (int[] Offsets, byte OperatorForUnusedEntries)
  Function builds the new offset array, object array and assembles the index. More...
 
virtual byte[]  AssembleIndex (int[] NewOffsets, byte[] NewObjects)
  Function creates the new index, inserting the count,offsetsize,offset array and object array. More...
 
virtual byte[]  BuildNewFile (int Font)
  The function builds the new output stream according to the subset process More...
 
virtual void  CopyHeader ()
  Function Copies the header from the original fileto the output list More...
 
virtual void  BuildIndexHeader (int Count, int Offsize, int First)
  Function Build the header of an index More...
 
virtual void  CreateKeys (CFFFont.OffsetItem fdarrayRef, CFFFont.OffsetItem fdselectRef, CFFFont.OffsetItem charsetRef, CFFFont.OffsetItem charstringsRef)
  Function adds the keys into the TopDict More...
 
virtual void  CreateNewStringIndex (int Font)
  Function takes the original string item and adds the new strings to accommodate the CID rules More...
 
virtual void  CreateFDSelect (CFFFont.OffsetItem fdselectRef, int nglyphs)
  Function creates new FDSelect for non-CID fonts. More...
 
virtual void  CreateCharset (CFFFont.OffsetItem charsetRef, int nglyphs)
  Function creates new CharSet for non-CID fonts. More...
 
virtual void  CreateFDArray (CFFFont.OffsetItem fdarrayRef, CFFFont.OffsetItem privateRef, int Font)
  Function creates new FDArray for non-CID fonts. More...
 
virtual int  CountEntireIndexRange (int indexOffset)
  Function computes the size of an index More...
 
- Package Functions inherited from iText.IO.Font.CFFFont
virtual void  GetDictItem ()
 
virtual CFFFont.RangeItem  GetEntireIndexRange (int indexOffset)
  a utility that creates a range item for an entire index More...
 

Additional Inherited Members

- Package Attributes inherited from iText.IO.Font.CFFFont
String  key
 
Object[]  args = new Object[48]
 
int  arg_count = 0
 
RandomAccessFileOrArray  buf
  A random Access File or an array More...
 
int  nameIndexOffset
 
int  topdictIndexOffset
 
int  stringIndexOffset
 
int  gsubrIndexOffset
 
int[]  nameOffsets
 
int[]  topdictOffsets
 
int[]  stringOffsets
 
int[]  gsubrOffsets
 
CFFFont.Font[]  fonts
 

Detailed Description

This Class subsets a CFF Type Font.

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.nosp@m.@mat.nosp@m.h.tau.nosp@m..ac..nosp@m.il)

Member Function Documentation

◆ AssembleIndex()

virtual byte [] iText.IO.Font.CFFFontSubset.AssembleIndex ( int[]  NewOffsets,
byte[]  NewObjects 
)
inlinepackagevirtual

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

Parameters
NewOffsets the subsetted offset array
NewObjects the subsetted object array
Returns
the new index created

◆ BuildFDArrayUsed()

virtual void iText.IO.Font.CFFFontSubset.BuildFDArrayUsed ( int  Font )
inlinepackagevirtual

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

Parameters
Font the Number of font being processed

◆ BuildFDSubrsOffsets()

virtual void iText.IO.Font.CFFFontSubset.BuildFDSubrsOffsets ( int  Font,
int  FD 
)
inlinepackagevirtual

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

Parameters
Font the font
FD The FDARRAY processed

◆ BuildGSubrsUsed()

virtual void iText.IO.Font.CFFFontSubset.BuildGSubrsUsed ( int  Font )
inlinepackagevirtual

Function scans the Glsubr used list to find recursive calls to Gsubrs and adds to Map and list

Parameters
Font the font

◆ BuildIndexHeader()

virtual void iText.IO.Font.CFFFontSubset.BuildIndexHeader ( int  Count,
int  Offsize,
int  First 
)
inlinepackagevirtual

Function Build the header of an index

Parameters
Count the count field of the index
Offsize the offsize field of the index
First the first offset of the index

◆ BuildNewCharString()

virtual void iText.IO.Font.CFFFontSubset.BuildNewCharString ( int  FontIndex )
inlinepackagevirtual

Function uses BuildNewIndex to create the new index of the subset charstrings.

Parameters
FontIndex the font

◆ BuildNewFile()

virtual byte [] iText.IO.Font.CFFFontSubset.BuildNewFile ( int  Font )
inlinepackagevirtual

The function builds the new output stream according to the subset process

Parameters
Font the font
Returns
the subsetted font stream

◆ BuildNewIndex()

virtual byte [] iText.IO.Font.CFFFontSubset.BuildNewIndex ( int[]  Offsets,
ICollection< int >  Used,
byte  OperatorForUnusedEntries 
)
inlinepackagevirtual

Function builds the new offset array, object array and assembles the index.

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
Used the Map of the used objects
OperatorForUnusedEntries the operator inserted into the data stream for unused entries
Returns
the new index subset version

◆ BuildNewIndexAndCopyAllGSubrs()

virtual byte [] iText.IO.Font.CFFFontSubset.BuildNewIndexAndCopyAllGSubrs ( int[]  Offsets,
byte  OperatorForUnusedEntries 
)
inlinepackagevirtual

Function builds the new offset array, object array and assembles the index.

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
OperatorForUnusedEntries the operator inserted into the data stream for unused entries
Returns
the new index subset version

◆ BuildNewLGSubrs()

virtual void iText.IO.Font.CFFFontSubset.BuildNewLGSubrs ( int  Font )
inlinepackagevirtual

Function builds the new local and global subsrs indices.

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

Parameters
Font the font

◆ BuildSubrUsed()

virtual void iText.IO.Font.CFFFontSubset.BuildSubrUsed ( int  Font,
int  FD,
int  SubrOffset,
int[]  SubrsOffsets,
ICollection< int >  hSubr,
IList< int >  lSubr 
)
inlinepackagevirtual

Function uses ReadAsubr on the glyph used to build the LSubr and Gsubr Map.

Function uses ReadAsubr on the glyph used to build the LSubr and Gsubr Map. The Map (of the lsubr only) is then scanned recursively for Lsubr and Gsubrs calls.

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 Map of the subrs used
lSubr list of the subrs used

◆ CalcBias()

virtual int iText.IO.Font.CFFFontSubset.CalcBias ( int  Offset,
int  Font 
)
inlinepackagevirtual

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

Parameters
Offset The offset to the relevant subrs index
Font the font
Returns
The calculated Bias

◆ CalcHints()

virtual int iText.IO.Font.CFFFontSubset.CalcHints ( int  begin,
int  end,
int  LBias,
int  GBias,
int[]  LSubrsOffsets 
)
inlinepackagevirtual

The function reads the subroutine and returns the number of the hint in it.

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
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.

◆ CopyHeader()

virtual void iText.IO.Font.CFFFontSubset.CopyHeader ( )
inlinepackagevirtual

Function Copies the header from the original fileto the output list

◆ CountEntireIndexRange()

virtual int iText.IO.Font.CFFFontSubset.CountEntireIndexRange ( int  indexOffset )
inlinepackagevirtual

Function computes the size of an index

Parameters
indexOffset The offset for the computed index
Returns
The size of the index

◆ CreateCharset()

virtual void iText.IO.Font.CFFFontSubset.CreateCharset ( CFFFont.OffsetItem  charsetRef,
int  nglyphs 
)
inlinepackagevirtual

Function creates new CharSet for non-CID fonts.

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

Parameters
charsetRef OffsetItem for the CharSet
nglyphs the number of glyphs in the font

◆ CreateFDArray()

virtual void iText.IO.Font.CFFFontSubset.CreateFDArray ( CFFFont.OffsetItem  fdarrayRef,
CFFFont.OffsetItem  privateRef,
int  Font 
)
inlinepackagevirtual

Function creates new FDArray for non-CID fonts.

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
privateRef OffsetItem for the Private Dict
Font the font

◆ CreateFDSelect()

virtual void iText.IO.Font.CFFFontSubset.CreateFDSelect ( CFFFont.OffsetItem  fdselectRef,
int  nglyphs 
)
inlinepackagevirtual

Function creates new FDSelect for non-CID fonts.

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

Parameters
fdselectRef OffsetItem for the FDSelect
nglyphs the number of glyphs in the font

◆ CreateKeys()

virtual void iText.IO.Font.CFFFontSubset.CreateKeys ( CFFFont.OffsetItem  fdarrayRef,
CFFFont.OffsetItem  fdselectRef,
CFFFont.OffsetItem  charsetRef,
CFFFont.OffsetItem  charstringsRef 
)
inlinepackagevirtual

Function adds the keys into the TopDict

Parameters
fdarrayRef OffsetItem for the FDArray
fdselectRef OffsetItem for the FDSelect
charsetRef OffsetItem for the CharSet
charstringsRef OffsetItem for the CharString

◆ CreateNewStringIndex()

virtual void iText.IO.Font.CFFFontSubset.CreateNewStringIndex ( int  Font )
inlinepackagevirtual

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

Parameters
Font the font

◆ EmptyStack()

virtual void iText.IO.Font.CFFFontSubset.EmptyStack ( )
inlinepackagevirtual

Empty the Type2 Stack

◆ HandelStack()

virtual void iText.IO.Font.CFFFontSubset.HandelStack ( )
inlinepackagevirtual

Function Checks how the current operator effects the run time stack after being run An operator may increase or decrease the stack size

◆ PopStack()

virtual void iText.IO.Font.CFFFontSubset.PopStack ( )
inlinepackagevirtual

Pop one element from the stack

◆ Process() [1/2]

virtual byte [] iText.IO.Font.CFFFontSubset.Process ( )
inlinevirtual

The Process function extracts one font out of the CFF file and returns a subset version of the original with the first name.

Returns
The new font stream

◆ Process() [2/2]

virtual byte [] iText.IO.Font.CFFFontSubset.Process ( String  fontName )
inlinevirtual

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
Returns
The new font stream

◆ PushStack()

virtual void iText.IO.Font.CFFFontSubset.PushStack ( )
inlinepackagevirtual

Add an item to the stack

◆ ReadASubr()

virtual void iText.IO.Font.CFFFontSubset.ReadASubr ( int  begin,
int  end,
int  GBias,
int  LBias,
ICollection< int >  hSubr,
IList< int >  lSubr,
int[]  LSubrsOffsets 
)
inlinepackagevirtual

The function reads a subrs (glyph info) between begin and end.

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
end the end point of the subr
GBias the bias of the Global Subrs
LBias the bias of the Local Subrs
hSubr the subroutines used as set
lSubr the subroutines used as list
LSubrsOffsets the offsets array of the subroutines

◆ ReadCommand()

virtual void iText.IO.Font.CFFFontSubset.ReadCommand ( )
inlinepackagevirtual

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

◆ ReadFDArray()

virtual void iText.IO.Font.CFFFontSubset.ReadFDArray ( int  Font )
inlinepackagevirtual

Read the FDArray count, offsize and Offset array

Parameters
Font the Number of font being processed

◆ ReadFDSelect()

virtual void iText.IO.Font.CFFFontSubset.ReadFDSelect ( int  Font )
inlinepackagevirtual

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

Parameters
Font The index of the font being processed

◆ StackOpp()

virtual int iText.IO.Font.CFFFontSubset.StackOpp ( )
inlinepackagevirtual

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

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