protected void ReadASubr(int begin,int end,int GBias,int LBias,Dictionary<int,int[]> hSubr,List<int> lSubr,int[] LSubrsOffsets)
{
// Clear the stack for the subrs
EmptyStack();
NumOfHints = 0;
// Goto begining of the subr
Seek(begin);
while (GetPosition() < end)
{
// Read the next command
ReadCommand();
int pos = GetPosition();
Object TopElement=null;
if (arg_count > 0)
TopElement = args[arg_count-1];
int NumOfArgs = arg_count;
// Check the modification needed on the Argument Stack according to key;
HandelStack();
// a call to a Lsubr
if (key=="callsubr")
{
// Verify that arguments are passed
if (NumOfArgs > 0)
{
// Calc the index of the Subrs
int Subr = (int)TopElement + LBias;
// If the subr isn't in the HashMap -> Put in
if (!hSubr.ContainsKey(Subr))
{
hSubr[Subr] = null;
lSubr.Add(Subr);
}
CalcHints(LSubrsOffsets[Subr],LSubrsOffsets[Subr+1],LBias,GBias,LSubrsOffsets);
Seek(pos);
}
}
// a call to a Gsubr
else if (key=="callgsubr")
{
// Verify that arguments are passed
if (NumOfArgs > 0)
{
// Calc the index of the Subrs
int Subr = (int)TopElement + GBias;
// If the subr isn't in the HashMap -> Put in
if (!hGSubrsUsed.ContainsKey(Subr))
{
hGSubrsUsed[Subr] = null;
lGSubrsUsed.Add(Subr);
}
CalcHints(gsubrOffsets[Subr],gsubrOffsets[Subr+1],LBias,GBias,LSubrsOffsets);
Seek(pos);
}
}
// A call to "stem"
else if (key == "hstem" || key == "vstem" || key == "hstemhm" || key == "vstemhm")
// Increment the NumOfHints by the number couples of of arguments
NumOfHints += NumOfArgs/2;
// A call to "mask"
else if (key == "hintmask" || key == "cntrmask")
{
// Compute the size of the mask
int SizeOfMask = NumOfHints/8;
if (NumOfHints%8 != 0 || SizeOfMask == 0)
SizeOfMask++;
// Continue the pointer in SizeOfMask steps
for (int i=0;i<SizeOfMask;i++)
GetCard8();
}
}
}