Fonts and font facilities supplied with Ghostscript

Table of contents

For other information, see the Ghostscript overview.


About Ghostscript fonts

Ghostscript is distributed with two kinds of files related to fonts:

Additionally, a file cidfmap can be used to create CID fonts for CJK font files on the system See the section on CID Font Substitution for details.

Most of the font files supplied with Ghostscript have the extension .pfb, and a few have .pfa or .gsf. Each file defines one ordinary PostScript Type 1 outline font which any PostScript language interpreter can use. Files with .pfa or .pfb extensions are also compatible with Adobe Type Manager (ATM) and with tools that don't include a full PostScript language interpreter; files with .gsf extension are incompatible with ATM and other tools. Ghostscript compiled with the "ttfont" option can also use TrueType fonts with the extension .ttf.

When Ghostscript needs a font, it must have some way to know where to look for it: that's the purpose of the Fontmap file, which associates the names of fonts such as /Times-Roman with the names of font files, such as n021003l.pfb. Fontmap can also create aliases for font names, so that for instance, /NimbusNo9L-Regu means the same font as /Times-Roman.


Ghostscript's free fonts

Two sets of free fonts are supplied for Ghostscript:


Font packages
System    File name    Contents    Types

DOS and
MS Windows
  gs###fn1.zip   Basic   .pfb
    gs###fn2.zip   Miscellaneous   Various, for
different fonts

Unix   ghostscript-fonts-std-#.##.tar.gz   Basic   .afm, .pfb,
.pfm
    ghostscript-fonts-other-#.##.tar.gz   Miscellaneous   .afm, .gsf,
.pfa, .pfm

"#.##" and "###" are the version number with and without punctuation. Fonts can be found at

ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/fonts/ (for several versions; generally the latest is preferred)

Other free fonts

Computer Modern Fontmap

Don Knuth's Computer Modern fonts are popular, free, and widely available. A Fontmap appropriate for these fonts is available from:

ftp://tug.ctan.org/tex-archive/fonts/cm/ps-type1/contrib/Fontmap.cmr

or from other CTAN sites.

Free Chinese (Hanzi) fonts

A free Chinese font, originally provided by courtesy of Jackson Technology, Ltd., Taiwan under the GPL and now distributed by the Taiwan NeXT User Group, is available from:

ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/hanzi/

Prof. Wu of the Department of Economics of National Taiwan University has created several free Type 1 Chinese fonts designed to be used with TeX. His e-mail is ntut019@ccms.ntu.edu.tw. The fonts are available from

ftp://cle.linux.org.tw/pub/fonts/cwfont/

Arphic Technology Co., Ltd., has made several free TrueType Chinese fonts available under the Arphic Public License, a license very similar to the GPL. (Ghostscript can use TrueType fonts if Ghostscript is compiled with the ttfont feature included: see here for more information.) The fonts and license are available from

ftp://cle.linux.org.tw/pub/fonts/arphic/

Free Japanese (Kanji) fonts

Mr. Tetsurou Tanaka of the Department of Engineering, University of Tokyo, has created a set of free Kanji fonts available from

ftp://ftp.ipl.t.u-tokyo.ac.jp/Font/

along with documentation in Japanese and English describing their conditions of use and how to use them. An older copy of these fonts, under somewhat different names, is available at the Ghostscript site:

ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/kanji/

Mr. Norio Katayama has done some work to make Ghostscript work well with Kanji fonts. An easy-to-install Kanji font for Ghostscript, with installation instructions, is at

http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-ttf.html

The same site has patches to make Ghostscript work with Japanese VF fonts, with documentation in both English and Japanese:

http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-vflib.html

Here are some other resources in Japanese relating to VFlib and using Ghostscript with Japanese fonts:

http://kakugawa.aial.hiroshima-u.ac.jp/~kakugawa/Hacks/
http://itohws03.ee.noda.sut.ac.jp/~matsuda/VFlib-FT/
Author <matsuda@itohws01.ee.noda.sut.ac.jp>
http://www.rd.nacsis.ac.jp/~katayama/homepage/ghostscript/Japanese.html
Author <katayama@rd.nacsis.ac.jp>

