Linux FAQ's & Manuals


fontconfig and xft

xft was designed from the start to support scalable fonts well, including anti-aliasing.6

contrary to the x11 core font system, fonts are not rendered by the x server when using the xft library, they are rendered by the application using the fonts. that way, the application gets direct access to the font files if necessary and full control over details in rendering the glyphs. this is required to achieve correct rendering for some languages. on top of that, direct access to the font files is very useful to embed the fonts used for display into the postscript output used for printing and achieve that the printout really looks like what was displayed on the screen.

the desktop environments kde and gnome, mozilla and many other applications already use xft by default on suse linux. that means xft is already used by the majority of applications on suse linux and is already more important than the old x11 core font system.

xft uses the fontconfig library to locate fonts and to influence some details how they are rendered. the behaviour of fontconfig is controlled by a system wide configuration file /etc/fonts/fonts.conf and a user specific configuration file ~/.fonts.conf. both of these fontconfig configuration files must start with

      <?xml version="1.0"?>      <!doctype fontconfig system "fonts.dtd">      <fontconfig> 

and end with

      </fontconfig> 

to add directories which are searched for fonts, one can add lines like the following

     <dir>/usr/local/share/fonts/</dir> 

but this is rarely necessary. the user specific font directory ~/.fonts is already included in /etc/fonts/fonts.conf by default. therefore, if a user wants to install additional fonts for her personal use, it is enough to copy them to ~/.fonts.

one can also add rules to the fontconfig configuration files like ~/.fonts.conf to influence the appearance of the fonts. for example, to switch off anti-aliasing for all fonts one can add

      <match target="font">          <edit name="antialias" mode="assign">              <bool>false</bool>          </edit>      </match> 

and to switch off anti-aliasing only for specific fonts one can use rules like

      <match target="font">          <test name="family">              <string>luxi mono</string>              <string>luxi sans</string>          </test>          <edit name="antialias" mode="assign">              <bool>false</bool>          </edit>      </match> 

which switches off anti-aliasing only for the fonts ``luxi mono'' and ``luxi sans''.

most applications use the font names sans-serif (or the equivalent sans), serif, or monospace by default. these are not names of real fonts, these are just generic aliases which are resolved to a suitable installed fonts depending on the language selected in the locale (see section 3).

a user can easily add rules to her ~/.fonts.conf to achieve that these aliases resolve to her favourite fonts, for example:

         <alias>                 <family>sans-serif</family>                 <prefer>                         <family>freesans</family>                 </prefer>         </alias>         <alias>                 <family>serif</family>                 <prefer>                         <family>freeserif</family>                 </prefer>         </alias>          <alias>                 <family>monospace</family>                 <prefer>                         <family>freemono</family>                 </prefer>         </alias> 

as most applications use these aliases by default, this setting affects almost the whole system and the user gets her favourite fonts almost everywhere without having to change the font settings of each application seperately.

to find out which fonts are installed and usable, the command fc-list can be used. for example,

     fc-list "" 

outputs a list of all installed fonts.

if the user wants to list the available fonts which are scalable scalable (:outline=true) and have all glyphs necessary for hebrew (:lang=he) and wants to list the font name (family), the style (style), the boldness (weight), and the name of the file containing the font (file), she can use the following command:

     /usr/x11r6/lib/x11/fonts/truetype/freesansbold.ttf: freesans:style=bold:weight=200     /usr/x11r6/lib/x11/fonts/truetype/freemonoboldoblique.ttf: freemono:style=boldoblique:weight=200     /usr/x11r6/lib/x11/fonts/truetype/freeserif.ttf: freeserif:style=medium:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freeserifbolditalic.ttf: freeserif:style=bolditalic:weight=200     /usr/x11r6/lib/x11/fonts/truetype/freesansoblique.ttf: freesans:style=oblique:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freeserifitalic.ttf: freeserif:style=italic:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freemonooblique.ttf: freemono:style=oblique:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freemono.ttf: freemono:style=medium:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freesans.ttf: freesans:style=medium:weight=80     /usr/x11r6/lib/x11/fonts/truetype/freeserifbold.ttf: freeserif:style=bold:weight=200     /usr/x11r6/lib/x11/fonts/truetype/freesansboldoblique.ttf: freesans:style=boldoblique:weight=200     /usr/x11r6/lib/x11/fonts/truetype/freemonobold.ttf: freemono:style=bold:weight=200 

the most important parameters which can be used with the fc-list command are:

parameter meaning and possible values
family name of the font family, for example ``freesans''
foundry the company which created the font, for example ``urw''
style style of the font, for example ``medium'', ``regular'', ``bold'', ``italic'', ``heavy'', ...
lang language(s) supported by the font, for example ``de'' (german), ``ja'' (japanese), ``zh-tw'' (traditional chinese), ``zh-cn'' (simplified chinese), ...
weight ``boldness'', for example ``80'' usually means not bold, ``200'' means bold.
slant ``slantness'', ``0'' means not slanted, ``100'' means slanted.
file the name of the font file.
outline ``true'' if it is an outline-font, otherwise ``false''.
scalable ``true'' if it is a scalable font, otherwise ``false''.
bitmap ``true'' if it is a bitmap font, otherwise ``false''.
pixelsize size of the font in pixels. when used with fc-list this parameter makes only sense for bitmap fonts.



footnotes

... anti-aliasing.6
xft and fontconfig was designed and implemented by keith packard. see also the fontconfig home page at http://www.fontconfig.org/
2005-03-09