Summary 

Toolkits that use the core X font protocol include Xt, Xaw, Xaw3d, Motif clones, Tk and GTK+-1.2.

Toolkits that use Xft are Qt and GTK+-2.

Over time, fontconfig/Xft will replace the core X font subsystem. At the present time, applications using the Qt 3 or GTK 2 toolkits (which would include KDE and GNOME applications) use the fontconfig and Xft font subsystem; most everything else uses the core X fonts.

Fonts 

http://users.dslextreme.com/~craig.lawson/linux_notes/x.html

Some font sources 

FontConfig 

Gentoo uses FontConfig. To add new fonts, either Type1 or TrueType:

  1. Create a subdirectory under one of the directories listed at the top of "/etc/fonts/fonts.conf". Example: /usr/share/fonts/cheapskate.

  2. Put fonts in the directory.

  3. That's it! FontConfig figures out when fonts are added or removed. You can list known fonts with "fc-list | sort | less"

Ghostscript 

Adding fonts to Ghostscript:

  1. Create a file in /etc/env.d called "99gs".

  2. Into the file put:

    GS_FONTPATH="/usr/share/fonts/cheapskate:/usr/share/fonts/..."

    including each directory of fonts that you want Ghostscript to use. Could be either Type1 or TrueType. 3. Run env-update.

documented on: 2006.07.29

Anti Aliased fonts 

http://www.rockhopper.dk/linux/software/configuring-fonts-in-x.html

If you want to have anti aliased fonts, your graphics card has to support the Render extension of X. To check this run xdpyinfo | grep -i render in a console, you should get

RENDER

It should be enabled on every new system by default, but if you don't get anti aliased fonts try to set two variables, one for QT (KDE) and one for GTK+ 2 (you can also use the variables to disable anti aliasing):

export QT_XFT=true
export GDK_USE_XFT=1

If you have a LCD display, you might what to have a look at subpixel anti aliasing (see below for resources).

documented on: 2006.07.29

Font configuration 

http://linuxfromscratch.org/pipermail/blfs-dev/2005-December/012685.html

Currently, the book contains the "X Window System Components" page. Font configuration is one of the topics discussed there. However, currently, this discussion has two weak points:

  1. It says "how", but not "why". See text below, please merge with the existing text as appropriate.

  2. Since r5440, it produces non-working xterm for Russians.

    The following things are convenient to discuss nearby:
  3. The LiveCD has very special needs for fonts, and I want to share this information with you.

  4. Randy McMurchy said that Andrew Benton wants to remove GTK1.

Details:

  1. There are two font systems in X window system. The first is the X core font protocol, the second is Xft.

X core font 

Font names relevant to X core font protocol look like -misc-fixed-medium-r-normal—13-120-75-75-c-80-iso8859-1. Such fonts are rendered by the X server without antialiasing. The server itself uses the "cursor" font for painting the mouse cursor, and the protocol specification requires the font "fixed" to be available. The character set name is the part of the font name: the application selects the font and only tells the X server to render numbered glyphs. E.g., glyph number 200 in the -misc-fixed-medium-r-normal—13-120-75-75-c-80-iso8859-1 font looks like the LATIN CAPITAL LETTER E WITH GRAVE, while in the -misc-fixed-medium-r-normal—13-120-75-75-c-80-iso8859-7 font, this numbered glyph looks like the GREEK CAPITAL LETTER THETA. Thus, it is very important that the applications which support non-English interface specify the character set of the font correctly: otherwise nobody will be able to understand what the strange characters on the screen mean. Bitmap fonts provided with Xorg or XFree86 cover significant portion of Unicode character repertoire.

Locations for those fonts are taken by the X server from font paths defined in its configuration file (xorg.conf or XF86Config). In the each directory mentioned in the font path, the server reads the "fonts.dir" file which maps font files to font names, the "fonts.alias" file that defines aliases (such as "9x18") for existing fonts, and the "fonts.scale" file that lists scalable fonts. These files are updated by the "mkfontscale" and "mkfontdir" commands. At runtime, the X font path can be adjusted with the "xset fp= /new/font/path1,/new/font/path2" command. The change will take effect after "xset fp rehash".

