Hello,
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.
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 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.
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
![PNG image](msg03117/xterm-el-right.png)
![PNG image](msg03117/xterm-el-wrong.png)
![PNG image](msg03117/xterm-ru-right.png)
![PNG image](msg03117/xterm-ru-wrong.png)
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page