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.
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
In order to use TrueType, you must also specify which font module the X server should be using in the "Module" section:
Section "Module"
Load "freetype"
Load "speedo"
Load "type1"
<load other modules....>
EndSection
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.
Minimum requirements for Anti-Aliasing:
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. Type 1 is also good, but may not render quite as well. 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 1.x does not support anti-aliasing. GNOME 2.0 has recently been released and does 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, not all do. KDE/QT is first out of the box and has good support. Also, xterm (yes, xterm!) supports the new extensions. An interesting example scavenged off usenet:
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 |
You might have to experiment with the size and charwidth values to get reasonable results.
The new rendering extensions configuration file, XftConfig, must be configured for the fonts you want to use. Note that as of Xft2, this changes to /etc/fonts/fonts.conf.
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. Essentially, this gives us two separate font handling engines: the traditional, "core" font engine, and the new, Xft engine. The core engine is still used in some situations.
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. If not, the system should gracefully fall back to the core X fonts engine.
By Danny Tholen <obiwan@mailmij.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.
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)
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.
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:
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?
Anti-aliasing my fonts are blurry and makes me dizzy!
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!
match
any family == "mono"
edit
spacing = mono;
My Symbol, Webdings, etc. fonts do not show up!
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.
I have a LCD screen on my laptop, can I use sub-pixel hinting instead of normal anti-aliasing?
or use rgb if you have a different type of monitor. For vertical AA you can try vbgr and vbgr.
#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.
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 can also turn on Xft debugging:
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.