Gentoo Wiki


Please improve it in any way that you see fit, and remove this notice {{Cleanup}} from the article. For tips on cleaning and formatting see Cleanup process

Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article

 XOrg IndexConfigurationHIDevices
FontsVideo CardsMonitors  




After changing the X server from XFree to X.Org, many people took issue with the font rendering and anti-aliasing, especially those with LCD flat panels. This HOWTO makes fonts considerably more readable. In addition, this HOWTO explains font installations.


Fonts on computers in general, and on Linux's X11 in particular, are a messy affair. There are many different font formats, ranging from old bitmap fonts to TrueType fonts. In addition, many fonts have problematic licensing and embedding issues. Finally, the main font rendering programs suffers from patent issues (which apple fortunately has not enforced yet) if you want to turn on hinting, which only adds to the confusion.

Many programs, notably Ghostscript, Mozilla, and TeX, have their own ideas about fonts and font configuration. This means that the information in this HOWTO may not be sufficient to get your fonts to work.

To give you an idea: X11 does not have one font subsystem, but two! The old "core X font subsystem" have names like -misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1. The newer font system is known as fontconfig, works with the Xft library and hopefully will eventually replace the old system entirely. In addition, there is a font server named xfs.

A Note on DPI

Before any software based tweaks, the best thing you can do to make sure that you get good looking fonts under Linux is to use an LCD/CRT monitor with at least 96 dpi (dots per inch). To calculate this, take the horizontal resolution and divide it by the width of the LCD/CRT screen (in inches). Anything less than 96 dpi will produce noticeable problems that no amount of tweaking will fix.

CRTs will almost always render fonts blurrier than LCDs because of the inherent blurring from the electron beam scan and the phosphor coated screen.

See HOWTO_Set_DPI_Dots_Per_Inch for setting your DPI.

Note on Comparing Windows/Mac OS Fonts to Linux Fonts

Windows (clear type) and Mac OS fonts will always look better than Linux fonts when a LCD has less than 96 dpi. When the dpi is 96 or greater, Linux fonts can look as good as or better than Windows or Mac OS. Of course, none of this is true if you install a patched libXft, which is available in the xeffects overlay.

Emerging the Necessary Packages

You will need the global USE flag truetype for various packages. If you plan to run the KDrive Tiny X Server, you should also set type1. Only if you will be running an X-Server for multiple clients should you need the font-server USE flag.

These are the necessary packages:

Essential high-quality fonts:

Ebuild Description
media-fonts/corefonts Microsoft's free-ish fonts: Arial, Andale Mono, Verdana, ...
media-fonts/ttf-bitstream-vera High-quality fonts by GNOME project: Vera Sans, Serif, Mono
Notable for Luxi Mono, a fixed width serif
media-fonts/terminus-font A clean fixed font for the console

Other popular fonts:

Ebuild Description
media-fonts/arkpandora Alternative to corefonts with nicer license. Includes font similar to Arial Mono
media-fonts/liberation-fonts GPL-2 Helvetica/Times/Courier replacement TrueType font set, courtesy of Red Hat
media-fonts/unifont Note: media-fonts/unifont blocks dev-util/eclipse-sdk)

If you want to see your national characters by default, then you should use dejavu font instead of ttf-bitstream-vera. To get it perform following steps:

# emerge -C ttf-bitstream-vera
# emerge dejavu
# echo "media-fonts/ttf-bitstream-vera-1.10-r3" >>/etc/portage/profile/package.provided

Enable the use flags either by editing /etc/make.conf or running:

# euse --enable truetype

And, if you plan to use KDrive Tiny X Server :

# echo "x11-base/kdrive type1" >> /etc/portage/package.use

If you updated your USE flags, you should re-emerge world:

# emerge --ask --verbose --newuse world

Then, emerge the packages (you can skip some of the unnecessary ones):

# emerge --ask --verbose --noreplace freetype corefonts freefonts artwiz-aleczapka-en \
    terminus-font ttf-bitstream-vera liberation-fonts-ttf unifont dejavu xorg-x11