Unicode CMaps

Some Unicode CMaps that can be used with Ghostscript are freely downloadable from

ftp://ftp.oreilly.com/pub/examples/nutshell/ujip/adobe/

Free Cyrillic fonts

N. Glonty and A. Samarin created in 1989 a Cyrillic extension of TeX's "Computer Modern" fonts, now freely available through the Comprehensive TeX Archive Network (CTAN), for instance at

ftp://ctan.tug.org/tex-archive/fonts/cyrillic/cmcyr/

CTAN's entire collection of Cyrillic fonts is, for instance, at

ftp://ctan.tug.org/tex-archive/fonts/cyrillic/

Basil K. Malyshev created the "Paradissa Fonts Collection" in 1993. It contained 165 fonts, including the Glonty and Samarin font above plus other Computer Modern, Euler, and LaTeX fonts, all in PostScript Type 1 format with .afm and .pfm files, compatible with ATM. The collection could once be found through CTAN, for instance at

http://www.ctan.org/tex-archive/fonts/

but the collection no longer seems to be available. However, the ctan fonts directory remains an excellent source of free fonts, many of which are offered in postscript as well we as TeX Metafont format.


(Partial) Unicode fonts

George W. Wilson is distributing some free partial Unicode fonts he created. These fonts currently lack Arabic and CJK characters, but they include a very large subset of the remaining Unicode set. They are available in both Type 1 and TrueType formats. See

http://bibliofile.mc.duke.edu/gww/fonts/Unicode.html

How Ghostscript gets fonts when it runs

Fonts occupy about 50KB each, so Ghostscript doesn't load them all automatically when it runs. Instead, as part of normal initialization Ghostscript runs a file gs_fonts.ps, which arranges to load fonts on demand using information from the font map. To preload all of the known fonts, invoke the procedure

loadallfonts

The file prfont.ps contains code to print a sample page of a font. Load this program by including it in the gs command line or by invoking

(prfont.ps) run

Then to produce a sampler of a particular font XYZ, invoke

/XYZ DoFont

For example,

/Times-Roman DoFont

For more information about how Ghostscript loads fonts during execution, see here.


Platform fonts

Ghostscript displays text on screen using whatever font technology is provided by the system on which it runs, by calling the system's API to display text. On platforms with X Windows, this is X Windows; on MS Windows it may be TrueType or ATM; Ghostscript neither knows nor cares.

The PostScript language specifies that fonts are data structures with particular contents (for instance, they include a bounding box for the font, an Encoding vector to specify the character set, etc.), and it is common for PostScript files to use this fact; also, characters can be used as clipping regions, and can be arbitrarily algorithmically rotated, skewed, expanded or condensed, etc. Most of this information is available in some form from the underlying graphics system, but one crucial piece is not: the actual scalable outlines of the characters, which Ghostscript needs in order to implement both clipping with character shapes and arbitrarily transformed characters. Consequently

Ghostscript needs the scalable outlines of any font mentioned in a document, and loads them from the disk (.pfa, .pfb, or .gsf file) in the usual way, even if it uses the platform's font machinery to display the characters. In other words, Ghostscript must still be able to find its font files.

To make matters worse, platforms use different names for their standard fonts. For example, the Times Roman font, for which PostScript files use the name "Times-Roman", may be known as "Times-Roman", "Times Roman", "Tms Rmn", "Times New Roman", or "TimesNewRoman". The name may even be completely different: the usual Helvetica-equivalent TrueType font is called "Arial". It is possible to deal with this situation by introducing aliases in Fontmap, but there are two reasons why Ghostscript does not currently do this:

  1. Methods of naming in different systems are so unstandardized that there seems to be no small set of alternative names likely to cover most situations. All five of the names above for Times Roman have been seen under Windows and OS/2, depending on the version of the system, whether it uses TrueType or ATM, and other unknown factors.
  2. Each alias takes up space at run time. If each of the standard fonts has three additional aliases, this might amount to 50KB of wasted space, which may be a lot on some smaller systems.

