MAY
14
2001

How to configure your Anti-Aliased desktop

Various people have been asking how to configure fonts with the new Xft extension, which enables AA fonts, among other things.
This is a short tutorial on how to configure the new Xft extension.

Configuring the Xft extension (including antialiasing)
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 document
I will explain the syntax and demonstrate some things you can do with this
file.

Structure
The basic structure revolves around a 'pattern'. A pattern is a set of
name/valuelist pairs, each valuelist 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 antialiasing 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 antialiased? (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),demibold, bold, black)

rasterizer     not yet used (probably "TrueType",
               "Type1", ...)

outline        outlines available? (boolean)

Syntax
dir

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 usefull 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¨

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 one of the properties found above under
Structure.

COMPARE is <, >, or
==.

CONSTANT is the value of the field-name in the appropiate type (see
under Structure).

You can use multiple matches before you use the edit statement.

edit FIELD-NAME ASSIGN EXPR SEMI

FIELD-NAME can be any of the above (see Structure) plus addionally:

pixelsize        font size in
pixels (integer)
charspace        characer space
(integer)
minspace        
minimal spacing (integer)

rgba             color hinting (string ¨rgb¨ or ¨bgr¨ and
                 vertical hinting ¨vrgb¨ ¨vbgr¨)

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)

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.

Examples
And now I´ll try to list a few usefull 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.

1) 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"

2) 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.

3) 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";

4) Antialiasing my fonts makes me dizzy!

Although there is a big fuz around AA in X, good fonts actually look
better if they are not antialiased. The antialiasing blurs the fonts by
adding grey 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 ofcourse is not working because they are blurred;) However, for very
small fonts, antialiasing may increase the readability of the fonts, because
with sharp edges, there are to little pixels available for your mind to
figure out what it means. And for bigger fonts, the edges become very jagged
when not anitaliased, so here you also might want to have aliased fonts.
Ofcourse you can also turn off the antialiasing for specific fonts. In
other operating systems, most truetype fonts are not antialiased between 8 and 12
pixels, while only large Type1 fonts are antialiased.

Use the following in your XftConfig to antialias only fonts of specific sizes:

match
    any size > 8

    any size < 15

edit

    antialias = false;

5) 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):

match
    any family ==
"mono"

edit

    spacing = mono;

6) 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 usefull way of figuring out these things is to activate debuging
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.

7) Why do my KDE programs start now soooo slow?

Currently, the Xft mechanism in XFree 4.0.3 has to parse the XftConfig file each time a program is started.
And the info of all these fonts has to be read. Newer versions (in CVS) will use a cache and are much faster.
Especially if you have many fonts this can be a problem, and the only real solution is to upgrade to a CVS version of XFree.

8) I have a LCD screen, can I use subpixel hinting instead of normal antialiasing?

Yes you can. Subpixel hinting uses colors instead of grey 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.

9) My fonts still look bad!

If you do not have some good truetype fonts, it is worth 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 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 it.

10) Other resources on the web...

Here you can find more info about setting up the render and Xft extensions:
SuSE HowTo
Lars Knoll HowTo
My own XftConfig can be found here;
remember that it is specifically adapted to my system, and you will have to edit it.

Feedback is appreciated!

Comments

[NU: Click here to skip this thread]

Who cares? Ximian 1.4 is out and it is the Linux desktop standard. All the heavyweights in the Unix world have thrown their weight behind it. KDE no longer stands a chance. Besides, it sucks.


By ac at Mon, 2001/05/14 - 5:00am

Why do I get the feeling your email address matches your IQ? Go "home" flaming.

Besides: _very_ cool tutorial. I was looking for something comprehensive like this for a very long time!


By Daniel Molkentin at Mon, 2001/05/14 - 5:00am

If you think so little of KDE why do you keep an eye on all of the latest info about it?


By ld at Mon, 2001/05/14 - 5:00am

Whatever a "Linux" desktop standard is. Rumours have it KDE runs also on other *NIX systems.
But rather having the heavyweights throwing their weights around I prefer those slim guys and girls doing a fantastic job..... ;-}

thanks for this tutorial, that was exactly what I needed


By christoph at Mon, 2001/05/14 - 5:00am

I don't agree that all of the Unix heavyweights are behind Ximian. Correct me if I am wrong, but the last time I wrote apps for gnome, I was writing straight C, since I switched to Qt/KDE I have been able to do everything in C++ and it is SO much cleaner, I will never look back. I have been using AA fonts on my desktop since qt-2.3 came out without any trouble at all, however I still found this HOWTO very helpful, my thanks go to the author.
I care..


By Neil at Mon, 2001/05/14 - 5:00am

