Lasso Soft Inc. > Home

  • Articles

Converting Mac Fonts to Unix

Introduction

Ghostscript gets its fonts from /usr/local/share/ghostscript/fonts. In addition, GhostScript reads its own Fontmap file to map names to files. If you want GS to use your existing Type 1 fonts, you will need to convert them to a usable, .pfb format. A command line utility by George Williams does just that: Fondu. Download the Mac OS X package from this site and install.

Converting A Font

Running the command line utility is simplicity itself, however, the feedback is minimal. Best bet is to take a look inside GhostScript's font folder first, which will look something like this:

  -rw-r--r--    1 root  wheel   31658 29 Dec  1999 a010013l.afm
  -rw-r--r--    1 root  wheel   34871 29 Dec  1999 a010013l.pfb
  -rw-r--r--    1 root  wheel    4679 29 Dec  1999 a010013l.pfm
  -rw-r--r--    1 root  wheel   31635 29 Dec  1999 b018012l.afm
  -rw-r--r--    1 root  wheel   44934 29 Dec  1999 b018012l.pfb
  -rw-r--r--    1 root  wheel    4681 29 Dec  1999 b018012l.pfm

 

Example: You want to add a PostScript Type 1 font called "Frutiger Roman" to GhostScript (the actual file could be called "FrutiRom"). First, log in to the terminal as root. Next, cd into the ghostscript fonts directory (/usr/local/share/ghostscript/fonts), where you wish to install your font. Then, type "fondu" in the Terminal, followed by a space, and drag the font into the Terminal window.  Then hit enter.  In other words, type "fondu" followed by the path to the font:

  [prompt$] sudo sh
  Password: [your admin password here]
  [prompt#] cd /usr/local/share/ghostscript/fonts/
  [prompt#] fondu ~/MyTypefaces/Frutiger/FrutiRom 

 

Now, take another look inside the GhostScript fonts folder - you should now see a line like this:

 -rw-r--r--    1 root  wheel   30916 13 Jun 22:35 Frutiger-Roman.pfb

 

Note that the permissions are important, so if they're not -rw-r--r--, then run the following command:

 chmod 644 Frutiger-Roman.pfb

and check the permissions again - which are now fine.

Editing the GhostScript Fontmap

Next, check the name of the font as it has been imported into the GhostScript fonts folder - this is the actual PostScript name, in this case "Frutiger-Roman". Time to edit the Fontmap, in the Terminal open the fontmap using your favourite command-line text editor (I use vim). The fontmap will be located inside the "lib" directory in the GhostScript version directory, e.g.:

 vi /usr/local/share/ghostscript/[version_number]/lib/fontmap.gs

 

Where [version_number] is the appropriate version number of your GhostScript install, e.g. "8.50". Scroll down to the line that reads "Actual Fonts", you will see something like

% Actual fonts

/URWBookmanL-DemiBold           (b018015l.pfb)        ;
/URWBookmanL-DemiBoldItal       (b018035l.pfb)        ;
/URWBookmanL-Ligh               (b018012l.pfb)        ;
/URWBookmanL-LighItal           (b018032l.pfb)        ;

 

Add the following line to tell GhostScript where to find your freshly installed copy of Frutiger Roman:

 /Frutiger-Roman   (Frutiger-Roman.pfb)       ;

 

A valid entry will contain the PostScript name preceded by a forward slash, the actual font file name in brackets, and a semicolon, all separated by tabs.  Remember to save the file and exit your text editor.

Testing

To see if GhostScript can successfully use Frutiger Roman, create a file in a text editor with the following contents:

  %!PS-Adobe-2.0 EPSF-1.2
  %%BoundingBox: 0 0 650 150

  /Frutiger-Roman findfont 72 scalefont setfont
  20 20 moveto
  (Frutiger Roman) show

  showpage

 

Save this file on your Desktop and call it "ghostscript_test.eps". Then run the following GhostScript command:

 gs -q -dNOPROMPT -dBATCH -dFirstPage=1 -dLastPage=1 -dGraphicsAlphaBits=4 -dTextAlphaBits=4
 -dNOPAUSE -dDEVICEWIDTH=650 -dDEVICEHEIGHT=150 -dDITHERPPI=72 -sDEVICE=jpeg -r72
 -sOutputFile=/users/[currentuser]/Desktop/ghostscript_test.jpg
 /users/[currentuser]/Desktop/ghostscript_test.eps;

 

...where you wish to replace [currentuser] with the name of the current user.  Note that GhostScript doesn't recognize shortcuts to the home directory, so you can't use ~/Desktop/...

If everything has gone as it should, you will now have a JPEG on your Desktop called "ghostscript_test.jpg" and it should contain the fontname in the correct font.

Troubleshooting

As of this writing, the only errors found are either due to corrupt Type 1 fonts, or spelling mistakes.  All names are case-sensitive, you therefore need to make sure that the names you use match correctly.  For example: 'Frutiger-roman' is not the same as 'Frutiger-Roman', etc.  Trailing spaces can also cause problems, so take care to prevent/eliminate them.

Author: Pier Kuipers
Created: 11 Sep 2008
Last Modified: 1 Mar 2011

Comments

No comments found
You must be logged in to comment.

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft