void ReconstructFDArray(int Font,OffsetItem[] fdPrivate)
{
// Build the header of the index
BuildIndexHeader(fonts[Font].FDArrayCount,fonts[Font].FDArrayOffsize,1);
// For each offset create an Offset Item
OffsetItem[] fdOffsets = new IndexOffsetItem[fonts[Font].FDArrayOffsets.Length-1];
for (int i=0;i<fonts[Font].FDArrayOffsets.Length-1;i++)
{
fdOffsets[i] = new IndexOffsetItem(fonts[Font].FDArrayOffsize);
OutputList.Add(fdOffsets[i]);
}
// Declare beginning of the object array
IndexBaseItem fdArrayBase = new IndexBaseItem();
OutputList.Add(fdArrayBase);
// For each object check if that FD is used.
// if is used build a new one by changing the private object
// Else do nothing
// At the end of each object mark its ending (Even if wasn't written)
for (int k=0; k<fonts[Font].FDArrayOffsets.Length-1; k++) {
//if (FDArrayUsed.ContainsKey(k))
//{
// Goto begining of objects
Seek(fonts[Font].FDArrayOffsets[k]);
while (GetPosition() < fonts[Font].FDArrayOffsets[k+1])
{
int p1 = GetPosition();
GetDictItem();
int p2 = GetPosition();
// If the dictItem is the "Private" then compute and copy length,
// use marker for offset and write operator number
if (key=="Private") {
// Save the original length of the private dict
int NewSize = (int)args[0];
// Save the size of the offset to the subrs in that private
int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].fdprivateOffsets[k],fonts[Font].fdprivateLengths[k]);
// Increase the private's length accordingly
if (OrgSubrsOffsetSize != 0)
NewSize += 5-OrgSubrsOffsetSize;
// Insert the new size, OffsetItem and operator key number
OutputList.Add(new DictNumberItem(NewSize));
fdPrivate[k] = new DictOffsetItem();
OutputList.Add(fdPrivate[k]);
OutputList.Add(new UInt8Item((char)18)); // Private
// Go back to place
Seek(p2);
}
// Else copy the entire range
else // other than private
OutputList.Add(new RangeItem(buf,p1,p2-p1));
}
//}
// Mark the ending of the object (even if wasn't written)
OutputList.Add(new IndexMarkerItem(fdOffsets[k],fdArrayBase));
}
}