ref: d9b9e15d6bbdae625b3613bb0a704d269cc83098
dir: /sys/src/cmd/gs/doc/Fonts.htm/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Fonts and font facilities supplied with Ghostscript</title> <!-- $Id: Fonts.htm,v 1.51 2005/10/20 19:46:23 ray Exp $ --> <!-- Originally: fonts.txt --> <link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style"> </head> <body> <!-- [1.0 begin visible header] ============================================ --> <!-- [1.1 begin headline] ================================================== --> <h1>Fonts and font facilities supplied with Ghostscript</h1> <!-- [1.1 end headline] ==================================================== --> <!-- [1.2 begin table of contents] ========================================= --> <h2>Table of contents</h2> <blockquote><ul> <li><a href="#About">About Ghostscript fonts</a> <li><a href="#Free_fonts">Ghostscript's free fonts</a> <li><a href="#Other_fonts">Other free fonts</a> <ul> <li><a href="#Computer_Modern">Computer Modern Fontmap</a> <li><a href="#Chinese">Free Chinese (Hanzi) fonts</a> <li><a href="#Japanese">Free Japanese (Kanji) fonts</a> <li><a href="#Unicode_CMaps">Unicode CMaps</a> <li><a href="#Cyrillic">Free Cyrillic fonts</a> <li><a href="#Partial_Unicode_fonts">(Partial) Unicode fonts</a> </ul> <li><a href="#Get_fonts">How Ghostscript gets fonts when it runs</a> <li><a href="#Platform_fonts">Platform fonts</a> <li><a href="#Add_fonts">Adding your own fonts</a> <ul> <li><a href="#Convert_BDF">Converting BDF fonts</a> </ul> <li><a href="#For_developers">For developers only</a> <ul> <li><a href="#Font_contents">Contents of fonts</a> <li><a href="#Precompiling">Precompiling fonts</a> <li><a href="#Short_identifiers">Precompiling fonts on platforms with identifier length limits</a> <li><a href="#Unique_IDs">Font names and unique IDs</a> <li><a href="#Codes">Codes used to make font file names</a> </ul> <li><a href="#Use_gs_fonts_with_X">Using Ghostscript fonts on X Windows displays</a> <ul> <li><a href="#Using_xset">Using <b><tt>xset</tt></b></a> <li><a href="#Font_permanent_installation">Permanent installation</a> <ul> <li><a href="#Configure_xfs">Configuring the <b><tt>xfs</tt></b> font server</a> <li><a href="#Configure_Xfree86">Xfree86 display servers</a> </ul> </ul> </ul></blockquote> <!-- [1.2 end table of contents] =========================================== --> <!-- [1.3 begin hint] ====================================================== --> <p>For other information, see the <a href="Readme.htm">Ghostscript overview</a>. <!-- [1.3 end hint] ======================================================== --> <hr> <!-- [1.0 end visible header] ============================================== --> <!-- [2.0 begin contents] ================================================== --> <h2><a name="About"></a>About Ghostscript fonts</h2> <p> Ghostscript is distributed with two kinds of files related to fonts: <ul> <li>the fonts themselves in individual files, and <li>a file "<tt><b>Fontmap</b></tt>" that defines for Ghostscript which file represents which font. </ul> <p> Additionally, a file <tt><b>cidfmap</b></tt> can be used to create CID fonts for CJK font files on the system See the section on <a href="Use.htm#CIDFontSubstitution">CID Font Substitution</a> for details. <p> Most of the font files supplied with Ghostscript have the extension <tt><b>.pfb</b></tt>, and a few have <tt><b>.pfa</b></tt> or <tt><b>.gsf</b></tt>. Each file defines one ordinary PostScript Type 1 outline font which any PostScript language interpreter can use. Files with <tt><b>.pfa</b></tt> or <tt><b>.pfb</b></tt> extensions are also compatible with Adobe Type Manager (ATM) and with tools that don't include a full PostScript language interpreter; files with <tt><b>.gsf</b></tt> extension are incompatible with ATM and other tools. Ghostscript compiled with the "ttfont" option can also use TrueType fonts with the extension <tt><b>.ttf</b></tt>. <p><a name="Fontmap"></a> When Ghostscript needs a font, it must have some way to know where to look for it: that's the purpose of the <b><tt>Fontmap</tt></b> file, which associates the names of <em>fonts</em> such as <b><tt>/Times-Roman</tt></b> with the names of font <em>files</em>, such as <tt><b>n021003l.pfb</b></tt>. <b><tt>Fontmap</tt></b> can also create aliases for font names, so that for instance, <b><tt>/NimbusNo9L-Regu</tt></b> means the same font as <b><tt>/Times-Roman</tt></b>. <hr> <h2><a name="Free_fonts"></a>Ghostscript's free fonts</h2> <p> Two sets of free fonts are supplied for Ghostscript: <ul> <li>35 commercial-quality Type 1 basic PostScript fonts -- Times, Helvetica, Courier, Symbol, etc. -- contributed by URW++ Design and Development Incorporated, of Hamburg, Germany (<a href="http://www.urwpp.de/">http://www.urwpp.de/</a>). Fontmap names them all. <li>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 <a href="Hershey.htm">documentation on Hershey fonts</a>. </ul> <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Font packages</font><hr> <tr> <td><b>System</b> <td> <td><b>File name</b> <td> <td><b>Contents</b> <td> <td><b>Types</b> <tr> <td colspan=7><hr> <tr valign=top> <td>DOS and<br>MS Windows <td> <td><b><tt>gs###fn1.zip</tt></b> <td> <td>Basic <td> <td><b><tt>.pfb</tt></b> <tr valign=top> <td> <td> <td><b><tt>gs###fn2.zip</tt></b> <td> <td>Miscellaneous <td> <td>Various, for<br>different fonts <tr> <td colspan=7><hr> <tr valign=top> <td>Unix <td> <td><b><tt>ghostscript-fonts-std-#.##.tar.gz</tt></b> <td> <td>Basic <td> <td><b><tt>.afm</tt></b>, <b><tt>.pfb</tt></b>,<br><b><tt>.pfm</tt></b> <tr valign=top> <td> <td> <td><b><tt>ghostscript-fonts-other-#.##.tar.gz</tt></b> <td> <td>Miscellaneous <td> <td><b><tt>.afm</tt></b>, <b><tt>.gsf</tt></b>,<br><b><tt>.pfa</tt></b>, <b><tt>.pfm</tt></b> </table> </blockquote> <p> "#.##" and "###" are the version number with and without punctuation. Fonts can be found at <blockquote> ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs###/ (for a particular version)<br> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/fonts/" class="offsite">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/fonts/</a> (for several versions) </blockquote> <hr> <h2><a name="Other_fonts"></a>Other free fonts</h2> <h3><a name="Computer_Modern"></a>Computer Modern Fontmap</h3> <p> Don Knuth's Computer Modern fonts are popular, free, and widely available. A Fontmap appropriate for these fonts is available from: <blockquote> <a href="ftp://tug.ctan.org/tex-archive/fonts/cm/ps-type1/contrib/Fontmap.cmr" class="offsite"> ftp://tug.ctan.org/tex-archive/fonts/cm/ps-type1/contrib/Fontmap.cmr</a> </blockquote> <p> or from other <a href="http://www.ctan.org/" class="offsite">CTAN</a> sites. <h3><a name="Chinese"></a>Free Chinese (Hanzi) fonts</h3> <p> 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: <blockquote> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/hanzi/" class="offsite">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/hanzi/</a> </blockquote> <p> 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 <a href="mailto:ntut019@ccms.ntu.edu.tw">ntut019@ccms.ntu.edu.tw</a>. The fonts are available from <blockquote> <a href="ftp://cle.linux.org.tw/pub/fonts/cwfont/" class="offsite">ftp://cle.linux.org.tw/pub/fonts/cwfont/</a><br> </blockquote> <p> 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 <tt><b>ttfont</b></tt> feature included: see <a href="Make.htm#Features_and_devices">here</a> for more information.) The fonts and license are available from <blockquote> <a href="ftp://cle.linux.org.tw/pub/fonts/arphic/" class="offsite">ftp://cle.linux.org.tw/pub/fonts/arphic/</a><br> </blockquote> <h3><a name="Japanese"></a>Free Japanese (Kanji) fonts</h3> <p> Mr. Tetsurou Tanaka of the Department of Engineering, University of Tokyo, has created a set of free Kanji fonts available from <blockquote> <a href="ftp://ftp.ipl.t.u-tokyo.ac.jp/Font/" class="offsite">ftp://ftp.ipl.t.u-tokyo.ac.jp/Font/</a><br> </blockquote> <p> 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: <blockquote> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/kanji/"> ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/3rdparty/fonts/kanji/</a><br> </blockquote> <p> 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 <blockquote> <a href="http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-ttf.html" class="offsite">http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-ttf.html</a> </blockquote> <p> The same site has patches to make Ghostscript work with Japanese VF fonts, with documentation in both English and Japanese: <blockquote> <a href="http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-vflib.html" class="offsite">http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-vflib.html</a> </blockquote> <p> Here are some other resources in Japanese relating to VFlib and using Ghostscript with Japanese fonts: <blockquote><dl compact> <dt><a href="http://kakugawa.aial.hiroshima-u.ac.jp/~kakugawa/Hacks/" class="offsite">http://kakugawa.aial.hiroshima-u.ac.jp/~kakugawa/Hacks/</a> <dt><a href="http://itohws03.ee.noda.sut.ac.jp/~matsuda/VFlib-FT/" class="offsite">http://itohws03.ee.noda.sut.ac.jp/~matsuda/VFlib-FT/</a> <dd>Author <<a href="mailto:matsuda@itohws01.ee.noda.sut.ac.jp">matsuda@itohws01.ee.noda.sut.ac.jp</a>> <dt><a href="http://www.rd.nacsis.ac.jp/~katayama/homepage/ghostscript/Japanese.html" class="offsite">http://www.rd.nacsis.ac.jp/~katayama/homepage/ghostscript/Japanese.html</a> <dd>Author <<a href="mailto:katayama@rd.nacsis.ac.jp">katayama@rd.nacsis.ac.jp</a>> </dl></blockquote> <h3><a name="Unicode_CMaps"></a>Unicode CMaps</h3> <p> Some Unicode CMaps that can be used with Ghostscript are freely downloadable from <blockquote> <a href="ftp://ftp.oreilly.com/pub/examples/nutshell/ujip/adobe/" class="offsite">ftp://ftp.oreilly.com/pub/examples/nutshell/ujip/adobe/</a> </blockquote> <h3><a name="Cyrillic"></a>Free Cyrillic fonts</h3> <p> N. Glonty and A. Samarin created in 1989 a Cyrillic extension of TeX's "Computer Modern" fonts, now freely available through the <a href="http://www.ctan.org/" class="offsite">Comprehensive TeX Archive Network</a> (CTAN), for instance at <blockquote> <a href="ftp://ctan.tug.org/tex-archive/fonts/cyrillic/cmcyr/" class="offsite">ftp://ctan.tug.org/tex-archive/fonts/cyrillic/cmcyr/</a> </blockquote> <p> <a href="http://www.ctan.org/" class="offsite">CTAN's</a> entire collection of Cyrillic fonts is, for instance, at <blockquote> <a href="ftp://ctan.tug.org/tex-archive/fonts/cyrillic/" class="offsite">ftp://ctan.tug.org/tex-archive/fonts/cyrillic/</a> </blockquote> <p> 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 <code>.afm</code> and <code>.pfm</code> files, compatible with ATM. The collection could once be found through CTAN, for instance at <blockquote> http://www.ctan.org/tex-archive/fonts/ <!-- orginal was ftp://ctan.tug.org/tex-archive/fonts/postscript/cm/ --> </blockquote> <p> but the collection no longer seems to be available. However, the <a href="http://www.ctan.org/tex-archive/fonts/" class="offsite">ctan fonts directory</a> remains an excellent source of free fonts, many of which are offered in postscript as well we as TeX Metafont format. <hr> <h3><a name="Partial_Unicode_fonts"></a>(Partial) Unicode fonts</h3> <p> 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 <blockquote> <a href="http://bibliofile.mc.duke.edu/gww/fonts/Unicode.html" class="offsite">http://bibliofile.mc.duke.edu/gww/fonts/Unicode.html</a> </blockquote> <h2><a name="Get_fonts"></a>How Ghostscript gets fonts when it runs</h2> <p> 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 <tt><b>gs_fonts.ps</b></tt>, which arranges to load fonts on demand using information from the font map. To preload all of the known fonts, invoke the procedure <blockquote><tt><b> loadallfonts </b></tt></blockquote> <p> The file <tt><b>prfont.ps</b></tt> contains code to print a sample page of a font. Load this program by including it in the <tt><b>gs</b></tt> command line or by invoking <blockquote><tt><b> (prfont.ps) run </b></tt></blockquote> <p> Then to produce a sampler of a particular font XYZ, invoke <blockquote><tt><b> /XYZ DoFont </b></tt></blockquote> <p>For example, <blockquote><tt><b> /Times-Roman DoFont </b></tt></blockquote> <p> For more information about how Ghostscript loads fonts during execution, see <a href="Use.htm#Font_lookup">here</a>. <hr> <h2><a name="Platform_fonts"></a>Platform fonts</h2> <p> 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. <p> 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 <blockquote> Ghostscript needs the scalable outlines of any font mentioned in a document, and loads them from the disk (<tt><b>.pfa</b></tt>, <tt><b>.pfb</b></tt>, or <tt><b>.gsf</b></tt> 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. </blockquote> <p> 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 "<b><tt>Times-Roman</tt></b>", may be known as "<b><tt>Times-Roman</tt></b>", "<b><tt>Times Roman</tt></b>", "<b><tt>Tms Rmn</tt></b>", "<b><tt>Times New Roman</tt></b>", or "<b><tt>TimesNewRoman</tt></b>". The name may even be completely different: the usual Helvetica-equivalent TrueType font is called "<b><tt>Arial</tt></b>". 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: <ol> <li>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. <li>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. </ol> <p> 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. <hr> <h2><a name="Add_fonts"></a>Adding your own fonts</h2> <p> 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. <p> 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. <p> In the PC world, Type 1 fonts are customarily given names ending in <tt><b>.PFA</b></tt> or <tt><b>.PFB</b></tt>. 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. <h3><a name="Convert_BDF"></a>Converting BDF fonts</h3> <p> 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 <tt><b>bdftops</b></tt> (Unix) or the command file <tt><b>bdftops.bat</b></tt> (DOS) converts a BDF file to a scalable outline using <tt><b>bdftops.ps</b></tt> . Run the shell command <blockquote><tt><b> bdftops BDF_filename [AFM_file1_name ...] gsf_filename fontname<br> UniqueID [XUID] [encodingname] </b></tt></blockquote> <p> The arguments have these meanings: <blockquote><table cellpadding=0 cellspacing=0> <tr valign=top> <td><tt><b>BDF_filename</b></tt> <td> <td>Input bitmap file in BDF format <td> <td> <tr valign=top> <td><tt><b>AFM_file1_name</b></tt> <td> <td>AFM files giving metrics <td> <td>(Optional) <tr valign=top> <td><tt><b>gsf_filename</b></tt> <td> <td>Output file <td> <td> <tr valign=top> <td><tt><b>fontname</b></tt> <td> <td>Name of the font <td> <td> <tr valign=top> <td><tt><b>UniqueID</b></tt> <td> <td>UniqueID (<a href="#Unique_IDs">as described below</a>) <td> <td> <tr valign=top> <td><tt><b>XUID</b></tt> <td> <td>XUID, in the form <tt><b>n1.n2.n3...</b></tt> (<a href="#Unique_IDs">as described below</a>) <td> <td>(Optional) <tr valign=top> <td><tt><b>encodingname</b></tt> <td> <td>"StandardEncoding" (the default), "ISOLatin1Encoding",<br>"SymbolEncoding", "DingbatsEncoding" <td> <td>(Optional) </table></blockquote> <p> For instance <blockquote><tt><b> bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000 1000000.1.41 </b></tt></blockquote> <p> Then make an entry in Fontmap for the <tt><b>.gsf</b></tt> file (<tt><b>pzdr.gsf</b></tt> in the example) as <a href="#Add_fonts">described above</a>. <hr> <h2><a name="For_developers"></a>For developers only</h2> <p> The rest of this document is very unlikely to be of value to ordinary users. <h3><a name="Font_contents"></a>Contents of fonts</h3> <p> 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. <h3><a name="Precompiling"></a>Precompiling fonts</h3> <p> 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 <tt><b>.pfa</b></tt> or <tt><b>.pfb</b></tt>, and it also includes all the Ghostscript <tt><b>.gsf</b></tt> 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. <p><a name="font2c"></a> The utility for precompiling fonts is named <tt><b>font2c</b></tt>. Note that since <tt><b>font2c</b></tt> uses the PostScript language program <tt><b>font2c.ps</b></tt>, 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, <blockquote><tt><b> font2c Times-Italic ptmri.c </b></tt></blockquote> <p> The first argument ("<b><tt>Times-Italic</tt></b>" above) is the font's name and the second ("<b><tt>ptmri.c</tt></b>") is the name of the resulting C file. You can use any file name you want, as long as it ends in "<tt><b>.c</b></tt>". It needn't be limited to eight characters unless your operating system requires this. If "<b><tt>XYZ.gsf</tt></b>" or "<b><tt>XYZ.pfa</tt></b>" is the font file's name in Fontmap, "<b><tt>XYZ.c</tt></b>" is a good choice for the C file. <p> 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 <a href="#Short_identifiers">short identifiers in C</a>. 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 <a href="Make.htm#VMS">the VMS directions</a> in the documentation on building Ghostscript, and ignore the rest of this section. <p> Note that fonts are not supplied with Ghostscript in precompiled form, since those files are quite large and can easily be recreated using <a href="#font2c"><tt><b>font2c</b></tt></a>. There is a makefile target to run <tt><b>font2c</b></tt> on all the fonts supplied with Ghostscript. Invoke it with <blockquote><b><tt> make fonts_standard_c </tt></b></blockquote> <p>Besides running <tt><b>font2c</b></tt>, 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 <a href="Make.htm#Makefile_overview">overview of makefiles</a> in the documentation on building Ghostscript for the list of makefiles for each platform. Find the definition of the <tt><b>FEATURE_DEVS</b></tt> macro in the makefile, which looks something like this: <blockquote><tt><b> FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev </b></tt></blockquote> <p> and add "ccfonts.dev": <blockquote><tt><b> FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)pipe.dev $(PSD)ccfonts.dev </b></tt></blockquote> <p> Next you must add the specific fonts to <tt><b>int.mak</b></tt>, 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. <p> Suppose you want to compile the Kana fonts into the executable. First pick one of <b><tt>ccfonts10</tt></b> through <b><tt>ccfonts15</tt></b> as the place you will do this, say <b><tt>ccfonts10</tt></b>. Add your compiled font file names, for instance <blockquote><tt><b> ccfonts10_=$(CFOBJ)fhirw.$(OBJ) </b></tt></blockquote> <p> (Note the underscore "_".) If this makes the line too long, use another line of the same form, for instance, <blockquote><tt><b> ccfonts11_=$(CFOBJ)fkarw.$(OBJ) </b></tt></blockquote> <p> Just below the <b><tt>ccfonts10_=</tt></b> line is a line <blockquote><tt><b> ccfonts10= </b></tt></blockquote> <p> (Note no underscore.) Add your own fonts to the end of this line, replacing dashes ("-") with underscores ("_") in the font names. For instance: <blockquote><tt><b> ccfonts10=Calligraphic_Hiragana </b></tt></blockquote> <p> Again, if a line becomes too long, add another line of the same form, for instance, <blockquote><tt><b> ccfonts10=Calligraphic_Hiragana<br> ccfonts11=Calligraphic_Katakana </b></tt></blockquote> <p> 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 <blockquote> <pre>$(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 </pre></blockquote> <p> Finally, run <tt><b>make</b></tt> to build an executable that includes the fonts you added. They are present in <b><tt>FontDirectory</tt></b> when Ghostscript starts up. <h3><a name="Short_identifiers"></a>Precompiling fonts on platforms with identifier length limits</h3> <p> 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. <p> Let <em><b>N</b></em> be the maximum number of significant characters in an identifier (typically 31). For each font whose name is longer than <em><b>N</b></em>-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 <em><b>N</b></em>-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 <em><b>N</b></em>-5 characters, but it's unnecessary. <p> You must do two different things for fonts that require a short name. <ol> <li>You must supply the short name as a third argument to <tt><b>font2c</b></tt>. For example, to compile <b><tt>NewCenturySchlbk-BoldItalic</tt></b> using the short name <b><tt>pncbi</tt></b>, <blockquote><tt><b> font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi </b></tt></blockquote> <li> 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, <blockquote><table cellpadding=0 cellspacing=0> <tr> <td>Use <td> <td><tt><b>ccfonts12=pncbi</b></tt> <tr> <td>Rather than <td> <td><tt><b>ccfonts12=NewCenturySchlbk_BoldItalic</b></tt> </table></blockquote> </ol> <p> 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. <hr> <h3><a name="Unique_IDs"></a>Font names and unique IDs</h3> <p> If you create your own fonts and will use them only within your own organization, you should use <tt><b>UniqueID</b></tt> values between 4000000 and 4999999, coded like this (see the <a href="#Codes">tables of codes</a> for font file names below): <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Coding of UniqueID "<tt><b>4TTWVE0</b></tt>"</font><hr> <tr> <td><tt><b>TT</b></tt> <td> <td><a href="#Typeface">Typeface</a> <td> <td>two-digit identifier <tr> <td><tt><b>W</b></tt> <td> <td><a href="#Weight">Weight</a> <td> <td>normal, bold, etc. <tr> <td><tt><b>V</b></tt> <td> <td><a href="#Variant">Variant</a> <td> <td>normal, italic, etc. <tr> <td><tt><b>E</b></tt> <td> <td><a href="#Expansion">Expansion</a> <td> <td>normal, condensed, etc. </table></blockquote> <p> 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. <p> If you plan to distribute fonts, ask Adobe to assign you some UniqueIDs and also an <tt><b>XUID</b></tt> for your organization. Contact <blockquote><address> Unique ID Coordinator<br> Adobe Developers Association<br> Adobe Systems, Inc.<br> 345 Park Avenue<br> San Jose, CA 95110-2704<br> +1-408-536-9000 telephone (ADA)<br> +1-408-536-6883 fax<br> <a href="mailto:fontdev-person@adobe.com">fontdev-person@adobe.com</a><br> </address></blockquote> <p> 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 <tt><b>bdftops</b></tt> program creates XUIDs of the form "<tt><b>[-X- 0 -U-]</b></tt>" where "<tt><b>-X-</b></tt>" is the organization XUID and "<tt><b>-U-</b></tt>" 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.) <p> 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 <tt><b>FTTWVVVE.gsf</b></tt> similarly to the construction for temporary UniqueIDs. <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Coding of font file name "<tt><b>FTTWVVVE.gsf</b></tt>"</font><hr> <tr> <td><tt><b>F</b></tt> <td> <td><a href="#Foundries">Foundry</a> <td> <td> <tr> <td><tt><b>TT</b></tt> <td> <td><a href="#Typeface">Typeface</a> <td> <td>two-digit identifier <tr> <td><tt><b>W</b></tt> <td> <td><a href="#Weight">Weight</a> <td> <td>normal, bold, etc. <tr> <td><tt><b>V</b></tt> <td> <td><a href="#Variant">Variant</a> <td> <td>normal, italic, etc. <tr> <td><tt><b>E</b></tt> <td> <td><a href="#Expansion">Expansion</a> <td> <td>normal, condensed, etc. </table></blockquote> <p> 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 "<b><tt>r</tt></b>" 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 <em>TUGboat</em> (the journal of the TeX Users Group). <h3><a name="Codes"></a>Codes used to make font file names</h3> <p> 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. <p> <a name="Foundries"></a> <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Font foundry codes</font><hr> <tr> <th>ID <th> <th align=left>Foundry <tr> <td colspan=3><hr> <tr> <td><tt><b>b</b></tt> <td> <td>Bitstream <tr> <td><tt><b>f</b></tt> <td> <td>Freely distributable and public-domain <tr> <td><tt><b>hr</b></tt> <td> <td>Hershey <tr> <td><tt><b>n</b></tt> <td> <td>IBM <tr> <td><tt><b>p</b></tt> <td> <td>Adobe ("p" for PostScript) <tr> <td><tt><b>u</b></tt> <td> <td>URW[++] </table></blockquote> <p> <a name="Typeface"></a> <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Typeface codes</font><hr> <tr valign=bottom> <th>ID <td> <th align=left>Name <td> <th align=left>Filename<br>prefix <td> <th align=left>Source <tr> <td colspan=7><hr> <tr> <td><tt><b>08</b></tt> <td> <td>Avant Garde <td> <td><tt><b>pag</b></tt> <td> <td>Adobe <tr> <td><tt><b>11</b></tt> <td> <td>Bookman <td> <td><tt><b>pbk</b></tt> <td> <td>Adobe <tr> <td><tt><b>01</b></tt> <td> <td>CharterBT <td> <td><tt><b>bch</b></tt> <td> <td>Bitstream <tr> <td><tt><b>02</b></tt> <td> <td>Courier <td> <td><tt><b>ncr</b></tt> <td> <td>IBM <tr> <td><tt><b>03</b></tt> <td> <td>Helvetica <td> <td><tt><b>phv</b></tt> <td> <td>Adobe <tr> <td><tt><b>04</b></tt> <td> <td>New Century Schoolbook <td> <td><tt><b>pnc</b></tt> <td> <td>Adobe <tr> <td><tt><b>09</b></tt> <td> <td>Palatino <td> <td><tt><b>ppl</b></tt> <td> <td>Adobe <tr> <td><tt><b>05</b></tt> <td> <td>Symbol <td> <td><tt><b>psy</b></tt> <td> <td>Adobe <tr> <td><tt><b>06</b></tt> <td> <td>Times <td> <td><tt><b>ptm</b></tt> <td> <td>Adobe <tr> <td>-- <td> <td>Utopia <td> <td><tt><b>put</b></tt> <td> <td>Adobe <tr> <td><tt><b>07</b></tt> <td> <td>Zapf Chancery <td> <td><tt><b>zc</b></tt> <td> <td>public domain <tr> <td><tt><b>10</b></tt> <td> <td>Zapf Dingbats <td> <td><tt><b>pzd</b></tt> <td> <td>Adobe <tr> <td><tt><b>12</b></tt> <td> <td>public domain Cyrillic <td> <td><tt><b>fcy</b></tt> <td> <td>public domain <tr> <td><tt><b>13</b></tt> <td> <td>Kevin Hartig Hiragana <td> <td><tt><b>fhi</b></tt> <td> <td>shareware <tr> <td><tt><b>14</b></tt> <td> <td>Kevin Hartig Katakana <td> <td><tt><b>fka</b></tt> <td> <td>shareware <tr> <td><tt><b>90</b></tt> <td> <td>Hershey Gothic English <td> <td><tt><b>hrge</b></tt> <td> <td>freeware <tr> <td><tt><b>91</b></tt> <td> <td>Hershey Gothic Italian <td> <td><tt><b>hrit</b></tt> <td> <td>freeware <tr> <td><tt><b>92</b></tt> <td> <td>Hershey Gothic German <td> <td><tt><b>hrgr</b></tt> <td> <td>freeware <tr> <td><tt><b>93</b></tt> <td> <td>Hershey Greek <td> <td><tt><b>hrgk</b></tt> <td> <td>freeware <tr> <td><tt><b>94</b></tt> <td> <td>Hershey Plain <td> <td><tt><b>hrpl</b></tt> <td> <td>freeware <tr> <td><tt><b>95</b></tt> <td> <td>Hershey Script <td> <td><tt><b>hrsc</b></tt> <td> <td>freeware <tr> <td><tt><b>96</b></tt> <td> <td>Hershey Symbol <td> <td><tt><b>hrsy</b></tt> <td> <td>freeware </table></blockquote> <p> <a name="Weight"></a> <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Font weight codes</font><hr> <tr> <th>ID <td> <th align=left>Type <td> <th align=left>Filename <tr> <td colspan=5><hr> <tr> <td><tt><b>0</b></tt> <td> <td>normal <td> <td><tt><b>r</b></tt> <tr> <td><tt><b>1</b></tt> <td> <td>bold <td> <td><tt><b>b</b></tt> <tr> <td><tt><b>2</b></tt> <td> <td>book <td> <td><tt><b>k</b></tt> <tr> <td><tt><b>3</b></tt> <td> <td>demi <td> <td><tt><b>d</b></tt> <tr> <td><tt><b>4</b></tt> <td> <td>light <td> <td><tt><b>l</b></tt> <tr> <td> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1"><a name="Variant"></a>Font variants</font><hr> <tr> <th>ID <td> <th align=left>Type <td> <th align=left>Filename <tr> <td colspan=5><hr> <tr> <td><tt><b>0</b></tt> <td> <td>normal <td> <td><tt><b>r</b></tt> (omitted when weight is normal) <tr> <td><tt><b>1</b></tt> <td> <td>italic <td> <td><tt><b>i</b></tt> <tr> <td><tt><b>2</b></tt> <td> <td>oblique <td> <td><tt><b>o</b></tt> <tr valign=top> <td><tt><b>3</b></tt> <td> <td>script, handwritten, swash <td> <td><tt><b>w</b></tt> <tr> <td> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1"><a name="Expansion"></a>Expansion</font><hr> <tr> <th>ID <td> <th align=left>Type <td> <th align=left>Filename <tr> <td colspan=5><hr> <tr> <td><tt><b>0</b></tt> <td> <td>normal <td> <td><tt><b>r</b></tt> (omitted when weight and variant are normal) <tr> <td><tt><b>1</b></tt> <td> <td>narrow <td> <td><tt><b>n</b></tt> </table></blockquote> <hr> <h2><a name="Use_gs_fonts_with_X"></a>Using Ghostscript fonts on X Windows displays</h2> <p> 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 "<b><tt>fonts.dir</tt></b>" and "<b><tt>fonts.scale</tt></b>". There are two main methods to configure your display to use these files. <ul> <li><a href="#Using_xset">With <b><tt>xset</tt></b></a> any user can add a new directory to the font search path for the duration of a session. <li>An administrator with root access can <a href="#Font_permanent_installation">add the Ghostscript font directory permanently</a> to the <a href="#X_font_catalog">X font server's catalog</a> or to an <a href="#Xfree86_fontpath">X display server's list of directories</a>. </ul> <h3><a name="Using_xset"></a>Using <b><tt>xset</tt></b></h3> <p> Users without root access can add the Ghostscript font directories to the font search path using <b><tt>xset</tt></b>. 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 <b><tt>xset</tt></b> should be added to the user's "<b><tt>.xsession</tt></b>" or "<b><tt>.xinitrc</tt></b>" startup script to make the fonts available at each login. <p> To add a new font directory, invoke <b><tt>xset</tt></b> like this: <blockquote> <b><tt>xset fp+</tt> <em>{directory}</em></b> </blockquote> <p> where <b><em>{directory}</em></b> 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 <blockquote> <b><tt>/usr/local/Ghostscript/share/fonts</tt></b> </blockquote> <h3><a name="Font_permanent_installation"></a>Permanent installation</h3> <p> 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. <h4><a name="Configure_xfs"></a>Configuring the <b><tt>xfs</tt></b> font server</h4> <p> An X display server can obtain its font resources from a dedicated X font server. <b><tt>xfs</tt></b> 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 <blockquote><b><tt> /usr/lib/X11/fs/config <br>/usr/X11/lib/X11/fs/config <br>/usr/X11R6/lib/X11/fs/config </tt></b></blockquote> <p> or some similar name. You can also use <b><tt>xfs</tt></b>'s "<b><tt>-config</tt></b>" command-line option to specify the location of the configuration file. <p><a name="X_font_catalog"></a> The configuration file designates a list ("catalog") of directories, each of which contains fonts and a font mapping database (the file "<b><tt>fonts.dir</tt></b>"). This list is specified with the "<b><tt>catalogue=</tt></b>" 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: <blockquote><b><tt> catalogue = /usr/local/share/Ghostscript/fonts/, <br>/usr/X11R6/lib/X11/fonts/misc/, <br>/usr/X11R6/lib/X11/fonts/Speedo/, <br>/usr/X11R6/lib/X11/fonts/Type1/, <br>/usr/X11R6/lib/X11/fonts/75dpi/, <br>/usr/X11R6/lib/X11/fonts/100dpi/ </tt></b></blockquote> <p> 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: <blockquote> <b><tt>kill -HUP</tt> <em>{pid}</em></b> </blockquote> <p> where <b><em>{pid}</em></b> is the font server process's numeric process ID, as obtained with the "<b><tt>ps</tt></b>" 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! <h4><a name="Configure_Xfree86"></a>Xfree86 display servers</h4> <p><a name="Xfree86_fontpath"></a> With the family of Xfree86 display servers, adding a new font directory permanently requires editing the "<b><tt>/etc/XF86Config</tt></b>" setup file to add a new "<b><tt>FontPath</tt></b>" to the "<b><tt>Files</tt></b>" section: <blockquote> <b><tt>Section "Files" <br> RgbPath "/usr/X11R6/lib/X11/rgb" <br> FontPath "/usr/local/share/Ghostscript/fonts" <br> FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled" <br> FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled" <br> FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled" <br> FontPath "/usr/X11R6/lib/X11/fonts/Type1" <br> FontPath "/usr/X11R6/lib/X11/fonts/Speedo" <br>EndSection</tt></b> </blockquote> <p> 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 <b><tt>xdm</tt></b>, you may have to kill it, because it is usually reset only between successive sessions. <p> This section by Bertrand Petit <<a href="mailto:eegs@phoe.frmug.org">eegs@phoe.frmug.org</a>> <!-- [2.0 end contents] ==================================================== --> <!-- [3.0 begin visible trailer] =========================================== --> <hr> <p> <small>Copyright © 1996, 1997, 1998, 1999, 2000 Aladdin Enterprises. All rights reserved.</small> <p> 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. For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or contact Artifex Software, Inc., 101 Lucas Valley Road #110, San Rafael, CA 94903, U.S.A., +1(415)492-9861. <p> <small>Ghostscript version 8.53, 20 October 2005 <!-- [3.0 end visible trailer] ============================================= --> </body> </html>