Guide to X11/Fonts

Fonts
When your X11 clients draw text, they use fonts, which are drawings of standard characters, such as letters, numerals, and punctuation. At minimum, a font is a typeface (also called family) such as Bitstream Vera Sans, Luxi Mono , Nimbus Roman No9 L , or fixed. More specifically, a font includes a size or style, such as Bitstream Vera Sans Bold Italic 10 point. Fonts also come in three categories called serif (like Nimbus Roman No9 L), sans-serif (like Bitstream Vera Sans), and monospace (like Luxi Mono or "fixed").

Fonts come in several font formats such as bitmap, TrueType, and PostScript. TrueType fonts are .ttf files. If the X11 server and client are at different computers, then you might have installed different fonts at each computer.

Core versus Xft fonts
X11 clients can draw texts in several different manners:
 * 1) Use the original core X11 protocol to draw text. With this approach, the X11 server loads and stores each character of a font. Thus, if the X11 server (with the screen and keyboard) and the X11 client (with your web browser or other window) are at different computers, then you must install fonts at the server. The server converts the characters into bitmaps and draws them upright, which means that you cannot rotate them. Further, the server never antialiases the fonts.
 * 2) Use the Xft library and RENDER extension to draw text. With this approach, the X11 client loads and stores each character of a font. You must install fonts at the client machine. The client converts the characters into geometric shapes. It decomposes the shapes into basic shapes such as triangles and trapezoids, then sends these to the server. The server draws the shapes and optionally provides antialiasing, which smooths the appearance of fonts. One can also rotate these shapes.
 * 3) Use a client-side library such as libart_lgpl or SDL_ttf to draw text. While libart_lgpl is a vector-graphics library, SDL_ttf is a library to draw text for programs that use the cross-platform Simple DirectMedia Layer. Typically, these libraries load the geometric shapes, then draw them into bitmaps, possibly antialiased and rotated, before sending them to the X11 server, as if the X11 server knew nothing about text. It is also possible for these libraries to do as Xft does and use RENDER.

The first X11 clients used the core X11 protocol to draw text, as that was the only choice. However, several clients now use Xft. Because GTK+ and Qt, the toolkits behind several applications including all GNOME and KDE applications, switched to Xft, many programs on most desktops, including Konqueror, now use Xft.

Configuring Xft with fontconfig
The older Xft version 1 had its own configuration scheme. Version 2, described here, uses fontconfig for its configuration. Because fontconfig is independent of X11, there are programs like fc-list which list fonts available to X11 programs like Konqueror, but do not themselves use X11. An easy terminal command to list available fonts is:

$ fc-list | sort | less

The default /etc/fonts/fonts.conf allows you to optionally create a custom file ~/.fonts.conf for your custom font settings.

Some customizations include:
 * 1) You can add additional directories that contain fonts. Fontconfig searches directories recursively. If you have a folder with .ttf files in it, then you can simply add it to ~/.fonts.conf; you do not need to write a fonts.scale or any other such file for fontconfig.
 * 2) You can specify additional fonts to search for obscure characters. If you do not see a right-arrow between these quotes "&rarr;" then the right-arrow character was not found during the search for characters to draw this sentence. In fact, the Bitstream and Luxi fonts included with Xorg and the Nimbus fonts from ghostscript do not have that character, but the "Standard Symbols L" font from ghostscript includes a right arrow.

However, ~/.fonts.conf uses a strict XML syntax. You must declare </tt> at the beginning of the file, and you must put everything else in the file between <tt> </tt> and <tt> </tt> tags, else it will not work.

Here is an example file, showing how to perform the two customizations: <?xml version="1.0"?> /usr/local/share/ghostscript/fonts sans-serif Standard Symbols L    serif Standard Symbols L   monospace Standard Symbols L

Adding a directory of fonts is simple: use <tt> /full/path </tt>. The above example adds <tt>/usr/local/share/ghostscript/fonts</tt>, which at some computers is the location of Ghostscript fonts including Standard Symbols L.

To add Standard Symbols L to the list of preferred fonts, so that we can always draw the right-arrow "&rarr;", is more difficult. Suppose that you had set the Konqueror web browser to use Luxi Serif to display web pages. You then had loaded some text including some right-arrows. When fontconfig failed to find a right-arrow in the Luxi Serif font, it resorted to the generic font name "serif", which is actually an alias for a list of preferred serif fonts.

For reference, here are the font aliases from the <tt>/etc/fonts/fonts.conf</tt> included with Xorg 6.9rc1.

serif Bitstream Vera Serif Times New Roman Thorndale AMT Luxi Serif Nimbus Roman No9 L 			 Times Frank Ruehl Kochi Mincho AR PL SungtiL GB 			 AR PL Mingti2L Big5 ï¼­ï¼³ ææ Baekmuk Batang FreeSerif sans-serif Bitstream Vera Sans Verdana Arial Albany AMT Luxi Sans Nimbus Sans L 			 Helvetica Nachlieli Kochi Gothic AR PL KaitiM GB 			 AR PL KaitiM Big5 ï¼­ï¼³ ã´ã·ãã¯ Baekmuk Dotum SimSun FreeSans monospace Bitstream Vera Sans Mono Andale Mono Courier New Cumberland AMT Luxi Mono Nimbus Mono L 			 Courier Miriam Mono Kochi Gothic AR PL KaitiM GB 			 Baekmuk Dotum FreeMono

Installing new fonts
Depending on your distribution there may be a foolproof font installation program - or not. In any case, using simple commands always works.

To install new fonts, just download the font files (for example ".ttf" files) and put them in the correct directory. For Xft with fontconfig, where and which types of fonts you can install is determined by the default configuration file  or the extra configuration in   or. Most distributions have in  the following line: ~/.fonts This means you can install new fonts in your home directory with simple user privileges. To update fontconfig you use the command.

To give an example: suppose you have downloaded the font  to your Desktop. Open your favorite terminal or a simple, and type: cd mkdir .fonts cd .fonts cp ~/Desktop/anicefont.ttf. fc-cache Done. You can check whether the font was successfully installed by using the command  (for example paging it with   and  ) and check for the name of your font:.