I'm a GNOME supporter too, but I find KDE's design much cleaner...

The only thing that really bugs me about KDE is QT licensing :(

I really hope the GNOME team will clean up GNOME and start to implement INTI (for C++)...

I think the KDE team is doing a great job (I love everything that supports Linux) but I really hope that someday we will have a standard desktop!

I hate it when people start flaming, it doesn't do anybody any good, we should all work together :)

Marc S


By Marc S at Mon, 2001/05/14 - 5:00am

> The only thing that really bugs me about KDE
> is QT licensing :(
??? I don't understand that - QT Free Edition is GPLed - is GPL not good enough for you? GNOME is GPLed, too... :-)

Greetinx,

Gunter Ohrner


By Gunter Ohrner at Mon, 2001/05/14 - 5:00am

I think he refers to the fact that Qt is GPL whereas GTK and Gnome libs are LGPL


By ac at Mon, 2001/05/14 - 5:00am

Hi!

Well, the FSF itself recommends the GPL in favour of LGPL and there are quite a few libs in GNOME that are GPLed, too. IIRC there was a discussion once to GPL all major GNOME libs so GNOME apps would be forced to be GPLed, too. I don't know if they did it or if they cancelled it.

Greetinx,

Gunter Ohrner


By Gunter Ohrner at Mon, 2001/05/14 - 5:00am

None of the essential Gnome libraries are GPL. And you probably remember the discussion backwards as there has been discussion that all essential gnome libs should be officially forced to be LGPLd or more liberally licensed. Not surprisingly RMS seems to have vetoed that.


By ac at Mon, 2001/05/14 - 5:00am

Although, I agree that it would be great if QT was LGPL'd, but if your a GNU fan, even Mr. Stallman has an article suggesting that all (well, most) libraries should also be GPL to further the movement. If you're a GNU fan, a GPL'd QT should make you excited!!!


By Anonymous at Mon, 2001/05/14 - 5:00am

> Ximian 1.4 is out and it is the Linux desktop standard.

You wish!


By Joe at Mon, 2001/05/14 - 5:00am

Although I am a GNOME supporter and use GNOME instead of KDE, trolls like you make me sick.
The GNOME vs KDE war is over! Go home and get a life!


By dc at Mon, 2001/05/14 - 5:00am

I agree, it's good for us Linux have so more choices than Windows & MacOS give for a desktop !

I hope there'll never be something like a "standard desktop", that's what M$ and Apple wanted to do since 20 years.

There's still a lot of work to do to have full font-AA everywhere (Gnome, Lesstif, whatever else...).


By Hervé PARISSI at Mon, 2001/05/14 - 5:00am

Ever get the feeling ac and dc are one and the same ?


By Da Maine Man at Mon, 2001/05/14 - 5:00am

Yeah, it's funny how ac and dc always reply to each other on both KDE and Gnome news.


By Henry Stanaland at Mon, 2001/05/14 - 5:00am

That is BECAUSE he is called ac.
"dc" is some kind of parody on the name "ac", get it?
I don't care whenether you believe me or not. It is the truth.


By dc at Tue, 2001/05/15 - 5:00am

Ever get the feeling ac and dc are 12 years old ?


By Da Maine Man at Wed, 2001/05/16 - 5:00am

I think you're the one who's 12 year old here.
I have done nothing wrong and yet you are accusing me!?


By dc at Wed, 2001/05/16 - 5:00am

How about we just ignore this guy from now on? He's always posting trying to start wars(on both KDE and Gnome news)...you shouldn't even bother replying. Obviously, he's just an idiot with too much time on his hands...too bad that he could better spend his time doing something productive.


By Henry Stanaland at Mon, 2001/05/14 - 5:00am

> Who cares? Ximian 1.4 is out and it is the
> Linux desktop standard. All the heavyweights
> in the Unix world have thrown their weight
> behind it. KDE no longer stands a chance.

That's strange. On my computer it seems like KDE is the Linux desktop standard. And there is no sign of change.


By Erik at Mon, 2001/05/14 - 5:00am

To you, the self-confessed troll:

Fact: KDE has it's own web browser, Gnome have to put up the shit Mozilla produces.

Fact: KDE has their own office suite. Gnome users have bits and pieces of shit applications.

Fact: KDE is designed by engineers. Gnome is hacked by kiddies.

Conclusion: who the fsck cares about Gnome anyway?


By Idiot-Buster at Mon, 2001/05/14 - 5:00am

Like I said, the GNOME vs KDE war is over.
If you want to respond on trolls, then flame the troll down.
He has nothing to do with GNOME.

1) Mozilla is not crap. Galeon + Mozilla 0.9 runs incredibly fast on my Pentium 166.
2) So it's not integrated yet. What's your point?
AbiWord and Gnumeric works fine even without some kind of integration center.
3) There are people who are involved with both KDE and GNOME. So by flaming like that you'll also be flaming at some KDE people.
4) I care about GNOME.

