LDP/LDP/retired/FDU.sgml

4308 lines
125 KiB
Plaintext
Raw Permalink Blame History

<!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<Article id="index">
<ArtHeader>
<Title>XFree86 Font De-uglification HOWTO</Title>
<AuthorGroup>
<Author>
<Firstname>Hal</Firstname>
<Surname>Burgiss</Surname>
<Affiliation>
<Address>
<Email>hal@foobox.net</Email>
</Address>
</Affiliation>
</Author>
</AuthorGroup>
<!--
$Id: FDU.sgml,v 1.15 2002/10/31 21:40:58 hal Exp $
-->
<PubDate>v2.04c, 30 October 2002</PubDate>
<!--
<RevHistory>
<Revision>
<RevNumber>v2.00</RevNumber>
<Date>2002-09-10</Date>
<Authorinitials>hb</Authorinitials>
</Revision>
<Revision>
<RevNumber>v0.1</RevNumber>
<Date>21 February 1999</Date>
<Authorinitials>dh</Authorinitials>
<RevRemark>
First release.
</RevRemark>
</Revision>
<Revision>
<RevNumber>v0.11</RevNumber>
<Date>27 February 1999</Date>
<Authorinitials>dh</Authorinitials>
<RevRemark>
Added copyright info to protect my butt.
</RevRemark>
</Revision>
<Revision>
<RevNumber>v0.12</RevNumber>
<Date>10 June 1999</Date>
<Authorinitials>dh</Authorinitials>
<RevRemark>
Added A Plea for Help.
</RevRemark>
</Revision>
<Revision>
<RevNumber>v0.20</RevNumber>
<Date>14 September 1999</Date>
<Authorinitials>dh</Authorinitials>
<RevRemark>
Added section on xfs for Redhatters. Many
thanks to Hal Burgiss for his contribution.
</RevRemark>
</Revision>
<Revision>
<RevNumber>v1.0</RevNumber>
<Date>23 November 1999</Date>
<Authorinitials>dh</Authorinitials>
<RevRemark>
Converted document to SGML, for submission to the Linux Documentation
Project. Removed Plea for Help.
</RevRemark>
</Revision>
<Revision>
<RevNumber>v1.5</RevNumber>
<Date>25 July 2000</Date>
<Authorinitials>hb</Authorinitials>
<RevRemark>
New sections, and various additions and cleanups.
</RevRemark>
</Revision>
</RevHistory>
-->
<KeywordSet>
<Keyword>
Font
</Keyword>
<Keyword>
TrueType
</Keyword>
<Keyword>
xfs
</Keyword>
<Keyword>
xfsft
</Keyword>
<Keyword>
XFree
</Keyword>
<Keyword>
X Windows
</Keyword>
<Keyword>
xfstt
</Keyword>
<Keyword>
freetype
</Keyword>
<Keyword>
Netscape
</Keyword>
<Keyword>
Mozilla
</Keyword>
<Keyword>
legible
</Keyword>
<Keyword>
Anti Aliasing
</Keyword>
<Keyword>
XftConfig
</Keyword>
</KeywordSet>
<Abstract>
<Para>
How to improve X Window fonts. Various tips for improving font handling for
XFree86, including sections on font servers, TrueType fonts, Mozilla, and
related topics.
</Para>
<Para>
<Comment>
Modify 'New Versions Section'!!!!!!!!!!!!!!!!
Remove my xfs!!!!!!!!!!!!!!
aspell -H -c FDU.sgml
submit@linuxdoc.org
http://feenix.burgiss.net/ldp/fdu/FDU.sgml.gz
=================================================
ToDo
RENDER not required for Xft2!!!
Changes 2.04:
TrueType hinting
http://www.xfree86.org/current/fonts.html (julius)
http://www.theregister.co.uk/content/4/27788.html (TT / freetype)
Mike Harris:
Xft1 (1.1), included with XFree86 stock sources uses XftConfig.
Keith Packard took the Xft1 library, enhanced it to use
fontconfig instead of XftConfig, removed the XftConfig baggage,
and released it as Xft 1.2 - a drop in replacement for Xft 1.x
for XFree86 4.2.0. So, what you get in Red Hat Linux 8.0, is the
Xft 1.1 library is gone, now replaced with Keith Packard's
official Xft 1.2 library which uses fontconfig. This allows Xft
to use one configuration file - /etc/fonts/fonts.conf, and
/etc/X11/XftConfig is now obsolete, and gone. Xft2 is a separate
RPM (Xft) because it was much easier to have it a separate RPM
package to update it quickly and easily without updating XFree86
packages every snapshot, as it was in development during Red Hat
Linux development. Having it separate made it ultra simple to
update, and makes no difference to the end user.
Correct. Xft1 development is intentionally not supported, as
Xft1 is considered legacy now. Qt is the main thing that used
Xft1, very few other things ever used it, and Qt now uses Xft2.
Supporting Xft1 for development when so few apps use it, is a
waste of time, and only holds back the widespread adoption of
Xft2. Xft2 is a significant improvement over Xft1, so the hope is
that any interesting applications will be ported to Xft2 properly
by their authors. Existing apps using Xft1 should run ok in 8.0
since the fontconfigized Xft1 makes configuration centralized,
while allowing precompiled Xft1 apps to continue to work. 1 such
app is xterm. 8.0 is a major new release, so ditching legacy
stuff, especially which not a lot of things use anyway is a good
time to do it. This will again as I said, put a fire under
everyone out there to port there Xft1 stuff to Xft2.
[more]
There are two font subsystems, the old one is 15-20 years old and
is referred to as "core X fonts"; these are classic X Window System
fonts. To install new fonts for this, instructions should be easy to
google up, it involves putting the fonts in a system directory and
running ttmkfdir and restarting the "xfs" font server. Core X fonts
have these properties:
- they are server-side, handled by the X server and xfs
- they are always monochrome (not antialiased)
- they have annoying names like "-urw-nimbus roman no9 l-medium-i-normal--0-0-0-0-p-0-iso8859-1"
The new font subsystem is being phased in to replace it. The new one
is called "fontconfig/Xft2" where fontconfig is the part that parses
/etc/fonts/fonts.conf and scans your ~/.fonts and /usr/share/fonts
directories, and Xft2 is the part that draws fonts on the screen.
- these fonts are client-side, handled by the application
- they can be used for printing etc. in addition to
display on the screen
- they can be rendered antialiased or not, as in Preferences->Fonts
rendering tweaks
- they have sane names like "Nimbus Sans"
So anyhow, we are currently in a transition period. Some applications,
namely those using Qt 3 or GTK 2, use the new system. Other
applications, most of the rest, use the old system. You have to
install the fonts once for each system.
Over time (for the most part we hope by the next release), everything
will move to the new system.
(Someone add this post to a FAQ somewhere! ;-)
Havoc
Links:
http://fontconfig.org/ and
http://fontconfig.org/mozilla/
Submitted: 2.01 Oct 3, 2002
Notes on better browsers than NS.
Mozilla/xft
http://sourceforge.net/projects/font-tool/ Michael Fratoni
Submitted 2.00 09/12/02
Changes 1.99pre
No more MS web fonts!!:
http://unixlab.cs.put.poznan.pl/pub/Windows/TTF-fonts/
Fixed http://gongolo.usr.dsi.unimi.it/~vigna/webFonts4Linux/
More on gdkxft, and AA.
More on Mozilla, userChrome.css, etc.
Touch up AbiSuite font issue.
Add Linus's usenet quote.
Comments on GNOME2.
Perl script for fonts.alias.
Improve the dpi section, and ad tip from Alex Jacques.
Some rewording of the TrueType section.
TODO:
<![CDATA[
type1inst (for type 1 fonts): 5.1 Type1. Adding Type1 fonts is
straightforward. Run type1inst on the directory containing the font. type1inst
will output a file called Fontmap . ...
linuxselfhelp.com/HOWTO/Font-HOWTO-5.html
From: Juliusz Chroboczek <jch@pps.jussieu.fr>
Date: Sun, 6 Oct 2002 19:05:42 +0200 (CEST)
Subject: De-uglification: XFree86 changes advance warning
To: hal@foobox.net
XFree86 4.3.0 will include a new utility, mkfontscale, which creates
fonts.scale files for both TrueType and Type 1 fonts, just like
ttmkfdir does for TrueType fonts.
You'll find pre-release versions of mkfontscale on
http://www.pps.jussieu.fr/~jch/software/files/
Regards,
Juliusz
Alex Jacques <alexj@pulver.com>:
xdpyinfo|grep resolution
indicated 88x91 dpi. Seems that horiz. and vert. resolution not being
the same caused the problem. 88 or 91 is about the right resolution for
my setup, hence I'd never bothered to configure it manually. Explicitly
telling the X server -dpi 91 fixed it completely (I now get
xdpyinfo|grep resolution => 91x91).
http://www.tuxfan.homeip.net:8080/core_fonts-0.1-3.noarch.rpm
I found the fonts in several locations:
http://unixlab.cs.put.poznan.pl/pub/Windows/TTF-fonts/
http://nuoriso.hel.fi/__files/ms_truetype_core_fonts_for_the_web/Win95-98-NT/ index.html
http://web.archive.org/web/20000420210719/http://www.microsoft.com/opentype/ fontpack/default.htm
Time to modify xf86ttfontool again, I think.
More reading here:
http://www.kottke.org/02/08/020813the_case_of_.html
And even a MS explination of sorts:
http://typographi.ca/2002_08_13.php#000428
]]>
Submitted 1.9 Mon 11/05/01 10:48:43 AM
Todo 1.9
ftlint (freetype) checks for bad fonts.
Changes 1.9
Added 2 URLs for Debian config from Paul Smith.
Added note about RH adding mkfontdir, etc to init script.
Changes for distros now handling font servers in several places, and
ways to dl/install MS TTF.
======================
Changes 1.8
Different URL for webfonts. Old one is broke.
Added the Debian msttcorefonts link.
Added nice AA/Xft section from Danny Tholen D.J.H.Tholen@bio.uu.nl
Gave full URL for MS fonts for text version.
Minor change to intro.
Added note on Abisuite ugly fonts
Added URL for webFonts4Linux
Added Kristen's Mozilla FAQ URL.
</Comment>
</Para>
</Abstract>
</ArtHeader>
<!-- end Art. header -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="intro">
<Title>Introduction</Title>
<Para>
An often heard complaint is the poor default fonts and font settings of X as
implemented by many Linux distributions. Some programs use fixed width
default fonts when a variable width font would be more appropriate. Other
programs use fonts that are so small as to be practically unreadable. Many of
the fonts that are bundled with XFree86 are not of the same quality as found
on some other platforms. XFree86 does come with a halfway decent courier
font, but its Times and Helvetica fonts are simple bitmap fonts that pixelize
when scaled. This is changing for the better recently, but a default Linux
desktop still often needs some tweaking to get the best fonts possible.
</Para>
<Para>
This HOWTO attempts to show how to adjust various font settings, install new
fonts, and a few other things that should greatly improve the appearance and
readability of fonts on the X Window Desktop. This is done by adjusting the
<Literal>FontPath</Literal> in the <FileName>XF86Config</FileName> file, by
adding switches to X server command line in <Command>startx</Command> or
<Command>xdm</Command> (and variants), by adding new fonts, and by
making sure TrueType fonts are installed and available. TrueType does
indeed make a huge difference in many applications.
</Para>
<Para>
Comments, corrections, additions and critiques are always welcome. You can
reach the author at <email>hal@foobox.net</email>. Contributions are also
welcomed. Especially anyone who really stays current with KDE and/or GNOME
issues! (So I guess nobody uses these since the silence is deafening?)
</Para>
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Conventions Used in this Document</Title>
<Para>
<ItemizedList>
<listitem>
<para>
<quote>X</quote> and <quote>XFree86</quote> are (incorrectly) used
here interchangably. The overwhelming percentage of Linux users indeed
use XFree86.org's X implementation, but there are other implentations
as well. The information here probably does not apply to those others in
most cases.
</para>
</listitem>
<ListItem>
<Para>
Where examples of commands are used, a <quote>#</quote> character is used to
denote where typically the command would be run as the root user. A
<quote>$</quote> is used where typically a non-root user would be executing
the command.
</Para>
</ListItem>
<ListItem>
<Para>
The examples use <FileName>/usr/local/share/fonts/ttfonts</FileName> as our
TrueType font directory. There is no magic to this location, and could
conceivably just as well be in any number of other locations. Some
distros may have a default location for TrueType fonts, and you may
want to use that instead.
</Para>
</ListItem>
<ListItem>
<Para>
References to "xfs" are to the xfs as packaged by Red Hat (and some other
distros) for versions 6.x and later. This differs significantly in some
respects from the stock XFree86 xfs.
</Para>
</ListItem>
<ListItem>
<Para>
References to "Netscape" are to the entire suite of programs from Netscape:
Communicator, Navigator, Messenger, etc. And for all intents and purposes,
font configuration in Mozilla is very similar (but generally looks
better!).
</Para>
</ListItem>
<ListItem>
<Para>
'XF86Config' is the X configuration file. This has changed to
'XF86Config-4' for XFree86 v4.x. For the most part, we'll just use
'XF86Config' here.
</Para>
<Para>
Also, while some aspects of XFree86 4.x configuration are the same as
3.3.x, there are some significant differences. We'll only highlight the
differences. So unless noted otherwise, any comments or examples should
apply to both 3.3.x and 4.x versions.
</Para>
</ListItem>
<ListItem>
<Para>
File system layout varies somewhat from distribution to distribution. It
is impossible to stay on top of every conceivable variation of who keeps
which files where. So take the examples here with a grain of salt if the
PATHs don't seem to match your system.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Change Log and What's New</Title>
<Para>
<ItemizedList>
<listitem>
<para>
2.04: October 30, 2002.
Include info on TrueType <quote>hinting</quote>, and enabling in
freetype sources (thanks Andreas Oesterhelt!). A few new useful links,
and minor cleanups.
</para>
<para>
If this keeps up, this document will have to be renamed the
<citetitle>Font Beautification HOWTO</citetitle> ;-).
</para>
</listitem>
<ListItem>
<Para>
2.03: October 17, 2002.
Some brief notes on Red Hat 8.0 differences/newness, notably the changes
that accompany Xft2. More on the distinction of core X fonts and Xft (and
then Xft2).
</Para>
</ListItem>
<ListItem>
<Para>
2.01: October 03, 2002.
Update links for obtaining the MS web fonts (TrueType fonts of choice).
There are two <ulink url="http://sf.net">Sourceforge</ulink> projects
with these fonts available, including.
<ulink url="http://sourceforge.net/projects/font-tool/">http://sourceforge.net/projects/font-tool/</ulink>.
</Para>
<para>
Add section to <link linkend="mozilla">Mozilla</link> configuration to
include info on Xft and anti-aliasing.
</para>
</ListItem>
<ListItem>
<Para>
2.00: September 12, 2002.
Wow, MS has taken down their webfonts page :( Not good news. Installing
TrueType is a key ingredient to better living through nice fonts.
</Para>
<para>
Major re-organization by moving the font server section to the appendix,
since any recent distro is already installing these, or they are
not any longer needed.
</para>
<para>
Some clarifications on gdkxft and font anti-aliasing. Finally, add
Aristotle Pagaltzis's perl script for converting <filename>fonts.dir</filename>
to <filename>fonts.alias</filename>. Include interesting example
of using anti-aliased TrueType fonts in <command>xterm</command>.
Note that GNOME 2 is out. Fix the usual assorted broken links.
</para>
<para>
Clarifications on <literal>dpi</literal> settings, and add tip
about unbalanced dpi causing major trouble with fonts.
</para>
</ListItem>
<ListItem>
<Para>
1.95: February 11, 2002. A few corrections. Removed the section on Fonts in
KDE since this has to have changed, and I don't know anything about KDE
(does anyone want to help here?). Added a brief section on gdkxft, which
adds anti-aliasing support for GTK+ 1.2 applications.
</Para>
</ListItem>
<ListItem>
<Para>
1.9: November 5, 2001. A few new links and some minor catch ups only.
</Para>
</ListItem>
<ListItem>
<Para>
1.8: June 25, 2001: Included a new section on Anti-aliasing and Xft from
Danny Tholen <Email>obiwan@mailmij.org</Email>. Many thanks on this not so
well documented subject. Also, Sebastiano Vigna's neat little package for
downloading and installing MS webfonts: <Ulink
URL="http://freshmeat.net/webFonts4Linux">http://freshmeat.net/webFonts4Linux</Ulink>.
A few other odds and ends.
</Para>
</ListItem>
<ListItem>
<Para>
1.70: April 18, 2001:
Added links for converting Mac TrueType Fonts (thanks to Karl A. Krueger),
links to Unicode TrueType fonts (thanks to Tzafrir Cohen for suggestions
and URLs), and added a section on anti-aliasing with X 4.0.2 (or greater).
Also, included a reference to <Ulink
URL="http://www.kyz.uklinux.net/cabextract.php3">cabextract</Ulink>, a
utility that is now available for extracting Win32 Fonts (among other
things) from a Window's <Quote>cab</Quote> archive.
</Para>
</ListItem>
<ListItem>
<Para>
1.60: March 21, 2001:
A few very minor changes. Most notable news is anti-aliasing support now
in XFree 4.02 (referenced in the Notes section only). Chinese translation
URL added.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>New Versions</Title>
<Para>
The pre-release versions of this document can be found at
<Ulink URL="http://feenix.burgiss.net/ldp/fdu/index.html">http://feenix.burgiss.net/ldp/fdu/index.html</Ulink>.
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2 id="legal">
<Title>Copyright</Title>
<Para>
Copyright &copy; 1999 by Doug Holland, 2002 Hal Burgiss.
</Para>
<Para>
Unless otherwise stated, Linux HOWTO documents are copyrighted by their
respective authors. Linux HOWTO documents may be reproduced and distributed
in whole or in part, in any medium physical or electronic, as long as this
copyright notice is retained on all copies. Commercial redistribution is
allowed and encouraged; however, the author would like to be notified of any
such distributions.
</Para>
<Para>
All translations, derivative works, or aggregate works incorporating any
Linux HOWTO documents must be covered under this copyright notice. That is,
you may not produce a derivative work from a HOWTO and impose additional
restrictions on its distribution. Exceptions to these rules may be granted
under certain conditions; please contact the Linux HOWTO coordinator for more
information.
</Para>
<Para>
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.
</Para>
<Para>
Many of the terms mentioned in this document are trade names. Unless
otherwise stated, all trademarks are property of their respective owners.
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2 id="credits">
<Title>Credits</Title>
<Para>
<MSGText>
<LiteralLayout>
Original author: Doug Holland.
Email: <Ulink URL="mailto:meldroc@frii.com">meldroc@frii.com</ULink>
WWW: <Ulink URL="http://www.frii.com/~meldroc/">http://www.frii.com/~meldroc/</ULink>
</LiteralLayout>
</MSGText>
</Para>
<Para>
<MSGText>
<LiteralLayout>
Updated and maintained by Hal Burgiss.
Email: <ULink URL="mailto:hal@foobox.net">hal@foobox.net</ULink>
WWW: <Ulink URL="http://feenix.burgiss.net/ldp/fdu">http://feenix.burgiss.net/ldp/fdu/</ULink>
</LiteralLayout>
</MSGText>
</Para>
<Para>
Special thanks go to:
<ItemizedList>
<ListItem>
<Para>
The developers of the <Ulink URL="http://www.xfree86.org">XFree86 Project</Ulink>,
for all the hard work and time they have given. Also, Juliusz Chroboczek for
his work with xfsft, and XFree86 4.x to help bring TrueType to the
hungry masses. And Keith Packard for his anti-aliasing, and other work.
This is not to slight the many, many other XFree86 volunteers.
</Para>
</ListItem>
<ListItem>
<Para>
Font wizard Kristin Aanestad, whose legwork and insight on much of the xfs,
TrueType, Netscape, and especially, the fonts.alias sections are much
appreciated. More from Kristin at <Ulink
url="http://home.c2i.net/dark/linux.html">Some Linux for Beginners</Ulink>
on a wide range of topics.
</Para>
</ListItem>
<ListItem>
<Para>
Danny Tholen <Email>obiwan@mailmij.org</Email> is responsible for the nice
Xft section, and examples.
</Para>
</ListItem>
<ListItem>
<Para>
The folks at <Ulink URL="news:comp.os.linux.x">comp.os.linux.x</ULink> who
gave me a hand in figuring all of this out in the first place.
</Para>
</ListItem>
<ListItem>
<Para>
The Linux community in general who made all of this possible
in the first place. Especially those who have offered suggestions and
comments that help to make this HOWTO a better resource. Keep those cards
and letters coming ;-)
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Translations</Title>
<!--
mail: Yu-Chia Chang (joezhang at ms10.hinet.net) Chinese translation.
http://www.linux.org.tw/CLDP/mini/FDU.html
-->
<Para>
Chinese: <Ulink URL="http://www.linux.org.tw/CLDP/mini/FDU.html">http://www.linux.org.tw/CLDP/mini/FDU.html</Ulink> by Yu-Chia Chang.
</Para>
</Sect2>
</Sect1>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="x-config">
<Title>X Server Configuration</Title>
<Para>
There are a few simple configuration tweaks that will help X do its job
better.
</Para>
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Setting The FontPath</Title>
<Para>
The first place to look for curing font problems is the
<FileName>XF86Config</FileName> file.
<FileName>/usr/X11/lib/X11/XF86Config</FileName> or
<FileName>/etc/X11/XF86Config</FileName> are the common locations. (This may
be <FileName>XF86Config-4</FileName> for XFree86 4.x.) If you haven't
guessed already, the most important part of this file relating to fonts is
the <Literal>FontPath.</Literal> Before we get into that, this would be a
good time to check the other parts of your X configuration. Bad monitor
settings can be even more of a headache than bad fonts, so make sure your
refresh rate is as high as your monitor can handle (85 Hz is great, 75 Hz is
OK, 60 Hz is painful.)
</Para>
<Para>
Use your favorite text editor and edit
<FileName>XF86Config</FileName>. Near the top of the file in the
"Files" section, you should see something vaguely like this:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
This much should be the same, or at least similar, for both XFree86 3.x and
4.x. The <Literal>FontPath</Literal> tells X where to find the fonts it uses
to render text on your display. Order is important -- when an X application
asks X to render some text, the X server usually has some leeway to choose the
font that is used. The X server then goes through the
<Literal>FontPath</Literal> and grabs the first font it sees that matches the
X client's criteria, and then displays it. (Note that Red Hat's xfs for versions 6.x
and later has a different way of setting the <Literal>FontPath</Literal>. See
the <xref LinkEnd="xfs"> below for more on xfs.)
</Para>
<Para>
If the 100dpi fonts are not listed, they probably did not get installed for
whatever reason, so you may want install them now. Default installations
may put 75dpi fonts before the 100dpi fonts. If you have a high
resolution display (1024x768 or higher), this means very tiny fonts. If this
is the case, the first tweak you'll use is to switch the 75dpi and 100dpi
FontPath lines:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
Next, specify that you prefer to use unscaled bitmap fonts. If you've ever
used Netscape or any other program that displays titles using big fonts,
you might have noticed that those fonts were pixelized. This is ugly and needs
to be corrected. So add <Literal>:unscaled</Literal> to the ends of the misc,
100dpi and 75dpi fonts. You can even use both unscaled and scaled fonts if
you want, just put the unscaled <Literal>FontPath</Literal> lines first to
tell X you prefer unscaled fonts if possible:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
After making these changes, restart X (and your font server, if installed).
Doesn't the desktop look better already?
</Para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>X Server Command Line Options</Title>
<Para>
The next thing you might need to do is adjust the command line options for
the X server. It is important that the <literal>dpi</literal> resolution
be accurate. Run this command:
</para>
<Para>
<literallayout>
<Literal>
$ xdpyinfo | grep resolution
resolution: 111x111 dots per inch
</Literal>
</literallayout>
</Para>
<para>
If this does not look to match what your monitor can do, or if it is
unbalanced (e.g <literal>98x95</literal>), you will need to use the
<Literal>-dpi</Literal> switch which specifies the display resolution in dots
per inch. As a lot of systems use high resolution displays these days,
chances are they'll be working at 100 dpi, or better. While an unbalanced
setting reportedly can really play havoc with some fonts.
</Para>
<Para>
If you start X from the console command prompt, type:
</Para>
<Para>
<Literal>
$ startx -- -dpi 100 -depth 16 # v4.x syntax
</Literal>
</Para>
<Para>
Or these options can be stored in <Filename>~/.xserverrc</FileName>. See the
<Command>startx</Command> and <Command>xinit</Command> man pages for more on
this.
</Para>
<Para>
If you use xdm (or friends such as gdm) for graphical logins, you'll want to
edit your <FileName>/usr/X11/lib/X11/xdm/Xservers</FileName> file (or
possibly <FileName>/etc/X11/xdm/Xservers</FileName>) which will have the
command line for the Xserver in it. Mine has the line:
</Para>
<Para>
<Literal>
:0 local /usr/X11R6/bin/X -dpi 100 -gamma 1.6
</Literal>
</Para>
<Para>
You want to specify a value that is compatible with your monitor's output.
</Para>
<Para>
More information is in the <Command>X</Command>, <Command>Xserver</Command>,
<Command>xdm</Command>, <Command>xinit,</Command> and
<Command>startx</Command> man pages.
</Para>
</Sect2>
</Sect1>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="TrueType">
<Title >TrueType Fonts
</Title>
<para>
Historically, the Unix world relied on Type 1 fonts for high
quality scalable fonts. Linux supports Type 1 quite well, both for
printing and for screen output. But, Type 1 never was widely adopted
by web designers, and on other platforms. TrueType, due to its association
with Windows, is the preferred web font. And XFree86 seems to render
TrueType a little better.
</para>
<para>
You won't find many decent TrueType fonts included with any distribution,
however. The reason is that there are not many quality TrueType fonts
available under a suitable license at this time. In fact, many of the
<quote>free</quote> ones, are rather poor. Many distributions are
including some TrueType fonts, and also including tools for automating the
process of adding TrueType fonts from external sources. See if that is an
option for you. This will be easiest route. You will definitely want
to add some quality TrueType fonts, one way or another.
</para>
<Para>
Because the boys in Redmond are very concerned with the appearance of their
software (as opposed to the internal workings ;), they built TrueType font
support into Windows. And of course no big surprise, but they got the idea
from Apple. In fact, TrueType is a registered trademark of Apple Computer,
Inc. Windows 9x, NT, 2K and nearly every other incarnation of Windows comes
with Arial, Times New Roman, and Courier New, which are roughly equivalent
to Helvetica, Times and Courier. TrueType fonts are scalable, so they look
good in large sizes, and they are well hinted, so they are readable at small
sizes. Many windows applications come with dozens more TrueType fonts.
And let's face it, those MS and Apple fonts are, generally speaking, just
plain better than the freely available ones with a suitable license. Don't
microwave your Windows CD yet, you'll want to get those quality fonts first!
</Para>
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Making TrueType Fonts Available</Title>
<Para>
Let's start with the fonts first. Any TrueType font included with the various
MS Windows incarnations should work. Don't forget word processors and other
apps that may include their own fonts. MacOS fonts will only work if
converted to a usable format. (See the <Link LinkEnd="links">links
section</Link> for converter packages.) There are also some 'free' TrueType
fonts available for download if you have already nuked that CD (see <Link
LinkEnd="links">links section</Link>).
</Para>
<para>
Many distributions are now bundling tools for automating the process of
including quality TrueType fonts. SuSE, Debian, and Mandrake do (Red Hat 7.x
does not at this time). See what packages you might have for this as this
will be the most painless way to go. Essentially, these tools help migrate
fonts from a Windows installation, or download those available from
Microsoft [note 08/15/02 MS has recently removed these fonts!] , and then
handle the installation and configuration all in one neat utility. If you do
have such a utility, the below information may not be necessary!
</para>
<Para>
In order to use TrueType, the fonts will have to be always accessible to
X. This means they will have to be on a filesystem that is
<Emphasis>always</Emphasis> mounted. This can conceivably be a Windows
partition on a dual boot system. Alternately, the fonts can be copied to
Linux. First <Command>su</Command> to root:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# su -
# mkdir -p /usr/local/share/fonts/ttfonts
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Now, change to the new font directory:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# cd /usr/local/share/fonts/ttfonts
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Then, add the fonts to this directory, either by copying them from your
Windows system:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# cp /mnt/&lt;path_to_fonts&gt;/*ttf .
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
or by downloading those available directly from Microsoft:
<Ulink
URL="http://www.microsoft.com/typography/fontpack/default.htm">http://www.microsoft.com/typography/fontpack/default.htm</Ulink>.
Note 08/17/02: Microsoft has recently <emphasis>discontinued this
page</emphasis>. At this time, the following pages (may!) still have these
fonts available (or google search for them):
</Para>
<para>
<simplelist>
<!-- 404
<member>
&nbsp;&nbsp;&nbsp;&nbsp;<ulink url="http://unixlab.cs.put.poznan.pl/pub/Windows/TTF-fonts/">http://unixlab.cs.put.poznan.pl/pub/Windows/TTF-fonts/</ulink>
</member>
-->
<member>
&nbsp;&nbsp;&nbsp;&nbsp;<ulink url="http://nuoriso.hel.fi/__files/ms_truetype_core_fonts_for_the_web/Win95-98-NT/index.html">http://nuoriso.hel.fi/__files/ms_truetype_core_fonts_for_the_web/Win95-98-NT/index.html</ulink>
</member>
<member>
&nbsp;&nbsp;&nbsp;&nbsp;<ulink url="http://web.archive.org/web/20000420210719/http://www.microsoft.com/opentype/fontpack/default.htm">http://web.archive.org/web/20000420210719/http://www.microsoft.com/opentype/fontpack/default.htm</ulink>
</member>
</simplelist>
</para>
<!--
These fonts are in self-extracting zip archives. The ones labeled for use
with Windows 3.1 can indeed be unpacked under Linux with the Linux
<Command>zip</Command> utility:
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# ls *exe | xargs -n 1 unzip -L
</LiteralLayout>
</MSGText>
</Literal>
</Para>
-->
<Para>
<!--
The '-L' option will convert to lower case font names (this may be necessary for
some versions of xfsft and Red Hat's xfs). Note that the current Linux zip
utility does not work with the 32 bit Win9x cab font archives. (It also looks
like Microsoft no longer has the 16 bit Arial, Courier and Times-Roman on
this site.)
-->
These can be unarchived under Linux with
<Command>cabextract</Command>, which can be found
<Ulink
URL="http://www.kyz.uklinux.net/cabextract.php3">http://www.kyz.uklinux.net/cabextract.php3</Ulink>.
This would now seem to be the best way to go at this time.
</Para>
<Para>
A slick solution to this from Sebastiano Vigna is his
<Ulink URL="http://freshmeat.net/webFonts4Linux">
http://freshmeat.net/webFonts4Linux</Ulink>, which automates
the downloading, extracting and installation of the Microsoft fonts
all in one neat package. A utility designed primarily for Red Hat can be found:
<ulink url="http://sourceforge.net/projects/font-tool/">http://sourceforge.net/projects/font-tool/</ulink>,
which includes all the core MS web fonts, plus relevant system configuration.
There is a tarball, as well as RPMs (both require cabextract).
</Para>
<Para>
You can also get an RPM of WebFonts that contains some of the MS Web
fonts from <Ulink
URL="ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm">ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm</Ulink>.
This has enough basic fonts to keep Mozilla and other web browsers happy.
Something similar for Debian is <Ulink
URL="http://packages.debian.org/unstable/graphics/msttcorefonts.html">http://packages.debian.org/unstable/graphics/msttcorefonts.html</Ulink>.
This does not include the actual fonts, but facilitates the installation.
</Para>
<Para>
If doing it yourself, you will also have to include the new TrueType
directory(s) in the X server's fontpath. So with your text editor of choice
add the line(s) as appropriate:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "/usr/local/share/fonts/ttfonts"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<para>
This configuration is for <quote>core X font</quote> support. For
additional configuration relating to the new Xft rendering engine,
see <link linkend="XFT">the sections below on XFT</link> and anti-aliasing.
</para>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect2 id="hinting">
<title>TrueType Hinting</title>
<para>
<quote>Hinting</quote> is a TrueType specific feature, that is generally
considered to be a useful technique that improves the appearance of TrueType
fonts. Unfortunately, there are some licensing and patent issues involved
with this, and it is disabled by default in the freetype sources! And also
quite likely that if you are using vendor supplied binaries, it is disabled
there as well.
</para>
<para>
To enable this feature, the sources need to be rebuilt. Look for
<filename>include/freetype/config/ftoption.h</filename> in the freetype
source tree, and then search for:
</para>
<para>
<screen>
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
</screen>
</para>
<para>
And very simply, make this small change:
</para>
<para>
<screen>
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
</screen>
</para>
<para>
Red Hat users can rebuild the src.rpm by toggling one setting at the top,
and accomplish the same thing:
</para>
<para>
<screen>
%define without_bytecode_interpreter 1
</screen>
</para>
<para>
And change to:
</para>
<para>
<screen>
%define without_bytecode_interpreter 0
</screen>
</para>
<para>
Other vendors may have a similar, easy-to-use mechanism.
</para>
<para>
Then rebuild and install the finished binaries. Be sure to restart X as well
since the freetype code is already loaded into memory by X.
</para>
<para>
Note that <quote>hinting</quote>, <quote>anti-aliasing</quote>, and
<quote>sub-pixel rendering</quote> are separate concepts (see <link
linkend="XFT">the section on Xft below</link> for more). Again, this is not a
cure-all for <quote>ugly</quote> fonts, but one more piece in the puzzle of
font <quote>beautification</quote>.
</para>
</sect2>
<!-- ~ End section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<sect2 id="ttf-config">
<Title>Configuration</Title>
<para>
This section pertains to installing and configuring TrueType fonts
for any <quote>freetype</quote> based font renderer. This would include
the <literal>freetype</literal> font module from XFree86-4.x,
Red Hat's <literal>xfs</literal>, and the <literal>xfsft</literal> font
server. Again, if you have used a distro supplied tool for migrating
TrueType fonts, it is likely this has been done for you already. The
steps described below would only be necessary for manual font installation.
</para>
<Para>
There is still more work to be done before we can actually use any TrueType
fonts. First, all font files must have lower case names. Secondly,
they shouldn't have embedded spaces. And then, we will need to create a
couple of configuration files to make things go.
</Para>
<Para>
Su to root, and change to the directory where the TrueType fonts are.
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# su -
# cd /usr/local/share/fonts/ttfonts
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
If there are any upper case font names, you can use the following script to
convert all names to lower case:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
#!/bin/sh
#
## -------- convert upper to lower case ---------
ls * | while read f
do
if [ -f $f ]; then
if [ "$f" != "`echo \"$f\" | tr A-Z a-z`" ]; then
#Note that 'This' will overwrite 'this'!
mv -iv "$f" "`echo \"$f\" | tr A-Z a-z`"
fi
fi
done
## eof
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Note the punctuation -- the backquotes are important! Remove any spaces from
font names too. Once the TrueType fonts are properly installed, you must
create both <FileName>fonts.dir</FileName> and
<FileName>fonts.scale</FileName> files. The following commands do this:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# ttmkfdir -o fonts.scale
# mkfontdir
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
If you don't have <command>ttmkfdir</command> installed, check your
distribution's repository, or it can be downloaded from:
<ulink url="http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz">http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz</ulink>.
This is necessary!
</Para>
<para>
As of Red Hat 7.1, the above commands are run from the xfs init script.
So restarting xfs (<command>/etc/rc.d/init.d/xfs restart</command>) will
accomplish the same thing for Red Hat users. Other distros may have
similar shortcuts.
</para>
<Para>
You should now have <FileName>fonts.dir</FileName> and
<FileName>fonts.scale</FileName> files in your TrueType font
directory. <Command>ttmkfdir</Command> is in the
<FileName>Freetype</FileName> RPM for Red Hat users, and must be run
before <Command>mkfontdir</Command>. With Debian based distros, there
is a similar utility called <Command>mkttfdir</Command>, and is in the
<Filename>fttools</FileName> Deb package. Though this apparently does not
generate as many encodings as <Command>ttmkfdir</Command>. These commands
may not always report errors, so verify that they were created and are not
empty files:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
$ ls -l fonts.*
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.dir
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.scale
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
If you encounter any problems, try <Command>ttmkfdir</Command> with the
<Command>- m</Command> switch. This will discard bad characters from the
font file. Specify a number such as 50 or l00
(<Command>ttmkfdir -m 50</Command>). The files themselves are text files.
Have a look:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
$ less fonts.dir
114
webdings.ttf -microsoft-Webdings-medium-r-normal--0-0-0-0-p-0-microsoft-symbol
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-ascii-0
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-fcd8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-9
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-1
[...]
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<para>
If <command>ttmkfdir</command> is persistently giving problems by
not generating a proper output file, there may be one or more
<quote>bad</quote> fonts (ie fonts it can't handle). In that
case, just start with a few common ones, like Arial and Verdana.
If this works, then add a few at a time.
</para>
<para>
Now be sure the new fonts are included in the <literal>FontPath</literal>.
And either restart X (Ctrl-Alt-BS), or the font server (if using one).
You could also try refreshing the <literal>FontPath</literal>:
</para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# xset fp rehash
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Red Hat 6.x/7.x users can update the FontPath and xfs:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# chkfontpath --add /usr/local/share/fonts/ttfonts
# /etc/rc.d/init.d/xfs restart
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
You should now be in business. You can check which fonts are available to X:
</Para>
<Para>
<Literal>
$ xlsfonts | less
</Literal>
</Para>
<Para>
or check them out further with <Command>xfontsel</Command>, or
<Command>gfontsel</Command>. If they are visible to
<Command>xlsfonts</Command>, then they are available to X and vice versa. If
they are not there, try restarting X with Ctrl-Alt-BS.
</Para>
<para>
This gets you as far as X knows about your new fonts. Individual applications
will need to be configured to use them. GNOME and KDE will require additional
steps as well (see the respective docs). You will also want to configure
Xft (see <link linkend="XFT">below</link>), if using XFree86 v4.x or later.
</para>
</sect2>
<!-- ~ End section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect2 id="fontservers">
<title>Font Servers</title>
<Para>
Historically, font servers were used to serve fonts over a network. Font
resources could then reside on one host, and clients could access them as
needed. But, the developers have enhanced these to include features such as
the ability to render TrueType fonts. XFree86 4.x <emphasis>does have built
in support</emphasis> for TrueType (see <Xref LinkEnd="x-4x">), making a font
server not a necessity, though some distros default to using a font server
for other reasons now.
</Para>
<para>
XFree86 3.x does not come with built in TrueType support, so you'll have to
add it yourself if you are using a 3.x version. This will mean installing a
supplemental font server that does support TrueType. And, of course,
installing the fonts themselves (see above). See the
<link linkend="appendix">Appendix</link> for font server installation,
and related tips.
</para>
<Para>
Any recent distro will have one or more font servers included, and the
important configuration should be done by the installation program.
</Para>
</sect2>
<!-- ~ End section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2 id="falias">
<Title>The fonts.alias File</Title>
<Para>
<FileName>fonts.alias</FileName> is yet another font configuration file that
can be used to tweak how fonts are handled. Like <FileName>fonts.scale</FileName>
and <FileName>fonts.dir</FileName>, <FileName>fonts.alias</FileName> must be in
the same directory as the fonts you are aliasing. It is not mandatory however,
but does solve certain potential problems. Here is an example from the first
line of<FileName>/usr/X11R6/lib/X11/fonts/misc/fonts.alias</FileName> on
a Red Hat system:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
<Literal>fixed</Literal> is the 'alias' here. Any time this is requested, we
actually get the font definition from the second column. Font too small? Just
change the definition. (Warning: this is a critical file, at least on Red Hat.)
The same principle applies to all fonts, including TrueType. In fact, if you
don't have TrueType, you could conceivably use this trick to have a
comparable Type 1, or other, font aliased as a TrueType.
</Para>
<Para>
<FileName>fonts.alias</FileName> is important for some applications that don't
handle the data provided by <FileName>fonts.scale</FileName> well. Most notably
here is Netscape. Without a <FileName>fonts.alias</FileName> you will find that
Netscape will only show point sizes of 0 and 12 available.
<FileName>fonts.alias</FileName> fixes this. You might also find that if you a
specify another size with the <Literal>scalable font</Literal> option under
<Literal>Preferences</Literal>, Netscape will not remember this setting.
Annoying! This is also fixed. So we really need this file. Sample excerpt from
a <FileName>fonts.scale</FileName>:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-ascii-0
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-fcd8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-1
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
These are scalable so we don't get any predefined point sizes. We will need to
create our <FileName>fonts.alias</FileName> something like this excerpt for
Arial:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
-monotype-Arial-medium-r-normal--6-60-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--7-70-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--8-80-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--10-100-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--9-90-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--11-110-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--10-100-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--11-110-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--12-120-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--13-130-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--13-130-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--14-140-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--14-140-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--15-150-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--15-150-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--18-180-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--18-180-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--24-240-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--24-240-75-75-p-0-iso8859-1
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
(<emphasis>Please note that I have split each line for readability</emphasis>.
There should be two columns all on one line, without the <Quote>\</Quote>, and
separated by at least one space.) This will keep Netscape happy. Also, if
font names should have embedded spaces, then you should enclose the filename
in quotes. You might also note the <Literal>pointsize</Literal> discrepancy
between the first and second columns of the first few rows. The first column
of the first entry has a '6', whereas this is aliased to a '9' in the second
column, and thus '9' point. This is by design and is an excellent way to
overcome the Netscape 'damn tiny fonts' syndrome. Adjust to suit your tastes,
resolution, and eyesight.
</Para>
<Para>
This file can be created manually with a text editor, or conceivably with some
fancy sed or awk scripting. There is an excellent discussion of this file,
and other font related topics at Kristin Aanestad's site at
<Ulink url="http://home.c2i.net/dark/linux.html#ttf">http://home.c2i.net/dark/linux.html</Ulink>. There is
also a link to a python script which can reportedly automatically generate
a <Filename>fonts.alias</FileName> file at this same site. A perl version
of this script is re-printed in the <link
linkend="appendixb">Appendix</link>. Thanks to Kristin whose work and insight
was the inspiration for this section!
</Para>
<para>
Another potential use of <filename>fonts.alias</filename> would be to map
one font to something quite different. Say you don't have TrueType fonts,
and didn't want to install Microsoft's. You could alias nice, scalable Type 1
fonts to a TrueType. That way when the system (or some web page) wants a
TrueType, you'd get something of comparable quality instead of bitmap that
doesn't scale well.
</para>
<Para>
Note that with XFree86 4.0.2 and greater, there are new font handling
mechanisms available via the Xft extensions. Font aliasing is done
in Xft's own configuration file: <Filename>XftConfig</FileName>. This
is the preferred method where anti-aliasing, and the other new rendering
features are desired. See the <Link LinkEnd="AA">Anti-aliasing Section</Link>
for more on this and de-mystification. This is only true where the
application (i.e. the toolkit, e.g QT) itself supports the new extensions!
At this time, not all do (yet).
</Para>
</Sect2>
</Sect1>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="x-4x">
<Title>XFree86 4.x</Title>
<Para>
<Ulink url="http://www.xfree86.org/4.0/">XFree86 4.0</Ulink>
introduced native support for TrueType fonts, along with other new
features. The enhanced font support is based on xfsft from Juliusz
Chroboczek, which in turn is based on the FreeType font library originally
from Mark Leisher, so the configuration is similar to xfsft and Red Hat's
patched xfs which use the same rendering engine. As of 4.0.2, XFree86 begins
to support anti-aliasing which is a technique for smoothing font outlines
(see section below).
</Para>
<Para>
The <Literal>FontPath</Literal> is still in <FileName>XF86Config</FileName>, as
always. For Red Hat 6/7 using a stock XFree86 4.x (i.e. NOT the Red Hat 7.x
supplied version), this will mean moving the Red Hat xfs
<Literal>FontPath</Literal> from <FileName>/etc/X11/fs/config</FileName> back
to <FileName>XF86Config</FileName>. A separate font server is no longer
needed just for TrueType support. You may disable it, unless it is needed to
serve fonts to other clients in a network environment. Or you may want to
still use it since there may be a very small performance gain in some
situations (at the cost of more memory utilized). See the section below for
Red Hat 7.x specific configuration issues.
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
Section "Files"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
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/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/share/fonts/default/Type1"
FontPath "/usr/local/share/fonts/ttfonts"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
EndSection
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
In order to use TrueType, you must also specify which font
<Literal>module</Literal> the X server should be using in the "Module"
section:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
Section "Module"
Load "freetype"
Load "speedo"
Load "type1"
&lt;load other modules....&gt;
EndSection
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
Note that there can be only one 'Module' section, so include any other
modules here as well. Again, this is the kind of configuration that your
distro should be doing during installation, and may not be
necessary, unless you are upgrading, or want to make manual changes
yourself.
</Para>
<Para>
You also must have a <FileName>fonts.scale</FileName> and
<FileName>fonts.dir</FileName> file for each TrueType font directory, just like
for xfsft and Red Hat's xfs (see Appendix). <command>ttmkfdir</command>,
<ulink url="http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz">http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz</ulink>,
will come in handy for <FileName>fonts.scale</FileName> if it is not
already installed. See the
<link linkend="ttf-config">Configuration</link> section above for more
details and examples.
</Para>
<Para>
<Literal>xtt</Literal> is another available TrueType module that is best known
for supporting ideographic (Oriental) type fonts. You can use either, but only
one at a time.
</Para>
<Para>
Most X server command line options are still the same as previous versions of X:
</Para>
<Para>
<Literal>
$ startx -- -dpi 100
</Literal>
</Para>
<!-- ~~~~~ New section ~~~~~ -->
<sect2 id="xft">
<title>Xft and Core Fonts</title>
<para>
As mentioned, the new font handling improvements are the result of the
development work behind <ulink
url="http://www.keithp.com/~keithp/render/Xft.tutorial">Xft</ulink>. Xft is
an on-going effort to improve and modernize X's font handling. The end
result will be radically different from the traditional X font handling
(known as <quote>core X fonts</quote>).
</para>
<para>
What we have now is essentially two different systems: one that has been
around since the dawn of time (or even before :), and one that is radically
new and <emphasis>still evolving</emphasis>! I emphasize this, since the
<quote>still evolving</quote> part is likely to cause some confusion until
the dust settles.
</para>
<para>
The initial release of Xft v1.0 with XFree86 4.0.2 is controlled by its
configuration file, <filename>XftConfig</filename>. This changes with later
versions, where the font configuration is handled by the
<command>fontconfig</command> library, with its main configuration typically located
<filename>/etc/fonts/fonts.conf</filename>. Of course, additional
development has brought other improvements as well. For more on the
Xft and Fontconfig, see the Fontconfig home page,
<ulink url="http://fontconfig.org/">http://fontconfig.org/</ulink>.
</para>
<para>
What we, as end users, will notice and appreciate most, is the anti-aliasing
support and other rendering enhancements we get from Xft. Though this is not
the only benefit.
</para>
</sect2>
<!-- ~ End section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2 id="AA">
<Title>Anti-aliasing</Title>
<Para>
Anti-aliasing is a technique for producing even smoother, crisper looking
fonts by subtly softening the sharp, jagged edges. This has long been a
feature of Apple and Microsoft font rendering, and is now making it's way
into X via the X Rendering Extension specification. The new extensions
provide other benefits as well. Distributions that support anti-aliasing with
their stable/official versions are now being released.
</Para>
<Para>
That is the good news. The bad news is that not all drivers support
anti-aliasing yet. This is a moving target, so you will have to dig around to
find whether your chipset is supported or not. The recently released 4.2
should have near universal support. More not-so-good news is that not all
applications are actually taking advantage of this yet. We will have
to wait for the various toolkits (TK, Xaw, etc) to catch up. KDE
is an exception, and has had strong AA support via the QT toolkit. The
recently released GNOME-2, has AA support now too.
</Para>
<para>
Anti-aliasing is not a cure-all, but is another piece of the font puzzle.
Some point sizes may look better if not anti-aliased, and some systems
just may not handle the various rendering enhancements as well as others.
</para>
<Para>
If you are reading this long after the publication date (October 2002),
hopefully most of these shortcomings will have been overcome. All hardware will
eventually be supported, mainstream distros will have shipped releases that
include the new extensions, and they will be enabled by default. Many apps
will look better since they will be <Quote>AA</Quote> aware, and we won't
have to jump through any configuration hoops just to make it work. In the
meantime, read on ...
</Para>
<Sect3>
<Title>Requirements</Title>
<Para>
Minimum requirements for Anti-Aliasing:
</Para>
<Para>
<ItemizedList>
<ListItem>
<Para>
XFree86 4.0.2 or later.
</Para>
</ListItem>
<ListItem>
<Para>
You graphic card's driver has to support anti-aliasing. If
4.0.2 (or greater) is already installed, you can get this information
direct from the driver with <Command>xdpyinfo</Command>. Run this and
look for <Quote>Number of Extensions:</Quote>. If this lists <Quote>RENDER</Quote> among them, then you should be good to go. If not, well, it isn't going
to work, and you will have to wait for an updated driver.
</Para>
</ListItem>
<ListItem>
<Para>
The Freetype2 library available from
<Ulink URL="http://www.freetype.org">http://www.freetype.org</Ulink>, and
also now bundled with XFree86. XFree needs to be linked against this, so
install and build first if building from scratch. Your distro should have
Freetype packages as well. Just make sure it is
<Filename>freetype-2</FileName>.
</Para>
</ListItem>
<ListItem>
<Para>
TrueType fonts are best for display purposes. Type 1 is also good,
but may not render quite as well. See above sections.
</Para>
</ListItem>
<ListItem>
<Para>
For KDE users, KDE supports anti-aliasing as of 2.x. This will require
QT-2.3.0 or later, and built with Xft support. A nice font HOWTO from
Troll Tech for KDE and QT can be found: <Ulink
URL="http://trolls.troll.no/lars/fonts/qt-fonts-HOWTO.html">http://trolls.troll.no/lars/fonts/qt-fonts-HOWTO.html</Ulink>.
</Para>
<Para>
GNOME 1.x does not support anti-aliasing.
GNOME 2.0 has recently been released and does have native support for
anti-aliasing.
</Para>
</ListItem>
<ListItem>
<Para>
Applications that <Quote>know</Quote> about anti-aliasing. Not necessarily
at the individual application level, but the libraries and toolkits (GTK,
TK, etc.) that the application are built against, must be able to use the new
features. At this time, not all do. KDE/QT is first out of the
box and has good support. Also, <Command>xterm</Command> (yes,
<command>xterm!</command>) supports the new
extensions. An interesting example scavenged off usenet:
</Para>
<para>
<screen>
<![CDATA[
From torvalds@penguin.transmeta.com Sun Apr 28 02:09:28 2002
From: torvalds@penguin.transmeta.com (Linus Torvalds)
Newsgroups: comp.os.linux.x
Subject: Re: X font recommendation
Organization: Transmeta Corporation
Lines: 24
Message-ID: <aa4ijq$259$1@penguin.transmeta.com>
Cache-Post-Path: palladium.transmeta.com!unknown@penguin.transmeta.com
Date: Tue, 23 Apr 2002 21:10:18 +0000 (UTC)
X-Trace: news.sjc.globix.net 1019596253 63.209.4.196 (Tue, 23 Apr 2002 14:10:53 PDT)
NNTP-Posting-Date: Tue, 23 Apr 2002 14:10:53 PDT
In article <aa492r$7hc5u$2@ID-99293.news.dfncis.de>,
William Park <opengeometry@NOSPAM.yahoo.ca> wrote:
>Peter Karlsson <root@localhost.localdomain> wrote:
>> What's wrong with "fixed"? :-)
>>
>> xterm -sb -sl 10000 -fg yellow -bg black -geometry 120x40 -fn fixed -bc
>
>This will load the default 6x13 fonts, aka.
> -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
>A bit too small, though it has correct proportions. If there is bigger
>size (8x16, 10x20, 12x24) of that fonts, then that would be ideal.
If you like anti-aliased fonts, the command line I prefer happens to be
xterm -geometry 100x40 -fa andale:size=11:charwidth=6
I think that font is from the MS free fontpack.
In order for it to work for you, you need to have the anti-aliasing
truetype fonts working well, and probably a good monitor (and some
people _hate_ that rounded look from anti-aliasing, and find it fuzzy
even then).
Linus
]]>
</screen>
</para>
<para>
You might have to experiment with the <literal>size</literal>
and <literal>charwidth</literal> values to get reasonable
results.
</para>
</ListItem>
<ListItem>
<Para>
The new rendering extensions configuration file,
<Filename>XftConfig</FileName>, must be configured for the fonts you want
to use. Note that as of Xft2, this changes to
<filename>/etc/fonts/fonts.conf</filename>.
</Para>
</ListItem>
<ListItem>
<Para>
The new extensions supplant much of what we have been doing with font
servers like xfs. <Filename>fonts.alias</FileName> and similar
configuration files, for instance, are not used for fonts that are
being controlled by the new extensions. Essentially, this gives us
two separate font handling engines: the traditional, <quote>core</quote>
font engine, and the new, Xft engine. The core engine is still used
in some situations.
</Para>
</ListItem>
</ItemizedList>
</Para>
</sect3>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect3>
<Title>Installation</Title>
<Para>
Keith Packard has a very brief summary of the steps required for building,
installing and configuring from source at <Ulink
URL="http://www.xfree86.org/~keithp/render/aafont.txt">http://www.xfree86.org/~keithp/render/aafont.txt</Ulink>. No need to reprint it here.
</Para>
<Para>
Newer distro releases are likely to have the foundation support for
anti-aliasing available now. Red Hat, for instance, has it available as of
Red Hat 7.1.
</Para>
<Para>
To verify the necessary components, first make sure the
<Quote>freetype</Quote> module (and any others) are loaded. Check the X
server output:
</Para>
<LiteralLayout>
(II) LoadModule: "freetype"
(II) Loading /usr/X11R6/lib/modules/fonts/libfreetype.a
(II) Module freetype: vendor="The XFree86 Project"
compiled for 4.0.3, module version = 1.1.9
Module class: XFree86 Font Renderer
ABI class: XFree86 Font Renderer, version 0.2
(II) Loading font FreeType
</LiteralLayout>
<Para>
Then verify if the <Quote>RENDER</Quote> extension is available, either check
with <Command>xdpyinfo</Command>, or check the X server log, typically
<Filename>/var/log/XFree86.0.log</FileName>:
</Para>
<LiteralLayout>
(II) Initializing built-in extension MIT-SHM
(II) Initializing built-in extension XInputExtension
(II) Initializing built-in extension XTEST
(II) Initializing built-in extension XKEYBOARD
(II) Initializing built-in extension LBX
(II) Initializing built-in extension XC-APPGROUP
(II) Initializing built-in extension SECURITY
(II) Initializing built-in extension XINERAMA
(II) Initializing built-in extension XFree86-Bigfont
(II) Initializing built-in extension RENDER
</LiteralLayout>
<Para>
If <Quote>RENDER</Quote> is there, anti-aliasing and the other advanced
rendering extensions should be available. If not, the system should
gracefully fall back to the core X fonts engine.
</Para>
</Sect3>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect3>
<Title>Xft Configuration (XftConfig)</Title>
<Para>
By Danny Tholen <Email>obiwan@mailmij.org</Email>
</Para>
<Para>
Xft is an interface to the freetype rasterizer written by Keith Packard,
member of the XFree86 Project, Inc. It allows applications to use fonts from
the new X render extension using a unified font naming scheme. In
<Filename>/etc/X11/XftConfig</FileName> (or
<Filename>/usr/X11R6/lib/X11/XftConfig</FileName>) you will find a
configuration file which can be adapted to suit your personal taste. In this
section I will explain the syntax and demonstrate some things you can do
with this file.
</Para>
<Para>
The following information is based on 4.0.3. 4.1 is just released, and there
may be a few new wrinkles not touched on here. Future versions are sure
to bring even more radical changes.
</Para>
<para>
Note that Xft2 makes radical changes to Xft configuration.
<filename>XftConfig</filename> is obsoleted and replaced by the new
<ulink url="http://fontconfig.org">fontconfig</ulink> libraries. Red Hat 8.x
users should read the <link linkend="rh80">Red Hat 8.0 Differences</link>
section first. Many of the principles described still apply, but the
configuration is radically different. FYI.
</para>
<!-- ~~~~~ New Section ~~~~~ -->
<Sect4 id="xftstructure">
<Title>XftConfig Structure</Title>
<Para>
The basic structure revolves around a 'pattern'. A pattern is a set of
name/value-list pairs, each value-list contains one or more typed values. A
certain application requests a font, for example:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
family: "Arial"
size: 12
encoding: "iso8859-1"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
A size 12 arial font in latin-1 encoding. The Xft extension will now try to
patch this pattern to all of the fonts available in the system. And
selecting the one with the best score. Before the matching is done Xft looks
in <Filename>XftConfig</FileName>. The requested pattern can here be extended
before use. An example is:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match any family == "Arial" edit antialias = true;
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
This will enable anti-aliasing for all fonts of the family Arial.
</Para>
<Para>
Also, the X server is queried to list all of its fonts; the XLFD contains
just enough information to match fonts roughly.
</Para>
<Para>
Here's a list of attributes used in matching fonts (in priority order, this
may not be up to date anymore!):
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
foundry font foundry (string, like <Quote>monotype</Quote>)
encoding font encoding (string, like <Quote>iso8859-1</Quote>)
spacing font spacing (integers or proportional (0), mono (100),
charcell (110))
bold is the font bold? (boolean)
italic is the font italic? (boolean)
antialias is the font anti-aliased? (boolean)
family font family (string)
size font size (double)
style font style (string, like "Bold Italic")
slant font slant (roman, italic, oblique)
weight font weight ( integers or light, medium (100), demi-bold,
bold, black)
rasterizer not yet used (probably "TrueType", "Type1", ...)
outline are outlines available? (boolean)
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</Sect4>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect4>
<Title>XftConfig Syntax</Title>
<Para>
<ItemizedList>
<ListItem>
<BridgeHead renderas=sect3>dir</BridgeHead>
<Para>
Adds a directory to the list of places Xft will look for fonts. There is no
particular order implied by the list; Xft treats all fonts about the same.
</Para>
</ListItem>
<ListItem>
<BridgeHead renderas=sect3>include and includeif</BridgeHead>
<Para>
Cause Xft to load more configuration parameters from the indicated file.
"includeif" doesn't elicit a complaint if the file doesn't exist. If the
file name begins with a <Quote>~</Quote> character, it refers to a path
relative to the home directory of the user. This is useful for
user-specific configurations.
</Para>
</ListItem>
<ListItem>
<BridgeHead renderas=sect3>match edit</BridgeHead>
<Para>
If a pattern from an application matches the pattern after
<Quote>match</Quote>, it is edited with the instructions in
<literal>edit</literal>. The pattern match is done as follows:
</Para>
<Para>
<LiteralLayout>
match <Literal>qual FIELD-NAME COMPARE CONSTANT</Literal>
</LiteralLayout>
</Para>
<Para>
where qual is either <Literal>any</Literal> (matches one specific font)
or <Literal>all</Literal> (matches all fonts). An example:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match all foundry==<3D>monotype<70>
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
which will match (and edit) all fonts belonging to the foundry
<Quote>monotype</Quote>.
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match any family==<3D>arial<61>
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
will match (and edit) one specific font with the family name
<Quote>arial</Quote>.
</Para>
<Para>
<Literal>FIELD-NAME</Literal> is any one of the properties found in the
above section <Link LinkEnd="xftstructure">Structure</Link>, or additionally:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
pixelsize font size in pixels (integer)
charspace character space (integer)
minspace minimal spacing (integer)
rgba color hinting (string <20>rgb<67> or <20>bgr<67> and
vertical hinting <20>vrgb<67> <20>vbgr<67>), aka sub-pixel hinting
xlfd x server font (string, type xlsfonts to
see a list of your xlfd strings)
file the font file (string)
core use X core fonts? (boolean)
render use render fonts? (boolean)
index I have no idea what this does:)
scalable is the font scalable (boolean)
scale scale the font (integer)
charwidth character width (integer)
charheight character height (integer)
matrix no idea (not really at least)
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
<Literal>COMPARE</Literal> can be <Literal>&lt;</Literal>,
<Literal>&gt;</Literal>, or <Literal>==</Literal>.
</Para>
<Para>
<Literal>CONSTANT</Literal> is the value of the field-name in the
appropriate type (see above section <Link
LinkEnd="xftstructure">Structure</Link>).
</Para>
<Para>
You can use multiple matches before you use the <Quote>edit</Quote>
statement:
</Para>
<Para>
<LiteralLayout>
edit <Literal>FIELD-NAME ASSIGN EXPR SEMI</Literal>
</LiteralLayout>
</Para>
<Para>
Where <Literal>ASSIGN</Literal> can be one of <Literal>=</Literal>,
<Literal>+=</Literal> or <Literal>=+</Literal>. With
<Literal>=</Literal>, the matching value in the pattern will be replaced
by the given expression. <Literal>+=</Literal> or <Literal>=+</Literal>
will prepend/append a new value to the list of values for the indicated
field.
</Para>
<Para>
<Literal>EXPR</Literal> sets the <Literal>FIELD-NAME</Literal> to a value.
</Para>
<Para>
<Literal>SEMI</Literal> is a semicolon (<Literal>;</Literal>). You can
use multiple instructions, separated by a semicolon. See below for
examples if this is confusing.
</Para>
</ListItem>
</ItemizedList>
</Para>
</Sect4>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect4>
<Title>XftConfig Examples</Title>
<Para>
And now I<>ll try to list a few useful configurations and explain them. Note
that it is configured for my system, and I may use different fonts than you,
so try to adapt the examples to your own needs.
</Para>
<Para>
<OrderedList>
<ListItem>
<Para>
How do I make fonts available to Xft?
</Para>
<Para>
List your Type 1 and TrueType font directories with <Quote>dir</Quote>. On my
system (Mandrake 7.2) this becomes:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
dir "/usr/X11R6/lib/X11/fonts/Type1"
dir "/usr/X11R6/lib/X11/fonts/drakfont"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</ListItem>
<ListItem>
<Para>
How do I use a user specific XftConfig file?
</Para>
<Para>
Put an <Filename>.xftconfig</FileName> file in your user directory and add:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
includeif "~/.xftconfig"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
to your standard <Filename>XftConfig</FileName>. This will enable a user
specific configuration file, but it will not complain if there is no such
file.
</Para>
</ListItem>
<ListItem>
<Para>
How do I make aliases for my fonts?
</Para>
<Para>
I noted that my KDE console asks for <Quote>mono</Quote> fonts when it is
looking for a fixed font. <Quote>console</Quote> is used when I select
<Quote>linux</Quote> in the font menu of the KDE konsole. Therefore, I used
two aliases for fonts which are also named <Quote>fixed</Quote>:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match any family == "fixed" edit family =+ "mono";
match any family == "console" edit family =+ "mono";
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</ListItem>
<ListItem>
<Para>
Anti-aliasing my fonts are blurry and makes me dizzy!
</Para>
<Para>
Although there is a big fuzz around AA in X, good fonts actually look better
if they are not anti-aliased. The anti-aliasing blurs the fonts by adding
gray pixels to the edges, and this may strain your eyes if you looking at
them for a long time. (Your eyes will try to get the fonts sharper, which
of course is not working because they are blurred;) However, for very small
fonts, anti-aliasing may increase the readability of the fonts, because with
sharp edges, there are too little pixels available for your mind to figure
out what it means. And for bigger fonts, the edges become very jagged when
not anti-aliased, so here you also might want to have aliased fonts. Of course
you can also turn off the anti-aliasing for specific fonts. In other
operating systems, most truetype fonts are not anti-aliased between 8 and 12
pixels, while only large Type1 fonts are anti-aliased.
</Para>
<Para>
Use the following in your <Filename>XftConfig</FileName> to anti-alias only
fonts of specific sizes:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match
any size > 8
any size < 15
edit
antialias = false;
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</ListItem>
<ListItem>
<Para>
My fixed fonts do not appear or look _very_ wrong in the KDE konsole or
similar programs!
</Para>
<Para>
I noted that somehow a lot of fixed font do not tell Xft that they are
fixed, and thus, mono spaced. Therefore only a part of the font is
displayed. We can manually set the spacing for these fonts (this assumes you
have fixed aliased with mono as in question 3 above):
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match
any family == "mono"
edit
spacing = mono;
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</ListItem>
<ListItem>
<Para>
My Symbol, Webdings, etc. fonts do not show up!
</Para>
<Para>
For some reason some (symbol) fonts are not correctly recognized, and Xft
will show your default font, or a font which has the closest match (which
is generally not what you mean at all). For Adobe Symbol and MS-webdings I
did the following to get them working:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match
any family == "webdings"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "symbol"
edit
antialias = false;
encoding += "glyphs-fontspecific";
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
A useful way of figuring out these things is to activate debugging with:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
export XFT_DEBUG=1024
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
This will generate a lot of output, especially if you have many fonts,
because it lists the properties and scores of every font available. You can
also use other values. For a nice summary of what happens (requested font,
XftConfig substitutions, X server additions and the finally matched font),
you can use XFT_DEBUG=2.
</Para>
</ListItem>
<ListItem>
<Para>
Why do my KDE programs start now soooo slooow?
</Para>
<Para>
The Xft mechanism in XFree prior to 4.1 had to parse the
<Filename>XftConfig</FileName> file each time a program was started. And the
info of all these fonts had to be re-read. As of X 4.1.0, a cache is used
and starting applications using Xft is much faster. Especially if you have
many fonts this can be very useful. So, upgrading XFree86, and related
packages, is a good idea.
</Para>
</ListItem>
<ListItem>
<Para>
I have a LCD screen on my laptop, can I use sub-pixel hinting instead of
normal anti-aliasing?
</Para>
<Para>
Yes you can. Sub-pixel hinting uses colors instead of gray pixels to do the
AA. I do not have a LCD screen so I do not have any idea of how it looks
but you can play with the <quote>rgba</quote> setting. Try:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
match edit rgba=bgr;
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
or use rgb if you have a different type of monitor. For vertical AA you can
try vbgr and vbgr.
</Para>
</ListItem>
<ListItem>
<Para>
My fonts still look bad!
</Para>
<Para>
Good quality fonts are needed to start with. If you do not have some good
TrueType fonts, it is worth it to go and look for them on the Internet.
Other reasons why your fonts still look bad can be because of your build of
freetype2. Snapshots versions before 2.0.2 were compiled with an option
that had some patent issues. Therefore, the standard 2.0.2 and 2.0.3
compiles without this option. To fix this, download the freetype2 source
rpm and change in include/freetype/config/ftoption.h line 314:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
to:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
and rebuild with this modified source. See the freetype2
<Filename>README</FileName> file for details. Adobe Courier looks terrible
on my system, so I made an alias so that Lucida console is displayed
instead. If anyone can get it to display nicely I would appreciate knowing
about it.
</Para>
</ListItem>
</OrderedList>
</Para>
<Para>
This is my <Filename>XftConfig</FileName>:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
#
# XftConfig
#
# By: Danny Tholen
#
# Use with Type1 and TrueType fonts
#
dir "/usr/X11R6/lib/X11/fonts/Type1"
dir "/usr/X11R6/lib/X11/fonts/drakfont"
dir "/usr/share/fonts/default/Type1"
#
# alias 'fixed' and 'console' for 'mono'
# (some programs ask for 'mono' if they mean 'fixed';)
#
match any family == "fixed" edit family =+ "mono";
match any family == "console" edit family =+ "mono";
#
#Check users config file
#
includeif "~/.xftconfig"
#
# Use TrueType fonts for defaults
# Danny: disabled
#match any family == "serif" edit family += "Times New Roman";
#match any family == "sans" edit family += "Verdana";
#
# Use lucida console as default fixed type font
# and set the spacing of "mono" to 100, this
# fixes broken fonts which are fixed, but do not
# set mono-spacing.
match
any family == "mono"
edit
family += "lucida console";
spacing = 100;
#
# Alias between XLFD families and font file family name, prefer local fonts
#
match any family == "Charter" edit family += "Bitstream Charter";
match any family == "Bitstream Charter" edit family =+ "Charter";
match any family == "Lucidux Serif" edit family += "LuciduxSerif";
match any family == "LuciduxSerif" edit family =+ "Lucidux Serif";
match any family == "Lucidux Sans" edit family += "LuciduxSans";
match any family == "LuciduxSans" edit family =+ "Lucidux Sans";
match any family == "Lucidux Mono" edit family += "LuciduxMono";
match any family == "LuciduxMono" edit family =+ "Lucidux Mono";
#
# TrueType font aliases
#
match any family == "Comic Sans" edit family += "Comic Sans MS";
match any family == "Comic Sans MS" edit family =+ "Comic Sans";
match any family == "Trebuchet" edit family += "Trebuchet MS";
match any family == "Trebuchet MS" edit family =+ "Trebuchet";
match any family == "Monotype" edit family =+ "Monotype.com";
match any family == "Andale Mono" edit family += "Monotype.com";
match any family == "Monotype.com" edit family =+ "Andale Mono";
# Danny:
# set the AA for different fonts
#
# most TT fonts do not need to be aliased between
# 8 and 15 points, although this might be a matter of taste.
match
any size > 8
any size < 15
edit
antialias = false;
# Danny: Courier looks terrible, and I
# cannot get most characters to fit nicely
# in their space. So I use courier 10 pitch
match
any family == "courier"
edit
family += "courier 10 pitch";
# these are symbols, and for some reason this needs to be added!:
match
any family == "webdings"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "symbol"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "Standard Symbols L"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "dingbats"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "Cursor"
edit
antialias = false;
encoding += "glyphs-fontspecific";
# maybe arial looks better like this?:
match
any family == "Arial"
any size > 7
any size < 15
edit
antialias = false;
# end
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</Sect4>
</Sect3>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect3 id="gtkaa">
<title>GTK and GNOME</title>
<para>
As mentioned above, KDE and QT do have solid anti-aliasing support with
recent releases. GNOME-2 has just recently been released as of this writing
(as of Aug 2002), and does have support for anti-aliasing, though is
not in widespread use (yet).
</para>
<para>
There is also the gdkxft project available at
<ulink url="http://sourceforge.net/projects/gdkxft/">http://sourceforge.net/projects/gdkxft/</ulink>.
This will add anti-aliasing support to GTK+ 1.2 applications (only!). This is
a stand-alone library and not a patch. It will only effect GTK+ 1.x widgets
(many of them but not all). There are some limitations, but mostly it works
as advertized. Read the included <filename>README</filename> closely, and
follow the instructions. An initial installation provides a good starting
point. I added some font families to <filename>/etc/gdkxft.conf</filename>
and I used some of Danny's suggestions above, and it seems to work
<application>mostly</application>. It's a bit of a kludge, but quite a nice
kludge ;-) Note, sadly this project seems to be no longer maintained.
</para>
<para>
There is also a couple of ways to get this working with Mozilla! On the same
page above is a replacement library that can be substituted for the Mozilla
library of the same name. Just a drop in replacement. But, this did not work
here (on Red Hat 7.2), it segfaulted. But building Mozilla from source with
the patch listed, did indeed work nicely! This step requires gdkxft to
be working as well. So it's a two step process to get Mozilla working, but
worth the effort if you want the best looking pages IMHO. There are also
development versions of Mozilla available from
<ulink
url="ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/">ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/</ulink>
that have Xft/TrueType support (see <link linkend="mozilla">the section
on Mozilla below</link>). Native Mozilla Xft support is probably working
its way into mainstream releases. [Note: This should happen with Mozilla
1.2.]
</para>
<!--
<para>
For RPM users, there is a spec file in the tarball, and an RPM can be built
with <quote>rpm -tb &lt;tarball&gt;.tgz</quote>. Then install the binary RPM
that is produced from that.
</para>
-->
</sect3>
<!-- ~ End section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect3>
<Title>Afterword</Title>
<Para>
You've gone through all the steps, and verified that the
<Quote>RENDER</Quote> extension is available, but you don't perceive a
difference? Well, maybe the applications themselves just aren't there yet,
and are not able to utilize these new features. Netscape, for
instance, is not able to take advantage of anti-aliasing.
</Para>
<Para>
So how to know what does and does not make use of anti-aliasing? A quick test
is to use something like xmag, or gimp, and enlarge the text considerably.
Look for diagonal lines, and if they are clearly stair-stepped with no
softened edges. If so, then while anti-aliasing is technically available, it
is not being used. With anti-aliasing you should see gradients instead of
well defined sharp edges. You can compare this with xterm and
<Quote>AA</Quote>:
</Para>
<Para>
<Literal>
$ xterm -fa charter -fs 14
</Literal>
</Para>
<para>
You can also turn on Xft debugging:
</para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
$ export XFT_DEBUG=2
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<para>
Then start apps from that same terminal. This will tell if anti-aliasing is
active for each font as its processed. This also gives some insight into
how Xft understands font names and other details.
</para>
<para>
One final point: anti-aliasing and TrueType are completely separate
issues. One does not depend on the other, though both together can
enhance appearance significantly. Especially, with good quality TrueType
fonts! But any font can potentially be anti-aliased.
</para>
</Sect3>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Red Hat 7.x and 8.x Differences</Title>
<!-- ~~~~~ New section ~~~~~ -->
<sect3>
<title>Red Hat 7.x</title>
<Para>
Red Hat 7.0 introduced some changes to X configuration over previous Red Hat
versions. It is also different from the stock XFree86 configuration as
addressed above. Notable differences:
</Para>
<Para>
<ItemizedList>
<ListItem>
<Para>
Both XFree86 3.3.6 and 4.x are included. If upgrading you may wind up
with 3.3.6. The X configuration file is <Filename>XF86Config</FileName> for
3.3.6 and <Filename>XF86Config-4</FileName> for 4.x. Of course, you'll need
to know which is which for editing and configuration purposes.
</Para>
</ListItem>
<ListItem>
<Para>
xfs is still handling all font duties. A default Red Hat 7.x installation
does not use the 'modules' section of XF86Config-4 for font handling.
Instead it relies on xfs, which has this capability built in. This is
different from a stock installation of XFree86 4.x where the X server does
all the font work -- including TrueType.
</Para>
</ListItem>
<ListItem>
<Para>
The socket for xfs is "unix/:7100" with RH 7.x, as opposed to "unix/:-1" in
previous versions (i.e. Red Hat 6.x).
</Para>
</ListItem>
<listitem>
<para>
As of Red Hat 7.1, the xfs init script actually runs
<command>mkfontdir</command> and <command>ttmkfdir</command> on
font directories known to xfs. So this step is not necessary when
new fonts are added. Just restart xfs.
</para>
</listitem>
</ItemizedList>
</Para>
</sect3>
<!-- ~ End section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect3 id="rh80">
<title>Red Hat 8.0</title>
<para>
Red Hat 8.0 still includes XFree86 4.2, but it includes some significant
changes! It is not clear at this time whether these are running changes
to 4.2, or Red Hat has ported changes that are scheduled to appear in
the soon to be released XFree86 4.3. Noteworthy changes:
</para>
<para>
<itemizedlist>
<listitem>
<para>
XFree86 3.3.6 is no longer bundled.
</para>
</listitem>
<listitem>
<para>
<filename>XF86Config-4</filename> is deprecated in favor of
<filename>XF86Config</filename> (X still uses the former if available
though).
</para>
</listitem>
<listitem>
<para>
The next generation of Xft is now used: Xft2! This means significant
changes to font configuration, i.e <filename>XftConfig</filename> is no
longer used in favor of <filename>/etc/fonts/font.conf</filename>, which
is now an xml document (with much of the same functionality). See
man fontconfig, and fc-cache.
</para>
</listitem>
<listitem>
<para>
The preferred location for fonts is now
<filename>/usr/share/fonts/</filename> and <filename>~/.fonts/</filename>.
The system will automatically recognize, and include, any fonts (including
TrueType) in these locations. See
<filename>/etc/fonts/fonts.conf</filename>.
</para>
</listitem>
<listitem>
<para>
Red Hat 8.0 of course includes GNOME-2, which has native anti-aliasing
support for GTK apps.
</para>
</listitem>
<listitem>
<para>
The xfs font server is still being used.
</para>
</listitem>
</itemizedlist>
</para>
</sect3>
</Sect2>
</Sect1>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="apps">
<Title>Adjusting Fonts in Specific Applications</Title>
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2>
<Title>Netscape</Title>
<para>
Note that Netscape 4.x should be considered obsolete these days. There
are much better choices including Mozilla, Galeon and Konqueror. This
section is being maintained for historical reasons; for those users
who may have to use older Netscapes for one reason or another; and
because it may have relevance to other applications.
</para>
<Para>
Let's face it, Netscape is an important application in Linux. We all use it,
and we all need it, so let's look at it specifically for a minute. An out of
the box Netscape installation is prone to the font problems we've discussed --
large fonts that get pixelized, splotchy looking fonts, fonts so small they
are unreadable. In short, ugly. Maybe this is why you are here?
</Para>
<Para>
Hopefully, at this point you have followed the above suggestions. These steps
can help greatly. TrueType font availability is almost a necessity. Many web
pages specify font families -- like Arial -- that are not typically available
to Linux users. This is bad design, but having some of the basic TrueType
fonts available will help greatly in overcoming the short-sightedness of some
designers. Microsoft -- can't live with 'em, can't live without 'em.
</Para>
<Para>
Assuming you have TrueType working, from the Netscape menu select
<Literal>Edit -> Preferences -> Fonts</Literal>. Open the <Literal>Variable
Width Font</Literal> droplist on the right side of the window. Your TrueTypes
should be there along with other fonts. Choose which ever one suits your fancy
as the default. Check the <Literal>Allow Scaling</Literal> checkbox too. If
the available point sizes are 0 and 12, you can go down and, and enter your
desired point size in the box to the right and click on the
<Literal>OK</Literal> button. The down-side to this is that Netscape will not
remember these settings, and you will have to do this each time you start
Netscape. <Emphasis>Unless</Emphasis> -- you have
<FileName>fonts.alias</FileName> set up already. Then this will solve these
problems. See <Xref LinkEnd="falias"> for more on <FileName>fonts.alias</FileName>.
</Para>
<Para>
You might consider experimenting with some <FileName>~/.Xdefaults</FileName> (or
perhaps it's<FileName>~/.Xresources</FileName> on your system) settings too:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
Netscape*DocumentFonts.sizeIncrement: 10
Netscape*documentFonts.maximumPoints: 240
Netscape*documentFonts.xResolution*iso-8859-1: 120
Netscape*documentFonts.yResolution*iso-8859-1: 120
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
The 'sizeIncrement' controls how much of a jump Netscape makes when different
'basefont' sizes are specified ala:
</Para>
<Para>
<Literal>
&lt;basefont size=7&gt;
</Literal>
</Para>
<Para>
for instance. The default is '20', which is a pretty good jump. Changing this
can help Netscape from scaling to too large and too small of a font. The x and
y resolutions are roughly equivalent to 'dpi' settings. Any random number
within reason can be used here. Experiment. Note: Mozilla does not use
this kind of configuration!
</Para>
<Para>
Then run:
</Para>
<Para>
<Literal>
$ xrdb -merge ~/.Xdefaults
</Literal>
</Para>
<Para>
(or <FileName>.Xresources</FileName> as the case may be) and restart Netscape.
There are many settings that can be tweaked or altered this way. Look at the
<FileName>Netscape.ad</FileName> (app defaults) file that should be included
with Netscape packages.
</Para>
<Para>
If this approach does not get the job done as far as the 'tiny fonts' problem
in Netscape, then see the <Filename>fonts.alias</FileName> section above. You
can really fine tune many things with this approach.
</Para>
</Sect2>
<!-- ~ End section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect2 id="mozilla">
<title>Mozilla</title>
<para>
Mozilla configuration should be roughly the same in many respects, but
it does not use the Xresources type X configuration. You might find, however,
that Mozilla does a much better job of handling fonts, and pages will look
better overall. Highly recommended! The only caveat is, it seems to need a
fairly fast system. It may be pretty sluggish on older hardware.
</para>
<para>
Also, some user preferences can be stored in
<quote><filename>user.js</filename></quote> and
<quote><filename>unix.js</filename></quote>. Not to be confused with
<quote><filename>prefs.js</filename></quote>. <filename>user.js</filename>
will likely have to be created by hand. Put
it in whatever <filename>.mozilla</filename> sub-directory you find
<filename>prefs.js</filename> in (this is not a consistent location, but
typically ends like <filename>*.slt</filename>). Attempt to set a minimum
font size:
</para>
<para>
<screen>
// Don't ever show me a font smaller than this: some samples.
user_pref("font.min-size.variable.", 12);
user_pref("font.min-size.variable.x-western", 12);
user_pref("font.min-size.fixed.x-western", 12);
</screen>
</para>
<para>
Other customizations can be made in <filename>userChrome.css</filename>
and <filename>userContent.css</filename>. Again, both should be placed in
the same directory as <filename>prefs.js</filename>. These files control
much of the <quote>UI</quote> (the skin outside the browser window).
</para>
<para>
More info is available from the Mozilla developers:
<ulink url="http://www.mozilla.org/unix/customizing.html">http://www.mozilla.org/unix/customizing.html</ulink>.
</para>
<para>
It is also possbible to have anti-aliasing of fonts with Mozilla now. This
might be a bit of work to get going at this time (Aug 2002), but it is
possible. See the next section.
</para>
<!-- ~ End section ~ -->
<!-- ~~~~~ New section ~~~~~ -->
<sect3 id="moz-xft">
<title>Mozilla with Xft</title>
<para>
As mentioned above, the Xft extensions that give us anti-aliasing, and
improved font handling, are slowly being rolled into Mozilla development.
Such packages are often labeled as <quote>TrueType</quote> enabled. The
reasoning being that they include native support for TrueType from within
Mozilla. Note, that seems to be a bit of misnomer since properly installed
TrueType fonts work quite well, even with ancient versions of Mozilla (though
no anti-aliasing). The difference being that Mozilla does some of its own
TrueType work.
</para>
<para>
There are many builds of Mozilla available, and it is not so easy to know
which have Xft support. There are tips for knowing if your installed version
does have this support, and then how to enable it here: <ulink
url="http://www.mozilla.org/projects/fonts/unix/enabling_truetype.html">http://www.mozilla.org/projects/fonts/unix/enabling_truetype.html</ulink>.
Worse comes to worse, you can download experimental versions from: <ulink
url="ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/">ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/</ulink>.
</para>
<para>
For whatever reason, Mozilla has its own Xft configuration, that is
independent of other system components. You must turn it on, and configure
it (unless your vendor has done this already)! I know what you are saying,
<quote>one more place to configure fonts, sigh ...</quote>.
</para>
<para>
The above page explains rather tersely how to do this. The highlights:
</para>
<para>
Requirements:
</para>
<para>
<simplelist>
<member>
&nbsp;&nbsp;&middot;&nbsp;&nbsp;XFree86 4.x with Xft support.
</member>
<member>
&nbsp;&nbsp;&middot;&nbsp;&nbsp;FreeType2 libraries.
</member>
<member>
&nbsp;&nbsp;&middot;&nbsp;&nbsp;Mozilla with Xft support.
</member>
<member>
&nbsp;&nbsp;&middot;&nbsp;&nbsp;TrueType fonts.
</member>
</simplelist>
</para>
<para>
Configuration:
</para>
<para>
You will need to hand edit the relevant <filename>unix.js</filename>
file, which is typically installed as
<filename>/usr/lib/mozilla-*/defaults/pref/unix.js</filename>, or
a similar location.
</para>
<para>
You will need to enable <literal>FreeType2</literal> (and possibly
define the version), and then list the directories that contain your TrueType
fonts (each listing must be uniquely identified, see example). Sample
excerpt:
</para>
<para>
<screen>
// TrueType ///////////////////////////////////////////
pref("font.FreeType2.enable", true);
pref("font.freetype2.shared-library", "libfreetype.so.6");
// if libfreetype was built without hinting compiled in
// it is best to leave hinting off. try it both ways to see.
pref("font.FreeType2.autohinted", true);
pref("font.FreeType2.unhinted", false);
// below a certian pixel size anti-aliased fonts produce poor results
pref("font.antialias.min", 10);
pref("font.embedded_bitmaps.max", 1000000);
pref("font.scale.tt_bitmap.dark_text.min", 64);
pref("font.scale.tt_bitmap.dark_text.gain", "0.8");
// sample prefs for TrueType font dirs
//pref("font.directory.truetype.1", "/u/sam/tt_font");
//pref("font.directory.truetype.2", "/u/sam/other/tt_font");
pref("font.directory.truetype.1", "/usr/share/fonts/truetype");
</screen>
</para>
<para>
The <literal>//</literal> characters are comments. Then restart
Mozilla. You should see it processing each font in the directories
you specified (if started from the command line). You then need to
go into the Mozilla font configuration (Edit -&gt; Preferences
-&gt; Appearance -&gt; Fonts), and select the appropriate fonts &mdash; these
must be the ones that are listed with <emphasis>the first letter as upper
cased</emphasis>:
</para>
<para>
<screen>
Afga-monotype-arial-iso8859-1
</screen>
</para>
<para>
This should now give you TrueType fonts <emphasis>with</emphasis>
anti-aliasing! Quite nice!
</para>
<para>
You should experiment with the <quote>hinting</quote> preferences. Having
hinting enabled made a significant improvement here.
</para>
</sect3>
</sect2>
</Sect1>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New Section Header ~~~~~~~~~ -->
<Sect1 id="end">
<Title>Odds and Ends</Title>
<Sect2 id="notes">
<Title>Notes</Title>
<ItemizedList>
<ListItem>
<Para>
Unfortunately there is no unified font handling system for Linux. You will have
to configure each individual program so you can use TrueType, Type 1 or fonts
that pique your fancy. And each program may well have its own way of doing
this so you will have to RTFM. Desktop Environments like GNOME and KDE may
provide much of this functionality however for apps that are under their
control.
</Para>
</ListItem>
<ListItem>
<Para>
Most GUI apps should be able to use TrueType, and Type 1 fonts too.
Wordperfect for Linux, however, cannot use TrueType. (See the
links section below for more on Wordperfect.) Text editors, terminal programs
and the like need fixed width fonts, and do not play well with TrueType or
other proportional fonts.
</Para>
</ListItem>
<ListItem>
<Para>
Though not discussed here, Type 1 fonts provide many of the same benefits
as TrueType and are historically better supported in the Unix world,
especially for printing. XFree86 still seems to render TrueType somewhat
better than Type 1. You likely have many of these installed already.
Unfortunately however, Type 1 are not a web standard like TrueType. But
they are suitable for many other purposes. They are where it's at for
printing. See <Ulink URL="http://www.ghostscript.com/">ghostscript</Ulink>
for more on this.
</Para>
</ListItem>
<ListItem>
<Para>
While it is possible to specify a default point size for the xfs font
server, very few applications will actually use this value.
</Para>
</ListItem>
<ListItem>
<Para>
Abiword comes with a suite of fonts, called 'Abisuite'. Apparently,
some of these fonts have the same names as some of the well known MS
TrueType fonts: Arial, etc. And apparently, these are not as good
quality. And because of the way X searches for fonts, it may find these
first and use these, even if the 'real' ones are installed and may be the
preferred choice. The solution is to either make sure your preferred fonts
come first in the FontPath or maybe to uninstall 'Abisuite' if it's not
needed.
</Para>
</ListItem>
<ListItem>
<Para>
The new Xft rendering extensions of XFree86 4.x will mostly supplant
similar features as provided by xfs, and older XFree86 extensions. For
instance, font aliasing should be done in <Filename>XftConfig</FileName>
if the new extensions are being used. This would only be true where
the application is built against a toolkit (like QT or GTK) that supports
the new extensions. This is still not universally supported.
</Para>
</ListItem>
</ItemizedList>
</Sect2>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<Sect2 id="links">
<Title>Links</Title>
<ItemizedList>
<ListItem>
<Para>
<Ulink URL="http://www.xfree86.org">XFree86 Project</Ulink>, the guys and gals
who do an incredible amount of work to give us a killer GUI environment. An
overview of XFree86 fonts:
<Ulink url="http://www.xfree86.org/current/fonts.html">XFree86 4.x</Ulink>.
And an explanation of Xft:
<ulink url="http://www.keithp.com/~keithp/render/Xft.tutorial">http://www.keithp.com/~keithp/render/Xft.tutorial</ulink>.
</Para>
</ListItem>
<listitem>
<para>
The Fontconfig home page is <ulink
url="http://fontconfig.org">http://fontconfig.org</ulink>, for all the
latest news on Xft and fontconfig (the future of X font handling).
</para>
</listitem>
<ListItem>
<Para>
The
<Ulink url="http://linuxdoc.org/HOWTO/XFree86-Video-Timings-HOWTO.html">Video
Timings HOWTO</Ulink>, the ins and outs of getting the most from your monitor.
(Applicable only to XFree86 v.3.x for the most part.)
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink URL="http://www.linuxdoc.org/HOWTO/Font-HOWTO.html">Font HOWTO</Ulink>
Many good tips for installing fonts and for applications such as StarOffice,
Applixware, Wordperfect, Ghostscript, TeX/LaTeX.
</Para>
</ListItem>
<ListItem>
<Para>
A <Ulink URL="http://www.moisty.org/~brion/linux/TrueType-HOWTO.html">TrueType HOWTO</Ulink>, good tips for printing, and a few application specific tips.
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink URL="http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/">xfsft Homepage</Ulink>,
TrueType font support for X. This is the origin of the "freetype" font module
for XFree86 4.x, and Red Hat's xfs. Good site, and good links to other
information related to fonts and TrueType.
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink url="http://home.c2i.net/dark/linux.html">Some Linux for Beginners</Ulink>. Great font site, and other Linux topics. Covers many of the topics
discussed here in more detail. Some font and other tips for
Mozilla: <Ulink URL="http://home.c2i.net/dark/My_Mozilla_FAQ.html">http://home.c2i.net/dark/My_Mozilla_FAQ.html</Ulink>.
</Para>
</ListItem>
<ListItem>
<Para>
Two guides specifically for Debian from Paul D. Smith:
<Ulink URL="http://www.paulandlesley.org/linux/xfree4_tt.html">http://www.paulandlesley.org/linux/xfree4_tt.html</Ulink> and for 3.3.x:
<Ulink URL="http://www.paulandlesley.org/linux/debian_tt.html">http://www.paulandlesley.org/linux/debian_tt.html</Ulink>.
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink URL="http://X-TT.dsl.gr.jp/">X-TrueType Homepage</Ulink>, and yet
another TrueType Font server, especially good for Japanese, Chinese and Korean
character sets. [Note: link is bad 08/18/02.]
</Para>
</ListItem>
<ListItem>
<Para>
Tips on font size problems from
<Ulink URL="http://help.netscape.com/kb/consumer/19960513-54.html">Netscape</Ulink>.
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink URL="http://www.rodsbooks.com/wpfonts/">Wordperfect for Linux -- Fonts
and Printers</Ulink> by Rod Smith, the author of
<CiteTitle>Using Corel Wordperfect 8 for Linux</CiteTitle>
from Que. Excellent information on Wordperfect and where TrueType fits in.
</Para>
</ListItem>
<!--
<ListItem>
<Para>
<Ulink
URL="http://www.microsoft.com/typography/fontpack/default.htm">Microsoft
Web Fonts</Ulink> direct from the Lion's den - and they are free! These
can be unpacked in Linux (see above).
</Para>
</ListItem>
-->
<ListItem>
<Para>
<Ulink URL="http://sourceforge.net/projects/font-tool/">http://sourceforge.net/projects/font-tool/</Ulink>,
contains the core MS TrueTyep fonts suitable for web browsing.
<Ulink URL="http://packages.debian.org/unstable/graphics/msttcorefonts.html">http://packages.debian.org/unstable/graphics/msttcorefonts.html</Ulink> is a similar package for Debian.
</Para>
</ListItem>
<ListItem>
<Para>
Sebastiano Vigna's <Ulink URL="http://gongolo.usr.dsi.unimi.it/~vigna/webFonts4Linux/">
http://gongolo.usr.dsi.unimi.it/~vigna/webFonts4Linux/</Ulink> automates the downloading,
extracting and installation of the Microsoft fonts all in one neat
package.
</Para>
</ListItem>
<!--
Broken link...can't find again...
<ListItem>
<Para>
<Ulink URL="http://www.fontsmart.com/fonts.htm">HP FontSmart TrueType
Fonts</Ulink>from Hewlett Packard - Garamond, Bodoni, Dark Courier, Euro Sign
and Ozzie Black. These can be unzipped in Linux with the
<Command>unzip</Command> utility.
</Para>
</ListItem>
-->
<ListItem>
<Para>
<Ulink URL="http://www.freewareconnection.com/fonts.html">Freeware Connection
-- Free Fonts Sites</Ulink> lots of links to lots of sites.
</Para>
</ListItem>
<ListItem>
<Para>
<Ulink URL="http://www.will-harris.com/fonts/freefonts.htm">Bitstream's
Geometric Slabserif</Ulink> TrueType Font.
</Para>
</ListItem>
<ListItem>
<Para>
Two converters for converting a Mac Font <Quote>suitcase</Quote> to a *nix
compatible font: <Ulink
URL="http://www.macinsearch.com/infomac2/font/util/tt-converter-15.html">http://www.macinsearch.com/infomac2/font/util/tt-converter-15.html</Ulink>
and
<Ulink URL="http://www.netmagic.net/~evan/shareware/#TTFontConvert">http://www.netmagic.net/~evan/shareware/#TTFontConvert</Ulink>
</Para>
</ListItem>
<ListItem>
<Para>
The Unicode HOWTO: <Ulink
URL="http://linuxdoc.org/HOWTO/Unicode-HOWTO.html">http://linuxdoc.org/HOWTO/Unicode-HOWTO.html</Ulink>
</Para>
</ListItem>
<ListItem>
<Para>
Two sources of 'free' TrueType fonts with large Unicode support are
Bitstream Cyberbit, which covers Roman, Cyrillic, Greek, Hebrew, Arabic,
combining diacritical marks, Chinese, Korean, Japanese, and more, and is
available from <Ulink URL="ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP">ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP</Ulink>.
And Lucida Sans Unicode, which is included in IBM's JDK 1.3.0beta for
Linux, and covers Roman, Cyrillic, Greek, Hebrew, combining diacritical
marks. This can be downloaded from <Ulink
URL="ftp://ftp.maths.tcd.ie/Linux/opt/IBMJava2-13/jre/lib/fonts/">ftp://ftp.maths.tcd.ie/Linux/opt/IBMJava2-13/jre/lib/fonts/</Ulink>
as LucidaSansRegular.ttf and LucidaSansOblique.ttf. Thanks to Tzafrir Cohen
for these references. He also has a nice page on Hebrew fonts and related
topics at <Ulink
URL="http://www.iglu.org.il/faq/?file=133">http://www.iglu.org.il/faq/?file=133</Ulink>.
</Para>
</ListItem>
<!--
<ListItem>
<Para>
I also maintain a
<Ulink URL="http://feenix.burgiss.net/xstuff/xfs.html">help and
trouble-shooting page</Ulink> on Red Hat's xfs. There is also an RPM there
with the MS TrueType fonts, and working fonts.scale and fonts.dir in the package.
</Para>
</ListItem>
-->
</ItemizedList>
</Sect2>
</Sect1>
<!-- ~ End section ~ -->
<!-- ~~~~~~~~ New section Header ~~~~~~~~~ -->
<appendix id="appendix">
<Title>Appendix: Font Servers</Title>
<Para>
There are several font servers available that handle TrueType: xfstt, xfsft,
and Red Hat's patched version of xfs based on xfsft. While these names are all
too similar, these are different packages. One, or more, of these should be
included with any recent Linux distribution, and you may have one installed
already. If so, use which ever one your distribution is set up to use.
</Para>
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>xfstt</Title>
<Para>
One such font server is xfstt. xfstt was designed specifically with TrueType
fonts in mind.
</Para>
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>Installation</Title>
<Para>
xfstt is <emphasis>very</emphasis> easy to install and configure. If it isn't
already installed, you'll want to download the tarball, or check your CD. The
most current version can be found at <Ulink
URL="http://metalab.unc.edu/pub/Linux/X11/fonts/">http://metalab.unc.edu/pub/Linux/X11/fonts/</ULink>
</Para>
<Para>
Once you have the tarball, unpack it:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
$ tar -zxvf xfstt-*tgz
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Then build and install it. Read the <FileName>INSTALL</FileName> file for
quick instructions, but it's a no brainer.
</Para>
<Para>
From the xfstt directory is all you have to do.
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# make
# make install
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
Then start xfstt with:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# xfstt --sync # updates xfstt's font database
# xfstt &#38; # runs xfstt in the background.
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
xfstt should be started before the X server starts. Once you have this working
correctly, you can add the above lines to
<FileName>/etc/rc.d/rc.local</FileName>, or other suitable start up file. Then
type:
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
$ xset +fp unix/:7101 # tells X about xfstt, and where to look for fonts.
</LiteralLayout>
</MSGText>
</Literal>
</Para>
<Para>
or add:
</Para>
<BlockQuote>
<Para>
<Literal>
FontPath "unix/:7101"
</Literal>
</Para>
</BlockQuote>
<Para>
to your <FileName>XF86Config</FileName> to tell X about the font
server. Rerun <Command>xfstt --sync</Command> any time the FontPath, or
contents, change.
</Para>
</section>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>Adjusting the Default Font Size</Title>
<Para>
If your TrueType fonts appear to be very tiny, the following commands
may help.
</Para>
<Para>
Add the <Literal>-dpi</Literal> switch to your X server command
line (see above to do this.)
</Para>
<Para>
Use the <Literal>--res</Literal> switch to tell xfstt to increase
the default resolution. Use the following command line.
</Para>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# xfstt --res 120
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</section>
</section>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<section id="xfs">
<Title>Red Hat's xfs</Title>
<Para>
As of Red Hat Linux 6.0, Red Hat based distributions (Mandrake, etc) have
included a specially patched version of xfs, the XFree86 Font Server, and
patched X servers as well. Red Hat's xfs includes the xfsft patch set which in
turn is built upon the FreeType Font library. Red Hat's xfs provides similar
functionality to xfstt. xfs is able to serve both TrueType and Type 1 fonts,
as well as legacy X fonts.
</Para>
<Para>
If you are using a Red Hat based distro, you should have xfs installed
already. If not, it is in the <FileName>XFree86-xfs*rpm</FileName>. To make
sure it runs as one of the default services, either use
<Command>ntsysv</Command> or:
</Para>
<Para>
<Literal>
# chkconfig --add xfs
</Literal>
</Para>
<Para>
Now xfs will start every time you boot.
</Para>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>Setting the xfs FontPath</Title>
<Para>
The default Red Hat installation of xfs serves fonts via a Unix Domain Socket.
We'll need to tell the X server where to look for xfs, and thus fonts. The
FontPath in <FileName>/etc/X11/XF86Config</FileName> must include for Red Hat
6.x:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "unix/:-1"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
This is changed for Red Hat 7.x to:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
FontPath "unix/:7100"
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
At least for a default configurations. This is a reference to the socket where
xfs is listening. You may include additional FontPaths, but these will be
handled by the X server, and not xfs. A clean install of Red Hat 6/7 should
have this already set up, but if you are upgrading from an older version, you
may have to change this yourself!
</Para>
<Para>
xfs then has its own, separate FontPath stored in
<FileName>/etc/X11/fs/config</FileName>. This is where it will look to find
fonts. This is over and above the X server's FontPath in
<FileName>XF86Config</FileName>. You can either add the new path(s) with a text
editor, or use the <Command>chkfontpath</Command> command:
</Para>
<Para>
<Literal>
# chkfontpath --add /new/font/path
</Literal>
</Para>
<Para>
The FontPath must exist before running <Command>chkfontpath</Command>. The
relevant section of <FileName>/etc/X11/fs/config</FileName> should now look
something like this:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,
/usr/X11R6/lib/X11/fonts/100dpi:unscaled,
/usr/X11R6/lib/X11/fonts/75dpi:unscaled,
/usr/X11R6/lib/X11/fonts/Type1,
/usr/X11R6/lib/X11/fonts/Speedo,
/usr/X11R6/lib/X11/fonts/misc,
/usr/X11R6/lib/X11/fonts/100dpi,
/usr/X11R6/lib/X11/fonts/75dpi,
/new/font/path
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
When adding a new FontPath for TrueType fonts, you will want to do this
step after installing and preparing the fonts. See the next section.
</Para>
</section>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>Getting the Fonts Ready</Title>
<Para>
Installation and configuration is the same as for other
<quote>freetype</quote> based font renderers (e.g. XFree86-4.x
freetype module). See the above <link
linkend="ttf-config">Configuration</link> section for details.
Actually, you should just be able to install the fonts, include
the new font directory to the <literal>FontPath</literal> with
the <command>chkfontpath</command> utility, and then reload
xfs:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
# service xfs reload
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
</section>
</section>
<!-- ~ End Section ~ -->
<!-- ~~~~~ New Section ~~~~~ -->
<section>
<Title>xfsft</Title>
<Para>
<Ulink url="http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/">xfsft</Ulink>
is a TrueType solution from Juliusz Chroboczek. xfsft is based on the
FreeType font library as developed by Mark Leisher and others. It is
essentially is a patch for XFree86's xfs and related libraries -- xfs + ft.
Red Hat's xfs is essentially xfsft with a few minor modifications. Also,
XFree86 4.x includes the <Literal>freetype</Literal> font module which is also
the result of Juliusz's work, and is one of the TrueType solutions available
for XFree86 4.x.
</Para>
<Para>
Building xfsft requires having at least some of the XFree86 source available,
in addition to xfsft itself, so this is not for the faint of heart.
Instructions for building and configuring xfsft are in the tarball, so I won't
go into details here. They are pretty straight forward. There are links to
binaries available at the xfsft home page (see above).
</Para>
<Para>
Note that you <emphasis>must</emphasis> also create
<FileName>fonts.scale</FileName> and <FileName>fonts.dir</FileName> files for
xfsft. <FileName>fonts.scale</FileName> can be created manually (ugh!), or with
the <Command>ttmkfdir</Command> utility. This is not included with xfsft but
you can get it here: <ulink
url="http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz">http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz</ulink>,
or probably on many Linux archives sites too. Red Hat has this as part of the
<FileName>Freetype</FileName> RPM. And for Debian it is called
<Command>mkttfdir </Command> and is in the <Filename>fttools</FileName>
package.
</Para>
<Para>
You will also need a configuration file. Here is a sample:
</Para>
<BlockQuote>
<Para>
<Literal>
<MSGText>
<LiteralLayout>
-----------------------------------------------------
clone-self = off
use-syslog = off
client-limit = 20
catalogue = /usr/local/share/font/ttfonts
error-file = /home/jec/fonts/xfs.errors
# in decipoints
default-point-size = 120
# x,y
default-resolutions = 100,100,75,75
-----------------------------------------------------
</LiteralLayout>
</MSGText>
</Literal>
</Para>
</BlockQuote>
<Para>
You can then run start xfsft:
</Para>
<Para>
<Literal>
# xfs -port 7100 -config /path/to/your/config/file &
</Literal>
</Para>
<Para>
You can then add xfsft to the X server's <Literal>FontPath</Literal>:
</Para>
<Para>
<Literal>
$ xset +fp tcp/localhost:7100
</Literal>
</Para>
<Para>
If all goes well, you could then add this <Literal>FontPath</Literal> to
<FileName>XF86Config</FileName>.
</Para>
</section>
</appendix>
<!-- ~ End Section ~ -->
<!-- ~~~~~~~~ New section Header ~~~~~~~~~ -->
<appendix id="appendixb">
<title>Appendix: <filename>fonts.dir</filename> to <filename>fonts.alias</filename></title>
<para>
Thanks to Aristotle Pagaltzis for providing this perl
version of a script to convert a <filename>fonts.scale</filename>
file to <filename>fonts.dir</filename>.
</para>
<para>
<programlisting>
<![CDATA[
#!/usr/bin/perl -w
# This utility is a direct translation right down to the comments
# from mkfontalias.py written by Roman Sulzhyk to assist people
# in de-uglification of their true type fonts. It creates a
# fonts.alias file from the fonts.dir file found in the directory.
# It supports all of the Python script's features:
#
# - maps the following MS webfonts:
# Verdana, Tahoma, Impact, Arial Black,
# Comic Sans MS, Georgia, Trebuchet MS
#
# - cheats by mapping 6, 7 and 8pt to 9pt fonts
#
# (c)2002 Aristotle Pagaltzis, licensed under the GPL
# http://www.gnu.org/copyleft/gpl.html
use strict;
my $infile = "fonts.dir";
my $outfile = "fonts.alias";
my @res = (75, 75);
my %cheat_map = (6 => 9, 7 => 9, 8 => 9);
my @font_sizes = (6..16, 18, 24);
my %font_map = (
"Arial" => "Arial",
"Times New Roman" => "Times New Roman",
"Verdana" => "Verdana",
"Tahoma" => "Tahoma",
"Impact" => "Impact",
"Arial Black" => "Arial Black",
"Comic Sans MS" => "Comic Sans MS",
"Georgia" => "Georgia",
"Trebuchet MS" => "Trebuchet MS",
"Courier New" => "Courier New"
);
# Read in the fonts.
open(THEFILE, "<", $infile) or die "Cannot read $infile: $! - are you sure you are in the fonts directory?\n";
my @fontdir = splice @{[ <THEFILE> ]}, 1; # Strip the first line
close THEFILE;
# Now, create the output
my @aliases;
foreach (@fontdir) {
# Get rid of the first entry, but mind that other may have
# spaces in them
my $font = join(" ", splice @{[ split ]}, 1) or die "Cannot parse $infile line: $_\n";
my @entries = split "-", $font;
die "Invalid font: $font\n" unless @entries == 15;
my $mapped_font = $font_map{$entries[2]} or next;
# Create a bunch of aliases, for each size
for my $size (@font_sizes) {
# Do the "cheating" - fallback to size if not in the cheat map
my $real_size = $cheat_map{$size} || $size;
# Add the entry to the aliases
push @aliases, join(
" ",
join("-", @entries[0..6], $real_size, $real_size * 10, @entries[9..14]),
join("-", @entries[0..1], $mapped_font, @entries[3..6], $size, $size * 10, @res, @entries[11..14])
);
}
}
# Boast
print "Created ", scalar(@aliases), " aliases\n";
# Backup the existing file
if(-e $outfile) {
my $bakfile = "$outfile.bak";
my $errormsg = "Cannot backup $outfile to $bakfile:";
die "$errormsg file exists\n" if -e $bakfile;
rename $outfile, $bakfile or die "$errormsg $!\n"
}
# Ok, write the file
open(THEFILE, ">", $outfile) or die "Cannot open $outfile for writing: $!\n";
print THEFILE map "$_\n", @aliases;
close THEFILE;
print "Wrote ", scalar(@aliases), " aliases to $outfile\n";
]]>
</programlisting>
</para>
</appendix>
</Article>