Toolkits that use the core X font protocol include Xt, Xaw, Xaw3d, Motif clones, Tk and GTK+-1.2. In order to configure the core font to be used in some non-GTK application, one usually has to edit some X resources corresponding to this application. In countries for which ISO-8859-1 is not a proper character set, this become quite tedious, since the configuration has to be edited for every application individually.

In some cases, applications rely upon the fonts named "fixed" or something like "9x18". A way exists to configure all such applications simultaneously to use the font with the proper character set, by modifying the font aliases. Instructions are different for Cyrillic and other users.

Cyrillic fonts and the pre-made fonts.alias file are available in /usr/lib/X11/fonts/cyrillic. It defines, e.g., "9x18" as an alias for -misc-fixed-medium-r-normal—18-120-100-100-c-90-koi8-r. For this alias to be used, the /usr/lib/X11/fonts/cyrillic directory must appear as the first directory in X font path. Otherwise, this alias will be taken from the /usr/lib/X11/fonts/misc/fonts.alias file, which is not a proper alias.

Users of ISO-8859-X encodings where X != 1 should modify the /usr/lib/X11/fonts/misc/fonts.alias file (and aliases in other relevant directories) by replacing the string "iso8859-1" with the proper encoding name. This is done by the fllowing command:

sed -i 's,iso8859-1\( \|$\),iso8859-[X]\1,g' \
    /usr/share/fonts/{75dpi,100dpi,misc}/fonts.alias

For GTK+-1.2, the fonts are described in /etc/gtk/gtkrc.[country or charset name]. The defaults are appropriate for most countries in non-UTF-8 locales. These settings are also reorted to work in UTF-8 locales with XFree86-4.5.0 out of the box. However, Xorg-6.8.2 (and, btw, 6.9.0 and 7.0.0) has a long-standing bug here, and won't choose the correct font at least for ru_RU.UTF-8. The solution is to remove entries with "*" in them from /etc/gtk/gtkrc.ru if this locale is used, and add a known-good iso10646-1 font, thus providing Xorg no chance to make an error in its font choice:

style "gtk-default-ru" {
        fontset =
"-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1"
}
class "GtkWidget" style "gtk-default-ru"
Warning the information above is old and essentially untested. I don't install GTK1 for a long time. Will recheck after posting if this really helps.

A better fix is described (in Russian) at http://wiki.fantoo.ru/index.php/HOWTO_GTK1_with_UTF8

Chinese users also seem to have problems with GTK+-1.2 in UTF-8 based locales.

xft 

Xft uses font names like "Monospace 12". Such fonts are taken from the client side, and the client uses Fontconfig for their enumeration and rendering control. By default, antialiased rendering is provided. Applications send the text as a sequence of Unicode code points. Conversion from and to the locale character set is the application's responsibility (but most applications that use Xft do it correctly out of the box).

Toolkits that use Xft are Qt and GTK+-2.

In order to make a font file available to Fontconfig, one has to mention the directory where it resides in /etc/fonts/local.conf, inside the <fontconfig> tags. The following example local.conf file lists common locations for outline fonts:

cat > /etc/fonts/local.conf << "EOF"
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/local.conf file for local customizations -->

<fontconfig>
<dir>/usr/X11R6/lib/X11/fonts/TTF</dir>
<dir>/usr/X11R6/lib/X11/fonts/OTF</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
</fontconfig>

EOF

The system-wide font directory /usr/share/fonts and the per-user ~/.fonts directory are already mentioned in /etc/fonts/fonts.conf.

Fontconfig maintains a cache of the font characteristics in each font directory. This cache can be regenerated at any time by issuing the "fc-cache" command. Fontconfig doesn't look at fonts.{alias,dir,scale} files at all.

