Preface

by G. Adam Stanislav
Whiz Kid Technomagic

PostScript is a programming language developed by Adobe mostly as a page description language. The language offers several ways of creating fonts (computer representations of a typeface). Commercial quality fonts usually follow one specific font format, called Type 1.

A typical Type 1 font starts with some introductory PostScript language code in the form of ASCII text. The main part of the font is encoded in a binary format, which allows the PostScript printer to interpret it very fast. Finally, some textual PostScript code ends the font.

The binary section of the font can either be in true binary, or it can be written as a series of hexadecimal numbers. A PostScript printer can understand either format.

Chapter 1 – File Formats

1.1. The PFB Format

A typical Type 1 font for the Intel-based computer platforms comes in the PFB format. In this format, the binary section is expressed in true binary. That of its own does not prevent a PostScript printer from understanding the font. But the font file contains additional information to mark the start of each section, as well as the end of the font. PostScript printers do not understand this additional information. In order to download such a font to a PostScript printer, this information must be removed from the file.

Additionally, it may be necessary to convert the true binary into an ASCII representation in hexadecimal digits. Whether this conversion is necessary depends on the communication path between the font file and the printer. If the font is transferred over a communication link that expects all data to come as 7-bit ASCII, such a conversion is necessary. Otherwise, it is not necessary but does not hurt anything. Therefore, if it is not known whether an ASCII conversion is required, it is safer to perform such a conversion.

By the way, the letters PFB stand for PostScript font binary.

1.2. The PFA Format

The Type 1 font can also come in the PFA format. This is an acronym for PostScript font ASCII. As that suggest, the font is in a plain text format. It requires no conversion. It can be downloaded directly to the PostScript printer by simply sending it to the printer through whatever communication link exists between the file and the printer.

The PFA format of Type 1 fonts is popular in the Unix environment. Not only because it does not need any further conversion before downloading to the PostScript printer, but also because of the way Unix programs work, often passing a stream of data through a series of filters, many of which prefer the data to be in the plain text format.

Chapter 2 – File Format Conversion

2.1. Conversion Utilities

Several utilities exist to convert PFB font files into the PFA format. One is even included with the popular ghostscript software, so, chances are that if your system deals with PostScript, it already has one.

Nevertheless, using the conversion utility that comes with ghostscript may simply be an overkill. That utility is a shell script that loads ghostscript and passes to it a conversion program written in PostScript. Considering that ghostscript is a very complex program, loading it to perform such a simple task as converting a file from one format to another may require the allocation of unnecessary system resources, which could otherwise be used by other processes.

Additionally, that utility expects its input to come from a file, so it cannot be used as a Unix filter.

I have seen other such utilities, utilities that are simple and do not take up too many system resources. But all those that I have seen expected their input to come from a file. None can take its input from stdin, so they cannot be used within a pipe. I am not saying that no such utility exists, only that I have not found it.

2.2. The pfbtopfa Utility

Because I needed a utility to convert PFB files to the PFA format, one that could read its input either from stdin or from a file, and write its output either to stdout or to a file, and because I could not find one, I wrote it myself and named it pfbtopfa.

Its usage is very simple. To convert a PFB file to a PFA file, all you have to do is type:

% pfbtopfa pfbfile pfafile

The first file name is the input file, which needs to be in the PFB format. The second file name is the output file, to which pfbtopfa will write the same font but in the PFB format.

If you need to specify the output file first, you can use a switch:

% pfbtopfa -o pfafile pfbfile

Or:

% pfbtopfa -o pfafile -i pfbfile

If you do not specify the PFA file, the output will go to stdout. If you do not specify the PFB file, the input will come from stdin, which allows you to pipe it to the output of some software that produces PostScript Type 1 fonts in the PFB format.

You could even use it to display the output of a PFB font foundry on a web page:

#! /bin/sh

cat << EOF
Content-type: text/plain

EOF

foundry | pfbtopfa

Chapter 3 – Download

You can download pfbtopfa by ftp or html. Either way, you will get the C source, which you can compile yourself.

[ Home ]