Installfont

PostScript Font installer program by Otto J. Makela <otto@jyu.fi>
Distributed under the GNU Public Licence ± see file COPYING for details.

Installfont is a program for properly installing a font on the NeXT system. The process for doing this may be found in the Developer Notes, but the explanation assumes a more-than passing familiarity with Unix, nor does it explain all the ways things may go wrong. I've built this c-shell script to try to automate this process and to try to avoid some of the usual trapfalls that you might hit. A preliminary version of this program that couldn't yet decode Macintoshâ fonts was greeted with great enthusiasm on the net, and when I mentioned that I thought that some utilities that had the same functionality as this program were rather expensive and that I'd written something similar, I was swamped with requests for installfont. So here it is!

What you will need

You will need to have a AFM (Adobe Font Metrics) file for each PostScript font file that you want to install. Installfont assumes that the PostScript file has the same filename as the AFM file, but a different extension. The PostScript font may be in any of the following formats:
· Macintoshâ printer font resource file
· PC Adobe Type Manager binary file
· Normal PostScript file, encrypted or not 

How to do it, and what happens

Make the two files (the .afm and the actual font file) available on the NeXT (insert a floppy, copy the files from a ftp site or whatever). Open a text shell shell and type
	installfont path/*.afm
to install all font files in the specified path. Note that the font is installed by giving the name of the AFM file that goes with it. As I said, installfont assumes that it will find the actual PostScript font file in the same directory as the AFM file, but with a different extension:
· Macintoshâ printer font resource files: #rsrc# (not visible on a Mac filesystem)
· PC Adobe Type Manager binary file: pfb
· Normal PostScript file: pfa, nxt, unAdobe or no extension

If the directory into which the fonts are to be installed does not exist, an attempt will be made to mkdir it. By default, fonts are installed to ~/Library/Fonts, but this may be changed by giving a directory name as the first argument to installfont. Thus, to install a set of fonts directly to the system-wide directory, type
	installfont /LocalLibrary/Fonts *.afm

First installfont scans the AFM file for the FontName line, which is then taken as the PostScript name for this font. A directory with this name is created in the install directory with the extension .font prepended. Then the font file and the AFM file are copied to this directory, with the appropriate names. The AFM file may contain either CR or LF newlines, all combinations are translated properly to the Unix newline convention. If the font is already a normal PostScript font, no newline translation is done, unpacked Macintoshâ and PC-ATM fonts get Unix newlines.

Once all fonts that were specified on the command line are installed, the programs buildafmdir and cacheAFMData are run on the install directory. If you just need these font directory files rebuilt, use ª-º as the sole argument to installfont.

Examples

Insert a Macintoshâ diskette labeled ªZaphodº with the files NewBasRom, NewBasRom.AFM, NewBasIta, NewBasIta.AFM, NewBasBol, NewBasBol.AFM, NewBasBolIta and NewBasBolIta.AFM, then type
	installfont /LocalLibrary/Fonts /Zaphod/*.AFM
to install the ITC New Baskerville font on your machine's system wide font directory.

Take the Chestnut CD-ROM disc ªToo Many Typefontsº, insert it into your CD-ROM drive and type
	installfont /TYPEFONTS/atm/*/*.afm
to install a huge bunch (around 350) of PC ATM fonts on your NeXT into your personal font directory (unfortunately, a part of these fonts are buggy and some directories don't even have AFM files, so installfont won't attempt to install them).

Things that go bump in the script

In spite of trying to make the script as bombproof as possible, there are quite a lot of things that may go wrong when installing a font that may have come from anywhere.

Surprisingly often you will see on ftp sites fonts with damaged or misencoded AFM files. There seems to be some conversion program for the PC which produces fonts where the PostScript name and the family name don't match.

By the way, the NS3.0 versions of buildafmdir and cacheAFMData (used by this program) are rumored to be buggy. Can't say about this, even the rumor made me use the 2.0 versions. Caveat emptor!

Other utilities

There are two other utilities distributed with this package, makelinks and testsheet.

Makelinks creates the old-style symbolic links  from the font directory outline, bitmap and afm subdirectories to the appropriate places in the font directory. These links are still required by some programs, I believe FrameMaker is one of these. Give the directory where the links are wanted as argument, the default is ~/Library/Fonts.

Testsheet outputs a PostScript font test sheet for the fonts which you specify on the command line, which will show the mapping for all 256 ASCII-mapped characters in a font. If you install large collections of fonts, these sheets will prove to be very useful for determining which fonts are worth keeping (for example, very few PD fonts seem to have the special characters needed in most European languages encoded correctly). This has only been tested on A4 size paper, I hope it works properly on letter size paper. As it removes paths and extensions from the command line arguments, you can simply type
	testsheet /LocalLibrary/Fonts/*.font | lpr
to produce a listing of all fonts  installed locally on your NeXT to the printer.

Suggested Reading

Next Developer, Concepts/Fonts.rtf: Preparing Fonts
NextAnswers, postscript.746: debugging PostScript fonts
Inside Macintosh I p.128
Adobe TechNote #5040: Supporting Downloadable PostScript Language Fonts
Adobe Systems: Adobe Type 1 Font Format

Future projects

I intend to write a program to translate Macintoshâ screen fonts to NeXT screen fonts, but first I need to find time for it. Another thing I'd like to extract from those Macintoshâ screen fonts is the information that is usually encoded in .afm files, which you don't always get with the Macintoshâ fonts (though you really should, some old versions of the Macintosh operating system need it). I'd also like to build a program to un-ªencryptº PostScript fonts, simply because it's possible. TrueType fonts are rather interesting, I'd like to get my hands on the format description.

Thanks

A million thanks to Rob Elliott <relliott@b11.b11.ingr.com> for pointing me in the correct direction on where to find the unpacking information and Mark Adler <madler@cco.caltech.edu> for telling me about the NeXT method of making the Macintosh file system resource fork available as .#rsrc#

This program would not have been written if Paula didn't undestand the hacker spirit.