386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / fonts.doc
CommitLineData
3e15cc4c
WJ
1 Copyright (C) 1990, 1991 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies.
19
20- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21
22This file, fonts.doc, describes the fonts and font facilities supplied
23with Ghostscript.
24
25For an overview of Ghostscript and a list of the documentation files, see
26README.
27
28Ghostscript fonts
29-----------------
30
31The fonts included with Ghostscript come in several parts:
32
33 - Font data in files *.gsf: each file defines one (transformable)
34 font specified in outline form.
35
36 - BuildChar procedures in gs_fonts.ps: these provide the
37 algorithms for interpreting the data in the .gsf files.
38
39 - The Fontmap file: this relates Ghostscript font names to .gsf
40 file names.
41
42Currently, the fonts supplied with Ghostscript are based on various public
43domain bitmap fonts, mostly the ones supplied with the X11 distribution
44from MIT, and on the public domain Hershey fonts. The fonts are
45distributed in the file `ghostscript-N.NNfonts.tar.Z'. The bitmap-derived
46fonts include the usual Helvetica, Times-Roman, and so on; see the file
47`Fontmap' for the complete list, in the usual roman, italic, bold, and
48bold italic styles (for the most part). The Hershey fonts, on the other
49hand, are quite different from traditional ones; the file `hershey.doc'
50describes them in more detail.
51
52There is also a single rather heavy home-grown font called Ugly. This
53font is the file `uglyr.gsf' in the Ghostscript source distribution.
54
55The file gs_fonts.ps, which is loaded as part of Ghostscript
56initialization, arranges to load fonts on demand using the information
57from Fontmap. If you want to preload all of the known fonts, invoke the
58procedure
59 loadallfonts
60This is not done by default, since the fonts occupy about 50K each and there
61are a lot of them.
62
63Ghostscript fonts are actually ordinary Ghostscript programs: they use the
64extension .gsf instead of .ps simply to be informative. This convention
65is only embodied in the Fontmap file: there is no code that knows about
66it.
67
68If you want to try out the fonts, prfont.ps contains code for printing a
69sampler. Load this program, by including it in the gs command line or by
70invoking
71 (prfont.ps) run
72and then to produce a sampler of a particular font, invoke
73 /fontName DoFont
74e.g.
75 /Times-Roman DoFont
76
77
78Contents of fonts
79-----------------
80
81A Ghostscript font is a dictionary with a standard set of keys as follows.
82The keys marked with a * have the same meanings as in P*stScr*pt fonts;
83those marked with # have the same meanings as in Adobe Type 1 fonts. Note
84that FontName is required; StrokeWidth is required for all stroked or
85outlined fonts; and Metrics is not currently supported.
86
87* - FontMatrix <array>: the transformation from character
88 coordinates to user coordinates.
89
90* - FontType <integer>: the type of the font, either 1 or 3.
91
92* - FontBBox <array>: the bounding box of the font.
93
94* - Encoding <array>: the map from character codes to character
95 names.
96
97* - FontName <name>: the name of the font.
98
99* - PaintType <integer>: an indication of how to interpret the
100 character description from CharInfo.
101
102* - StrokeWidth <number>: the stroke width for outline fonts.
103
104* - FontInfo <dictionary>: additional information about the font
105 (optional, not used by the standard Ghostscript software).
106
107* - UniqueID <integer>: a unique number identifying the font.
108
109* - BuildChar <procedure>: the procedure for showing a character
110 (not required in type 1 fonts).
111
112# - CharStrings <dictionary>: the map from character names to character
113 descriptions (relevant only in type 1 fonts).
114
115# - Private <dictionary>: additional information used by the
116 algorithms for rendering outlines fonts (relevant only in type 1
117 fonts).
118
119The format of values in the CharStrings and Private dictionaries are
120described in the Adobe Type 1 Font Format book.
121
122Adding your own fonts
123---------------------
124
125The program bdftops.ps (and invoking shell script bdftops.bat or bdftops)
126converts these bitmap files to Ghostscript input, using the Ghostscript
127``type1imagepath'' operator to convert the bitmaps into outlines.
128
129If you want to add fonts of your own, you need to do two things. First,
130edit Fontmap to include an entry for your new font at the end. The format
131for entries is documented in the Fontmap file. Second, you need to
132prepare the .gsf file. If you are converting a file from BDF format, the
133Ghostscript distribution already includes a program for doing this: run
134the shell command
135 bdftops <BDF_file_name> [<AFM_file1_name> ...] <your_gsf_file_name>
136 <font_name> <uniqueID> [<encoding_name>]
137e.g.,
138 bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000
139You may find it helpful to read, and to add an entry to, the fonts.mak
140file, which is a makefile for converting the standard Ghostscript fonts.
141
142There is a similar utility to convert files from .PFB form to plain text
143.gsf form. Run the shell command
144 pfbtogs <.PFB_file_name> <gsf_file_name>
145e.g.,
146 pfbtogs timesrmn.pfb ptmr.gsf
147Files in .PFA form can be used directly by Ghostscript -- no conversion is
148required, just an entry in Fontmap.
149
150Starting in release 2.4, Ghostscript can also use .PFB fonts directly: you
151don't have to run pfbtogs, just put the .PFB file in the Fontmap.
152
153Precompiling fonts
154------------------
155
156You can compile any font into C and link it into the Ghostscript
157executable. This doesn't have any effect on rendering speed, but it
158eliminates the time for loading the font dynamically.
159
160The utility for precompiling fonts is called font2c. (Note that font2c is
161actually a PostScript program, so you must have some version of
162Ghostscript already running to be able to run font2c.) For example, to
163precompile the Times-Roman font,
164 font2c Times-Roman timesrmn.c
165where the first argument is the font name and the second is the name of
166the .c file. (You can use any file name you want, as long as it ends in
167.c. It doesn't have to be limited to 8 characters, unless your operating
168system requires this.)
169
170Besides running font2c, you must edit the makefile so that the file will
171be compiled from C to machine code, and linked into the executable.
172First, you must add the compiled fonts "feature" to your platform-specific
173makefile. On MS-DOS systems, you edit turboc.mak, tbcplus.mak, or
174watc.mak; on Unix systems, you edit makefile. (The situation on VMS
175systems that do not use `make' is too complicated to describe here;
176contact Aladdin Enterprises for assistance.) Find the definition of
177FEATURE_DEVS in the makefile, e.g.,
178 FEATURE_DEVS=filter.dev dps.dev
179Add ccfonts.dev on the end, e.g.,
180 FEATURE_DEVS=filter.dev dps.dev ccfonts.dev
181
182Next, you must add the specific fonts to the generic makefile. On MS-DOS
183systems, you edit gs.mak; on Unix systems, you edit makefile. Find the
184line in the relevant makefile that says
185 ccfonts_=ugly.$(OBJ) cour.$(OBJ)
186Edit this to add your compiled font file names, e.g.,
187 ccfonts_=ugly.$(OBJ) cour.$(OBJ) timesrmn.$(OBJ)
188Then find the line that says
189 $(SHP)gsaddmod ccfonts -oper font_Ugly font_Courier
190Add your own fonts to the end of this line. If the line gets too long,
191add another line of the same form, e.g.,
192 $(SHP)gsaddmod ccfonts -oper font_Ugly font_Courier
193 $(SHP)gsaddmod ccfonts -oper font_Times_Roman
194Notice that you must replace `-' by `_' in the font name. Now find the
195lines that say
196 ugly.$(OBJ): ugly.c $(CCFONT)
197
198 cour.$(OBJ): cour.c $(CCFONT)
199Add a similar line for each font, separating these lines from each other
200by a blank line. In our example,
201 ugly.$(OBJ): ugly.c $(CCFONT)
202
203 cour.$(OBJ): cour.c $(CCFONT)
204
205 timesrmn.$(OBJ): timesrmn.c $(CCFONT)
206
207Finally, run `make'. The executable will now include the fonts you added.
208They will be present in FontDirectory when Ghostscript starts up.
209
210Fonts that have been precompiled and linked in this way do not need to
211appear in the Fontmap, although if they do appear there, no harm is done.
212
213Because of RAM and compiler limitations, you shouldn't use compiled fonts
214on MS-DOS systems unless you are using a 32-bit compiler such as Watcom
215C/386 or djgpp.
216
217Note that ugly.c and cour.c are not supplied with the Ghostscript fileset,
218since they are quite large and can easily be recreated using the font2c
219program as described above.