The (preliminary) TrueType HOWTO Brion Vibber, brion@pobox.com v0.5, 9 July 1998 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 http://pobox.com/~brion/linux/TrueType-HOWTO.html. ______________________________________________________________________ Table of Contents 1. Introduction 1.1 Disclaimer 1.2 Credits 1.3 Document History 1.4 Feedback 1.5 Distribution 2. What is TrueType? 3. Printing 3.1 PostScript Printers 3.2 Ghostscript 4. X Window System 4.1 xfstt 4.2 xfsft 4.3 Commercial font servers 5. Conversion 5.1 Converting to Bitmap Fonts 5.2 Converting to Adobe Type 1 5.3 Converting to Adobe Type 42 6. Applications 6.1 Applixware 6.2 The GIMP 6.3 Netscape Communicator 6.4 StarOffice 6.5 TeX 6.6 Wine, the Windows Emulator 6.7 WordPerfect 6.8 Other Applications 7. TrueType Utilities 8. Program Development 8.1 FreeType 8.2 GLTT 9. Other Issues 9.1 ``Smart Quotes'' ______________________________________________________________________ 1. Introduction This document is intended to explain how to use TrueType fonts with Linux and applications that run under Linux. 1.1. Disclaimer 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 brion@pobox.com or post in one of the comp.os.linux.* newsgroups, I read most of them. 1.2. Credits Juliusz Chroboczek - Type 42 conversion Herbet Duerr - General xfstt and StarOffice-specific info Jrg Pommnitz - ttmkfdir Subhas Roy - Suggested that this HOWTO be made Rod Smith - Proper sequence of utilities for TrueType to PostScript conversions, ApplixWare info Brion Vibber (brion@pobox.com) - The document itself 1.3. Document History v0.5, 9 July 1998: New stuff - ttmkfdir & ttutils 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 http://pobox.com/~brion/linux/TrueType.html. 1.4. Feedback If you find any errors or really confusing bits in this document, feel free to drop me a line at brion@pobox.com. Remember that this is a preview release, not a final document, so not all sections are yet complete. 1.5. Distribution 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 not a complete HOWTO at this time. 2. What is TrueType? 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 Apple for use in their MacOS operating system in 1990. It was later licensed by 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. 3. Printing 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. 3.1. PostScript Printers 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 ``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 ``Converting to Adobe Type 1''. 3.2. Ghostscript 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 http://www.cs.wisc.edu/~ghost/. Red Hat users can download Ghostscript 5.10 RPM packages from Red Hat's FTP site . To use your TrueType fonts with Ghostscript, the .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 .ttf files into the Ghostscript fonts directory (probably /usr/share/ghostscript/fonts/), or leave them elsewhere and use explicit pathnames when you add them to Ghostscript's 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 times.ttf, timesbd.ttf, timesbi.ttf, and timesi.ttf into the fonts directory and add these lines: (Times New Roman) (times.ttf) ; (Times New Roman Bold) (timesbd.ttf) ; (Times New Roman Bold Italic) (timesbi.ttf) ; (Times New Roman Italic) (timesi.ttf) ; to the Fontmap file. If you are using the xfstt font server to use TrueType fonts in X, you can use the --gslist and --sync options to generate a list suitable for includion into Ghostscript's Fontmap file. 4. X Window System 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, xfstt and xfsft, and also a number of commercial products. 4.1. xfstt 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 xfsft (see below). You can download xfstt from sunsite.unc.edu in the /pub/Linux/X11/fonts directory. The current version is 0.9.9. Usage of xfstt is fairly straightforwardly explained in the INSTALL and FAQ files included in the archive. 4.2. xfsft Xfsft is a modification of the standard X font server to add TrueType font support using the Freetype 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 xfsft from its home page at http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/. Note that xfsft requires that you construct a fonts.scale file that lists the fonts to be used. This can be done manually or by using ttmkfdir, which uses the FreeType library to determine font names and encodings automatically. Download it here . 4.3. Commercial font servers 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 ``ApplixWare'' for information on using TrueType fonts with this combination. 5. Conversion In some cases it is necessary or useful to convert TrueType fonts into a format more suitable for use in other programs. 5.1. Converting to Bitmap Fonts In some cases it may be desirable to produce a bitmap font from a TrueType font. A utility for converting TrueType fonts to .bdf format, ttf2bdf, is included with the FreeType library . 5.2. Converting to Adobe Type 1 Adobe PostScript Type 1 fonts are supported directly by many programs, including WordPerfect (see section ``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 ttf2pt1 which in conjunction with the Type 1 utilities (available at the same site) can perform the necessary conversions. Once you have ttf2pt1, ttf2pfa, and t1asm installed in your path, the following shell script (or something similar) can be used to convert a TrueType .ttf font file into an Adobe Type 1 .pfb file with an .afm font metric file (needed by WordPerfect and some other programs): #!/bin/sh # dofont - convert a .ttf to .pfb/.afm # usage: dofont # converts .ttf -> .pfb & .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 This process works by first using ttf2pfa to create a Type 3 .pfa file (which is not usable by most applications) and an .afm file; if you do not neet .afm files for your programs then you can skip this step. Then ttf2pt1. is used to create a Type 1 .pfa font. However, this file is not a correctly formed font file and t1asm must be used to create a proper file from it. The -b option is used to create a .pfb (binary) font file; if you wish you can create a proper .pfa (ASCII) font file by removing the -b option, however not all programs will take .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 ``Applications''. 5.3. Converting to Adobe Type 42 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 ttfps to convert the files. 6. Applications 6.1. Applixware 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 web page on this subject. (I'll add some detail shortly, until then refer to that web page.) 6.2. The GIMP The GNU Image Manipulation Program works quite well with a TrueType-capable font server (see section ``X Window System''). 6.3. Netscape Communicator Netscape/Mozilla Communicator/Navigator 4.x and 5.x will display TrueType fonts on screen using a font server (see section ``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 ``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. 6.4. StarOffice Fonts must be configured for X and for the printer in order to be used in StarOffice 4. You also need an .afm font metric file, and must inform StarOffice that the font is available. First, use a ``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 ``converting'' fonts to create a Type 1 font and an .afm file. For those with non-PostScript printers, the TrueType fonts can be used directly in ``Ghostscript'', and afm files can be generated using a script called afmmaker.ps like so: gs -q -dNODISPLAY -dBATCH afmmaker.ps > arialbd.afm after editing the font name. (NOTE: This should be easier!!!!! Also find that script...) Alternatively the TrueType to Adobe Type 3 converter 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 .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 .afm file should go in xp3/fontmetrics/afm (probably under $HOME/Office40 for personal settings or /usr/local/Office40 for global settings), and the .pfb file (if using a PostScript printer) should go in xp3/pssoftfonts. Ghostscript users must also list the fonts as being contained in the printer's ROM; do this by editing the appropriate file in xp3/ppds/. Note that GENERIC.PS, the ppd file for the generic PostScript printer, simply includes HPIIP522.PS, so if you're using the generic driver edit that file instead. You can use 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 xp3/psstd.fonts associates printer fonts with screen fonts. Ghostscript users should specify the fonts' names, and PostScript printer users should use the converted fonts' filenames (excluding .pfb extension). xfstt users can use ttf2so from the TTFutils (NAY!) to produce suitable data from 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 .afm files. It will be improved very soon....) 6.5. TeX ttf2pk, a utility for converting TrueType fonts to PK format for use with TeX, is included with the FreeType library . 6.6. Wine, the Windows Emulator Actually, Wine Is Not an Emulator, but that's 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 ``X Window System'') for onscreen display, and Ghostscript (see section ``Ghostscript'') in conjunction with the Windows PostScript printer driver for printing. 6.7. WordPerfect WordPerfect 7 for Linux does not support TrueType fonts. However it does support Adobe Type 1 fonts, so you can use ttf2pt1 (see section ``Converting TrueType to Adobe Type 1'') to convert your TrueType fonts to Adobe Type 1. Once you have converted your fonts, copy the .pfb and .afm files into the WordPerfect fonts directory (typically /usr/local/wp7/shlib10) and run the WordPerfect font installation program (xwpfi, typically located in /usr/local/wp7/shbin10) to install the fonts. For more information on Linux WordPerfect and fonts, see Rod Smith's excellent site on Linux WordPerfect Fonts & Printers . 6.8. Other Applications For applications not mentioned here, I recommend first trying an X font server (see section ``X Window System'') and then, if that doesn't work, converting the TrueType fonts to another format (see section ``Converting''). If neither of these works and you cannot figure something out on your own, post to comp.os.linux.x for X applications or 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 most recent version of this document, please e-mail me so that I can add the information to the next version. 7. TrueType Utilities 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. o ttf2ps can be used to convert TrueType fonts to Adobe Type 42 fonts; see ``Converting to Adobe Type 42''. o ttf2pt1 can be used to convert TrueType fonts to Adobe Type 1 and Type 3 fonts, and to create .afm font metric files. The Type 1 Utilities (t1utils), available from the ttf2pt1 web site, are required to create working Type 1 font files. See ``Converting to Adobe Type 1'' o The TTFUtils package includes a number of small labor-saving utilities: o tt2ft: converts xfstt's font list to a standard X fonts.scale file which can be used with xfsft o tt2so: converts xfstt's font list to a StarOffice psstd.fonts file o starafm: creates .afm files compatible with StarOffice o tt2type1: a wrapper for ttf2pt1 to simplify conversion to Adobe Type 1 fonts Note that these may not yet be available. Be patient! o ttinst can create a fonts.scale file for specified TrueType fonts, useful for xfsft. The current version, 0.61, does not appear to be compatible with FreeType 1.1. 8. Program Development 8.1. FreeType 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 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. 8.2. GLTT 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 Moonlight Creator . 9. Other Issues This section contains other information that doesn't fit into the rest of the document. 9.1. ``Smart Quotes'' 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 e-mail me , I'd like my quotes to match up and I'm sure many others do as well!