Fonts and font facilities supplied with Ghostscript

## Table of contents

> - About Ghostscript fonts
> - Ghostscript's free fonts
> - Other free fonts
>   - A free Chinese (Hanzi) font
>   - Free Japanese (Kanji) fonts
>   - Unicode CMaps
>   - Free Cyrillic fonts
> - How Ghostscript gets fonts when it runs
> - Platform fonts
> - Adding your own fonts
>   - Converting BDF fonts
> - For developers only
>   - Contents of fonts
>   - Precompiling fonts
>   - Precompiling fonts on platforms with identifier length limits
>   - Font names and unique IDs
>   - Codes used to make font file names

For other information, see the Ghostscript overview.

## About Ghostscript fonts

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

- the fonts themselves in individual files, and
- a file "`Fontmap`" that defines for Ghostscript which file represents which font.

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:

- 35 commercial-quality Type 1 basic PostScript fonts -- Times, Helvetica, Courier, Symbol, etc. -- contributed by URW++ Design and Development Incorporated, of Hamburg, Germany (http://www.urwpp.de/). Fontmap names them all.
- A miscellaneous set including Cyrillic, kana, and fonts derived from the free Hershey fonts, with improvements (such as adding accented characters) by Thomas Wolff. The Hershey-based fonts are quite different from traditional printer or display fonts; you can read about them in more detail in the documentation on Hershey fonts.

> 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://ftp.cs.wisc.edu/ghost/aladdin/gs###/ (for a particular version)
> ftp://ftp.cs.wisc.edu/ghost/aladdin/fonts/ (for several versions)

## Other free fonts

### A free Chinese (Hanzi) font

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://ftp.ifcss.org/pub/software/fonts/big5/next/
> ftp://ftp.cs.wisc.edu/ghost/hanzi/

### 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://ftp.cs.wisc.edu/ghost/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://www.ldl.jaist.ac.jp/~akr/nonresearch/free-software/ghostscript/index.ja.html
>   Author <akr@jaist.ac.jp>
> http://www.se.hiroshima-u.ac.jp/~kakugawa/Hacks/Hacks-JIS.html
> http://itohws03.ee.noda.sut.ac.jp/~matsuda/VFlib-FT/
>   Author <matsuda@itohws01.ee.noda.sut.ac.jp>

### Unicode CMaps

The Unicode CMaps distributed 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/cmcyr/

Basil K. Malyshev created the "Paradissa Fonts Collection" in 1993. It contains 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 can be found through CTAN, for instance at

> ftp://ctan.tug.org/tex-archive/fonts/postscript/cm/

These fonts are covered by this license:

> Paradissa fonts collection.
> Copyright © 1993, Basil K. Malyshev. All Rights Reserved.

> Licensing agreement

> The author of this fonts grants to any individual or non-commercial organization the right to use and to make an unlimited number of copies of full collection or selected fonts when this is done WITHOUT CHARGE and has attached this licence agreement.

> This fonts cannot be sold or distributed with any commercial product without written authorization from the author. If you want to charge a small fee for distribute fonts as is or with any software, you should contact the author.

> This restriction is not intended to apply to connect time charges, or flat rate connection/download fees for electronic bulletin board services.

> Basil K. Malyshev <malyshev@mx.ihep.su> 22 December 1993, Protvino, Russia.

## 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`

## 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; Aladdin Enterprises takes 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.

### Precompiling fonts

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 "`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`. A makefile "`cfonts.mak`" runs `font2c` on all the fonts supplied with Ghostscript. Invoke it with

> `make -f cfonts.mak` (on some systems `make -fcfonts.mak`)

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=psl3.dev pdf.dev dpsnext.dev pipe.dev rasterop.dev`

and add "ccfonts.dev":

> `FEATURE_DEVS=psl3.dev pdf.dev dpsnext.dev pipe.dev rasterop.dev 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_=fhirw.$(OBJ)`

(Note the underscore "_".) If this makes the line too long, use another line of the same form, for instance,

> `ccfonts11_=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

> `

>     fhirw.$(OBJ):
>     	fhirw.c $(CCFONT)
>     	$(CCCF) fhirw.c

>     fkarw.$(OBJ):
>     	fkarw.c $(CCFONT)
>     	$(CCCF) fkarw.c

> `

Finally, run `make` to build an executable that includes the fonts you added. They are present in `FontDirectory` when Ghostscript starts up.

### Precompiling fonts on platforms with identifier length limits

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.

1. You must supply the short name as a third argument to `font2c`. For example, to compile `NewCenturySchlbk-BoldItalic` using the short name `pncbi`,

   > `font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi`

2. Then when you add the font name to the definition of one of the ccfonts* macros in the makefile, use the short name, not the actual font name, for instance,

   > 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.

### 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, 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

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 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).

### Codes used to make font file names

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 prefix |  | Source
> `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

> Font weight codes
> ID |  | Type |  | Filename
> `0` |  | normal |  | `r`
> `1` |  | bold |  | `b`
> `2` |  | book |  | `k`
> `3` |  | demi |  | `d`
> `4` |  | light |  | `l`
> Font variants
> ID |  | Type |  | Filename
> `0` |  | normal |  | `r` (omitted when weight is normal)
> `1` |  | italic |  | `i`
> `2` |  | oblique |  | `o`
> `3` |  | script, handwritten, swash |  | `w`
> Expansion
> ID |  | Type |  | Filename
> `0` |  | normal |  | `r` (omitted when weight and variant are normal)
> `1` |  | narrow |  | `n`

Copyright © 1996, 1997, 1998 Aladdin Enterprises. All rights reserved.

This file is part of Aladdin Ghostscript. See the Aladdin Free Public License (the "License") for full details of the terms of using, copying, modifying, and redistributing Aladdin Ghostscript.

Ghostscript version 5.50, 16 September 1998