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