isMetrics = true;
break;
}
}
if (!isMetrics)
throw new DocumentException("Missing StartCharMetrics in " + fileName);
while ((line = rf.readLine()) != null)
{
StringTokenizer tok = new StringTokenizer(line);
if (!tok.hasMoreTokens())
continue;
String ident = tok.nextToken();
if (ident.equals("EndCharMetrics"))
{
isMetrics = false;
break;
}
Integer C = new Integer(-1);
Integer WX = new Integer(250);
String N = "";
int B[] = null;
tok = new StringTokenizer(line, ";");
while (tok.hasMoreTokens())
{
StringTokenizer tokc = new StringTokenizer(tok.nextToken());
if (!tokc.hasMoreTokens())
continue;
ident = tokc.nextToken();
if (ident.equals("C"))
C = Integer.valueOf(tokc.nextToken());
else if (ident.equals("WX"))
WX = new Integer((int)Float.parseFloat(tokc.nextToken()));
else if (ident.equals("N"))
N = tokc.nextToken();
else if (ident.equals("B")) {
B = new int[]{Integer.parseInt(tokc.nextToken()),
Integer.parseInt(tokc.nextToken()),
Integer.parseInt(tokc.nextToken()),
Integer.parseInt(tokc.nextToken())};
}
}
Object metrics[] = new Object[]{C, WX, N, B};
if (C.intValue() >= 0)
CharMetrics.put(C, metrics);
CharMetrics.put(N, metrics);
}
if (isMetrics)
throw new DocumentException("Missing EndCharMetrics in " + fileName);
if (!CharMetrics.containsKey("nonbreakingspace")) {
Object[] space = (Object[])CharMetrics.get("space");
if (space != null)
CharMetrics.put("nonbreakingspace", space);
}
while ((line = rf.readLine()) != null)
{
StringTokenizer tok = new StringTokenizer(line);
if (!tok.hasMoreTokens())
continue;
String ident = tok.nextToken();
if (ident.equals("EndFontMetrics"))
return;
if (ident.equals("StartKernPairs"))
{
isMetrics = true;
break;
}
}
if (!isMetrics)
throw new DocumentException("Missing EndFontMetrics in " + fileName);
while ((line = rf.readLine()) != null)
{
StringTokenizer tok = new StringTokenizer(line);
if (!tok.hasMoreTokens())
continue;
String ident = tok.nextToken();
if (ident.equals("KPX"))
{
String first = tok.nextToken();
String second = tok.nextToken();
Integer width = new Integer((int)Float.parseFloat(tok.nextToken()));
Object relates[] = (Object[])KernPairs.get(first);
if (relates == null)
KernPairs.put(first, new Object[]{second, width});
else
{
int n = relates.length;
Object relates2[] = new Object[n + 2];
System.arraycopy(relates, 0, relates2, 0, n);
relates2[n] = second;
relates2[n + 1] = width;
KernPairs.put(first, relates2);
}
}
else if (ident.equals("EndKernPairs"))
{
isMetrics = false;
break;
}
}
if (isMetrics)
throw new DocumentException("Missing EndKernPairs in " + fileName);
rf.close();
}