Note: This How-To is separated into several posts for clarity and easier reading.
Upgrading to Mandrake Linux 10, I have found that the UI (User interface) font of gtk1.x look rather ugly. Upon searching the web and a little experimenting by myself, I have discovered the trick to modify the UI font for gtk1 and gtk2 applications as well:
Here are my suggestions, as performed under Mandrake 10:
1) Install Microsoft web font thru corefonts package (Optional):
http://corefonts.sourceforge.net/
Mandrake Source RPM build:
http://ben.reser.org/corefonts/
Cabextract 1.0
http://www.kyz.uklinux.net/cabextract.php
2) You have to know what locale environment you are in:
To find out, in terminal you can enter:
$ locale
In English Unicode environment, it is likely en_US.UTF-8,
or in my case en_HK.UTF-8 (English for Hong Kong).
3) The trick to look up the UI font setting is in the directory
/etc/gtk and
/etc/gtk-2.0, for gtk1 and gtk2 applications respectively:
3.1) For gtk1 application
Eg: Mozilla X11, XMMS, Gimp-1.2.x
Now, the locale environment information you have found in step 2 became useful:
For example, if your locale is
zh_TW.big5 (Taiwan Chinese, Big5 Encoding),
then you should look up the file /etc/gtk/gtkrc.
zh_TW.big5
In the directory
/etc/gtk
There's no such file as
gtkrc.en_US.utf-8, so I would guess this means the locale setting will fall back to
gtkrc.utf-8, and it does!
Examining /etc/gtk/gtkrc.utf-8 under Mandrake 10 shows this:
Quote:
style "gtk-default" {
fontset = "-*-Nimbus Sans L-medium-r-normal--14-*-*-*-p-*-iso10646-1,\
-*-clearlyu-medium-r-normal--17-*-*-*-p-*-iso10646-1,\
-*-r-*-iso10646-1,*"
}
class "GtkWidget" style "gtk-default"
|
The string
-*-Nimbus Sans L-medium-r-normal--14-*-*-*-p-*-iso10646-1 is the old style for X11 server to display font information, before XFT/fontconfig was born last year. Whereas
,\ is the separator for adding another font.
Hence, if you want to use another UI font in gtk1 apps, you have to look up the name of that font
in the old X11 style, which is recorded in the font metafile such as
fonts.alias,
fonts.dir or
fonts.scale. They should be placed in the same directory where the fonts reside, inside the following path:
/usr/X11R6/lib/X11/fonts/
/usr/share/fonts/
/usr/share/fonts/ttf
For example, if I want to use
Microsoft Arial font as the UI font for gtk1 apps, with the corefont package (see step 1) installed in this path:
/usr/X11R6/lib/X11/fonts/msttcorefonts/
Then I can look up the old style X11 font information from:
/usr/X11R6/lib/X11/fonts/msttcorefonts/fonts.dir
/usr/X11R6/lib/X11/fonts/msttcorefonts/fonts.scale
Upon examining the file
fonts.dir, I have located the font information for Microsoft Arial
in X11 style as:
Quote:
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso10646-1
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-dosencoding-cp850
.
.
.
|
Where
-is10646-1 and
-dosencoding-cp850 are encoding schemes, the font name is basically the same.
Hence the font name for Microsoft Arial (with Unicode encoding) in old X11 style is as this:
-monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso10646-1
Hence you can modify the file
/etc/gtk/gtkrc.utf-8 by adding this font name, followed by the separator
,\
Quote:
style "gtk-default" {
fontset = "-monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso10646-1,\
-*-Nimbus Sans L-medium-r-normal--14-*-*-*-p-*-iso10646-1,\
-*-clearlyu-medium-r-normal--17-*-*-*-p-*-iso10646-1,\
-*-r-*-iso10646-1,*"
}
class "GtkWidget" style "gtk-default"
|
Save the file.
Finished!
Now launch a gtk1 application in en_US.UTF-8 locale and your UI font will look great again.