For X.Org 7.0: if you use UTF-8, you will need fonts for Eastern/CJK character sets. See this thread on the Gentoo Forums. Some examples:

International X11 Fixed Fontsmedia-fonts/intlfonts

Programmers' Fonts

Programmers often need monospaced fonts that are readable at small sizes.

Font NameEbuild
Aerial Monomedia-fonts/arkpandora
Andale Monomedia-fonts/corefonts
Vera Sans Monomedia-fonts/ttf-bitstream-vera
Luxi Monomedia-fonts/font-bh-type1

The following fonts are not in portage, but are freely available and worth Google'ing for:

Windows Fonts

If you feel constrained by the free fonts, Microsoft Windows, Office, et cetera, come with some excellent fonts that are not included in media-fonts/corefonts. True Type Fonts can be installed in the /usr/share/fonts directory, or subdirectories below it. These are detected automatically, when the X system is started. If you haven't wiped your Windows partition yet, the *.ttf files you'll find there could be used with Note that in order to use those fonts legally, you must have an appropriate license.

Some of Windows Vista's fonts deserve special mention: Candara, Consolas (monospaced), Corbel.

Hinting Information

Hinting is part of the rendering process of a font. In general, hinting guides the rasterizer so that it produces a better looking onscreen font, especially with smaller font sizes. Due to possible patent issues, FreeType has the option of being compiled with TrueType's BCI, Byte Code Interpreter.

Without BCI, the default, FreeType uses its own auto-hinter to improve the quality of the onscreen fonts at small sizes. The auto-hinter is still a work in progress, and improves with each release of FreeType. The auto-hinter usually produces excellent results. However, many feel that TrueType's native BCI produces results superior to the auto-hinter, especially on combined dual-head layouts, as it uses the hinting information contained in the font.

If you live in a country where software patents are not an issue or you interpret the possible patent issues as unlikely since Apple knows about FreeType and hasn't filed a lawsuit, you can enable the BCI by disabling the bindist USE flag. See The FreeType Project's article on FreeType and Patents for more information.

# echo "media-libs/freetype -bindist" >> /etc/portage/package.use
# emerge -av freetype

If you find out that fonts are too fuzzy on your LCD panel, please try to enable bindist and see the difference. It might work better for you.

Configuration Files

With the fonts installed, you now have to modify the config files in order to make the system recognize them. These are the files you have to modify:

To check which fonts are installed, you can use fc-list (a part of media-libs/fontconfig) and xlsfonts. For visuals on available fonts, try media-gfx/gnome-specimen (a font preview application) and gnome-extra/gucharmap (a unicode character map viewer).

The Xft Font System

The system wide configuration file resides at /etc/fonts/local.conf while ~/.fonts.conf is an optional user font configuration file which takes precedence over system wide changes, except in regards to anti-aliasing settings which cannot be overridden by users.

You don't need to set all the font directories unless you install fonts in non-standard places. /etc/fonts/fonts.conf includes /usr/share/fonts and everything beneath that, as well as a few other directories such as ~/.fonts.

Note that /etc/fonts/local.conf and ~/.fonts.conf are XML files that and are easier to edit with a editors that support XML syntax highlighting. Included in the following example are many options you may want to use:

File: /etc/fonts/local.conf or ~/.fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/local.conf file to configure system font access -->

<!-- Use the Autohinter -->
	<match target="font">
		<edit name="autohint" mode="assign"><bool>true</bool></edit>

<!-- Disable Autohinting for bold fonts -->
	<match target="font">
   		<test name="weight" compare="more"><const>medium</const></test>
   		<edit name="autohint" mode="assign"><bool>false</bool></edit>

<!-- Enable sub-pixel rendering -->
<!-- Uncomment this if you have an LCD screen
        <match target="font">
                <edit name="rgba" mode="assign"><const>rgb</const></edit>
<!-- Exclude/Include a range of fonts for Anti Aliasing -->
	<match target="font">
		<test qual="any" name="size" compare="more"><double>9</double></test>
		<test qual="any" name="size" compare="less"><double>14</double></test>
		<edit name="antialias" mode="assign"><bool>true</bool></edit>

