v2.04c, 30 October 2002
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.
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 FontPath in the XF86Config file, by adding switches to X server command line in startx or xdm (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.
Comments, corrections, additions and critiques are always welcome. You can reach the author at <email@example.com>. 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?)
The pre-release versions of this document can be found at http://feenix.burgiss.net/ldp/fdu/index.html.
Copyright © 1999 by Doug Holland, 2002 Hal Burgiss.
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.
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.
In short, we wish to promote dissemination of this information through as many channels as possible. However, we do wish to retain copyright on the HOWTO documents, and would very much like to be notified of any plans to redistribute the HOWTOs, this one in particular! Web page authors are free to link to this HOWTO without restriction, though the author would appreciate an email informing him of this, just so he can boost his ego by knowing who else reads and links to this document.
Many of the terms mentioned in this document are trade names. Unless otherwise stated, all trademarks are property of their respective owners.
Special thanks go to:
There are a few simple configuration tweaks that will help X do its job better.
The first place to look for curing font problems is the XF86Config file. /usr/X11/lib/X11/XF86Config or /etc/X11/XF86Config are the common locations. (This may be XF86Config-4 for XFree86 4.x.) If you haven't guessed already, the most important part of this file relating to fonts is the FontPath. 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.)
Use your favorite text editor and edit XF86Config. Near the top of the file in the "Files" section, you should see something vaguely like this:
This much should be the same, or at least similar, for both XFree86 3.x and 4.x. The FontPath 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 FontPath 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 FontPath. See the Section A.2 below for more on xfs.)
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:
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 :unscaled 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 FontPath lines first to tell X you prefer unscaled fonts if possible:
After making these changes, restart X (and your font server, if installed). Doesn't the desktop look better already?
The next thing you might need to do is adjust the command line options for the X server. It is important that the dpi resolution be accurate. Run this command:
$ xdpyinfo | grep resolution
resolution: 111x111 dots per inch
If this does not look to match what your monitor can do, or if it is unbalanced (e.g 98x95), you will need to use the -dpi 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.
If you start X from the console command prompt, type:
$ startx -- -dpi 100 -depth 16 # v4.x syntax
Or these options can be stored in ~/.xserverrc. See the startx and xinit man pages for more on this.
If you use xdm (or friends such as gdm) for graphical logins, you'll want to edit your /usr/X11/lib/X11/xdm/Xservers file (or possibly /etc/X11/xdm/Xservers) which will have the command line for the Xserver in it. Mine has the line:
:0 local /usr/X11R6/bin/X -dpi 100 -gamma 1.6
You want to specify a value that is compatible with your monitor's output.
More information is in the X, Xserver, xdm, xinit, and startx man pages.
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.
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 "free" 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.
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!
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 links section for converter packages.) There are also some 'free' TrueType fonts available for download if you have already nuked that CD (see links section).
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!
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 always mounted. This can conceivably be a Windows partition on a dual boot system. Alternately, the fonts can be copied to Linux. First su to root:
# su -
Now, change to the new font directory:
# cd /usr/local/share/fonts/ttfonts
Then, add the fonts to this directory, either by copying them from your Windows system:
# cp /mnt/<path_to_fonts>/*ttf .
or by downloading those available directly from Microsoft: http://www.microsoft.com/typography/fontpack/default.htm. Note 08/17/02: Microsoft has recently discontinued this page. At this time, the following pages (may!) still have these fonts available (or google search for them):
These can be unarchived under Linux with cabextract, which can be found http://www.kyz.uklinux.net/cabextract.php3. This would now seem to be the best way to go at this time.
A slick solution to this from Sebastiano Vigna is his http://freshmeat.net/webFonts4Linux, 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: http://sourceforge.net/projects/font-tool/, which includes all the core MS web fonts, plus relevant system configuration. There is a tarball, as well as RPMs (both require cabextract).
You can also get an RPM of WebFonts that contains some of the MS Web fonts from ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm. This has enough basic fonts to keep Mozilla and other web browsers happy. Something similar for Debian is http://packages.debian.org/unstable/graphics/msttcorefonts.html. This does not include the actual fonts, but facilitates the installation.
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:
This configuration is for "core X font" support. For additional configuration relating to the new Xft rendering engine, see the sections below on XFT and anti-aliasing.
"Hinting" 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.
To enable this feature, the sources need to be rebuilt. Look for include/freetype/config/ftoption.h in the freetype source tree, and then search for:
And very simply, make this small change:
Red Hat users can rebuild the src.rpm by toggling one setting at the top, and accomplish the same thing:
And change to:
Other vendors may have a similar, easy-to-use mechanism.
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.
Note that "hinting", "anti-aliasing", and "sub-pixel rendering" are separate concepts (see the section on Xft below for more). Again, this is not a cure-all for "ugly" fonts, but one more piece in the puzzle of font "beautification".
This section pertains to installing and configuring TrueType fonts for any "freetype" based font renderer. This would include the freetype font module from XFree86-4.x, Red Hat's xfs, and the xfsft 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.
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.
Su to root, and change to the directory where the TrueType fonts are.
# su -
If there are any upper case font names, you can use the following script to convert all names to lower case:
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 fonts.dir and fonts.scale files. The following commands do this:
# ttmkfdir -o fonts.scale
If you don't have ttmkfdir installed, check your distribution's repository, or it can be downloaded from: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz. This is necessary!
As of Red Hat 7.1, the above commands are run from the xfs init script. So restarting xfs (/etc/rc.d/init.d/xfs restart) will accomplish the same thing for Red Hat users. Other distros may have similar shortcuts.
You should now have fonts.dir and fonts.scale files in your TrueType font directory. ttmkfdir is in the Freetype RPM for Red Hat users, and must be run before mkfontdir. With Debian based distros, there is a similar utility called mkttfdir, and is in the fttools Deb package. Though this apparently does not generate as many encodings as ttmkfdir. These commands may not always report errors, so verify that they were created and are not empty files:
$ ls -l fonts.*
If you encounter any problems, try ttmkfdir with the - m switch. This will discard bad characters from the font file. Specify a number such as 50 or l00 (ttmkfdir -m 50). The files themselves are text files. Have a look:
If ttmkfdir is persistently giving problems by not generating a proper output file, there may be one or more "bad" 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.
Now be sure the new fonts are included in the FontPath. And either restart X (Ctrl-Alt-BS), or the font server (if using one). You could also try refreshing the FontPath:
# xset fp rehash
Red Hat 6.x/7.x users can update the FontPath and xfs:
# chkfontpath --add /usr/local/share/fonts/ttfonts
You should now be in business. You can check which fonts are available to X:
$ xlsfonts | less
or check them out further with xfontsel, or gfontsel. If they are visible to xlsfonts, then they are available to X and vice versa. If they are not there, try restarting X with Ctrl-Alt-BS.
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 below), if using XFree86 v4.x or later.
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 does have built in support for TrueType (see Section 4), making a font server not a necessity, though some distros default to using a font server for other reasons now.
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 Appendix for font server installation, and related tips.
Any recent distro will have one or more font servers included, and the important configuration should be done by the installation program.
fonts.alias is yet another font configuration file that can be used to tweak how fonts are handled. Like fonts.scale and fonts.dir, fonts.alias 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/usr/X11R6/lib/X11/fonts/misc/fonts.alias on a Red Hat system:
fixed 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.
fonts.alias is important for some applications that don't handle the data provided by fonts.scale well. Most notably here is Netscape. Without a fonts.alias you will find that Netscape will only show point sizes of 0 and 12 available. fonts.alias fixes this. You might also find that if you a specify another size with the scalable font option under Preferences, Netscape will not remember this setting. Annoying! This is also fixed. So we really need this file. Sample excerpt from a fonts.scale:
These are scalable so we don't get any predefined point sizes. We will need to create our fonts.alias something like this excerpt for Arial:
(Please note that I have split each line for readability. There should be two columns all on one line, without the "\", 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 pointsize 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.
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 http://home.c2i.net/dark/linux.html. There is also a link to a python script which can reportedly automatically generate a fonts.alias file at this same site. A perl version of this script is re-printed in the Appendix. Thanks to Kristin whose work and insight was the inspiration for this section!
Another potential use of fonts.alias 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.
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: XftConfig. This is the preferred method where anti-aliasing, and the other new rendering features are desired. See the Anti-aliasing Section 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).
XFree86 4.0 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).
The FontPath is still in XF86Config, 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 FontPath from /etc/X11/fs/config back to XF86Config. 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.
In order to use TrueType, you must also specify which font module the X server should be using in the "Module" section:
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.
You also must have a fonts.scale and fonts.dir file for each TrueType font directory, just like for xfsft and Red Hat's xfs (see Appendix). ttmkfdir, http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz, will come in handy for fonts.scale if it is not already installed. See the Configuration section above for more details and examples.
xtt 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.
Most X server command line options are still the same as previous versions of X:
$ startx -- -dpi 100
As mentioned, the new font handling improvements are the result of the development work behind Xft. 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 "core X fonts").
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 still evolving! I emphasize this, since the "still evolving" part is likely to cause some confusion until the dust settles.
The initial release of Xft v1.0 with XFree86 4.0.2 is controlled by its configuration file, XftConfig. This changes with later versions, where the font configuration is handled by the fontconfig library, with its main configuration typically located /etc/fonts/fonts.conf. Of course, additional development has brought other improvements as well. For more on the Xft and Fontconfig, see the Fontconfig home page, http://fontconfig.org/.
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.
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.
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.
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.
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 "AA" aware, and we won't have to jump through any configuration hoops just to make it work. In the meantime, read on ...
Minimum requirements for Anti-Aliasing:
Keith Packard has a very brief summary of the steps required for building, installing and configuring from source at http://www.xfree86.org/~keithp/render/aafont.txt. No need to reprint it here.
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.
To verify the necessary components, first make sure the "freetype" module (and any others) are loaded. Check the X server output:
Then verify if the "RENDER" extension is available, either check with xdpyinfo, or check the X server log, typically /var/log/XFree86.0.log:
If "RENDER" 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.
By Danny Tholen <firstname.lastname@example.org>
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 /etc/X11/XftConfig (or /usr/X11R6/lib/X11/XftConfig) 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.
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.
Note that Xft2 makes radical changes to Xft configuration. XftConfig is obsoleted and replaced by the new fontconfig libraries. Red Hat 8.x users should read the Red Hat 8.0 Differences section first. Many of the principles described still apply, but the configuration is radically different. FYI.
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:
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 XftConfig. The requested pattern can here be extended before use. An example is:
match any family == "Arial" edit antialias = true;
This will enable anti-aliasing for all fonts of the family Arial.
Also, the X server is queried to list all of its fonts; the XLFD contains just enough information to match fonts roughly.
Here's a list of attributes used in matching fonts (in priority order, this may not be up to date anymore!):
foundry font foundry (string, like "monotype")
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.
This is my XftConfig:
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).
There is also the gdkxft project available at http://sourceforge.net/projects/gdkxft/. 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 README closely, and follow the instructions. An initial installation provides a good starting point. I added some font families to /etc/gdkxft.conf and I used some of Danny's suggestions above, and it seems to work mostly. It's a bit of a kludge, but quite a nice kludge ;-) Note, sadly this project seems to be no longer maintained.
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 ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/ that have Xft/TrueType support (see the section on Mozilla below). Native Mozilla Xft support is probably working its way into mainstream releases. [Note: This should happen with Mozilla 1.2.]
You've gone through all the steps, and verified that the "RENDER" 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.
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 "AA":
$ xterm -fa charter -fs 14
You can also turn on Xft debugging:
$ export XFT_DEBUG=2
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.
One final point: anti-aliasing and TrueType are completely separate issues. One does not depend on the other, though both together can can enhance appearance significantly. Especially, with good quality TrueType fonts! But any font can potentially be anti-aliased.
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:
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:
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.
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?
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.
Assuming you have TrueType working, from the Netscape menu select Edit -> Preferences -> Fonts. Open the Variable Width Font 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 Allow Scaling 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 OK 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. Unless -- you have fonts.alias set up already. Then this will solve these problems. See Section 3.5 for more on fonts.alias.
You might consider experimenting with some ~/.Xdefaults (or perhaps it's~/.Xresources on your system) settings too:
The 'sizeIncrement' controls how much of a jump Netscape makes when different 'basefont' sizes are specified ala:
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!
$ xrdb -merge ~/.Xdefaults
(or .Xresources as the case may be) and restart Netscape. There are many settings that can be tweaked or altered this way. Look at the Netscape.ad (app defaults) file that should be included with Netscape packages.
If this approach does not get the job done as far as the 'tiny fonts' problem in Netscape, then see the fonts.alias section above. You can really fine tune many things with this approach.
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.
Also, some user preferences can be stored in "user.js" and "unix.js". Not to be confused with "prefs.js". user.js will likely have to be created by hand. Put it in whatever .mozilla sub-directory you find prefs.js in (this is not a consistent location, but typically ends like *.slt). Attempt to set a minimum font size:
Other customizations can be made in userChrome.css and userContent.css. Again, both should be placed in the same directory as prefs.js. These files control much of the "UI" (the skin outside the browser window).
More info is available from the Mozilla developers: http://www.mozilla.org/unix/customizing.html.
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.
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 "TrueType" 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.
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: http://www.mozilla.org/projects/fonts/unix/enabling_truetype.html. Worse comes to worse, you can download experimental versions from: ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/.
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, "one more place to configure fonts, sigh ...".
The above page explains rather tersely how to do this. The highlights:
You will need to hand edit the relevant unix.js file, which is typically installed as /usr/lib/mozilla-*/defaults/pref/unix.js, or a similar location.
You will need to enable FreeType2 (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:
The // 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 -> Preferences -> Appearance -> Fonts), and select the appropriate fonts — these must be the ones that are listed with the first letter as upper cased:
This should now give you TrueType fonts with anti-aliasing! Quite nice!
You should experiment with the "hinting" preferences. Having hinting enabled made a significant improvement here.
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.
One such font server is xfstt. xfstt was designed specifically with TrueType fonts in mind.
xfstt is very 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 http://metalab.unc.edu/pub/Linux/X11/fonts/
Once you have the tarball, unpack it:
$ tar -zxvf xfstt-*tgz
Then build and install it. Read the INSTALL file for quick instructions, but it's a no brainer.
From the xfstt directory is all you have to do.
Then start xfstt with:
# xfstt --sync # updates xfstt's font database
xfstt should be started before the X server starts. Once you have this working correctly, you can add the above lines to /etc/rc.d/rc.local, or other suitable start up file. Then type:
$ xset +fp unix/:7101 # tells X about xfstt, and where to look for fonts.
to your XF86Config to tell X about the font server. Rerun xfstt --sync any time the FontPath, or contents, change.
If your TrueType fonts appear to be very tiny, the following commands may help.
Add the -dpi switch to your X server command line (see above to do this.)
Use the --res switch to tell xfstt to increase the default resolution. Use the following command line.
# xfstt --res 120
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.
If you are using a Red Hat based distro, you should have xfs installed already. If not, it is in the XFree86-xfs*rpm. To make sure it runs as one of the default services, either use ntsysv or:
# chkconfig --add xfs
Now xfs will start every time you boot.
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 /etc/X11/XF86Config must include for Red Hat 6.x:
This is changed for Red Hat 7.x to:
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!
xfs then has its own, separate FontPath stored in /etc/X11/fs/config. This is where it will look to find fonts. This is over and above the X server's FontPath in XF86Config. You can either add the new path(s) with a text editor, or use the chkfontpath command:
# chkfontpath --add /new/font/path
The FontPath must exist before running chkfontpath. The relevant section of /etc/X11/fs/config should now look something like this:
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.
Installation and configuration is the same as for other "freetype" based font renderers (e.g. XFree86-4.x freetype module). See the above Configuration section for details. Actually, you should just be able to install the fonts, include the new font directory to the FontPath with the chkfontpath utility, and then reload xfs:
xfsft 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 freetype font module which is also the result of Juliusz's work, and is one of the TrueType solutions available for XFree86 4.x.
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).
Note that you must also create fonts.scale and fonts.dir files for xfsft. fonts.scale can be created manually (ugh!), or with the ttmkfdir utility. This is not included with xfsft but you can get it here: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz, or probably on many Linux archives sites too. Red Hat has this as part of the Freetype RPM. And for Debian it is called mkttfdir and is in the fttools package.
You will also need a configuration file. Here is a sample:
You can then run start xfsft:
# xfs -port 7100 -config /path/to/your/config/file &
You can then add xfsft to the X server's FontPath:
$ xset +fp tcp/localhost:7100
If all goes well, you could then add this FontPath to XF86Config.
Thanks to Aristotle Pagaltzis for providing this perl version of a script to convert a fonts.scale file to fonts.dir.