Truetype Fonts in Debian Mini Howto
Truetype Fonts in Debian Mini Howto
Table of Contents
TrueType Fonts in Debian mini−HOWTO......................................................................................................1
Bear Giles, bgiles@coyotesong.com......................................................................................................1
1. Introduction..........................................................................................................................................1
2. Display (what they never told you)......................................................................................................1
3. Display (X and the font servers)..........................................................................................................1
4. Printing (ghostscript)...........................................................................................................................1
5. Content Generation..............................................................................................................................1
6. Unanswered questions.........................................................................................................................2
7. Obtaining TrueType Fonts...................................................................................................................2
8. Legalities..............................................................................................................................................2
1. Introduction..........................................................................................................................................2
1.1 Disclaimer..........................................................................................................................................2
1.2 Credits................................................................................................................................................2
1.3 Additional links..................................................................................................................................3
1.4 Change log.........................................................................................................................................3
1.5 Feedback............................................................................................................................................3
1.6 Related projects..................................................................................................................................3
1.7 Distribution........................................................................................................................................3
2. Display (what they never told you)......................................................................................................3
2.1 A look ahead to XFree86 4.0.............................................................................................................5
2.2 Review: Preparation before changing X configuration files..............................................................5
3. Display (X and the font servers)..........................................................................................................5
3.1 Setting up the xfs Font Server............................................................................................................6
3.2 Setting up the xfstt Font Server and installing TrueType fonts.........................................................7
3.3 Using TrueType fonts........................................................................................................................9
3.4 Installing additional TrueType fonts..................................................................................................9
3.5 Internationalization............................................................................................................................9
3.6 Security Issues.................................................................................................................................10
4. Printing (ghostscript).........................................................................................................................11
4.1 Configuring Ghostscript to use TrueType fonts..............................................................................11
4.2 Printing TrueType font specimens...................................................................................................12
5. Content Generation............................................................................................................................13
5.1 Generating AFM font metrics..........................................................................................................13
5.2 Generating font.map files.................................................................................................................13
5.3 Image manipulation: GIMP.............................................................................................................13
5.4 ASCII to PostScript conversion: enscript........................................................................................14
5.5 Text Formatting and Typesetting: groff...........................................................................................14
5.6 Text Formatting and Typesetting: TeX............................................................................................15
6. Unanswered questions.......................................................................................................................15
7. Obtaining TrueType Fonts.................................................................................................................16
7.1 A comment about using Microsoft's free TrueType fonts...............................................................16
8. Legalities............................................................................................................................................17
i
TrueType Fonts in Debian mini−HOWTO
Bear Giles, [email protected]
v0.3, 10 January 2000
This document describes how to configure a Debian system to use TrueType fonts for display and printing.
The most recent version of this document can be obtained in HTML format at
http://www.dimensional.com/~bgiles/debian−tt.html
1. Introduction
• 1.1 Disclaimer
• 1.2 Credits
• 1.3 Additional links
• 1.4 Change log
• 1.5 Feedback
• 1.6 Related projects
• 1.7 Distribution
4. Printing (ghostscript)
• 4.1 Configuring Ghostscript to use TrueType fonts
• 4.2 Printing TrueType font specimens
5. Content Generation
• 5.1 Generating AFM font metrics
• 5.2 Generating font.map files
• 5.3 Image manipulation: GIMP
6. Unanswered questions
7. Obtaining TrueType Fonts
• 7.1 A comment about using Microsoft's free TrueType fonts
8. Legalities
1. Introduction
A Linux installation typically contains several independent sets of fonts or font metrics. A quick glance at my
system shows fonts or font metrics spread across the following directories:
TrueType fonts are designed to eliminate this problem by allowing the same font files to be used for both
display and printing. This HOW−TO attempts to show how to use TrueType fonts for display, printing, and
document preparation on Debian GNU/Linux systems.
1.1 Disclaimer
The information in this document is, to the best of my knowledge, correct. However this HOWTO is still in
preliminary versions and what works for me may not work for you. Even if it does work for you, I am not a
professional technical writer and I have been known to gloss over critical details.
1.2 Credits
Created by Bear Giles, <[email protected]>
Thanks go to:
6. Unanswered questions 2
TrueType Fonts in Debian mini−HOWTO
1.5 Feedback
Comments, corrections, additions and critiques are always welcome. You can reach me at
[email protected].
The FreeType engine is a free and portable TrueType font rendering engine. The code is a
clean−room implementation that is totally independent of the Apple and Microsoft implementations.
(A question has recently been raised about a possible Apple patent, however.) FreeType is a library,
not a font server or a complete text rendering library.
1.7 Distribution
This is the first draft and I expect it to change significantly after publication, I ask that you refer to the latest
version at http://www.dimensional.com/~bgiles/debian−tt.html. The permanent home for
this document will eventually be at http://www.coyotesong.com/
All displayed fonts are measured in points. One inch is exactly 72 points. Why 72? Partly because of the
limitations of mechanical typesetting machines and partly because it's evenly divisible by 2, 3, 4, 6, 8, 9, 12,
18 and 24. It's also worth noting that the default unit in PostScript is one point.
(Historical note: I lied. Until the introduction of PostScript an inch was exactly 72.27 points, but that point
size was set in the era of mechanical printers with metal stamps in a handful of standard sizes. With computer
displays and laser printers, it's easy to get fonts in any size and 72 makes much more sense for the reason
mentioned above.)
As a general rule, most text should be between 7 and 12 points. Anything smaller than 6 points is literally
"the fine print." Line printers used 9 or 12 point type (for 8 or 6 lines/inch, respectively).
In contrast, all video drivers must ultimately measure fonts in pixels. To your video driver, your screen is
1024x800 pixels, not 10 by 8 inches (or 720 by 576 points).
To map from points (which we use to specify a font size) to pixels (which we use to blit the video memory)
we must know our screen's resolution. This is usually measured in "dots per inch (dpi)," although it's really
pixels per inch. These are the units used in the two sets of bitmap fonts included with XFree86:
fonts−75 is intended for use on low−end displays with a resolution of approximately 75 dpi,
fonts−100 is intended for use on mid−range displays with a resolution of approximately 100 dpi. There
are no bitmap fonts intended for use on high−end displays with a resolution of over 120 dpi.
As a concrete example, a 13" diagonal screen (11.1" usable) displaying a 640x480 pixel image has a
resolution of 72.0 dpi. This Is Not A Coincidence. In fact, most web pages (and Microsoft applications) are
designed around a canonical display with a resolution of exactly 72 dpi. XFree86's default configuration
assumes a display with a resolution of 75 dpi.
Back in the real world, nobody runs 640x480 video anymore. Nobody uses 13" diagonal screens anymore.
Since video cards have improved faster than video monitors it's not uncommon to have a configuration like
mine: 19" diagonal screen, (17+" usable), 1600x1200 pixels, 117 dpi resolution.
If I run a stock X configuration, all of my fonts are approximately 2/3 of the intended size. It's not an
exaggeration to say that all fonts are cut down by a full size: large fonts (12 pts) appear medium (9). Medium
fonts (9 pts) appear small (6).
There are three things we can do to fix this. First, We should tell the X server our actual screen resolution:
/etc/X11/xdm/Xservers
Second, we should ensure that we use the 100 dpi bitmapped fonts in preference to the 75 dpi fonts.
/etc/X11/XF86Config
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
EndSection
Finally, if one of our bitmapped fonts isn't an exact match the X server will attempt to "scale" a similar font
via pixel replication. The results are rarely pleasant to use. Assuming we have a reasonably powerful system,
we can tell the server to use scaled fonts by default, then bitmaps which are exact matches, and scaled
bitmaps as a last resort.
/etc/X11/XF86Config
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
EndSection
You will still need to make the appropriate changes to your font path, since the server should not second
guess your explicit configuration.
• Install XFS
• Configure XFS
Edit /etc/X11/xfs/config and change the catalogue to contain the contents of your
FontList. You may also wish to change the default−resolutions value.
/etc/X11/xfs/config
• Restart XFS
root shell
# /etc/init.d/xfs restart
Before we change our XF86Config file, we should verify that the xfs server is working by listing
them through the font server:
user shell
....
We're now ready to tell the X server to use the xfs font server. We keep one static font path as a
fallback position in case of a problem with xfs. (We keep "misc" since it contains fixed, the
default font.)
/etc/X11/XF86Config
Section "Files"
FontPath "unix/:7100"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
EndSection
• Restart X
Restart X with startx, unless you like living life dangerously. If that's the case, name me the
beneficiary of your unusually large life insurance policy and restart xdm.
Once we have an X session established, we can verify that our server sees all of the xfs fonts by
listing them through the X server.
user shell
$ xlsfonts
−adobe−courier−bold−i−normal−−0−0−0−0−m−0−iso8859−1
−adobe−courier−bold−o−normal−−0−0−100−100−m−0−iso8859−1
−adobe−courier−bold−o−normal−−0−0−75−75−m−0−iso8859−1
....
• Install XFSTT
Copy your TrueType fonts into the /usr/share/fonts/truetype directory. These files
usually have a .ttf extension, and they should have 0444 permissions.
3.2 Setting up the xfstt Font Server and installing TrueType fonts 7
TrueType Fonts in Debian mini−HOWTO
root shell
# /etc/init.d/xfstt force−reload
Before we change our XF86Config file, we should verify that the xfstt server is working.
Important: the Debian xfstt server listens to port 7101, not 7100. Also, the default permissions
will require you to run this query as root.
We're now ready to tell the X server to use the xfstt font server. We want it to use TrueType fonts
in preference to all others.
/etc/X11/XF86Config
Section "Files"
FontPath "unix/:7101"
FontPath "unix/:7100"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
EndSection
Once we have an X session established, we can verify that our server sees all of the TrueType fonts
by listing them.
3.2 Setting up the xfstt Font Server and installing TrueType fonts 8
TrueType Fonts in Debian mini−HOWTO
−ttf−arial mt black−medium−r−normal−regular−0−0−0−0−p−0−iso8859−1
−ttf−arial narrow−bold−i−normal−bold italic−0−0−0−0−p−0−iso8859−1
....
3.5 Internationalization
xfstt has the ability to generate multiple font encodings, provided that the TrueType font contains the
necessary glyphs. To enable fonts other than iso8859−1/unicode−1, you must manually edit the
/etc/init.d/xfstt script:
/etc/init.d/xfstt
• windows−1253 (Greek)
• windows−1254
• windows−1255
• windows−1256
• windows−1257
• symbol−0
• wingding−0
• wingreek−0
• cp−437 (various IBM code pages)
• cp−737
• cp−850
• cp−851
• cp−852
• cp−853
• cp−855
• cp−857
• cp−860
• cp−861
• cp−862
• cp−863
• cp−864
• cp−865
• cp−866
• cp−869
• cp−895
• atari−st
• unicode−2
The first 128 characters in the iso8859−x encodings is always ASCII. The windows− fonts embrace and
extend iso8859−1 with additional characters such as "smart quotes." (Since these extensions, such as
"smart quotes" are undefined in iso8859−1, they are usually rendered as question marks.)
• http://ppewww.ph.gla.ac.uk/%7Eflavell/iso8859/iso8859−pointers.html,
• http://anubis.dkuug.dk/i18n/ and
• http://czyborra.com/charsets/iso8859.html.
This means that anyone, anywhere, can connect to your font server. Since xfs (and presumably xfsts)
"clone" to support more users there's a trivial denial−of−service attack against these systems. It's probably
safe to use the font servers on dialup lines (since you're present to handle problems), but DSL and cable
modem users should use a firewall.
4. Printing (ghostscript)
Starting with version 4, ghostscript has supported TrueType fonts as a compile−time option. Two
Debian packages provide ghostscript:
In practice, I've found it beneficial to make several small changes to the font definitions generated by xfstt.
First, if a font name does not contain any spaces, I change the name to the usual notation. If a font name does
contain spaces, I replace all spaces with dashes and the original name is added as an alias to the new name.
Finally, I prepend TTF− (or MS−) to all font names to minimize problems caused by a TrueType font having
an identical name to an preexisting font.
Thus
(Arial) (/usr/share/fonts/truetype/arial.ttf) ;
(Arial Bold Italic) (/usr/share/fonts/truetype/arialbi.ttf) ;
becomes
/MS−Arial (/usr/share/fonts/truetype/arial.ttf) ;
/MS−Arial−Bold−Italic (/usr/share/fonts/truetype/arialbi.ttf) ;
(Arial Bold Italic) /MS−Arial−Bold−Italic ;
/Arial /MS−Arial ;
The aliases ensure that ghostscript and xfstt can still specify the same font by a common name.
Much more significantly, with the change in the font names it's possible to instruct ghostscript to use
TrueType fonts instead of the standard fonts. The documentation claims that this is also possible with
parenthetical notation, but I could not get it to work.
For instance, we can instruct ghostscript to replace Helvetica fonts with Microsoft's free Arial fonts by
appending the following lines to the /etc/gs.Fontmap file:
4. Printing (ghostscript) 11
TrueType Fonts in Debian mini−HOWTO
/Helvetica /MS−Arial ;
/Helvetica−Oblique /MS−Arial−Italic ;
/Helvetica−Bold /MS−Arial−Bold ;
/Helvetica−BoldOblique /MS−Arial−Bold−Italic ;
Similar aliases can be defined for the other standard fonts. These aliases would be most useful on
samba printers serving Windows clients.
#!/bin/sh
set −e
IFS= ')'
If you wish to print only a few fonts, the following script will be easier to use:
#!/bin/sh
set −e
while read −p "Font name, or ^D to exit: " fontname
do
cat << EOM | lpr
%!PS
(/usr/lib/ghostscript/5.50/prfont.ps) run
$fontname DoFont
EOM
done
5. Content Generation
5.1 Generating AFM font metrics
AFM font metrics files are not required for display existing files with TrueType fonts, but they are necessary
to create new files. The ghostscript program /usr/lib/ghostscript/5.50/printafm.ps could be
used to generate these metric files, but I have found the ttf2afm program from the tetex−bin package
to be easier to use.
The following script will generate an afm file for all TrueType fonts in a directory:
#!/bin/sh
set −e
for i in *.TTF
do
/usr/bin/ttf2afm $i > ${i%TTF}afm
done
for i in *.ttf
do
/usr/bin/ttf2afm $i > ${i%ttf}afm
done
One minor problem with ttf2afm is that some applications expect afm files to start with the
StartFontMetrics tag, but files created by ttf2afm start with a comment. This "problem" is easily
fixed by hitting each file with a text editor.
I have been unable to find documentation on this file format, unlike fonts.dir, fonts.scale, and
fonts.alias, all created by the mkfontdir program. However the minimum format appears to be quite
simple:
Aliases appear to be implemented via multiple entries, and the filename extension must be in lowercase.
5. Content Generation 13
TrueType Fonts in Debian mini−HOWTO
Once I had made these changes, I had no problem using TrueType fonts.
user shell
Besides man pages, an incredible amount of Unix documentation uses troff formatting with ms (and
occasionally me) macros. The Debian xbooks package, for example, has 43 files using troff with
ms macros. With groff, this material can be attractively printed.
Groff is a very powerful system, but it's the grandchild (or great−grandchild) of a program used to typeset
1960's era printing presses. Font support in groff reflects that heritage. Groff, in contrast to its
predecessors, uses PostScript as the default output format so our earlier work with ghostscript takes care
of half of the problem −− groff does not have to deal with reading TrueType font files. It does need to have
accurate font metrics, and this section describes how to regenerate the necessary groff files:
/usr/share/groff/font/devps/DESC
Device description file
/usr/share/groff/font/devps/text.enc
Encoding used for text fonts
/usr/share/groff/font/devps/generate/textmap
Standard mapping.
/usr/share/groff/font/devps/generate/Makefile
Standard makefile
/usr/share/groff/font/devps/generate/Makefile
− afmdir=/usr/local/afm
+ afmdir=/usr/share/fonts/truetype
change the name of the fonts to their TrueType equivalent (e.g., if we're using Microsoft's free TrueType
fonts we would replace Helvetica with Arial), and change TEXTFONTS and the like to only include
those fonts we are redefining.
user shell
$ cd /usr/share/groff/font/devps
$ make −f generate/Makefile
As usual, the best way to verify the changes is to use a visually distinctive font. E.g., if you are using the
Microsoft free TrueType fonts you can use Mistral for TR.
(I expect royalties from everyone who reconfigures their system to print manual pages in Old English fonts
next April First!)
TeX fonts can created with mktexmf, but I have little information on the exact process. More details will be
provided shortly.
6. Unanswered questions
• Applications
The biggest unanswered question is why netscape communicator can use TrueType fonts,
ghostscript can use the same TrueType fonts, yet pages printed by netscape look nothing
like the screen.
The short answer is that netscape generates PostScript output with standard fonts (Helvetica and
Times−Roman) instead of the user−specified or HTML−specified fonts. The long answer is that I
have absolutely no idea why it forces this behavior, or if there is a way to override it.
http://www.microsoft.com/typography/faq/faq8.htm
Clearly, it is legal and reasonable for Linux users to download and install these fonts, and I would like to
thank Microsoft for making them available.
Since another clause restricts their redistribution "in any form that adds value to commercial products" I don't
expect to see these fonts packaged in main anytime soon. (Could they be packaged in non−free, perhaps
as an installer package...?)
Now that that's out of the way, I redirect your attention to the second statement. Microsoft actively
encourages web page developers to specify their fonts on web pages, and many HTML editors explicitly
name fonts.
Many web sites, when viewed by standard Netscape/Linux, can best be described as... legible. Some aren't
even that. Not coincidentally the sites which are, um, legible are also usually the sites that explicitly state all
font information in their web pages.
After I installed these fonts I noticed that most of these problematic sites became significantly more
attractive. Many were still highly Windows−centric, but at least I didn't flinch every time I loaded their pages.
My recommendation is to install Microsoft's free TrueType fonts for your browser. You are not required to
create web pages that use these fonts, nor do you have to configure ghostscript to use them.
8. Legalities
Copyright © 1999 by Bear Giles.
Unless otherwise stated, Linux HOWTO documents are copyrighted by their respective authors. Linux
HOWTO documents may be reproduced and distributed whole or in part, in any medium physical or
electronic, as long as this copyright notice is retained in all copies. Commercial redistribution is allowed and
encouraged; however, the author would like to be notified of any such distributions.
All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be
covered under this copyright notice. That is, you may produce a derivative work from a HOWTO and impose
additional restrictions on distribution. Exceptions to these rules may be granted under certain conditions;
please contact the Linux HOWTO cordinator for more information.
In short, we wish to promote dissemination of this information through as many channels as possible.
However, we do wish to retain copyright on the HOWTO documents, and would very much like to be
notified of any plans to redistribute the HOWTOs, this one in particular! Web page authors are free to link to
this HOWTO without restriction, though the author would appreciate an email informing him of this, just so
he can boost his ego by knowing who else reads and links to this document.
Many of the terms mentioned in this document are trade names. Unless otherwise stated, all trademarks are
property of their respectve owners.
8. Legalities 17