Applications generally use "generic" font names such as "Monospace", "Sans" and "Serif". Fontconfig resolves these names to a font that has all characters that cover the orthography of the language indicated by the locale settings. For doing so, it uses the knowledge from the /etc/fonts/fonts.conf file. Unfortunately, this file doesn't contain information about recenty-introduced or rarely-used fonts, and fontconfig won't attempt to use such unknown fonts when the application asks for a generic family name such as "Monospace", "Sans" or "Serif".

Applications that use other font families by default and don't accept substitutions from Fontconfig will display only blank lines when the default font doesn't cover the orthography of the user's language. This happens, e.g., with fluxbox in ru_RU.KOI8-R locale. The solution is to specify another font in the default theme.

additional fonts 

Standard scalable fonts that come with Xorg provide very poor Unicode coverage. It is advised that you install these fonts in order to improve the situation:

DejaVu fonts: http://dejavu.sourceforge.net/, for Latin-based scripts with accents and Cyrillic. Glyphs that are also present in Bitstream Vera fonts should look exactly the same. Work is in progress for Greek. Fontconfig won't use these fonts for substituting "Sans", "Serif" and "Monospace" by default, a bug has been filed. In the meantime, you can globally replace the string "Bitstream Vera" with "DejaVu" in /etc/fonts/fonts.conf. Winh DejaVu fonts installed, Bitstream Vera fonts are useless.

FreeFont: http://download.savannah.nongnu.org/releases/freefont/, ugly set of font that cover almost every non-CJK character. By default, used by fontconfig as a last resort for attempts to substitute generic family names.

Microsoft Core fonts: http://corefonts.sourceforge.net/, they provide slightly worse Unicode coverage than FreeFont, but are better hinted. Be sure to check the license before using them. Fontconfig knows about them by default.

Arphic fonts: http://cle.linux.org.tw/fonts/Arphic, they cover Chinese. Fontconfig knows tham by default and uses for substituting "Monospace", "Sans" and "Serif" when it is appropriate. Note that today Chinese users prefer the Firefly New Sung font.

Firefly New Sung font: http://cle.linux.org.tw/fonts/FireFly, covers Chinese, has embedded bitmaps for small font sizes. Fontconfig doesn't know about it by default and doesn't use it for substitution of generic family names. Due to the embedded bitmaps, fonts stay clear even at 9pt (Arphic fonts are unacceptably blurry at this size). In order to take advantage of these embedded bitmaps, antialiasing must be disabled for this font at sizes between 12 and 16 pixels in /etc/fonts/local.conf.

Kochi fonts: http://osdn.dl.sourceforge.jp/efont/4845/, cover Japanese. Fontconfig knows about them by default and uses for substitution of generic family names when appropriate.

Baekmuk fonts: http://kldp.net/frs/download.php/1429/baekmuk-ttf-2.2.tar.gz, cover Korean, known to fontconfig by default.

Nimbus fonts: installed with Ghostscript, cover Latin and Cyrillic (ugly).

Note that only Microsoft fonts have good hinting information for non-Latin1 glyphs. Such glyphs in other fonts actually benefit from disabling (!) bytecode interpreter in FreeType.

2) Let's see this in practice. Attached are the screenshots of xterm in ru_RU.KOI8-R and el_GR locales, before (wrong) and after (right) the adjustment of core font aliases. Please use them as testcases in the future.

3) The LiveCD must display everything correctly in any locale. Since any configuration besides setting $LANG takes too much time and has to be redone at every boot, a user will consider our LiveCD broken if such configuration is needed. Thus, we have to choose applications carefully.

Xterm does work correctly in any locale without further configuration if one sets the Vt100.locale resource to 1 in /etc/X11/app-defaults/XTerm and applies this patch while compiling Xorg: http://www.linuxfromscratch.org/~alexander/patches/xorg-6.8.2-luit_race-2.patch. This patch is no longer needed with X11R6.9.0 and X11R7.0.0, but they also don't install xterm by default. It is also posible to make Xterm use Xft, by also setting the VT100.faceName resource to the font name like "Monospace".