So the next time, flame/spam/kill the troll, not GNOME.


By dc at Tue, 2001/05/15 - 5:00am

ac needs a life. It seems odd how quick he is to always be one of the first to respond to any accomplishment that enhances KDE, saying, with no reasons to back it up, that GNOME is better. Impress me ac, tell me why. And, tell me what relevance it has to this discussion, I'm more than interested to hear that as well.


By dingodonkey at Mon, 2001/05/14 - 5:00am

I think it is great that someone put together this tutorial to help those that can have this now. It looks to be at least six months until Gnome users are so lucky.

signed,
One Very Happy Ximian Gnome User (who has to wait for AA fonts)


By Garrett Mickelson at Tue, 2001/05/15 - 5:00am

Actually, you are quite wrong. KDE is still the desktop standard. KDE is used on more Linux systems than any other D.E. in the world.
KDE also does not depend on stuff from dead companies (Eazel), and is the default desktop of the most popular Linux distro in March (SuSE).

-Tim


By Timothy R. Butler at Mon, 2001/05/21 - 5:00am

a lot of troll's here...

what about ximian alias eazel?

dead or dead?

read this article... guys.

wich wm becomes the standard?

end of the road for eazel?

http://linuxtoday.com/news_story.php3?ltsn=2001-05-12-001-20-NW-GN


By steve_qui at Mon, 2001/05/14 - 5:00am

C'mon, just because there are a few so-called "GNOME supporters" (aka Trolls) doesn't mean you can just flame at Gnome & Friends.
There are lots of KDE trolls at Gnotices too.


By dc at Mon, 2001/05/14 - 5:00am

Gosh - I was impressed by the detail of this tutorial. Perhaps I'm being lazy, but first, my fonts all worked under a clean Mandrake 8.0 install. I then copied the win2000 AA fonts into one of the directories and restarted the XFS.

Everything looks great. Sure, the smaller fonts are antialiased - but it actually looks good. And while my monitor is good at the current res (1600x1200 - Hitachi CM771) it's by no means some crystal-clear thing.

Otherwise, I'm *so* glad I don't have to edit font resources and so forth such as I used to have to do with getting fonts working for the gimp... Again, kudos to all involved!
K


By EKH at Mon, 2001/05/14 - 5:00am

Nice tutorial. I just wish I could work out why my Xft won't serve TrueType fonts. If I use it, I get only Type1 and bitmap fonts available. If I don't use it, I get all the fonts on my system, but none of them are antialiased.

Is there anything special I have to do to get it recognising TrueType fonts? I'm using XFree86-4.0.3 and Qt-2.3, both compiled from source, and my normal TrueType server (X's freetype engine) works fine, just (obviously) without AA.


By MaW at Mon, 2001/05/14 - 5:00am

Install mandrake 8.0. Problem will be solved.

Craig


By Craig at Mon, 2001/05/14 - 5:00am

Might be caused by your video card drivers, I had the same problem with the older NVidia drivers, but with the latest drivers this is fixed.


By Proton at Mon, 2001/05/14 - 5:00am

add to your /usr/X11R6/lib/X11/XftConfig:

dir "/path/to/truetype/fonts"


By Evandro at Mon, 2001/05/14 - 5:00am

I had the same problem
I added
dir "/usr/X11R6/lib/X11/fonts/TrueType"
to the /usr/X11R6/lib/X11/XftConfig file
and removed the Type1 and TrueType paths out
of XF86Config file (I don't use xfs server)
as explained in another tutorial on this same site


By wb at Mon, 2001/05/14 - 5:00am

Nice tutorial. I just wish I could work out why my Xft won't serve TrueType fonts. If I use it, I get only Type1 and bitmap fonts available. If I don't use it, I get all the fonts on my system, but none of them are antialiased.

Is there anything special I have to do to get it recognising TrueType fonts? I'm using XFree86-4.0.3 and Qt-2.3, both compiled from source, and my normal TrueType server (X's freetype engine) works fine, just (obviously) without AA.


By MaW at Mon, 2001/05/14 - 5:00am

Did you add your direcory with TT fonts to XftConfig,
with the 'dir' syntax?

Danny


By Danny at Mon, 2001/05/14 - 5:00am

Yes, I did. Didn't make a blind bit of difference - it's like my TrueType fonts just don't exist.


By MaW at Tue, 2001/05/15 - 5:00am

