Convert a PFB Type 1 Font to PFA with pfbtopfa
You will finish with an ASCII PFA copy of a binary PostScript Type 1 font, while leaving the original PFB file unchanged. The examples use the pfbtopfa wrapper supplied by Ghostscript 10.02.1, from Debian package version 10.02.1~dfsg1-0ubuntu7.9. Allow about ten minutes, plus time to locate a font you are permitted to convert.
The route
Jump straight to the step you need, or tick off Done means at the end.
This is a file conversion, not a font installation. You need Ghostscript, a readable .pfb file, and write access to the destination directory. The commands below are ordinary user commands. There is no reason to use sudo unless the input is in a protected directory and you have separately decided that copying it is safe.
1. Check the installed tool
Confirm the executable and package version before relying on examples. This is read-only:
$ command -v pfbtopfa
/usr/bin/pfbtopfa
$ dpkg-query -W -f='${Package} ${Version}\n' ghostscript
ghostscript 10.02.1~dfsg1-0ubuntu7.9
$ gs --version
10.02.1
The installed manual describes the interface as pfbtopfa input.pfb [output.pfa]. The wrapper invokes gs(1); it is not a general-purpose font editor and it does not install the result in a system font directory.
Checkpoint
You know the exact input path, the Ghostscript version, and a destination directory where you can create a new file.
2. Inspect the input without changing it
Use the real path in place of /path/to/font.pfb. Check that it exists, is readable, and is a regular file:
$ input='/path/to/font.pfb'
$ ls -l -- "$input"
$ test -f "$input" && test -r "$input" && echo 'input is a readable regular file'
input is a readable regular file
Keep the source extension accurate in your notes. A file name alone does not prove that the contents are a valid PFB font, but it makes later checks easier. Do not edit the PFB file in place. It is the only copy you may have, and conversion failure does not provide an undo operation for changes you made beforehand.
3. Convert to a named output
Choose a new destination explicitly. The second argument is optional, but naming it makes scripts and reviews clearer:
$ output='/tmp/font-copy.pfa'
$ pfbtopfa "$input" "$output"
$ printf 'exit status: %s\n' "$?"
exit status: 0
The wrapper accepts exactly one or two positional file names; it does not provide a separate option parser. Quote both variables because paths may contain spaces or shell metacharacters. The command writes the output file; it does not modify the PFB source.
Safety warning
If $output already exists, the converter may replace it. Check first when the destination matters:
$ test ! -e "$output" && echo 'destination is unused'
destination is unused
If it is an existing useful file, select another name. If you deliberately need to replace it, make a backup before converting:
$ cp --preserve=all -- "$output" "$output.bak"
$ pfbtopfa "$input" "$output"
$ cmp -- "$output" "$output.bak" || true
That last comparison normally reports that the new output differs from the backup. To recover the old destination after stopping to check the situation, remove the new file and move the backup back into place: rm -- "$output" && mv -- "$output.bak" "$output". Do not run that recovery command blindly; verify both paths first.
4. Verify the PFA result
A zero exit status says that the wrapper completed. Confirm that the output exists, is non-empty, and looks like PostScript text:
$ test -s "$output" && echo 'output is non-empty'
output is non-empty
$ file -- "$output"
/tmp/font-copy.pfa: PostScript Type 1 font text (font-name 1.00)
$ head -n 1 -- "$output"
%!PS-AdobeFont-1.0: font-name 1.00
The exact font name and version depend on the input. A PFA normally begins with a PostScript font header and contains readable text. Do not treat a matching file extension as proof of success. If file reports generic data or the first line is absent, keep the PFB and investigate rather than installing the result.
You can also ask Ghostscript to read the generated font without writing anything:
$ gs -q -dBATCH -dNOPAUSE -sDEVICE=nullpage "$output"
$ printf 'Ghostscript validation status: %s\n' "$?"
Ghostscript validation status: 0
This check exercises Ghostscript's parser. It does not prove that every application will accept the font, that its metadata is desirable, or that the font licence permits redistribution.
5. Understand the default destination
When the second argument is omitted, pfbtopfa derives a PFA name from the input file's base name and asks Ghostscript to write that name in the current working directory. It does not preserve the input directory in the output path. For a font already in your working directory, use:
$ pfbtopfa /work/font.pfb
$ test -s ./font.pfa && echo 'derived output exists'
derived output exists
Check the derived path before running this form, because an existing .pfa with the same base name is a possible overwrite target. The explicit-output form is safer for repeatable jobs, temporary conversions, and batch scripts. With Ghostscript's default file-access restrictions, an absolute explicit output path is also less surprising than relying on the current directory.
6. Diagnose failures without losing the source
If the command cannot open the input, check the path and permissions:
$ ls -l -- "$input"
$ test -r "$input" && echo readable || echo 'not readable'
$ ls -ld -- "$(dirname -- "$output")"
If the destination cannot be created, choose a directory you own or fix its permissions through your normal system-administration process. Do not make a whole directory world-writable just to complete a conversion. If Ghostscript prints an unrecoverable error, preserve the original PFB, remove only an incomplete output after checking its path, and try a known-good font to separate an input problem from an installation problem.
Keep both files until the PFA has passed the header, size, file, and Ghostscript checks. When you are certain the new copy is no longer needed, remove it with its exact path. Removing the source is irreversible and is not required for conversion.
Done means
pfbtopfaand Ghostscript 10.02.1 are installed and identified.- The original PFB remains unchanged and readable.
- A separately named PFA exists, is non-empty, and has a PostScript Type 1 header.
filerecognises the result and Ghostscript reads it with exit status 0.- No system font directory, service, or package configuration was changed.