Other terminal emulators that work out of the box are rxvt-unicode, konsole and any vte-based terminal (the LiveCD currently uses XFCE Terminal from http://www.os-works.com/).

All above-mentioned non-Microsoft scalable fonts are present on the CD.

Since there are no applications on the CD that use X core font protocol and output anything besides ASCII, I have removed all bitmap fonts from the latest development CD (not released yet), and the /usr/lib/X11/fonts directory simply doesn't exist. For the required "fixed" and "cursor" fonts, the ones built into libXfont.so (from X1R7.0.0) are used (one-line patch required for xorg-server). Thus, issues described in the first part of this mail don't apply.

4) Andrew Benton wants to remove GTK1 and other legacy toolkits from the book, and he made X core fonts misconfigured as the first step (his exact words: "I removed it [FontPath instruction for Cyrillic users — AEP] because we install Fontconfig. Fonts are not configured in xorg.conf or XF86Config"). While I agree that such removal may be a good thing (it is already done on the LiveCD), I must say that if we do this, we should warn the readers that our configuration is deliberately broken for the case when they install such obsolete toolkits themselves.

Alexander E. Patrakov

Optimal Use of Fonts on Linux 

http://www.tldp.org/HOWTO/html_single/Font-HOWTO/

Copyright (c) 2006 Avi Alkalay, Donovan Rebbechi, Hal Burgiss

2006-07-02

Table of Contents 

  1. Introduction

  2. Why Fonts on Linux Aren't Straight Forward ?

    2.1. X.org Font Subsystems
  3. The Easy Steps to Enlighten Your Desktop

    3.1. Get a Better FreeType RPM
    3.2. Configure Your Desktop
  4. Font Packages

    4.1. Bitstream Vera Fonts
    4.2. Webcore Fonts
  5. Producing Portable Documents

    5.1. Linux to Windows and vice-versa
    5.2. Linux to Linux
    5.3. Any to Any with OpenOffice.org and Bitstream Vera Fonts
    5.4. A Very Small Guide of Style
  6. Create RPMs of Your Fonts

    6.1. Step 1: Prepare Your Environment to Build The Package
    6.2. Step 2: Prepare the Fonts Files to Package
    6.3. Step 3: Create a .spec File With This Template
    6.4. Step 4: Build It
  7. Designer's Guide for Modern Good Looking Documents

    7.1. Families of Typefaces
    7.2. Classifications of Typefaces
    7.3. Ligatures, Small caps fonts and expert fonts
    7.4. Font Metrics and Shapes
  8. Font Technologies

    8.1. Bitmap Fonts
    8.2. TrueType Fonts
    8.3. Type 1 Fonts
    8.4. Type3 Fonts
    8.5. Type 42 Fonts
    8.6. Type 1 vs TrueType -- a comparison
  9. Getting Fonts For Linux

    9.1. True Type
    9.2. Type 1 Fonts and Metafont
  10. Useful Font Software for Linux

  11. Ethics and Licensing Issues Related to Type

  12. References

    12.1. Font Information
    12.2. Postscript and Printing Information

Glossary

A. Recompiling FreeType for BCI
B. Recompiling an RPM Ready for Your Distribution
C. We Need Your Help
D. About this Document

2.1. X.org Font Subsystems 

At the present time, X.org and XFree86 use two font subsystems, each with different characteristics:

  1. The original (15+ year old) subsystem is referred to as the "core X font subsystem". Fonts rendered by this subsystem are not anti-aliased, are handled by the X server, and have names like:

    -misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
  2. The newer font subsystem is known as "fontconfig", and allows applications direct access to the font files. Fontconfig is often used along with the Xft library, which allows applications to render fontconfig fonts to the screen with antialiasing. Fontconfig uses more human-friendly names like:

    Luxi Sans-10

Over time, fontconfig/Xft will replace the core X font subsystem. At the present time, applications using the Qt 3 or GTK 2 toolkits (which would include KDE and GNOME applications) use the fontconfig and Xft font subsystem; most everything else uses the core X fonts.