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. 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. See the section below
for Red Hat 7.x specific configuration issues.
Note that there can be only one 'Module' section, so include any other
modules here as well.
You also must to create fonts.scale and
fonts.dir file for each TrueType font directory, just like
for xfsft and Red Hat's xfs.
ttmkfdir
will come in handy for fonts.scale. See the xfs
Section 3.2.2 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.
X server command line options are still the same as previous versions of X:
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 thanks to Keith Packard. 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 few
applications are actually taking advantage of this yet. We will have
to wait for the various toolkits (TK, GTK, Xaw, etc) to catch up.
If you are reading this long after the publication date (February 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 ...
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 xdpyinfo. Run this and
look for "Number of Extensions:". If this lists "RENDER" 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.
The Freetype2 library available from
http://www.freetype.org, 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
freetype-2.
TrueType fonts are best for display purposes. Type1 is also good. See
above sections.
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: http://trolls.troll.no/~lars/fonts/qt-fonts-HOWTO.html.
GNOME does not support anti-aliasing at this time in stable releases (as
of 1.4). Awaiting GTK implementation (probably for GTK 2.0). Apparently
this will be available later this year, so stay tuned. GNOME 2.0 will
have native support for anti-aliasing.
Applications that "know" 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, there are scant few. KDE/QT is first out
of the box. Also, xterm supports the new extensions.
The new rendering extensions configuration file,
XftConfig, must be configured for the fonts you want
to use.
The new extensions supplant much of what we have been doing with font
servers like xfs. fonts.alias and similar
configuration files, for instance, are not used for fonts that are
being controlled by the new extensions.
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:
(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
Then verify if the "RENDER" extension is available, either check
with xdpyinfo, or check the X server log, typically
/var/log/XFree86.0.log:
(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
If "RENDER" is there, anti-aliasing and the other advanced
rendering extensions should be available.
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.
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:
family: "Arial"
size: 12
encoding: "iso8859-1"
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")
encoding font encoding (string, like "iso8859-1")
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)
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.
include and includeif
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 "~" character, it refers to a path
relative to the home directory of the user. This is useful for
user-specific configurations.
match edit
If a pattern from an application matches the pattern after
"match", it is edited with the instructions in
edit. The pattern match is done as follows:
match qual FIELD-NAME COMPARE CONSTANT
where qual is either any (matches one specific font)
or all (matches all fonts). An example:
match all foundry==¨monotype¨
which will match (and edit) all fonts belonging to the foundry
"monotype".
match any family==¨arial¨
will match (and edit) one specific font with the family name
"arial".
FIELD-NAME is any one of the properties found in the
above section Structure, or additionally:
pixelsize font size in pixels (integer)
charspace character space (integer)
minspace minimal spacing (integer)
rgba color hinting (string ¨rgb¨ or ¨bgr¨ and
vertical hinting ¨vrgb¨ ¨vbgr¨), 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)
COMPARE can be <,
>, or ==.
CONSTANT is the value of the field-name in the
appropriate type (see above section Structure).
You can use multiple matches before you use the "edit"
statement:
edit FIELD-NAME ASSIGN EXPR SEMI
Where ASSIGN can be one of =,
+= or =+. With
=, the matching value in the pattern will be replaced
by the given expression. += or =+
will prepend/append a new value to the list of values for the indicated
field.
EXPR sets the FIELD-NAME to a value.
SEMI is a semicolon (;). You can
use multiple instructions, separated by a semicolon. See below for
examples if this is confusing.
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.
How do I make fonts available to Xft?
List your Type 1 and TrueType font directories with "dir". On my
system (Mandrake 7.2) this becomes:
dir "/usr/X11R6/lib/X11/fonts/Type1"
dir "/usr/X11R6/lib/X11/fonts/drakfont"
How do I use a user specific XftConfig file?
Put an .xftconfig file in your user directory and add:
includeif "~/.xftconfig"
to your standard XftConfig. This will enable a user
specific configuration file, but it will not complain if there is no such
file.
How do I make aliases for my fonts?
I noted that my KDE console asks for "mono" fonts when it is
looking for a fixed font. "console" is used when I select
"linux" in the font menu of the KDE konsole. Therefore, I used
two aliases for fonts which are also named "fixed":
match any family == "fixed" edit family =+ "mono";
match any family == "console" edit family =+ "mono";
Anti-aliasing my fonts are blurry and makes me dizzy!
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.
Use the following in your XftConfig to anti-alias only
fonts of specific sizes:
match
any size > 8
any size < 15
edit
antialias = false;
My fixed fonts do not appear or look _very_ wrong in the KDE konsole or
similar programs!
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):
match
any family == "mono"
edit
spacing = mono;
My Symbol, Webdings, etc. fonts do not show up!
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:
match
any family == "webdings"
edit
antialias = false;
encoding += "glyphs-fontspecific";
match
any family == "symbol"
edit
antialias = false;
encoding += "glyphs-fontspecific";
A useful way of figuring out these things is to activate debugging with:
export XFT_DEBUG=1024
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.
Why do my KDE programs start now soooo slooow?
The Xft mechanism in XFree prior to 4.1 had to parse the
XftConfig 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.
I have a LCD screen on my laptop, can I use sub-pixel hinting instead of
normal anti-aliasing?
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 "rgba" setting. Try:
match edit rgba=bgr;
or use rgb if you have a different type of monitor. For vertical AA you can
try vbgr and vbgr.
My fonts still look bad!
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:
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
to:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
and rebuild with this modified source. See the freetype2
README 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.
This is my XftConfig:
#
# 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";
#
# 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;
As mentioned above, KDE and QT do have solid anti-aliasing support with
recent releases. GNOME, however, does not support anti-aliasing natively in
stable releases (as of Feb 2002). But it is under developement and will be
available when 2.0 is released, which should not be far away. If you are
adventurous, you might consider getting the current development snapshot, and
play with that.
In the meantime, there is the gdkxft project available at
http://sourceforge.net/projects/gdkxft/.
This will add anti-aliasing support to GTK+ 1.2 applications. This is a
stand-alone library and not a patch. It will only effect GTK+ widgets (many
of them but not all). There are some limitations, but mostly it works as
advertized. Read the included README closely. An initial
installation provides a good starting point. I used some of Danny's
suggestions above, and it seems to work mostly.
Even with the latest Mozilla (widgets only AFAICT)! GNOME users will need to
use the "gdkxft" supplied theme.
For RPM users, there is a spec file in the tarball, and an RPM can be built
with "rpm -tb <tarball>.tgz". Then install the binary RPM
that is produced from that.
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
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 quaility TrueType
fonts!
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:
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 XF86Config for
3.3.6 and XF86Config-4 for 4.x. Of course, you'll need
to know which is which for editing and configuration purposes.
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.
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).
As of Red Hat 7.1, the xfs init script actually runs
mkfontdir and ttmkfdir on
font directories known to xfs. So this step is not necessary when
new fonts are added. Just restart xfs.