Optimizing Slackware Linux's Fonts
Getting Unicode/UTF-8 Support
Setting A Unicode Locale
Unicode support will allow Slackware to display non-Latin characters. UTF-8 is the most common Unicode character encoding. Most of Slackware's components (including the console and X) support UTF-8-encoded characters, but this functionality needs to be turned on.
When using Slackware's liloconfig (which is run during Slackware's installation) to set up lilo, you will be asked whether to “USE UTF-8 TEXT CONSOLE?” Say yes.
Then prime Slackware to support Unicode characters by setting your locale to a Unicode one. It's as simple as editing /etc/profile.d/lang.sh and changing the LANG variable from en_US to en_US.UTF-8.
To test, download ucs-fonts.tar.gz and untar it. Among the extracted files will be an examples directory. In an xterm, go there and cat quickbrown.txt.
The European languages should be properly displayed.
Depending on where you live, a locale other than en_US.UTF-8 might be appropriate. I recommend first reading Linux.com's Controlling your locale with environment variables, then using a list of language codes and country codes to figure out your locale.
Setting Up A Unicode X Terminal
To get full Unicode support requires an X terminal that actually has full Unicode support. My favorite is rxt-unicode. Install both rxvt-unicode and its dependency libAfterImage from SlackBuilds.org: libAfterImage first, then rxvt-unicode.
Here's what you need to set rxvt-unicode and XTerm up:
As an aside, rxvt-unicode supports transparency. Therefore, this is a good time to make Midnight Commander transparent. Transparent themes for mutt and irssi can be found on their project websites.
Disable gpm because it causes programs like vim and links to lock up in rxvt-unicode (really!). You can do it manually (chmod -x /etc/rc.d/rc.gpm), or with pkgtool.
When running rxvt-unicode, “cat” the files in ucs-font's example's directory again. You should be able to see every Unicode character in those files.
Setting A Console Console Font
The Terminus font is a very nice Unicode font for the Linux console. Install it from SlackBuilds.org. Then add the following to your ~/.bashrc (or zshrc, if you're using zsh):
if [ $TERM = "linux" ]; then
setfont ter-v16n
fi
Setting Your X Font Resolution
You'll have the best proportioned typography if you set X to use a font resolution of 96 DPI. If you enter xdpyinfo | grep resolution, you should get back: resolution: 96x96 dots per inch. If your resolution is anything else, you'll have to set it manually.
If you start X with startx, edit /usr/bin/startx and change
defaultserverargs=""
to
defaultserverargs="-dpi 96"
If you start X with a login manager, edit the configuration file and add -dpi 96 to the ends of the “/usr/bin/X” commands. Under Slackware 13.1, the files are /etc/X11/xinit/Xservers (for xdm) and /usr/share/config/kdm/kdmrc (for kdm).
Other Configurations
There are two reasons to prefer a font resolution other than 96 DPI. One is visual impairment; higher-resolution fonts will be larger and easier to see. The other is software that requires another resolution. MythTV, which requires 100 DPI fonts, is an example. If you use MythTV, use the Display_Size section of its wiki to set your font resolution,
Understanding Linux's Font Subsystem
You need to understand, at this point, what Fontconfig is and how it's configured. Fontconfig is the font subsystem used by almost all recent Linux software, including all GTK2 and Qt applications. Its configuration is stored in /etc/fonts. One directory, /etc/fonts/conf.avail, stores available configuration files. Fontconfig does not read from conf.avail. Rather, the files there are symlinked into /etc/fonts/conf.d, which Fontconfig does read. After modifying any of those files, or a directory referenced by one of those files, you run fc-cache -f -v as root to refresh Fontconfig.
For example, symlinking /etc/fonts/conf.avail/10-autohint.conf into /etc/fonts/conf.d enables the autohinter. Removing that file from conf.d disables the autohinter. For another example, adding a font into a directory read by Fontconfig will make that font available.
There's a README file in /etc/fonts/conf.d with more.
Getting Subpixel Rendering (LCD Monitors Only)
If you have an LCD monitor, you might want to patch your rendering system for subpixel rendering.
Rebuilding Your Font Rendering Subsystem
Slackware's unpatched Freetype has no subpixel rendering capabilities at all. Its source directory has patches to enable it, and its SlackBuild has comments on their use. But why stop there? Unofficial patches to further improve Freetype's subpixel rendering capabilities have existed for years. They are maintained in, among other places, Arch Linux's unofficial repositories and Ubuntu's official ones.
Gentoo's users maintain, in their lcd-filtering and devnull overlays, the best collection I've found. Their ebuild files can build packages that supports either Cleartype-style rendering or Ubuntu-style rendering. I took their ebuilds and converted them to SlackBuilds.
These SlackBuilds build for Ubuntu-style rendering by default. To get Cleartype-style rendering instead, enter export USE=cleartype before building your packages and unset USE when you're done.
Erase your /etc/fonts directory. Then rebuild and install the following packages in order:
Freetype
Fontconfig
libXft
Cairo
Setting It Up
I recommend removing 10-no-sub-pixel.conf from conf.d, then rerunning fc-cache -f -v.
Then check your monitor's subpixel layout at Subpixel layout - Lagm LCD test. You may then, in one of two ways, set Fontconfig's subpixel layout to match. The first is to symlink the appropriate file from conf.avail into conf.d (10-subpixel-rgb.conf in my case), then rerun fc-cache. The other is to set it in Xfce's, KDE's, and/or GNOME's control panel. Remember, you can run xfsettingsd (Xfce 4.6), xfce-mcs-manager (Xfce 4.0–4.4), or gnome-settings-daemon to get Xfce or GNOME's appearance settings in another DE or WM.
Rebuilding Firefox (32-bit Slackware only)
Programs distributed as binaries might be statically linked against their own versions of these libraries. If so, they will not support subpixel rendering. The solution is to rebuild them to be dynamically linked against your system libraries (particularly Cairo). For example, the Firefox binary from mozilla.org is statically linked. This is, unfortunately, what's in 32-bit Slackware (64-bit Slackware has a custom-built Firefox package that is dynamically linked).
If you're using 32-bit Slackware, the easiest way to get a dynamically linked Firefox is to use slackware64's mozilla-firefox SlackBuild. Download the entire slackware64-current/source/xap/mozilla-firefox directory. Then edit the mozilla-firefox.SlackBuild file there. Set the SlackBuild's ARCH to i486, and its NUMJOBS to to a value appropriate to your system. NUMJOBS corresponds to Gentoo's MAKEOPTS variable, which is documented in Gentoo's handbook. Then run it, and a dynamically linked 32-bit Firefox package will be waiting for you in /tmp.
Stock Firefox

Recompiled Firefox

Xdefaults
The X resource database should be made aware of your font settings. Put the following (or a variation matching your /etc/fonts settings) in your .Xdefaults file:
! Xft.antialias: 1
Xft.dpi: 96
Xft.hinting: 1
Xft.hintstyle: hintfull
Xft.lcdfilter: lcddefault
Xft.rgba: rgb
Xft.rgba, of course, is set to the value you found in the subpixel order test.
Setting Your Native Resolution
Remember to max your X resolution. This is necessary for subpixel rendering to work.
Adding More Fonts
General Procedures
Do the following:
mkdir -p /usr/local/share/fonts
cd /etc/fonts
cp fonts.conf local.conf
Then edit local.conf and erase everything between the <fontconfig> and </fontconfig> tags. In its place put the following:
<dir>/usr/local/share/fonts</dir>
You can then install new fonts by putting them in /usr/local/share/fonts. The files that belong in /usr/local/share/fonts are the actual font files: .ttf, .otf, .dfont, etc. After installing them, run fc-cache -f -v.
This way, the individual fonts you've installed yourself are kept separate from those installed via Slackware packages. You can then very easily back up your /usr/local/share/fonts directory.
Google Font Directory
Everyone should have a copy of the Google Font Directory You can download the fonts from the Google Code page. The Source section tells you how to get a copy of the repository. That's where the fonts are.
These include the Android OS fonts, which are among the best user interface fonts available.
After installing them, put the following file, 35-droid.conf, in /etc/fonts/conf.d. Then rerun fc-cache. Your sans, serif and monospace aliases will be set to Android fonts, and your desktop environments and window managers will be using them exclusively.
The directory also includes the monospaced Inconsolata font, which is particulary good for terminals and text editors.
Webcore Fonts
You need Microsoft's core fonts for the web to display webpages. (Other webpages, I mean; mine uses Google fonts). Install them using the webcore-fonts SlackBuild from SlackBuilds.org. Make sure you read the directions, as Slackware includes workarounds for not having them.
Unicode Fonts
Acquire the DownloadFonts.sh script from the Unicode Font Guide. When run, it downloads dozens of Unicode fonts covering every language under the sun. Useful if the Google fonts aren't filling your needs.
Miscellaneous
X Server
Some applications still get their fonts through the X server instead of through Fontconfig. To make your fonts available to the X server, edit /etc/X11/xorg.conf and add /usr/local/share/fonts as a FontPath.
You also need to do the following after installing new fonts:
cd /usr/local/share/fonts
/usr/X11R6/bin/mkfontscale
/usr/X11R6/bin/mkfontdir/
If you then restart the X server, then fonts you just installed will show up in xlsfonts and xfontsel.
I also recommend the following one-time change:
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
to
FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled/"
The reason are that the unscaled bitmap fonts in these directories look better than scaled ones, and the 100dpi fonts more closely match your X server's resolution.
Bytecode Interpretation
One controversial piece of advice is enabling the Freetype bytecode interpreter. This was very popular before Freetype started including an autohinter. In my opinon, most Linux-specific fonts now look better with the autohinter and were probably designed to be rendered with it. This includes the Bitstream Vera, DejaVu and Liberation fonts.
Droid fonts look good with either the autohinter or the bytecode interpreter.
Like the amount of hinting (slight, medium or full) to use, whether to use the bytecode interpreter is a matter of taste. To experiment with it, first recompile Freetype to enable it. There are comments in the Slackware's Freetype SlackBuild on how to do so. (The custom Freetype SlackBuild above also enables it). Then, ensure that /etc/fonts/conf.d contains 10-hinting.conf, disable the autohinter by removing 10-autohint.conf and rerunning fc-cache.
The bytecode interpreter will be used for any font not autohinted.
A better solution might be to selectively disable the autohinter only for certain fonts, such as the webcore fonts. In fact, the webcore fonts SlackBuild puts a file in conf.avail that does exactly that.
Java
Text in some Java applications, such as Netbeans, can look particularly bad, especially if you're not running gnome-settings-daemon or xfsettingsd.
To fix that, add the following to /etc/profile:
export
_JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd_hrgb'
The lcd_hrgb setting should be changed as appropriate, depending on your monitor's subpixel order. Please refer to the Java Fonts - Sun JRE page on Arch Linux's wiki for directions.
My Settings
Here are my current font settings: