Code with Finding: |
class CFFFontSubset {
/**
* Function builds the new local & global subsrs indices. IF CID then All of
* the FD Array lsubrs will be subsetted.
* @param Font the font
* @throws IOException
*/
@SuppressWarnings("unchecked")
protected void BuildNewLGSubrs(int Font)throws IOException
{
// If the font is CID then the lsubrs are divided into FontDicts.
// for each FD array the lsubrs will be subsetted.
if(fonts[Font].isCID)
{
// Init the hashmap-array and the arraylist-array to hold the subrs used
// in each private dict.
hSubrsUsed = new HashMap[fonts[Font].fdprivateOffsets.length];
lSubrsUsed = new ArrayList[fonts[Font].fdprivateOffsets.length];
// A [][] which will store the byte array for each new FD Array lsubs index
NewLSubrsIndex = new byte[fonts[Font].fdprivateOffsets.length][];
// An array to hold the offset for each Lsubr index
fonts[Font].PrivateSubrsOffset = new int[fonts[Font].fdprivateOffsets.length];
// A [][] which will store the offset array for each lsubr index
fonts[Font].PrivateSubrsOffsetsArray = new int[fonts[Font].fdprivateOffsets.length][];
// Put the FDarrayUsed into a list
ArrayList<Integer> FDInList = new ArrayList<Integer>(FDArrayUsed);
// For each FD array which is used subset the lsubr
for (int j=0;j<FDInList.size();j++)
{
// The FDArray index, Hash Map, Array List to work on
int FD = FDInList.get(j).intValue();
hSubrsUsed[FD] = new HashMap<Integer, int[]>();
lSubrsUsed[FD] = new ArrayList<Integer>();
//Reads the private dicts looking for the subr operator and
// store both the offset for the index and its offset array
BuildFDSubrsOffsets(Font,FD);
// Verify that FDPrivate has a LSubrs index
if(fonts[Font].PrivateSubrsOffset[FD]>=0)
{
//Scans the Charstring data storing the used Local and Global subroutines
// by the glyphs. Scans the Subrs recursively.
BuildSubrUsed(Font,FD,fonts[Font].PrivateSubrsOffset[FD],fonts[Font].PrivateSubrsOffsetsArray[FD],hSubrsUsed[FD],lSubrsUsed[FD]);
// Builds the New Local Subrs index
NewLSubrsIndex[FD] = BuildNewIndex(fonts[Font].PrivateSubrsOffsetsArray[FD],hSubrsUsed[FD],RETURN_OP);
}
}
}
// If the font is not CID && the Private Subr exists then subset:
else if (fonts[Font].privateSubrs>=0)
{
// Build the subrs offsets;
fonts[Font].SubrsOffsets = getIndex(fonts[Font].privateSubrs);
//Scans the Charstring data storing the used Local and Global subroutines
// by the glyphs. Scans the Subrs recursively.
BuildSubrUsed(Font,-1,fonts[Font].privateSubrs,fonts[Font].SubrsOffsets,hSubrsUsedNonCID,lSubrsUsedNonCID);
}
// For all fonts subset the Global Subroutines
// Scan the Global Subr Hashmap recursively on the Gsubrs
BuildGSubrsUsed(Font);
if (fonts[Font].privateSubrs>=0)
// Builds the New Local Subrs index
NewSubrsIndexNonCID = BuildNewIndex(fonts[Font].SubrsOffsets,hSubrsUsedNonCID,RETURN_OP);
//Builds the New Global Subrs index
NewGSubrsIndex = BuildNewIndex(gsubrOffsets,hGSubrsUsed,RETURN_OP);
}
}
|