This section explains how to configure both Xft and the core fonts system to access newly-installed fonts.
Xft has no configuration mechanism itself, rather it relies upon the fontconfig library to configure and customize fonts. That library is not specific to X11R6.8 or indeed on any particular font output mechanism. This discussion describes how fontconfig, rather than Xft, works.
Fontconfig looks for fonts in a set of well-known directories that
include all of X11R6.8's standard font directories
/usr/X11R6/lib/X11/lib/fonts/*') by default) as well as a
directory called `
.fonts/' in the user's home directory.
Installing a font for use by Xft applications is as simple
as copying a font file into one of these directories.
Fontconfig will notice the new font at the next opportunity and rebuild its list of fonts. If you want to trigger this update from the command line (for example in order to globally update the system-wide Fontconfig information), you may run the command `
$ cp lucbr.ttf ~/.fonts/
Fontconfig's behaviour is controlled by a set of configuration files: a
system-wide configuration file, `
a user-specific file called `
.fonts.conf' in the user's home
directory (this can be overridden with the `
Every Fontconfig configuration file must start with the following boilerplate:
In addition, every Fontconfig configuration file must end with the following line:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig>
The default Fontconfig configuration file includes the directory
~/.fonts/' in the list of directories searched for font
files, and this is where user-specific font files should be installed.
In the unlikely case that a new font directory needs to be added, this
can be done with the following syntax:
Another useful option is the ability to disable anti-aliasing (font smoothing) for selected fonts. This can be done with the following syntax:
Anti-aliasing can be disabled for all fonts by the following incantation:
<match target="font"> <test qual="any" name="family"> <string>Lucida Console</string> </test> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match>
<match target="font"> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match>
Xft supports sub-pixel rasterisation on LCD displays. X11R6.8 should automatically enable this feature on laptops and when using an LCD monitor connected with a DVI cable; you can check whether this was done by typing
If this doesn't print anything, you will need to configure Render for your particular LCD hardware manually; this is done with the following syntax:
$ xdpyinfo -ext RENDER | grep sub-pixel
The string `
<match target="font"> <edit name="rgba" mode="assign"> <const>rgb</const> </edit> </match>
rgb' within the `
</const>' specifies the order of pixel components on your display, and should be changed to match your hardware; it can be one of `
rgb(normal LCD screen), `
bgr' (backwards LCD screen), `
vrgb' (LCD screen rotated clockwise) or `
vbgr' (LCD screen rotated counterclockwise).
Because most current applications use the core fonts system by default, it is necessary to explicitly configure them to use Xft. How this is done depends on the application.
XTerm can be set to use Xft by using the `
-fa' command line
option or by setting the `
$ xterm -fa "Courier"
For applications based on GTK+ 2.0 (including GNOME 2 applications),
the environment variable `
GDK_USE_XFT' should be set to `
$ export GDK_USE_XFT=1
GTK+ 2.2 uses Xft by default.
For KDE applications, you should select ``Anti-alias fonts'' in the ``Fonts'' panel of KDE's ``Control Center''. Note that this option is misnamed: it switches KDE to using Xft but doesn't enable anti-aliasing in case it was disabled by your Xft configuration file.
(What about Mozilla?)
If some Xft-based applications don't seem to notice the changes you are making to your configuration files, they may be linked against an old version of Xft. In order to fix the problem, you should relink them against a current version of Xft; on most systems, it is enough to install the current version of the Xft and Fontconfig libraries.
If, for some reason, you cannot upgrade the shared libraries, please check the Xft(3) manual page included with XFree86 4.2 for the configuration mechanisms of the previous version of Xft.
Installing fonts in the core system is a two step process. First, you need to create a font directory that contains all the relevant font files as well as some index files. You then need to inform the X server of the existence of this new directory by including it in the font path.
The X11R6.8 server can use bitmap fonts in both the cross-platform BDF format and the somewhat more efficient binary PCF format. (X11R6.8 also supports the obsolete SNF format.)
Bitmap fonts are normally distributed in the BDF format. Before
installing such fonts, it is desirable (but not absolutely necessary)
to convert the font files to the PCF format. This is done by using the
You will then want to compress the resulting PCF font files:
$ bdftopcf courier12.bdf
$ gzip courier12.pcf
After the fonts have been converted, you should copy all the font
files that you wish to make available into a arbitrary directory, say
/usr/local/share/fonts/bitmap/'. You should then create the
index file `
fonts.dir' by running the command `
(please see the mkfontdir(1)
manual page for more information):
$ mkdir /usr/local/share/fonts/bitmap/ $ cp *.pcf.gz /usr/local/share/fonts/bitmap/ $ mkfontdir /usr/local/share/fonts/bitmap/
All that remains is to tell the X server about the existence of the new font directory; see Setting the server font path below.
The X11R6.8 server supports scalable fonts in four formats: Type 1, Speedo, TrueType and CIDFont. This section only applies to the former three; for information on CIDFonts, please see Installing CIDFonts later in this document.
Installing scalable fonts is very similar to installing bitmap fonts:
you create a directory with the font files, and run `
to create an index file called `
There is, however, a big difference: `
automatically recognise scalable font files. For that reason, you
must first index all the font files in a file called
fonts.scale'. While this can be done by hand, it is best done
by using the `
Under some circumstances, it may be necessary to modify the `
$ mkfontscale /usr/local/share/fonts/Type1/ $ mkfontdir /usr/local/share/fonts/Type1/
fonts.scale' file generated by
mkfontscale; for more information, please see the mkfontdir(1) and mkfontscale(1) manual pages and Core fonts and internationalisation later in this document.
The CID-keyed font format was designed by Adobe Systems for fonts with large character sets. A CID-keyed font, or CIDFont for short, contains a collection of glyphs indexed by character ID (CID).
In order to map such glyphs to meaningful indices, Adobe provide a set
of CMap files. The PostScript name of a font generated from a
CIDFont consists of the name of the CIDFont and the name of the CMap
separated by two dashes. For example, the font generated from the
Munhwa-Regular' using the CMap `
The CIDFont code in X11R6.8 requires a very rigid directory
structure. The main directory must be called `
CID' (its location
defaults to `
/usr/X11R6/lib/X11/fonts/CID' but it may be
located anywhere), and it should contain a subdirectory for every CID
collection. Every subdirectory must contain subdirectories
CIDFont (containing the actual CIDFont files),
(containing all the needed CMaps),
AFM (containing the font
metric files) and
CFM (initially empty). For example, in the
case of the font
Munhwa-Regular that uses the CID collection
Adobe-Korea1-0, the directory structure should be as follows:
CID/Adobe-Korea1/CIDFont/Munhwa-Regular CID/Adobe-Korea1/CMap/UniKS-UCS2-H CID/Adobe-Korea1/AFM/Munhwa-Regular.afm CID/Adobe-Korea1/CFM/ CID/fonts.dir CID/fonts.scale
After creating this directory structure and copying the relevant
files, you should create a `
fonts.scale' file. This file has the
same format as in the case of (non-CID) scalable fonts, except that
its first column contains PostScript font names with the extension
.cid' appended rather than actual filenames:
(both names on the same line). Running `
1 Adobe-Korea1/Munhwa-Regular--UniKS-UCS2-H.cid \ -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-iso10646-1
mkfontdir' creates the `
$ cd /usr/local/share/fonts/CID $ mkfontdir
Finally, you should create the font metrics summary files in the
CFM' by running the command `
If no CFM files are available, the server will still be able to use the CID fonts but querying them will take a long time. You should run `
$ mkcfm /usr/local/share/fonts/CID
mkcfm' again whenever a change is made to any of the CID-keyed fonts, or when the CID-keyed fonts are copied to a machine with a different architecture.
The list of directories where the server looks for fonts is known as the font path. Informing the server of the existence of a new font directory consists of putting it on the font path.
The font path is an ordered list; if a client's request matches multiple fonts, the first one in the font path is the one that gets used. When matching fonts, the server makes two passes over the font path: during the first pass, it searches for an exact match; during the second, it searches for fonts suitable for scaling.
For best results, scalable fonts should appear in the font path before
the bitmap fonts; this way, the server will prefer bitmap fonts to
scalable fonts when an exact match is possible, but will avoid scaling
bitmap fonts when a scalable font can be used. (The `
hack, while still supported, should no longer be necessary in X11R6.8.)
You may check the font path of the running server by typing the command
$ xset q
xset' utility may be used to modify the font path for the
current session. The font path is set with the command
a new element is added to the front with
xset +fp, and added to
the end with
xset fp+. For example,
$ xset +fp /usr/local/fonts/Type1 $ xset fp+ /usr/local/fonts/bitmap
Conversely, an element may be removed from the front of the font path
xset -fp', and removed from the end with `
You may reset the font path to its default value with
xset fp default'.
For more information, please consult the xset(1) manual page.
The default font path (the one used just after server startup or
xset fp default') is specified in the X server's
xorg.conf' file. It is computed by appending all the
directories mentioned in the `
FontPath' entries of the
Files' section in the order in which they appear.
FontPath "/usr/local/fonts/Type1" ... FontPath "/usr/local/fonts/bitmap"
For more information, please consult the xorg.conf(5) manual page.
If you seem to be unable to use some of the fonts you have
installed, the first thing to check is that the `
are correct and that they are readable by the server (the X server
usually runs as root, beware of NFS-mounted font directories). If
this doesn't help, it is quite possible that you are trying to use a
font in a format that is not supported by your server.
X11R6.8 supports the BDF, PCF, SNF, Type 1, Speedo, TrueType, OpenType and CIDFont font formats. However, not all X11R6.8 servers come with all the font backends configured in.
On most platforms, the X11R6.8 servers are modular: the font
backends are included in modules that are loaded at runtime. The
modules to be loaded are specified in the `
xorg.conf' file using
If you have trouble installing fonts in a specific format, you may want to check the server's log file in order to see whether the relevant modules are properly loaded. The list of font modules distributed with X11R6.8 is as follows:
"bitmap": bitmap fonts (`
*.pcf' and `
"freetype": TrueType fonts (`
*.ttf' and `
*.ttc'), OpenType fonts (`
*.otf' and `
*.otc') and Type 1 fonts (`
*.pfa' and `
"type1": alternate Type 1 backend (`
*.pfa' and `
*.pfb') and CIDFont backend;
"xtt": alternate TrueType backend (`
*.ttf' and `
"speedo": Bitstream Speedo fonts (`
Load' directive is case-sensitive.