If you don't seem to be getting nice characters on the screen under MS Windows, you can try adding aliases to Fontmap, according to the documentation you'll find in there.


Adding your own fonts

Ghostscript can use any Type 0, 1, 3, 4, or 42 font acceptable to other PostScript language interpreters or to ATM, including MultiMaster fonts. Beginning with release 4.0, Ghostscript can also use TrueType fonts if it was compiled with the "ttfont" option.

To add fonts of your own, you must edit Fontmap to include at the end an entry for your new font; the format for entries is documented in Fontmap itself. Since later entries in Fontmap override earlier entries, a font you add at the end supersedes any corresponding fonts supplied with Ghostscript and defined earlier in the file.

In the PC world, Type 1 fonts are customarily given names ending in .PFA or .PFB. Ghostscript can use these directly: you just need to make the entry in Fontmap. If you want to use with Ghostscript a commercial Type 1 font (such as fonts obtained in conjunction with Adobe Type Manager), please read carefully the license that accompanies the font to satisfy yourself that you may do so legally; we take no responsibility for any possible violations of such licenses. The same applies to TrueType fonts.

Converting BDF fonts

Ghostscript provides a way to construct a (low-quality) Type 1 font from a bitmap font in the BDF format popular in the Unix world. The shell script bdftops (Unix) or the command file bdftops.bat (DOS) converts a BDF file to a scalable outline using bdftops.ps . Run the shell command

bdftops BDF_filename [AFM_file1_name ...] gsf_filename fontname
          UniqueID [XUID] [encodingname]

The arguments have these meanings:

BDF_filename    Input bitmap file in BDF format     
AFM_file1_name   AFM files giving metrics   (Optional)
gsf_filename   Output file    
fontname   Name of the font    
UniqueID   UniqueID (as described below)    
XUID   XUID, in the form n1.n2.n3... (as described below)   (Optional)
encodingname   "StandardEncoding" (the default), "ISOLatin1Encoding",
"SymbolEncoding", "DingbatsEncoding"
  (Optional)

For instance

bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000 1000000.1.41

Then make an entry in Fontmap for the .gsf file (pzdr.gsf in the example) as described above.


For developers only

The rest of this document is very unlikely to be of value to ordinary users.

Contents of fonts

As noted above, Ghostscript accepts fonts in the same formats as PostScript interpreters. Type 0, 1, and 3 fonts are documented in the PostScript Language Reference Manual (Second Edition); detailed documentation for Type 1 fonts appears in a separate Adobe book. Type 2 (compressed format) fonts are documented in separate Adobe publications. Type 4 fonts are not documented anywhere; they are essentially Type 1 fonts with a BuildChar or BuildGlyph procedure. Types 9, 10, and 11 (CIDFontType 0, 1, and 2) and Type 32 (downloaded bitmap) fonts are documented in Adobe supplements. Type 42 (encapsulated TrueType) fonts are documented in an Adobe supplement; the TrueType format is documented in publications available from Apple and Microsoft. Ghostscript does not support Type 14 (Chameleon) fonts, which use a proprietary Adobe format.

Font names and unique IDs

If you create your own fonts and will use them only within your own organization, you should use UniqueID values between 4000000 and 4999999.

If you plan to distribute fonts, ask Adobe to assign you some UniqueIDs and also an XUID for your organization. Contact

Unique ID Coordinator
Adobe Developers Association
Adobe Systems, Inc.
345 Park Avenue
San Jose, CA 95110-2704
+1-408-536-9000 telephone (ADA)
+1-408-536-6883 fax
fontdev-person@adobe.com

