The (preliminary) TrueType HOWTO <author>Brion Vibber, <tt><htmlurl url="mailto:brion@pobox.com" name="brion@pobox.com"></tt> <date>v0.4, 16 June 1998 <abstract> This document is intended to explain how to use TrueType fonts with Linux. The most recent version of this HOWTO can be obtained in HTML format at <htmlurl url="http://pobox.com/~brion/linux/TrueType-HOWTO.html" name="http://pobox.com/~brion/linux/TrueType-HOWTO.html">. </abstract> <toc> <sect>Introduction<label id="main-intro"> <p> This document is intended to explain how to use TrueType fonts with Linux and applications that run under Linux. <sect1>Disclaimer<label id="disclaimer"> <p> The information in this is document is, to the best of my knowledge, correct. However this HOWTO is still in preliminary versions and may contain incomplete, confusing, misleading, or even incorrect information. It is being provided in this form so that such errors can be spotted and corrected; think of it as being in beta testing. So, don't do anything foolish, keep backups handy if you make major changes to your system, and if you have difficulties contact me at <htmlurl url="mailto:brion@pobox.com" name="brion@pobox.com"> or post in one of the comp.os.linux.* newsgroups, I read most of them. <sect1>Credits<label id="credits"> <p> Brion Vibber (brion@pobox.com) - The document itself Subhas Roy - Suggested that this HOWTO be made Rod Smith - Proper sequence of utilities for TrueType to PostScript conversions, ApplixWare info Herbet Duerr - General xfstt and StarOffice-specific info Juliusz Chroboczek - Type 42 conversion <sect1>Document History<label id="history"> <p> v0.4, 16 June 1998: List of tools, Applix info, etc. v0.3, 12 June 1998: StarOffice directions, some minor updates to xfstt and Ghostscript. Applixware info is on the way... Will soon also add info on the latest xfsft & something called ttinst. Heck, there's all kinds of stuff that's not here yet! ;) Also there's some mention of Type 42 fonts. Don't know how well the really work but they sound good - it's the Ultimate Answer to the Ultimate Question of PostScript, TrueType, and Everything! Good things a-comin' soon. v0.2, 22 May 1998: Finally got a chance to get some more work done on this... Now includes a working example of TrueType to PostScript font conversions, more info on using font servers, and WordPerfect. v0.1, 20 March 1998: Initial preliminary version created. Basically a skeleton for later work, not much actual info yet. The most current version of this document will always be available on the World Wide Web at <htmlurl url="http://pobox.com/~brion/linux/TrueType.html" name="http://pobox.com/˜brion/linux/TrueType.html">. <sect1>Feedback<label id="feedback"> <p> If you find any errors or really confusing bits in this document, feel free to drop me a line at <htmlurl url="mailto:brion@pobox.com" name="brion@pobox.com">. Remember that this is a preview release, not a final document, so not all sections are yet complete. <sect1>Distribution<label id="distrib"> <p> <!-- For the future... This document may be freely copied and distributed for informational purposes. It may not be modified, except for reformatting, without the permission of the author. If you wish to translate this document into another language you may do so, however you should contact the author first so that updated versions of this document can be sent out to translators as well as directly to the Linux Documentation Project. --> Since this document is not yet complete, I ask that you do not redistribute this document without first asking for permission. Not all information contained herein is complete, and some may be wrong, so you should be aware that this is <bf/not/ a complete HOWTO at this time. <sect>What is TrueType?<label id="whatsttf"> <p> TrueType is a scalable font technology, which represents glyphs by describing their outlines so that they may be drawn, or rasterized, at any size without the blocky aliasing caused by scaling when using bitmapped fonts. TrueType also makes use of a technique called ``hinting'' which describes appropriate ways to modify the shape of a character for proper rasterizing at small sizes. This allows TrueType fonts to be both displayed on screen at small sizes and used for printing at high resolutions without significant loss of quality. TrueType technology was originally developed by <htmlurl url="http://www.apple.com" name="Apple"> for use in their MacOS operating system in 1990. It was later licensed by <htmlurl url="http://www.microsoft.com" name="Microsoft"> for use in their Windows operating system. Since these two operating systems run on the vast majority of personal computers, there are a very large number of TrueType fonts available, many of them shareware or free, available for download over the internet or for purchase en masse on CD-ROM as well as more expensive commercial offerings. <sect>Printing<label id="printing"> <p> Unlike operating systems such as Windows and MacOS, Linux and other unices do not have a device-independant printing subsystem. Unfortunately this makes it somewhat complicated to figure out how to use TrueType fonts for printing. Some applications have their own special printer support, but most assume that the printer is capable of interpreting the Adobe PostScript language; for those who do not have PostScript printers, there is a program called Ghostscript that can interpret PostScript code, rasterize it, and output it in native printer code for most types of printers. <sect1>PostScript Printers<label id=postscript> <p> Newer versions of PostScript (version 2017 and up) support Type 42 fonts, which essentially consist of a PostScript font directory wrapped around a TrueType font. If your printer supports these fonts and you can get them to work in your applications, this is the best solution since there is no loss of quality in converting TrueType fonts to Type 42. See <ref id=type42 name="Converting to Adobe Type 42">. If your printer does not support Type 42 fonts, or your applications cannot deal with them as well as you like, you should convert the fonts to Type 1. There may be some loss of quality, especially at small sizes, but the fonts are more widely useable. See <ref id=ttf2pt1 name="Converting to Adobe Type 1">. <sect1>Ghostscript<label id="ghostscript"> <p> Ghostscript can interpret PostScript code and rasterize it for output to printers that do not natively interpret PostScript. Ghostscript versions 4 and later support TrueType fonts as long as that support was enabled when Ghostscript was compiled. You can obtain the latest version of Ghostscript (currently 5.10) from <htmlurl url="http://www.cs.wisc.edu/~ghost/" name="http://www.cs.wisc.edu/~ghost/">. Red Hat users can download Ghostscript 5.10 RPM packages from <url url="ftp://ftp.redhat.com/pub/contrib" name="Red Hat's FTP site">. To use your TrueType fonts with Ghostscript, the <tt/.ttf/ font files must be accessible, either on a mounted MS-DOS or VFAT filesystem or copied onto a Linux partition. You can either copy or symbolically link the <tt/.ttf/ files into the Ghostscript <tt/fonts/ directory (probably <tt>/usr/share/ghostscript/fonts/</tt>), or leave them elsewhere and use explicit pathnames when you add them to Ghostscript's <tt/Fontmap/ file. Don't forget that bold, italic, and bold italic versions are technically separate fonts and reside in separate files. For instance, to add the font Times New Roman, copy <tt/times.ttf/, <tt/timesbd.ttf/, <tt/timesbi.ttf/, and <tt/timesi.ttf/ into the <tt/fonts/ directory and add these lines: <tscreen><verb> (Times New Roman) (times.ttf) ; (Times New Roman Bold) (timesbd.ttf) ; (Times New Roman Bold Italic) (timesbi.ttf) ; (Times New Roman Italic) (timesi.ttf) ; </verb></tscreen> to the <tt/Fontmap/ file. If you are using the <tt/xfstt/ font server to use TrueType fonts in X, you can use the <tt/--gslist/ and <tt/--sync/ options to generate a list suitable for includion into Ghostscript's <tt/Fontmap/ file. <sect>X Window System<label id="X"> <p> The X Window System, the primary GUI used on unices such as Linux, does not currently include native support for TrueType fonts. However X does provide for programs called font servers which can provide font rasterization services for X servers that do not support certain kinds of fonts or do not have the fonts installed locally. There are two open-source font servers that support TrueType fonts, <tt/xfstt/ and <tt/xfsft/, and also a number of commercial products. <sect1>xfstt<label id="xfstt"> <p> <tt/Xfstt/ is a font server designed exclusively to serve TrueType fonts to the local machine. As such it supports only TrueType fonts and makes the assumption that the client has the same byte order as the server, so if you want to use the font server to serve other types of fonts and/or serve fonts to multiple machines on a network, you are probably better off using <tt/xfsft/ (see below). You can download xfstt from <htmlurl url="ftp://sunsite.unc.edu" name="sunsite.unc.edu"> in the <htmlurl url="ftp://sunsite.unc.edu/pub/Linux/X11/fonts/%21INDEX.html" name="/pub/Linux/X11/fonts"> directory. The current version is 0.9.9. Usage of <tt/xfstt/ is fairly straightforwardly explained in the <tt/INSTALL/ and <tt/FAQ/ files included in the archive. <!-- This doesn't seem to be true. Investigate further. Also, <tt/xfstt/ treats font sizes differently from typical X font servers; the glyphs are sized (at least on a 75 dpi X server) to fairly closely match the sizes of glyphs under Microsoft Windows at 96 dpi. This unfortunately can cause some odd-looking circumstances when TrueType and non-TrueType fonts are mixed on screen as the sizes do not match up. --> <sect1>xfsft<label id="xfsft"> <p> <tt/Xfsft/ is a modification of the standard X font server to add TrueType font support using the <url name= "Freetype" url="http://www.physiol.med.tu-muenchen.de/~robert/freetype.html"> library. If you need to use TrueType fonts with a real font server this should do it for you. You can download the beta of <tt/xfsft/ from its home page at <htmlurl url="http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/" name="http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/">. Note that <tt/xfsft/ requires that you construct a <tt/fonts.scale/ file that lists the fonts to be used. This can be done manually or by using <tt/ttinst/, available from the same location. <sect1>Commercial font servers<label id="commercial"> <p> There are a number of commercial TrueType font servers. Some commercial Unices, such as HP-UX, include TrueType-capable font servers; if you have such a machine on your network you can use its font server and access the fonts from your Linux workstations. Gallium FontTastic, a TrueType-capable font server, is included with ApplixWare, a commercial office suite for Linux. See <ref id="applix" name="ApplixWare"> for information on using TrueType fonts with this combination. <sect>Conversion<label id="convert"> <p> In some cases it is necessary or useful to convert TrueType fonts into a format more suitable for use in other programs. <sect1>Converting to Bitmap Fonts<label id="bitmap"> <p> In some cases it may be desirable to produce a bitmap font from a TrueType font. A utility for converting TrueType fonts to <tt/.bdf/ format, <tt/ttf2bdf/, is included with the <url name="FreeType library" url="http://www.freetype.org">. <sect1>Converting to Adobe Type 1<label id="ttf2pt1"> <p> Adobe PostScript Type 1 fonts are supported directly by many programs, including WordPerfect (see section <ref id="wp" name="WordPerfect">) and most X servers. For those which do not support TrueType fonts at all, such as WordPerfect, it is necessary to convert the fonts to Type 1 format in order to use them. There are a number of commercial programs that will perform such conversions, however few if any of them are available for Linux. There is an open source program called <url url="http://www.netspace.net.au/~mheath/ttf2pt1/" name="ttf2pt1"> which in conjunction with the Type 1 utilities (available at the same site) can perform the necessary conversions. Once you have <tt/ttf2pt1/, <tt/ttf2pfa/, and <tt/t1asm/ installed in your path, the following shell script (or something similar) can be used to convert a TrueType <tt/.ttf/ font file into an Adobe Type 1 <tt/.pfb/ file with an <tt/ .afm/ font metric file (needed by WordPerfect and some other programs): <tscreen><verb> #!/bin/sh # dofont - convert a .ttf to .pfb/.afm # usage: dofont <fontfile> # converts <fontfile>.ttf -> <fontfile>.pfb & <fontfile>.afm # Make the .afm and a type 3 .pfa which we will junk ttf2pfa $1.ttf $1 # Make the type 1 (pseudo) .pfa ttf2pt1 $1.ttf $1 # Make a .pfb t1asm -b $1.pfa > $1.pfb # Junk the pseudo .pfa rm -f $1.pfa </verb></tscreen> This process works by first using <tt/ttf2pfa/ to create a Type 3 <tt/.pfa/ file (which is not usable by most applications) and an <tt/.afm/ file; if you do not neet <tt/.afm/ files for your programs then you can skip this step. Then <tt/ttf2pt1/. is used to create a Type 1 <tt/.pfa/ font. However, this file is not a correctly formed font file and <tt/t1asm/ must be used to create a proper file from it. The <tt/-b/ option is used to create a <tt/.pfb/ (binary) font file; if you wish you can create a proper <tt/.pfa/ (ASCII) font file by removing the <tt/-b/ option, however not all programs will take <tt/.pfa/ files and the file will be larger. Once you have the Type 1 font files, install them as appropriate to the programs you wish to use them with; Type 1 font installation is outside the scope of this document except for specific applications mentioned in the section <ref id="apps" name="Applications">. <sect1>Converting to Adobe Type 42<label id="type42"> <p> An Adobe Type 42 font is essentially a PostScript wrapper around a TrueType font. Since the font data is not changed at all, there is no loss of quality in conversion. If you have a PostScript printer that understands such fonts and you can convince your applications to use and display them (if applicable), then this is probably the best way to deal with the fonts. You can use the program <tt><url name=ttfps url="ftp://ftp.dcs.ed.ac.uk/pub/jec/programs/ttfps.tar.gz"></tt> to convert the files. <sect>Applications<label id="apps"> <sect1>Applixware<label id="applix"> <p> The ApplixWare office suite includes a TrueType-capable font server, Gallium FontTastic. Installing fonts with FontTastic is a relatively simple matter, and groups of fonts can be enabled and disabled at will. Unfortunately, fonts installed in FontTastic will be sent to your printer as pre-rendered 300 dpi bitmaps by ApplixWare. Many printers today provide much higher resolution, and to make use of it it is necessary to use a separate font server and GhostScript if you are using a non-PostScript printer. Both methods are described in detail on Rod Smith's <url name="web page" url="http://www.users.fast.net/~rodsmith/fonts.html"> on this subject. (I'll add some detail shortly, until then refer to that web page.) <sect1>The GIMP<label id="gimp"> <p> The <url url="http://www.gimp.org" name="GNU Image Manipulation Program"> works quite well with a TrueType-capable font server (see section <ref id="X" name="X Window System">). <sect1>Netscape Communicator<label id="netscape"> <p> Netscape/Mozilla Communicator/Navigator 4.x and 5.x will display TrueType fonts on screen using a font server (see section <ref id="X" name="X Window System">). Unfortunately Netscape will not use anything but the standard PostScript fonts for printing, so even if you have TrueType fonts installed with Ghostscript (see section <ref id="ghostscript" name="Ghostscript">) they will not be printed. Instead you will see standard Times, Helvetica, or Courier. Anyone who wishes to prove me wrong is welcomed to do so - especially all you Mozilla hackers out there. <sect1>StarOffice<label id="staroffice"> <p> Fonts must be configured for X and for the printer in order to be used in StarOffice 4. You also need an <tt/.afm/ font metric file, and must inform StarOffice that the font is available. First, use a <ref id=X name="font server"> to make your TrueType fonts available to applications in X. If you have a PostScript printer you will probably want to see the section on <ref id=convert name="converting"> fonts to create a Type 1 font and an <tt/.afm/ file. For those with non-PostScript printers, the TrueType fonts can be used directly in <ref id=ghostscript name="Ghostscript">, and <tt/afm/ files can be generated using a script called <tt/afmmaker.ps/ like so: <tscreen><verb> gs -q -dNODISPLAY -dBATCH afmmaker.ps > arialbd.afm </verb></tscreen> after editing the font name. (NOTE: This should be easier!!!!! Also find that script...) Alternatively the TrueType to Adobe Type 3 converter <tt/ttf2pfa/ can create .afm files from TrueType fonts, however you will need to run it through another script. (Look for that web page!!!) It should be noted that it seems to work without <tt/.afm/ files, but it doesn't seem to like resizing them. Haven't tried printing anything yet. Also, I've been using dashes (-) instead of spaces ( ) in font names, I don't know if this makes a difference. Will look into it. The <tt/.afm/ file should go in <tt>xp3/fontmetrics/afm</tt> (probably under <tt>$HOME/Office40</tt> for personal settings or <tt>/usr/local/Office40</tt> for global settings), and the <tt/.pfb/ file (if using a PostScript printer) should go in <tt>xp3/pssoftfonts</tt>. Ghostscript users must also list the fonts as being contained in the printer's ROM; do this by editing the appropriate file in <tt>xp3/ppds/</tt>. Note that <tt/GENERIC.PS/, the ppd file for the generic PostScript printer, simply includes <tt/HPIIP522.PS/, so if you're using the generic driver edit that file instead. You can use <tt/gs2so/ from the TTFutils (Not Available Yet! Wait a couple days or do it manually) to convert Ghostscript's Fontmap file into a list that you can put into this file. The file <tt>xp3/psstd.fonts</tt> associates printer fonts with screen fonts. Ghostscript users should specify the fonts' names, and PostScript printer users should use the converted fonts' filenames (excluding <tt/.pfb/ extension). <tt/xfstt/ users can use <tt/ttf2so/ from the TTFutils (NAY!) to produce suitable data from <tt/xfstt/'s font list. (Note that this section is still a little fuzzy, I haven't worked out all the details yet, especially as regards to <tt/.afm/ files. It will be improved very soon....) <sect1>TeX<label id="tex"> <p> <tt/ttf2pk/, a utility for converting TrueType fonts to PK format for use with TeX, is included with the <url url="http://www.freetype.org" name="FreeType library">. <sect1>Wine, the Windows Emulator<label id="wine"> <p> Actually, Wine Is Not an Emulator, but that's <url url="http://www.winehq.com" name="another story">. Wine does not yet include native TrueType rendering support (although this is something that is being planned), so it is necessary to use one of the X font server programs (see section <ref id="X" name="X Window System">) for onscreen display, and Ghostscript (see section <ref id="ghostscript" name="Ghostscript">) in conjunction with the Windows PostScript printer driver for printing. <sect1>WordPerfect<label id="wp"> <p> WordPerfect 7 for Linux does not support TrueType fonts. However it does support Adobe Type 1 fonts, so you can use <tt/ttf2pt1/ (see section <ref id="ttf2pt1" name="Converting TrueType to Adobe Type 1">) to convert your TrueType fonts to Adobe Type 1. Once you have converted your fonts, copy the <tt/.pfb/ and <tt/.afm/ files into the WordPerfect fonts directory (typically <tt>/usr/local/wp7/shlib10</tt>) and run the WordPerfect font installation program (<tt/xwpfi/, typically located in <tt>/usr/local/wp7/shbin10</tt>) to install the fonts. For more information on Linux WordPerfect and fonts, see Rod Smith's excellent site on <url url="http://www.users.fast.net/~rodsmith/wpfonts.html" name="Linux WordPerfect Fonts & Printers">. <sect1>Other Applications<label id="other"> <p> For applications not mentioned here, I recommend first trying an X font server (see section <ref id="X" name="X Window System">) and then, if that doesn't work, converting the TrueType fonts to another format (see section <ref id="convert" name="Converting">). If neither of these works and you cannot figure something out on your own, post to <htmlurl url="news:comp.os.linux.x" name="comp.os.linux.x"> for X applications or <htmlurl url="news:comp.os.linux.misc" name="comp.os.linux.misc"> for non-X applications to see if there is anyone else who has already figured it out for that application. If you sucessfully figure out how to use TrueType fonts with an application not mentioned in the <url name="most recent version" url="http://pobox.com/~brion/linux/TrueType-HOWTO.html"> of this document, please <url name="e-mail" url="mailto:brion@pobox.com"> me so that I can add the information to the next version. <sect>TrueType Utilities<label id="utils"> <p> This section contains a list of utilities for using TrueType fonts. Most of them are referenced earlier in this document but they are listed here for easier reference. <itemize> <item> <tt><url url="ftp://ftp.dcs.ed.ac.uk/pub/jec/programs/ttfps.tar.gz" name="ttf2ps"></tt> can be used to convert TrueType fonts to Adobe Type 42 fonts; see <ref id="type42" name="Converting to Adobe Type 42">. <item> <tt><url url="http://www.netspace.net.au/~mheath/ttf2pt1/" name="ttf2pt1"></tt> can be used to convert TrueType fonts to Adobe Type 1 and Type 3 fonts, and to create <tt/.afm/ font metric files. The Type 1 Utilities (<tt/t1utils/), available from the <tt/ttf2pt1/ web site, are required to create working Type 1 font files. See <ref id="ttf2pt1" name="Converting to Adobe Type 1"> <item> The <url url="http://pobox.com/~brion/linux/ttf.html" name="TTFUtils"> package includes a number of small labor-saving utilities: <itemize> <item><tt/tt2ft/: converts <tt/xfstt/'s font list to a standard X <tt/fonts.scale/ file which can be used with <tt/xfsft/ <item><tt/tt2so/: converts <tt/xfstt/'s font list to a StarOffice <tt/psstd.fonts/ file <item><tt/starafm/: creates <tt/.afm/ files compatible with StarOffice <item><tt/tt2type1/: a wrapper for <tt/ttf2pt1/ to simplify conversion to Adobe Type 1 fonts </itemize> Note that these may not yet be available. Be patient! <item> <tt/ttinst/ can create a <tt/fonts.scale/ file for specified TrueType fonts, useful for <tt/xfsft/. The current version, 0.61, does not appear to be compatible with FreeType 1.1. </itemize> <sect>Program Development<label id="devel"> <sect1>FreeType<label id="freetype"> <p> If you want to roll your own programs that can natively use TrueType fonts, including the ability to perform antialiasing, you might want to look into the <url url="http://www.freetype.org" name="FreeType"> project. It is a library for reading TrueType font files and rasterizing glyphs, and is available in both ANSI C and Pascal. The license is similar to the BSD license: the library is provided as-is, royalty-free, and you can do whatever you want with it (i.e., use it in whole or in part in freeware, shareware, or commercial software) as long as you give them credit. <sect1>GLTT<label id="gltt"> <p> <url url="http://home.worldnet.fr/~rehel/gltt/gltt.html" name="GLTT"> is a library for rendering TrueType fonts using OpenGL. It uses the FreeType library for the fonts and can be used with either ``real'' OpenGL or Mesa. GLTT is used by the 3d modeler <url url="http://www.cybersociety.com/moonlight/" name="Moonlight Creator">. <sect>Other Issues<label id="faq"> <p> This section contains other information that doesn't fit into the rest of the document. <sect1>``Smart Quotes''<label id=quotes> <p> In the Unix/Linux world, many programs attempt to spruce up quotes by using both forward single-quotes (') and backward single-quotes (`). For instance: `a quote' looks nicer than 'a quote', and ``another quote'' looks nicer than "another quote". However this often does not look right with TrueType fonts. Typically the single-quote/apostrophe glyph is vertical (|) instead of slanted (/), so you get a mismatched pair (\...| or \\...||) instead of a matching pair (\.../ or \\...//). In the Windows world, a similar trick is used by many word-processing applications, often called ``Smart Quotes''. However instead of the regular quotes, special matching characters are used. Since these characters are not in the standard ISO-8859 character sets typically used under Unix, these glyphs are ignored by Linux font servers and the like and are often not even available for use with documents that were created under Windows, leaving unpleasant boxes in the place of quotes. It is probably possible to modify the various TrueType font renderers to use a hacked character set that replaces the standard quotes with matching ones. If anyone has done so, please <url url="mailto:brion@pobox.com" name="e-mail me">, I'd like my quotes to match up and I'm sure many others do as well! </article>