For other information, see the Ghostscript overview.
Ghostscript is distributed with two kinds of files related to fonts:
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.
Two sets of free fonts are supplied for Ghostscript:
Font packages
System File name Contents Types
Unix gnu-gs-fonts-std-#.##.tar.gz Basic .afm, .pfb,
.pfmgnu-gs-fonts-other-#.##.tar.gz Miscellaneous .afm, .gsf,
.pfa, .pfm
"#.##" and "###" are the version number with and without punctuation. The fonts are not updated every release, so just use the most recent versions. Fonts can be found at
ftp://ftp.gnu.org/gnu/ghostscript/ (and mirrors)
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.
A free PostScript font for Traditional Chinese "KaiSu" in OCF format, originally provided 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/hanzi/
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.enel.ucalgary.ca/People/far/howto/gs-ttf.html
The same site has patches to make Ghostscript work with Japanese OCF fonts via VFlib, with documentation in both English and Japanese:
http://www.enel.ucalgary.ca/People/far/howto/gs-vflib.html
Here are some other resources in Japanese relating to VFlib and using Ghostscript with Japanese OCF 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>
Hwan Design Inc. created Hangul TrueType fonts (including Hanja) and released under license similar to BSD. These fonts can be used as CID-keyed font via on-the-fly CIDFontType2 conversion. Refer CJK.htm
ftp://ftp.mizi.com/pub/baekmuk/
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/
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
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.
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:
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.
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. To add CID-keyed fonts, refer CJK.htm.
If you want to use with Ghostscript a commercial fonts (fonts sold as individual package, Type 1 and CID fonts bundled to Adobe products, TrueType fonts bundled to Microsoft Windows and Apple Macintosh, etc), please read carefully the license that accompanies the font to satisfy yourself that you may do so legally. The license of bundled fonts are usually quite varied: browsing-only, printable, and embeddable. The license of the system and the license of fonts on the system must be descriminated. Even if you have officially licensed system, it does not mean you can use bundled fonts as you want. In addition to, TrueType and OpenType format have internal flags to restrict embedding, but, unfortunately, sometimes they does not reflect the license correctly. You have to check the license of EACH fonts which you want to use with Ghostscript. We take no responsibility for any possible violations of such licenses.
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.
The rest of this document is very unlikely to be of value to ordinary users.
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.
You can precompile -- convert -- any Type 1 font into C, then compile and build it into the Ghostscript executable. (Type 1 fonts include any font whose name ends with .pfa or .pfb, and it also includes all the Ghostscript .gsf fonts except the Hershey fonts.) This has no effect on rendering speed, but it eliminates the time to load the font dynamically, which may make a big improvement in total rendering time, especially for multi-page documents. It also reduces the number of auxiliary files required at run time. Fonts precompiled and built into Ghostscript this way need not appear in Fontmap, although if they do appear there, no harm is done.
The utility for precompiling fonts is named font2c. Note that since font2c uses the PostScript language program font2c.ps, Ghostscript must already be available to run it, and Fontmap must contain entries for the fonts you want to compile. For example, to precompile the Times-Italic font,
font2c Times-Italic ptmri.c
The first argument ("Times-Italic" above) is the font's name and the second ("ptmri.c") is the name of the resulting C file. You can use any file name you want, as long as it ends in ".c". It needn't be limited to eight characters unless your operating system requires this. If "XYZ.gsf" or "XYZ.pfa" is the font file's name in Fontmap, "XYZ.c" is a good choice for the C file.
Under VMS, or other systems whose the C compilers limit the length of identifiers, you must do something slightly more complicated; for that see the section on short identifiers in C. On VMS also, you must quote the font name ("{font name}") to preserve the name's mixed upper and lower case. For VMS environments in general see the VMS directions in the documentation on building Ghostscript, and ignore the rest of this section.
Note that fonts are not supplied with Ghostscript in precompiled form, since those files are quite large and can easily be recreated using font2c. There is a makefile target to run font2c on all the fonts supplied with Ghostscript. Invoke it with
make fonts_standard_c
Besides running font2c, you must compile the fonts and link them into the executable. To do this, add the compiled fonts feature to your platform-specific makefile. See the overview of makefiles in the documentation on building Ghostscript for the list of makefiles for each platform. Find the definition of the FEATURE_DEVS macro in the makefile, which looks something like this:
FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev
and add "ccfonts.dev":
FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev $(PSD)ccfonts.dev
Next you must add the specific fonts to int.mak, the platform-independent makefile for the interpreter. This makefile already has rules for the standard fonts supplied with Ghostscript, so if you just want to compile the standard fonts, you needn't do anything else. Now we describe how to compile other fonts into the executable, such as the Utopia or Kana fonts, or your own fonts.
Suppose you want to compile the Kana fonts into the executable. First pick one of ccfonts10 through ccfonts15 as the place you will do this, say ccfonts10. Add your compiled font file names, for instance
ccfonts10_=$(CFOBJ)fhirw.$(OBJ)
(Note the underscore "_".) If this makes the line too long, use another line of the same form, for instance,
ccfonts11_=$(CFOBJ)fkarw.$(OBJ)
Just below the ccfonts10_= line is a line
ccfonts10=
(Note no underscore.) Add your own fonts to the end of this line, replacing dashes ("-") with underscores ("_") in the font names. For instance:
ccfonts10=Calligraphic_Hiragana
Again, if a line becomes too long, add another line of the same form, for instance,
ccfonts10=Calligraphic_Hiragana
ccfonts11=Calligraphic_Katakana
After all the lines of this form, add a pair of lines to compile each font, separating these entries from the "ccfonts*" lines and from each other with a blank line. In our example this becomes
$(CFOBJ)fhirw.$(OBJ): $(CFGEN)fhirw.c $(CCFONT) $(CFCC) $(CFO_)fhirw.$(OBJ) $(C_) $(CFGEN)fhirw.c $(CFOBJ)fkarw.$(OBJ): $(CFGEN)fkarw.c $(CCFONT) $(CFCC) $(CFO_)fkarw.$(OBJ) $(C_) $(CFGEN)fkarw.c
Finally, run make to build an executable that includes the fonts you added. They are present in FontDirectory when Ghostscript starts up.
On some platforms the C compiler or linker limits the number of significant characters usable in an identifier. On such platforms, you must do a little extra work.
Let N be the maximum number of significant characters in an identifier (typically 31). For each font whose name is longer than N-5 characters, pick an arbitrary identifier that we will call the "short name". This can be any string you want, as long as it contains only letters, digits, and underscores; is no longer than N-5 characters; and is different from all other font names and short names. A good choice for this is the name of the C file. There is no harm in doing this for fonts with names shorter than N-5 characters, but it's unnecessary.
You must do two different things for fonts that require a short name.
font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
Use ccfonts12=pncbi Rather than ccfonts12=NewCenturySchlbk_BoldItalic
Everything else is as described above. This procedure doesn't change the name of the font in Fontmap or as seen from within Ghostscript; it just works around a limitation of some older compilers.
If you create your own fonts and will use them only within your own organization, you should use UniqueID values between 4000000 and 4999999, coded like this (see the tables of codes for font file names below):
Coding of UniqueID "4TTWVE0"
TT Typeface two-digit identifier W Weight normal, bold, etc. V Variant normal, italic, etc. E Expansion normal, condensed, etc.
This scheme will not work forever: as soon there are more than 99 typefaces, or more than 9 weights or variants, we will have to do something else. But it suffices for the near future.
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.)
Because Ghostscript runs on many different systems, including DOS, the names of font files can be no longer than 8 characters. We therefore construct a font's filename FTTWVVVE.gsf similarly to the construction for temporary UniqueIDs.
Coding of font file name "FTTWVVVE.gsf"
F Foundry TT Typeface two-digit identifier W Weight normal, bold, etc. V Variant normal, italic, etc. E Expansion normal, condensed, etc.
Since a font can have multiple variants (for example, Lucida Regular Sans Typewriter Italic) we allocate three letters to that; if a font has four variants, you're on your own. If a font does have multiple variants, it's best to add the expansion letter "r" to make clear which letters are variants and which the expansion. This scheme is very close to the one proposed in "Filenames for fonts", published in the first 1990 issue of TUGboat (the journal of the TeX Users Group).
In the following tables we make no attempt to be exhaustive: instead we have simply allocated entries for those things that we needed for the fonts that we are actually distributing.
Font foundry codes
ID Foundry
b Bitstream f Freely distributable and public-domain hr Hershey n IBM p Adobe ("p" for PostScript) u URW[++]
Typeface codes
ID Name Filename
prefixSource
08 Avant Garde pag Adobe 11 Bookman pbk Adobe 01 CharterBT bch Bitstream 02 Courier ncr IBM 03 Helvetica phv Adobe 04 New Century Schoolbook pnc Adobe 09 Palatino ppl Adobe 05 Symbol psy Adobe 06 Times ptm Adobe -- Utopia put Adobe 07 Zapf Chancery zc public domain 10 Zapf Dingbats pzd Adobe 12 public domain Cyrillic fcy public domain 13 Kevin Hartig Hiragana fhi shareware 14 Kevin Hartig Katakana fka shareware 90 Hershey Gothic English hrge freeware 91 Hershey Gothic Italian hrit freeware 92 Hershey Gothic German hrgr freeware 93 Hershey Greek hrgk freeware 94 Hershey Plain hrpl freeware 95 Hershey Script hrsc freeware 96 Hershey Symbol hrsy freeware
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.
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
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.
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!
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 © 1996, 1997, 1998, 1999, 2000 Aladdin Enterprises. 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 the license contained in the file LICENSE in this distribution.
Ghostscript version 7.07, 17 May 2003