The XUID is a Level 2 PostScript feature that serves the same function as the UniqueID, but is not limited to a single 24-bit integer. The bdftops program creates XUIDs of the form "[-X- 0 -U-]" where "-X-" is the organization XUID and "-U-" is the UniqueID. (Aladdin Enterprises' organization XUID, which appears in a few places in various font-related files distributed with Ghostscript, is 107; do not use this for your own fonts that you distribute.)


Using Ghostscript fonts on X Windows displays

The standard X11 distribution can display various kinds of fonts, including the Adobe Type 1 format, so font files distributed with Ghostscript can be used on X Windows displays. Beginning with Ghostscript version 6.0, the font archive contains the directory files needed to map Ghostscript's font files to XLFDs. Those files are named "fonts.dir" and "fonts.scale". There are two main methods to configure your display to use these files.

Using xset

Users without root access can add the Ghostscript font directories to the font search path using xset. Such a setting is transient and must be repeated each time the display server is reset or restarted, typically at login, so the call to xset should be added to the user's ".xsession" or ".xinitrc" startup script to make the fonts available at each login.

To add a new font directory, invoke xset like this:

xset fp+ {directory}

where {directory} is the full pathname to the directory containing the fonts on the host running the X display server. For common Ghostscript installations the path is

/usr/local/Ghostscript/share/fonts

Permanent installation

A system administrator, or anyone with the necessary root privilege, can make Ghostscript's fonts permanently available to the managed X display servers. This setup depends on the servers and the methods used to make the fonts available.

Configuring the xfs font server

An X display server can obtain its font resources from a dedicated X font server. xfs is a prototype font server included in the X Consortium X11 distribution. It is configured with a file located in a directory whose exact location is installation-dependent and could be any of

/usr/lib/X11/fs/config
/usr/X11/lib/X11/fs/config
/usr/X11R6/lib/X11/fs/config

or some similar name. You can also use xfs's "-config" command-line option to specify the location of the configuration file.

The configuration file designates a list ("catalog") of directories, each of which contains fonts and a font mapping database (the file "fonts.dir"). This list is specified with the "catalogue=" keyword followed by a list of absolute directory paths separated by commas. To add the Ghostscript directory, include its full name in the catalog list, for example:

catalogue = /usr/local/share/Ghostscript/fonts/,
/usr/X11R6/lib/X11/fonts/misc/,
/usr/X11R6/lib/X11/fonts/Speedo/,
/usr/X11R6/lib/X11/fonts/Type1/,
/usr/X11R6/lib/X11/fonts/75dpi/,
/usr/X11R6/lib/X11/fonts/100dpi/

The fonts are searched in the order the directories are specified, so an XLFD mapped by the Ghostscript directory could shadow a previous similar description specified in the following directories. Once the file is modified, instruct the font server to reload the configuration file by sending it the USR1 signal:

kill -HUP {pid}

where {pid} is the font server process's numeric process ID, as obtained with the "ps" command. Be sure to check that the server is still alive after signaling it: it is very picky and could decide to shut itself down if something is wrong in the new configuration. If this happens, restart the server by hand and try to figure out from its output what's happening. If the font server dies, display servers using it will experience problems, so be sure to send the signal from the console or from a display not using that font server!

Xfree86 display servers

With the family of Xfree86 display servers, adding a new font directory permanently requires editing the "/etc/XF86Config" setup file to add a new "FontPath" to the "Files" section:

Section "Files"
     RgbPath    "/usr/X11R6/lib/X11/rgb"
     FontPath   "/usr/local/share/Ghostscript/fonts"
     FontPath   "/usr/X11R6/lib/X11/fonts/misc:unscaled"
     FontPath   "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
     FontPath   "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
     FontPath   "/usr/X11R6/lib/X11/fonts/Type1"
     FontPath   "/usr/X11R6/lib/X11/fonts/Speedo"
EndSection

The fonts are searched in the order the directories are specified, so an XLFD mapped by the Ghostscript directory could shadow a previous similar description specified in the following directories. Once this global configuration is edited, the new fonts become available to all Xfree86 servers in use on that host. If a server is running, it must be restarted to take effect: just quit the current session in the usual way. If the server is under the control of xdm, you may have to kill it, because it is usually reset only between successive sessions.

This section by Bertrand Petit <eegs@phoe.frmug.org>


Copyright © 2000-2006 Artifex Software, Inc. All rights reserved.

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at http://www.artifex.com/ or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.

Ghostscript version 8.63, 1 August 2008