class Pfm2afm {
private void putheader() throws IOException {
out.print("StartFontMetrics 2.0\n");
if (copyright.length() > 0)
out.print("Comment " + copyright + '\n');
out.print("FontName ");
in.seek(fontname);
String fname = readString();
out.print(fname);
out.print("\nEncodingScheme ");
if (charset != 0)
out.print("FontSpecific\n");
else
out.print("AdobeStandardEncoding\n");
/*
* The .pfm is missing full name, so construct from font name by
* changing the hyphen to a space. This actually works in a lot
* of cases.
*/
out.print("FullName " + fname.replace('-', ' '));
if (face != 0) {
in.seek(face);
out.print("\nFamilyName " + readString());
}
out.print("\nWeight ");
if (weight > 475 || fname.toLowerCase().indexOf("bold") >= 0)
out.print("Bold");
else if ((weight < 325 && weight != 0) || fname.toLowerCase().indexOf("light") >= 0)
out.print("Light");
else if (fname.toLowerCase().indexOf("black") >= 0)
out.print("Black");
else
out.print("Medium");
out.print("\nItalicAngle ");
if (italic != 0 || fname.toLowerCase().indexOf("italic") >= 0)
out.print("-12.00");
/* this is a typical value; something else may work better for a
specific font */
else
out.print("0");
/*
* The mono flag in the pfm actually indicates whether there is a
* table of font widths, not if they are all the same.
*/
out.print("\nIsFixedPitch ");
if ((kind & 1) == 0 || /* Flag for mono */
avgwidth == maxwidth ) { /* Avg width = max width */
out.print("true");
isMono = true;
}
else {
out.print("false");
isMono = false;
}
/*
* The font bounding box is lost, but try to reconstruct it.
* Much of this is just guess work. The bounding box is required in
* the .afm, but is not used by the PM font installer.
*/
out.print("\nFontBBox");
if (isMono)
outval(-20); /* Just guess at left bounds */
else
outval(-100);
outval(-(descender+5)); /* Descender is given as positive value */
outval(maxwidth+10);
outval(ascent+5);
/*
* Give other metrics that were kept
*/
out.print("\nCapHeight");
outval(capheight);
out.print("\nXHeight");
outval(xheight);
out.print("\nDescender");
outval(-descender);
out.print("\nAscender");
outval(ascender);
out.print('\n');
}
}