Getting fonts to look good on linux can be a frustrating experience. Below are notes on setting up X.org on Slackware, but everything is generic enough it should apply to other distros and to recent versions of Xfree86.
The first step is to actually get some fonts. In addition to fonts distributed with Xfree86 and X.org, here are some other popular font resources:
[...]
Installing fonts is usually pretty straightforward:
If the fonts don't come with fonts.scale and similar files, create those with the following commands, in order:
# /usr/X11R6/bin/mkfontscale /path/to/your/fonts/ # /usr/X11R6/bin/mkfontdir /path/to/your/fonts/ # /usr/X11R6/bin/mkfontdir -e # /usr/X11R6/lib/X11/fonts/encodings
To find out what dpi settings are being used, do "xdpyinfo | grep resolution".
To specify the settings, edit the startx script.
First do "which startx" to find where the script is, then edit as root:
# defaultserverargs="-dpi 96"
To set 96 dpi for example. The default on Slackware is 75; some people feel 96 is preferable.
Xft is also part of the general Xfree86 and X.org offering. With Xft, applications have direct access to fonts and handle the rendering. This means that applications need to be written to support Xft. Xft handles Truetype fonts and anti-aliasing well.
Fontconfig - Xft relies on fontconfig to configure and set up fonts. There is a general fontconfig configuration file at /etc/fonts/fonts.conf; this file is system generated and should not be edited because changes may be overwritten by the system. To make system-wide changes, edit /etc/fonts/local.conf instead. Individual users can also create a ~.fonts.conf file in their home directory.
Note: Xft (Xft1) used /etc/X11/Xftconfig as main config file, and this file is still mentioned in lots of documentation, web postings, etc.; Xft2 uses /etc/fonts/fonts.conf and /etc/fonts/local.conf.
Editing /etc/fonts/local.conf or ~/fonts.conf:
To add a font directory so it's available to Xft, add the following:
<dir>/path/to/fonts/</dir>
Enabling or disabling antialiasing for all fonts (change false to true to enable):
<match target="font"> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match>
You can also turn antialiasing on and off for specific fonts:
<match target="font"> <test name="family"> <string>Font Name</string> </test> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match>
To choose a custom serif, sans serif, or monospace font, add the following:
<alias> <family>sans-serif</family> <prefer> <family>Bitstream Vera Sans</family> </prefer> </alias>
Substitute serif or monospace for sans-serif to customize the fonts. The idea here is that most applications don't specify specific fonts; they just specify a serif font, or a monospaced font.
Main freetype site: http://freetype.sourceforge.net/index2.html
According to its site, Freetype2 is a "software font engine". It's available as part of the Xfree86/X.org X server.
Because of patent issues, many default installs of freetype2 have byte-hinting turned off; usually auto-hinting is enabled but, for many fonts, byte-hinting is supposed to do a better job. To get freetype enabled with byte-hinting, download freetype from the freetype site and manually edit the following file:
include/freetype/config/ftoption.h
and uncomment the "define TT_CONFIG_OPTION_BYTECODE_INTERPRETER" line. The include file is well commented and is worth a read too. The package itself compiles with "configure —prefix=/usr && make, as root make install".
Main fontconfig site: http://freedesktop.org/software/fontconfig
According to the official site, fontconfig is "a library for configuring and customizing font access." The XFree86 documentation describes fontconfig in the following manner: "The Xft library has undergone a major restructuring, and is now split into fontconfig (which deals with font discovery and configuration and is independent from X), and Xft itself (which uses fontconfig and deals with font rasterisation and rendering)." I wasn't able to find similar documentation on X.org but I assume it's similar.
In other words, fontconfig is how fonts are set up and configured for use with Xft. Fontconfig comes as part of the main X package and doesn't need to be installed separately; I'm not sure there's an advantage to compiling a separate package.
Fontconfig should rebuild the list of fonts while it's running. If you need to force this, run: fc-cache
Gtk+2.2 uses Xft by default. To specify the default font used in gtk2 applications, create a file "~/.gtkrc-2.0" and add a line:
gtk-font-name = "Tahoma 8" or similar.
GTK+2.0 needs to have a variable set in order to use xft. Set the environment variable "GDK_USE_XFT" to "1" :
export GDK_USE_XFT=1
I assume this could also be done in a start up file (~./profile).
KDE. To enable Xft in KDE, click "Antialias fonts" in the font section of the KDE Control Center. This doesn't automatically antialias fonts; what is does is switch KDE to use Xft (you could modify /etc/fonts/local.conf to turn off antialiasing for example).
Mozilla. Mozilla needs to have xft support enabled when it's compiled. See my Mozilla page for how this can be done. http://www.jeffmccoy.info/linux/internet/mozilla.php
list all available fonts. You can also add a font-pattern to see only fonts which meet specific criteria:
$ fc-list :pattern
for example
$ fc-list :family $ fc-list :lang=en # or any two letter language code