Funny that you say bitmap fonts work with Xft, because Xft does not support bitmapped fonts yet.

Did you compile against freetype 2.0.2? And be
sure to put XftConfig in the correct directory.
You can send me some debug info (see the tutorial on how to do that) and I will try to figure it out.

Danny


By Danny at Tue, 2001/05/15 - 5:00am

What I meant about the bitmap fonts was that they were there, in that X was serving them. Should've made that clearer really - although KDE seemed to only be able to see my Type 1 fonts, of which I have very few.

I'll have to try again and experiment - I compiled against whichever version of freetype is included with XFree86 4.0.3's source.


By MaW at Tue, 2001/05/15 - 5:00am

Wow, thanks a lot !!
I have always wanted to ONLY antialias fonts more than about 15 points in size.

Another thing that bugs me, is the clumsy way that I currently toggle anti-aliasing per application.
So instead of calling QT_XFT=0 every time b4 I run kwrite I did something like this:

cd /opt/kde2/bin
mv kwrite kwrite.bin
echo 'QT_XFT=0 ; kwrite.bin $*' > kwrite.bash
chmod +x kwrite.bash
ln -s kwrite.bash kwrite

Now, kwrite is no longer anti-aliased.
I wonder if there is a section in some config file that allows inclusion/exclusion of applications in/from anti-aliasing.

If there isn't, maybe it could look a bit like this

match
any app == konsole
any app == kwrite
edit
antialias = false;

Or maybe qtaa.allow and a qtaa.deny files or similar would make sense to have.
-------


By Risto Treksler at Mon, 2001/05/14 - 5:00am

A year have passed and my video card is still not supported by XFree86 4...

Hello XVideo. Hello anti-alias. Hello NewCoolFeatures(void).
May be see eachother in 50 years.


By dc at Mon, 2001/05/14 - 5:00am

Well, with a GeForce or 3Dfx card being cheap, maybe its time to support a Linux supporter.

Pricewatch.com has em dirt cheap!


By GreenLinux at Mon, 2001/05/14 - 5:00am

No PCI cards these days are cheap enough for me...


By dc at Tue, 2001/05/15 - 5:00am

I would sell my G200 for $50 :)


By Anonymous at Tue, 2001/05/15 - 5:00am

I'm using antialiased fonts now since a couple of weeks and they almost work. One thing, though, still bothers me: The system doesn't accept the settings for the "fixed font". Although I can select a TrueType version of courier in kcontrol/look&feel/fonts and it is shown correctly in the example line, the system doesn't use it (in the konsole part of konqueror, kate or gideon).
It uses instead the TT font that comes first in the TT directory when sorted alphabetically. Of course all paths are set correctly in XftConfig and there's no obsolete "kdefonts" file around (like in dep's case). I also think, that my XFree (4.0.3 as of SuSE 7.1) is patched to work with fixed fonts. Has anyone had the same problem and knows how to solve it? (Note: I'm not talking of konsole itself, which works properly with AA. Just the konsole part doesn't!)


By Melchior FRANZ at Mon, 2001/05/14 - 5:00am

What if you try to select a custom font in
konsole itself? Are there any fonts shown?

Danny


By Danny at Mon, 2001/05/14 - 5:00am

No, that doesn't help. As I already said, it's not a konsole problem. Konsole itself =does= work. Just the konsole kparts not, and there's not custom font setting facility in the kpart. Just the one from kcontrol. But that's exactly my problem. The system doesn't accept the kcontrol font settings (and =only= these!).


By Melchior FRANZ at Mon, 2001/05/14 - 5:00am

Ah, I see what you mean and think you have
hit a bug in KDE. Workaround would be to
alias the font that is selected automatically
with a font which is more to your liking.

Danny


By Danny at Mon, 2001/05/14 - 5:00am

No, I had already tried that workaround, desperately. A few minutes ago I had another look at that issue, and now I know why it didn't work: Not the font with the alphabetically lowest font file name was taken, but that with the lowest =internal= name. So the link couldn't work. Now I have copied the Monotyope Courier New and named it "aaaaaaa.ttf" (for cosmetic reasons, see above), then I changed the internal font name from "Courier New" to "AAAAAAA New" and turned off AA for this font in ~/.xftconfig. This is an ugly hack, but it works. I still do not know whom to blame -- KDE? the X-server?


By Melchior FRANZ at Mon, 2001/05/14 - 5:00am

I suspect KDE, but I'm not sure. More people have reported this problem, but not on all setups.
And the workaround you took is the only one I know about (see also the xfree render maillinglist).

Danny


By Danny at Tue, 2001/05/15 - 5:00am

Pages