<!-- And/Or disable Anti Aliasing for a range on pixel-based size.
     Disabling this using both methods seems to fix Firefox. -->
	<match target="font">
		<test compare="less" name="pixelsize" qual="any"><double>20</double></test>
		<edit mode="assign" name="antialias"><bool>false</bool></edit>

<!-- Other config options that were added to previous versions of config files in the Gentoo Wiki HOWTO.
     Need clarification. -->
	<match target="font">
		<edit name="hinting" mode="assign"><bool>true</bool></edit>
		<edit name="hintstyle" mode="assign"><const>hintmedium</const></edit>


Some settings should not reside in a system wide config file, unless it is certain that all users will approve of such tweaks. These may better belong in ~/.fonts.conf

File: ~/.fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- ~/.fonts.conf file to configure system font access -->

	<!-- Replace Courier with a better-looking font -->
	<match target="pattern" name="family">
		<test name="family" qual="any"><string>Courier</string></test>
		<edit name="family" mode="assign">
			<!-- Other choices - Courier New, Luxi Mono -->
			<string>Bitstream Vera Sans Mono</string>

	<!-- Reject bitmap fonts in favour of Truetype, Postscript, etc. -->
				<patelt name="scalable"><bool>false</bool></patelt>


Remember that all changes to /etc/fonts/local.conf are system wide and will be overridden by ~/.fonts.conf, except for the anti-aliasing setting which will be forced on if set in the system wide file. The syntax of /etc/fonts/local.conf is exactly the same as the local user font configuration file ~/.fonts.conf and therefore you may copy either file and rename it as the other.


You will almost certainly want to use some form of font hinting. There are two forms of Hinting supported by Gentoo Linux:

By default, FreeType's auto hinter is used, and is the default setting in the example configuration file. However, when using autohinting you will also most likely want to disable autohinting on bold fonts to prevent bold fonts from appearing too wide. The example file defaults autohinting on bold fonts to be off.
TrueType Byte Code Interpreter (BCI)
If you have compiled FreeType to use the TrueType Byte Code Interpreter (see above), and wish to use the BCI, then turn the auto hinter off entirely. (Make sure that <edit name="autohint" mode="assign"><bool>true</bool></edit> uses false instead of true. There are possible patent issues with using the TrueType BCI; if you wish to avoid the issue entirely, don't use the BCI.

Both KDE and GNOME have nice GUIs in which the user can select between 'light,' 'medium,' and 'strong' hinting. This appears to refer to the FreeType 'auto hinter', and not the BCI. If you use the BCI, the only settings that seem to make any difference is to have hinting 'off' entirely (which looks ugly). In other words 'light,' 'medium,' and 'strong' hinting appear to all look identical when the BCI is used instead of the auto hinter.

Sub-Pixel Rendering

In the above file, the sub-pixel rendering option is commented out because it is only useful for LCD panels. When enabled on a CRT display it only causes X.Org to do more rendering work. Possible values are "none", "rgb", "bgr", "vrgb" and "vbgr" for the sub-pixel rendering type. The most common type of LCD panel is the "rgb" type, which is what the example above uses.


The anti-aliasing option is commented out because some people prefer to exclude or include a set of font sizes from getting anti-aliasing applied to them. It is a common tweak that makes your fonts look much more like the Windows® default fonts. When disabling anti-aliasing make sure to also disable sub-pixel rendering to achieve the best non anti-aliased fonts.

User Fonts

If you have your own fonts in a different directory than the default /usr/share/fonts/ (or the corresponding /usr/local/share/fonts/), you will want to add:

File: /etc/fonts/local.conf or ~/.fonts.conf

to the end of your config files (just before </fontconfig>.


When configuring X it is important to make sure that it has the correct understanding of the size of your screen, make also sure that you're running LCDs at their native resolution, which is used to calculate the horizontal and vertical pitch (DPI) of the screen - fonts in GTK+ apps seem to get especially uglified by bad screen info. This can also cause mis-sizing of fonts in various apps. Some fonts will be sized correctly depending on the method used, others will be of different sizes. I noticed the biggest differences when browsing pages with Firefox. If it used CSS it was fine, if it use HTML the sizing was either huge or small depending on the direction of the wrong DPI setting. I also found 96 DPI is a good size.


See HOWTO Set DPI Dots Per Inch for setting the DPI using various methods.

Next we have to list our font directories in /etc/X11/xorg.conf. The font paths are searched in the order they are listed, so before we're done we'll tweak that order a bit.

Reasonably modern applications and DE's such as Gnome and KDE use fontconfig so the only fonts that are actually required via the X server (or font server) is fixed and cursor.


The first path we want on our list is /usr/share/fonts/misc. This is where the all-important fixed and cursor fonts are kept. These are crucial for the proper operation of X.Org. This is where the default cursor is located, and putting it first in the path keeps X from using the custom cursors that some font packages install (artwiz).

The :unscaled option tells X to use the unscaled versions of these fonts whenever possible to prevent pixelation. This can apply to any bitmap font.


These are the base bitmap fonts. We usually want 75dpi to be loaded before 100dpi since a lot of themes expect it. Most modern monitors will have a high dpi however, so if you find yourself squinting to read menus, you might want to experiment switching the order.


Type1 and TrueType fonts. The order shouldn't matter much, but might be notable that both of these packages contain the Luxi Sans/Serif/Mono fonts.


These are Microsoft's TrueType core fonts and a collection of TrueType fonts, respectively.


If you emerged the packages suggested above you should also have this list of fonts.


These are usually not needed, and are mostly empty or non-existent. To be sure check the file fonts.dir inside each directory. If this file contains a '0' the directory does not need to be added to the font path.


All the directories of the new fonts you just emerged. The order shouldn't matter as most of the fonts these packages provide are unique. If you're worried about a particular font, place it higher up. You can check a list of what fonts are provided in each directory's fonts.dir file.

Now to make a few final changes to the order. Take the base bitmap fonts and put them last. This is because we now have much better TTF or Type1 versions of some of these fonts we'd rather use. Also, media-fonts/corefonts contains a lot of, um, core fonts and should be pretty high on the list.

The end result should look something like this:

File: /etc/X11/xorg.conf
FontPath    "/usr/share/fonts/misc:unscaled"
FontPath    "/usr/share/fonts/Type1"
FontPath    "/usr/share/fonts/TTF"
FontPath    "/usr/share/fonts/corefonts"
FontPath    "/usr/share/fonts/freefonts"
FontPath    "/usr/share/fonts/terminus"
FontPath    "/usr/share/fonts/ttf-bitstream-vera"
FontPath    "/usr/share/fonts/unifont"
FontPath    "/usr/share/fonts/75dpi:unscaled"
FontPath    "/usr/share/fonts/100dpi:unscaled"
FontPath    "/usr/share/fonts/artwiz"

(Credit for some of the above goes to the XFree86 Font De-uglification HOWTO)

Also further down in the same file, please pay attention to the line where the freetype module is loaded. It should be uncommented:

File: /etc/X11/xorg.conf
Load "freetype"

Screenshot Examples

To the left are two screenshot examples of the Web page highlighting the different font configuration options.

Optimized for LCD
Optimized for LCD
Anti-Aliasing off - Like Windows®
Anti-Aliasing off - Like Windows®

Restarting Services

After modifying config files, you have to restart If you use an X display manager such as GDM, KDM, XDM, etc., you may be able to simply log out of your session and restart X by pressing Ctrl+Alt+Backspace at the login screen. If that doesn't work, restarting is possible by restarting the xdm service).

Someone could notice a system freeze by launching the following commands in, so I advise to launch them in another terminal, that is press CTRL + ALT + F1 and log in. (Pressing ALT + F7 will return you to X from the console.)

# /etc/init.d/xdm restart

After executing this command, your X display manager should restart. You should have anti-aliased fonts after logging back in.


Mozilla Firefox 1.0+

Make sure you have started Firefox at least once, so that you have a profile in ~/.mozilla/firefox/

Go to about:config in your browser, or alternatively, edit the user.js file in ~/.mozilla/firefox/, where xxx are letters or numbers.

Firefox 1.0.4 keeps a prefs.js file in ~/.mozilla/firefox/xxx.default/ where xxx is a string of numbers and letters.

Through the about:config dialog, or in the user.js file you have to insert the following lines as shown below:

Attention: Setting "font.FreeType2.printing" to true might cause Firefox to die when trying to print on cups.

File: ~/.mozilla/firefox/___.default/prefs.js
// TrueType
user_pref ("font.FreeType2.enable", true);
user_pref ("font.freetype2.shared-library", "");
// if libfreetype was built without hinting compiled in
// it is best to leave hinting off
user_pref ("font.FreeType2.autohinted", true);
user_pref ("font.FreeType2.unhinted", true);
// below a certain pixel size anti-aliased fonts produce poor results
user_pref ("font.antialias.min",        0);
user_pref ("font.embedded_bitmaps.max", 1000000);
// sample user_pref s for TrueType font dirs
user_pref ("", "/usr/share/fonts/ttf-bitstream-vera");
user_pref ("", "/usr/share/fonts/TTF");
user_pref ("", "/usr/share/fonts/corefonts");
user_pref ("", "/usr/share/fonts/freefont");
user_pref ("font.FreeType2.printing", true);

If you have followed this HOWTO you shouldn't have problem with the listed directories, otherwise you can change them.

In Firefox 1.0, go to Edit » Preferences » General » Fonts & Colors.

In Firefox 1.5, go to Edit » Preferences » Content » Fonts & Colors » Advanced.

Then, set these parameters:

You should also check that the following boxes are not ticked: Always use my: Fonts

Then restart Firefox and browse with antialiased fonts!

If you are using KDE and Firefox is not antialiased after this, go to Control Centre->Appearance and Themes->Fonts, disable anti-aliasing, hit apply, and then enable anti-aliasing and hit apply.

Mozilla Thunderbird 0.7, 1.0.2 and Later

There are very few options in Thunderbird that relate to fonts, so all options must be applied to user.js. Create this file in ~/.thunderbird/default/xxxxxxxx.slt/ (or, in newer versions, ~/.thunderbird/xxxxxxxx.default/). In user.js you have to insert the same lines as were entered for Mozilla Firefox: note: prefs.js is generated by thunderbird at runtime, you must create user.js in the same directory to make persistent changes.

File: ~/.thunderbird/default/xxxxxxxx.slt/user.js
// TrueType
user_pref ("font.FreeType2.enable", true);
user_pref ("font.freetype2.shared-library", "");
// if libfreetype was built without hinting compiled in
// it is best to leave hinting off
user_pref ("font.FreeType2.autohinted", true);
user_pref ("font.FreeType2.unhinted", true);
// below a certain pixel size anti-aliased fonts produce poor results
user_pref ("font.antialias.min",        0);
user_pref ("font.embedded_bitmaps.max", 1000000);
user_pref ("font.scale.tt_bitmap.dark_text.min", 0);
user_pref ("font.scale.tt_bitmap.dark_text.gain", "0.0");
// sample user_pref s for TrueType font dirs
user_pref ("", "/usr/share/fonts/ttf-bitstream-vera");
user_pref ("", "/usr/share/fonts/TTF");
user_pref ("", "/usr/share/fonts/corefonts");
user_pref ("", "/usr/share/fonts/freetype");
user_pref ("font.FreeType2.printing", true);

Then, with Thunderbird 1.0.2 opened, go to: Edit » Preferences » Fonts Or (on 0.7) Tools » Options » Fonts and set these parameters:

Proportional: Serif (Size: 16)
Serif: Bits-bitstream vera serif
Sans-serif: Bits-bitstream vera sans
Monospace: Bits-bitstream vera sans mono (Size: 12)
Minimum font size: 9

You should also check that the following boxes are ticked: Allow messages to use other fonts

Then restart Thunderbird and read your mail with crisp, clean fonts!

KDE Applications Size Problems

If in your kde apps the fonts are the wrong size but you don't have kde installed (you can not change it from Control Center) you just have to edit your ~/.kde/share/config/kdeglobals with something like:

File: ~/.kde/share/config/kdeglobals
 StandardFont=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0
 activeFont=Bitstream Vera Sans,7,-1,5,75,0,0,0,0,0
 fixed=Bitstream Vera Sans Mono,7,-1,5,50,0,0,0,0,0
 font=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0
 menuFont=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0
 taskbarFont=Bitstream Vera Sans,7,-1,5,50,1,0,0,0,0
 toolBarFont=Bitstream Vera Sans,7,-1,5,50,0,0,0,0,0

The number after the font name is the size. (I don't know what the other numbers are, just try)

It happened that my Firefox toolbar/menu fonts were enormous. To solve just add to your ~/.mozilla/firefox/<yourprofile>/chrome/userChrome.css:

File: ~/.mozilla/firefox/<yourprofile>/chrome/userChrome.css
* {
    font-family: Sans-Serif !important;
    font-size: 8pt !important;
and do the same for Thunderbird (~/.thunderbird/<profile>/chrome/userChrome.css)

If somehow the '*' does not work for you, this CSS snippet covers most of the Firefox/Thunderbird GUI:

File: ~/.mozilla/firefox/<yourprofile>/chrome/userChrome.css
statusbar, input, menu, menuitem, menulist, label, description, tree, treechildren, .tree-bodybox, {
    font-family: Sans-Serif !important;
    font-size: 8pt !important;

In my case, after making all those changes, the fonts for the input fields (buttons, text entry, or drop-down menus) in some web pages like Google or Amazon were way too big and still using one of the ugly fonts. To change that, go to userContent.css (that's different from the userChrome.css file we just modified), and add the following entry:

File: ~/.mozilla/firefox/<yourprofile>/chrome/userContent.css
input, textarea, select, button,
input[type="button"], input[type="reset"], input[type="submit"] {
   font-size: 8pt !important;
   font-family: Verdana !important;


KDE users probably know Konsole, the KDE X terminal emulator. But some users get the following error if they try to use the Linux font: Font `-misc-console-medium-r-normal--16-160-72-72-c-80-iso10646-1' not found.

You can solve this by executing the following steps:

  1. Start kdesu kcmshell kcmfontinst when you are in kde.
  2. Give the root password.
  3. Click on the add fonts icon (an @-sign with a +-sign on it)
  4. Go to the dir /usr/kde/3.2/share/fonts/ and add all fonts (files ending in .pcf.gz) available.

Blurry and Unreadable Fonts

For me, my fonts would occasionally become unreadable in Gnome 2.12.

Completely disabling AntiAliasing (comment out those sections in /etc/fonts/local.conf and ~/.fonts.conf as they are in the examples above) solves this problem.

Startx Error

Hell-Razor found out a quick fix to the following "Fontconfig error" when trying to startx:

"Fontconfig warning: no <cachedir> elements found. Check configuration." 
"Fontconfig warning: adding <cachedir>/var/cache/fontconfig</cachedir>" 
"Fontconfig warning: adding <cachedir>~/.fontconfig</cachedir>

An easy fix to this is to run:

emerge --noconfmem --oneshot fontconfig && dispatch-conf


If after all this work, you find that you do not have a good font for XEmacs (which does not support anti-aliasing), then try the neep fonts. The package you need is:

 emerge x11fonts-jmk

Then add another FontPath entry in your xorg.conf, like so:

File: xorg.conf
FontPath    "/usr/share/fonts/jmk"

Restart the font system (exit from X). Then try setting your XEmacs font to "Neep Alt". You probably want the "alt" version since the regular version has a wonky ampersand character.

Related Topics

These are the topics from which I took informations in order to write this HOWTO:


I want to thank the Gentoo Italian Community and the Gentoo Community, which make Gentoo so powerful and incredible. A special thank to BlueRaven for his explanation about fonts in [xfree] caratteri sfocati and to FonderiaDigitale who led me to the final solution for my problem.

A special thank you to Pattern in the #gentoo-amd64 channel and Marienz in #gentoo for the Fontconfig problem. Without you guys I would have torn my hair out.

See Also

Retrieved from ""

Last modified: Thu, 02 Oct 2008 01:41:00 +0000 Hits: 346,805