LDP/LDP/howto/linuxdoc/TT-Debian.sgml

951 lines
32 KiB
Plaintext

<!doctype linuxdoc system>
<article>
<title>TrueType Fonts in Debian mini-HOWTO
<author>Bear Giles,
<tt><url url="mailto:bgiles@coyotesong.com"
name="bgiles@coyotesong.com"></tt>
<date>v0.3, 10 January 2000
<abstract>
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
<tt><url url="http://www.dimensional.com/~bgiles/debian-tt.html"
name="http://www.dimensional.com/~bgiles/debian-tt.html"></tt>
</abstract>
<toc>
<sect> Introduction
<p>
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:
<itemize>
<item><tt/XFree86/ stores its fonts in <tt>/usr/X11R6/lib/X11/fonts/</tt>
<item><tt/Ghostscript/ stores its fonts in <tt>/usr/lib/ghostscript/fonts/</tt>
<item<tt/TeX/ stores its fonts in <tt>/usr/lib/texmf/fonts/</tt>
<item>The Debian <tt/kbd/ package stores its fonts in <tt>/usr/share/consolefonts/</tt>
<item><tt/Groff/ stores its metrics in <tt>/usr/share/font/devps/</tt>
<item><tt/Enscript/ (ASCII to PostScript converter) stores its metrics
in <tt>/usr/share/enscript/*.afm</tt>
</itemize>
Needless to say, these fonts are not coordinated.
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.
<sect1>Disclaimer
<p>
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.
So have fun, but play it safe and keep backups.
<sect1> Credits
<p>
Created by Bear Giles, <tt><url url="mailto:bgiles@coyotesong.com"
name="<bgiles@coyotesong.com>"></tt>
Thanks go to:
<itemize>
<item> Brion Vibber,
<tt><url url="mailto:brion@pobox.com" name="<brion@pobox.com>"></tt>, who
wrote the
<tt><url url="http://pobox.com/~brion/linux/TrueType-HOWTO.html"
name="(preliminary) TrueType HOW-TO (http://pobox.com/~brion/linux/TrueType-HOWTO.html)"></tt>
<item> Doug Holland,
<tt><url url="mailto:meldroc@frii.com" name="<meldroc@frii.com>"></tt>,
who wrote the
<tt><url url="http://www.frii.com/~meldroc/Font-Deuglification.html"
name="XFree86 Font Deuglification HOW-TO
(http://www.frii.com/~meldroc/Font-Deuglification.html)"></tt>
</itemize>
<sect1> Additional links
<p>
These links don't directly discuss Debian systems or packages, but
they may still be interesting to readers of this mini-HOWTO.
<itemize>
<item> Using TrueType Fonts with RedHat Linux
<tt><url url="http://www.kegel.com/linux/tt.html"
name="(http://www.kegel.com/linux/tt.html)"></tt>
<item> X Font Tools
<tt><url url="http://www.hex.net/~cbbrowne/xfonts.html"
name="(http://www.hex.net/~cbbrowne/xfonts.html)"></tt>
<item> Getting fonts to look pretty under GNU/Linux for applications like
StarOffice <tt><url url="http://king.ccrc.wustl.edu/~zubin/fonts.html"
name="(http://king.ccrc.wustl.edu/~zubin/fonts.html)"></tt>
<item>How to use True Type &copy; fonts for StarOffice Under Linux
<tt><url url="http://www.mindspring.net/~john_mcl/adding_fonts.html"
name="(http://www.mindspring.net/~john_mcl/adding_fonts.html)"></tt>
</itemize>
<sect1> Change log
<p>
<itemize>
<item>0.1. Sept. 16, 1999: First release.
<item>0.2. Sept. 16, 1999: added "additional links" section.
<item>0.3. Jan. 10, 2000: reader feedback! Added clarification
of several details.
</itemize>
<sect1> Feedback
<p>
Comments, corrections, additions and critiques are always welcome. You can
reach me at <url url="mailto:bgiles@coyotesong.com"
name="bgiles@coyotesong.com">.
<sect1> Related projects
<p>
<itemize>
<item> FreeType
<url url="http://www.freetype.org/" name="http://www.freetype.org/">
<p>
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 <em>patent</em>, however.) FreeType is a
library, not a font server or a complete text rendering library.
</itemize>
<sect1> Distribution
<p>
This is the first draft and I expect it to change significantly
after publication, I ask that you refer to the latest version
at <tt><url url="http://www.dimensional.com/~bgiles/debian-tt.html"
name="http://www.dimensional.com/~bgiles/debian-tt.html"></tt>.
The permanent home for this document will eventually be at
<tt><url url="http://www.coyotesong.com/"
name="http://www.coyotesong.com/"></tt>
<sect> Display (what they never told you)
<p>
Before we dive into setting up TrueType fonts under X, we should
review the difference between points and pixels... and why we care.
All displayed fonts are measured in <em>points</em>. 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 <em/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
<em>pixels</em>. 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: <tt/fonts-75/ is
intended for use on low-end displays with a resolution of approximately
75 dpi, <tt/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:
<tscreen>
<em>/etc/X11/xdm/Xservers</em>
<code>
#:0 local /usr/X11R6/bin/X -bpp 16
:0 local /usr/X11R6/bin/X -bpp 16 -dpi 120
</code></tscreen>
Second, we should ensure that we use the 100 dpi bitmapped fonts
in preference to the 75 dpi fonts.
<tscreen>
<em>/etc/X11/XF86Config</em>
<code>
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
</code></tscreen>
Finally, if one of our bitmapped fonts isn't an exact match the
<tt/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.
<tscreen>
<em>/etc/X11/XF86Config</em>
<code>
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
</code></tscreen>
<sect1>A look ahead to XFree86 4.0
<p>
I've just been informed that XFree86 will support DDC communications,
if the video card and monitor both support it. This will allow the
X server to query the monitor for its physical dimensions and the
server will automatically compute the correct DPI setting.
You will still need to make the appropriate changes to your font path,
since the server should not second guess your explicit configuration.
<sect1>Review: Preparation before changing <tt/X/ configuration files.
<p>
Any time we make changes to the X11 configuration files, it's an
excellent idea to disable <tt/XDM/ by putting <tt/exit 0/ somewhere
near the top of the file. If you don't do this and <tt/X/ is unable
to start for some reason, <tt/XDM/ will put your system into a nasty
busy loop that is an unspeakable pain to correct. You Have Been Warned.
<sect> Display (<tt/X/ and the font servers)
<p>
Strictly speaking, it is not absolutely necessary to set up font servers
to use TrueType fonts with <tt/X/ servers. If you wish to use
static files instead of a font server, please see the instructions for
setting up TrueType fonts for <tt/ghostscript/.
<sect1>Setting up the <tt/xfs/ Font Server
<p>
At this point I assume you have a working <tt>/etc/X11/XF86Config</tt>
file that loads explicitly specifies each directory in the <tt/FontPath/.
We will convert it to use the <tt/xfs/ Font Server.
<itemize>
<item>Install <tt/XFS/
<p>
If you have not already done so, install <tt>main/binary-*/x11/xfs_*.deb</tt>.
<item>Configure <tt/XFS/
<p>
Edit <tt>/etc/X11/xfs/config</tt> and change the <tt/catalogue/ to
contain the contents of your <tt/FontList/. You may also wish to
change the <tt/default-resolutions/ value.
<tscreen>
<em>/etc/X11/xfs/config</em>
<code>
# paths to search for fonts
catalogue =
/usr/X11R6/lib/X11/fonts/100dpi/:unscaled,
/usr/X11R6/lib/X11/fonts/75dpi/:unscaled,
/usr/X11R6/lib/X11/fonts/misc/,
/usr/X11R6/lib/X11/fonts/Speedo/,
/usr/X11R6/lib/X11/fonts/Type1/,
/usr/X11R6/lib/X11/fonts/100dpi/,
/usr/X11R6/lib/X11/fonts/75dpi/
# x1,y1,x2,y2,...
default-resolutions = 100,100,75,75
</code></tscreen>
<item>Restart <tt/XFS/
<p>
Restart <tt/XFS/ in the usual Debian manner:
<tscreen>
<em>root shell</em>
<code>
# /etc/init.d/xfs restart
</code></tscreen>
<item>Verify that <tt/XFS/ is working
<p>
Before we change our <tt/XF86Config/ file, we should verify that the <tt/xfs/
server is working by listing them through the font server:
<tscreen>
<em>user shell</em>
<code>
$ fslsfonts -server unix/:7100
-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
....
</code></tscreen>
<item>Change <tt>/etc/X11/XF86Config</tt> to use <tt/xfs/
<p>
We're now ready to tell the X server to use the <tt/xfs/ font server.
We keep one static font path as a fallback position in case of a problem
with <tt/xfs/. (We keep "misc" since it contains <tt/fixed/, the
default font.)
<tscreen>
<em>/etc/X11/XF86Config</em>
<code>
Section "Files"
FontPath "unix/:7100"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
EndSection
</code></tscreen>
<item>Restart <tt/X/
<p>
Restart <tt/X/ with <tt/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 <tt/xdm/.
<item>Verify that the <tt/XFS/ fonts are visible
<p>
Once we have an X session established, we can verify that our server
sees all of the <tt/xfs/ fonts by listing them through the <tt/X/ server.
<tscreen>
<em>user shell</em>
<code>
$ 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
....
</code></tscreen>
</itemize>
<sect1>Setting up the <tt/xfstt/ Font Server and installing TrueType fonts
<p>
At this point I assume you have a working <tt/xfs/ font server and wish
to add TrueType support via <tt/xfstt/.
<itemize>
<item>Install <tt/XFSTT/
<p>
If you have not already done so, install <tt>main/binary-*/x11/xfstt_*.deb</tt>.
<item>Installing the TrueType Fonts
<p>
Copy your TrueType fonts into the <tt>/usr/share/fonts/truetype</tt>
directory. These files usually have a <tt/.ttf/ extension, and they
should have <tt/0444/ permissions.
<item>Restart the <tt/XFSTT/ Font Server
<p>
Restart the <tt/xfstt/ server with the <tt/force-reload/ flag
<tscreen>
<em>root shell</em>
<code>
# /etc/init.d/xfstt force-reload
</code></tscreen>
<item>Verify that <tt/XFSTT/ is working
<p>
Before we change our <tt/XF86Config/ file, we should verify that the <tt/xfstt/
server is working.
<em>Important: the Debian <tt/xfstt/ server listens to
port 7101, not 7100. Also, the default permissions will require you
to run this query as root.
</em>
<tscreen>
<em>user and root shells</em>
<code>
$ fslsfonts -server unix/:7101
_FSTransSocketUNIXConnect: Can't connect: errno = 111
fslsfonts: unable to open server "unix/:7101"
# fslsfonts -server unix/:7101
-ttf-arial black-medium-r-normal-regular-0-0-0-0-p-0-iso8859-1
-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
</code></tscreen>
<item>Change <tt>/etc/X11/XF86Config</tt> to use <tt/xfstt/
<p>
We're now ready to tell the X server to use the <tt/xfstt/ font server.
We want it to use TrueType fonts in preference to all others.
<tscreen>
<em>/etc/X11/XF86Config</em>
<code>
Section "Files"
FontPath "unix/:7101"
FontPath "unix/:7100"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
EndSection
</code></tscreen>
<item>Verify that <tt/XFSTT/ fonts are visible
<p>
Once we have an X session established, we can verify that our server
sees all of the TrueType fonts by listing them.
<tscreen><code>
$ xlsfonts | grep ttf
-ttf-arial black-medium-r-normal-regular-0-0-0-0-p-0-iso8859-1
-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
....
</code></tscreen>
</itemize>
<sect1> Using TrueType fonts
<p>
At this point it should be possible to use a TrueType font in
applications like <tt/GIMP/, <tt/Netscape/ or <tt/StarOffice/.
Since most TrueType fonts aren't monospaced you probably don't want
to use one of them with <tt/xterm/ - these programs use monospacing
the size of the largest character cell.
<sect1> Installing additional TrueType fonts
<p>
If you are using the <tt/xfstt/ font server, it's trivial to install
additional TrueType fonts.
<itemize>
<item>Copy the new font(s) into <tt>/usr/share/fonts/truetype/</tt>
<item>Restart <tt/xfs/ with <tt>/etc/init.d/xfs restart</tt>
</itemize>
<sect1> Internationalization
<p>
<tt/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 <tt>/etc/init.d/xfstt</tt> script:
<tscreen>
<em>/etc/init.d/xfstt</em>
<code>
- start-stop-daemon --start --quiet --exec $XFSTT -- \
--port $portno --daemon
+ start-stop-daemon --start --quiet --exec $XFSTT -- \
--port $portno --encoding iso8859-1,koi8-r,windows-1252,symbol-0 \
--daemon
</code></tscreen>
The recognized encodings in Debian 2.1 are:
<itemize>
<item>iso8859-1 (Latin 1 - Western Europe)
<item>iso8859-2 (Latin 2 - Central and Eastern Europe)
<item>iso8859-3 (Latin 3 - Esperanto and Maltese)
<item>iso8859-4 (Latin 4 - superceded by Latin 6)
<item>iso8859-5 (Cyrillic)
<item>iso8859-6 (Arabic)
<item>iso8859-7 (Greek)
<item>iso8859-8 (Hebrew)
<item>iso8859-9 (Latin 5 - Latin 1 with Turkish, not Icelandic)
<item>iso8859-10 (Latin 6 - Nordic languages, replaces Latin 4)
<item>koi8-r (Cyrillic)
<item>windows-1250 (Central Europe)
<item>windows-1251 (Cyrillic)
<item>windows-1252
<item>windows-1253 (Greek)
<item>windows-1254
<item>windows-1255
<item>windows-1256
<item>windows-1257
<item>symbol-0
<item>wingding-0
<item>wingreek-0
<item>cp-437 (various IBM code pages)
<item>cp-737
<item>cp-850
<item>cp-851
<item>cp-852
<item>cp-853
<item>cp-855
<item>cp-857
<item>cp-860
<item>cp-861
<item>cp-862
<item>cp-863
<item>cp-864
<item>cp-865
<item>cp-866
<item>cp-869
<item>cp-895
<item>atari-st
<item>unicode-2
</itemize>
The first 128 characters in the <tt/iso8859-x/ encodings is always ASCII.
The <tt/windows-/ fonts embrace and extend <tt/iso8859-1/ with additional
characters such as "smart quotes." (Since these extensions, such as "smart
quotes" are undefined in <tt/iso8859-1/, they are usually rendered as
question marks.)
Excellent source for additional information on character set encodings
are at
<itemize>
<item><tt><url url="http://ppewww.ph.gla.ac.uk/%7Eflavell/iso8859/iso8859-pointers.html"
name="http://ppewww.ph.gla.ac.uk/%7Eflavell/iso8859/iso8859-pointers.html"></tt>,
<item><tt><url url="http://anubis.dkuug.dk/i18n/"
name="http://anubis.dkuug.dk/i18n/"></tt> and
<item><tt><url url="http://czyborra.com/charsets/iso8859.html"
name="http://czyborra.com/charsets/iso8859.html"></tt>.
</itemize>
<sect1> Security Issues
<p>
I used Unix sockets above, but the standard Debian packages also
configure <tt/xfs/ and <tt/xfstt/ to listen to TCP/IP ports 7100 and
7101, respectively. Access to these ports should be controlled
by the <tt/trusted-clients/ field in <tt>/etc/X11/xfs/config</tt>,
but this option is not implemented in XFree86 3.3.2.3a.
This means that anyone, anywhere, can connect to your font server.
Since <tt/xfs/ (and presumably <tt/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.
<sect>Printing (<tt/ghostscript/)
<p>
Starting with version 4, <tt/ghostscript/ has supported TrueType
fonts as a compile-time option. Two Debian packages provide <tt/ghostscript/:
<itemize>
<item><tt>main/binary-*/text/gs_*.deb</tt> is DFSG-compliant version 5.10,
<item><tt>non-free/binary-*/gs-aladdin_*.deb</tt> is non-DFSG-compliant
version 5.50.
</itemize>
Both versions support TrueType fonts.
<sect1>Configuring <tt/Ghostscript/ to use TrueType fonts
<p>
If you have a working <tt/xfstt/ server, it is easy to configure
<tt/ghostscript/ to use TrueType fonts. We simply execute the
following command:
<tscreen><code>
# xfstt --gslist --sync >> /etc/gs.Fontmap
</code></tscreen>
In practice, I've found it beneficial to make several small changes
to the font definitions generated by <tt/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 <tt/TTF-/ (or <tt/MS-/) to all font names to
minimize problems caused by a TrueType font having an identical
name to an preexisting font.
Thus
<tscreen><code>
(Arial) (/usr/share/fonts/truetype/arial.ttf) ;
(Arial Bold Italic) (/usr/share/fonts/truetype/arialbi.ttf) ;
</code></tscreen>
becomes
<tscreen><code>
/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 ;
</code></tscreen>
The aliases ensure that <tt/ghostscript/ and <tt/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 <tt/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 <tt/ghostscript/ to replace Helvetica fonts
with Microsoft's free Arial fonts by appending the following lines to the
<tt>/etc/gs.Fontmap</tt> file:
<tscreen><code>
/Helvetica /MS-Arial ;
/Helvetica-Oblique /MS-Arial-Italic ;
/Helvetica-Bold /MS-Arial-Bold ;
/Helvetica-BoldOblique /MS-Arial-Bold-Italic ;
</code></tscreen>
Similar aliases can be defined for the other standard fonts.
These aliases would be most useful on <tt/samba/ printers serving
Windows clients.
<sect1>Printing TrueType font specimens
<p>
The best way to verify that <tt/ghostscript/ is properly configured to use
TrueType fonts is to print font specimen pages. Assuming that you're
running <tt/ghostscript/ 5.50 and that it is your default print queue,
you can print all TrueType fonts with the following command:
<tscreen><code>
# xfstt --gslist --sync | printfont
</code></tscreen>
where <tt/printfont/ is the following shell script
<tscreen><code>
#!/bin/sh
set -e
IFS= ')'
while read fontname rest
do
cat << EOM | lpr
%!PS
(/usr/lib/ghostscript/5.50/prfont.ps) run
$fontname) DoFont
EOM
done
</code></tscreen>
If you wish to print only a few fonts, the following script will be
easier to use:
<tscreen><code>
#!/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
</code></tscreen>
<sect> Content Generation
<sect1> Generating <tt/AFM/ font metrics
<p>
<tt/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 <tt>/usr/lib/ghostscript/5.50/printafm.ps</tt>
could be used to generate these metric files, but I have found
the <tt/ttf2afm/ program from the <tt/tetex-bin/ package to be easier
to use.
The following script will generate an <tt/afm/ file for all TrueType
fonts in a directory:
<tscreen><code>
#!/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
</code></tscreen>
One minor problem with <tt/ttf2afm/ is that some applications expect
<tt/afm/ files to start with the <tt/StartFontMetrics/ tag, but
files created by <tt/ttf2afm/ start with a comment. This "problem"
is easily fixed by hitting each file with a text editor.
<sect1>Generating <tt/font.map/ files
<p>
Once we have our <tt/afm/ files, we need to tell the system how to
find them. This is often done via the <tt/font.map/ file.
I have been unable to find documentation on this file format, unlike
<tt/fonts.dir/, <tt/fonts.scale/, and <tt/fonts.alias/, all created by
the <tt/mkfontdir/ program. However the minimum format appears to
be quite simple:
<itemize>
<item>Font name, without whitespace
<item><tt/AFM/ filename, without extension
</itemize>
Aliases appear to be implemented via multiple entries, and the filename
extension must be in lowercase.
<sect1>Image manipulation: <tt/GIMP/
<p>
<tt/GIMP/ is the Gnu image manipulation and paint program. I did not
have to make any additional changes to use TrueType fonts in <tt/gimp/.
<sect1>ASCII to PostScript conversion: <tt/enscript/
<p>
<tt/Enscript/ is a program that converts ASCII to PostScript. Other
programs which serve a similiar purpose are <tt/a2ps/ and <tt/mpage/.
<tt/Enscript/ allows two-up rotation, watermarks, headers, and
keyword-based syntax coloring. It does not reformat text and is
commonly used to print source listing.
To use TrueType fonts with <tt/enscript/, you must do two things:
<itemize>
<item>Add <tt>/usr/share/fonts/truetype</tt> to your <tt/AFMPath/.
<item>Specify a TrueType font, either explicitly or by aliasing a
default font.
</itemize>
For details, see the <tt/enscript/ documentation.
Once I had made these changes, I had no problem using TrueType
fonts.
<sect1>Text Formatting and Typesetting: <tt/groff/
<p>
<tt/Groff/ is the Gnu front end of the groff/troff document
formatting system. The power of <tt/Groff/ is best seen with
<tt/man/ pages.
<tscreen>
<em>user shell</em>
<code>
$ zcat /usr/man/man1/groff.1.gz | groff -man | lpr
</code>
</tscreen>
Besides man pages, an incredible amount of Unix documentation
uses <tt/troff/ formatting with <tt/ms/ (and occasionally <tt/me/)
macros. The Debian <tt/xbooks/ package, for example, has 43
files using <tt/troff/ with <tt/ms/ macros. With <tt/groff/, this
material can be attractively printed.
<tt/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 <tt/groff/ reflects that heritage.
<tt/Groff/, in contrast to its predecessors, uses PostScript as
the default output format so our earlier work with <tt/ghostscript/
takes care of half of the problem -- <tt/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 <tt/groff/ files:
<tscreen>
<em>Groff PostScript description files</em>
<code>
/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
</code>
</tscreen>
We must edit the Makefile,
<tscreen>
<em>/usr/share/groff/font/devps/generate/Makefile</em>
<code>
- afmdir=/usr/local/afm
+ afmdir=/usr/share/fonts/truetype
</code>
</tscreen>
change the name of the fonts to their TrueType equivalent (e.g.,
if we're using Microsoft's free TrueType fonts we would replace
<tt/Helvetica/ with <tt/Arial/), and change <tt>TEXTFONTS</tt>
and the like to only include those fonts we are redefining.
We must also edit <tt>/usr/share/groff/font/devps/generate/afmname</tt>
to use the TrueType font names and <tt/afm/ files, and to remove an
<tt/"-e"/ flag from <tt/awk/.
After all of this, we can rebuild the <tt/groff/ tables with
<tscreen>
<em>user shell</em>
<code>
$ cd /usr/share/groff/font/devps
$ make -f generate/Makefile
</code>
</tscreen>
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 <tt/Mistral/ for <tt/TR/.
(I expect royalties from everyone who reconfigures their system to
print manual pages in Old English fonts next April First!)
<sect1>Text Formatting and Typesetting: <tt/TeX/
<p>
<tt/TeX/ is the other common set of text formatting and typesetting
programs on most GNU/Linux systems.
<tt/TeX/ fonts can created with <tt/mktexmf/, but I have little
information on the exact process. More details will be provided shortly.
<sect>Unanswered questions
<p>
<itemize>
<item> Applications
<p>
The biggest unanswered question is why <tt/netscape communicator/
can use TrueType fonts, <tt/ghostscript/ can use the same
TrueType fonts, yet pages printed by <tt/netscape/ look nothing
like the screen.
The short answer is that <tt/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.
</itemize>
<sect> Obtaining TrueType Fonts
<p>
If you're looking for TrueType fonts, here are several places
where you can start looking:
<itemize>
<item>c:\windows\fonts on the boat anchor in the corner
<item>Microsoft's Free TrueType Fonts
<tt><url url="http://www.microsoft.com/typography/fontpack/"
name="http://www.microsoft.com/typography/fontpack/"></tt>
<item>Acid Fonts
<tt><url url="http://www.acidcool.com/" name="http://www.acidcool.com/"></tt>
<item>The Font Ring
<tt><url url="http://www.webring.org/cgi-bin/webring?ring=fontring&amp;list"
name="http://www.webring.org/cgi-bin/webring?ring=fontring&amp;list"></tt>
</itemize>
<sect1> A comment about using Microsoft's free TrueType fonts
<p>
No article on TrueType support under Linux would be complete without
a comment about Microsoft's free TrueType fonts. First the legality
of using Microsoft's free core fonts:
<quote>
<em><tt><url url="http://www.microsoft.com/typography/faq/faq8.htm"
name="http://www.microsoft.com/typography/faq/faq8.htm"></tt></em>
<code>
Q. What can I do with these fonts?
&middot; Anyone can download and install these fonts for
their own use.
&middot; [Web page] designers can specify the fonts within
their own Web pages.
...
</code>
</quote>
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 <tt/main/ anytime soon. (Could they be
packaged in <tt/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 <tt/ghostscript/ to
use them.
<sect>Legalities
<p>
Copyright &copy; 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.
</article>