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: 96×96 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.37, the files are /etc/X11/xdm/Xservers (for xdm) and /usr/share/config/kdm/kdmrc (for kdm). In 13.1, the file for xdm was /etc/X11/xinit/Xservers.
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.
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
One of the best places to get fonts is the Google Font Directory. Just pick-and-choose from the free fonts there, and download them individually.
From there, Droid Sans, Droid Sans Mono and Droid Serif are probably the best user interface fonts available. If you like them, put 35-droid.conf in /etc/fonts/conf.d. It will set your sans, serif and monospace aliases to these Android fonts, and make your desktop environment or window manager use them exclusively.
Anonymous Pro and Inconsolata are particularly good for terminals and text editors. Possibly even better than Droid Sans Mono.
Ubuntu makes an excellent alternative to Droid Sans. Either works well as the main user interface font.
Webcore Fonts
You need Microsoft’s core fonts for the web to display webpages. (Other webpages, I mean; mine uses Google fonts).
There are two ways to get them. The first, of course, is to copy them from a Windows or OS X installation.
The second is to install them using the webcore-fonts SlackBuild from SlackBuilds.org.
Either way, remove /etc/fonts/conf.d/60-liberation.conf. That file is a workaround for not being able to include them.
Getting Subpixel Rendering (LCD Monitors Only)
If you have an LCD monitor, that you run at full resolution, you might want to patch your rendering system for subpixel rendering.
Do not enable subpixel rendering if you’re using a non-LCD monitor (such as a CRT), or if you’re not running X at its native resolution (which is probably the case if you’re running Slackware in a virtual machine).
Rebuilding Your Font Rendering Subsystem
You have two options. You can enable Freetype’s default subpixel rendering capabilities, or you can rebuild your your font rendering subsystem to use a custom patchset.
Default Rendering
Download the source directory for Slackware’s Freetype package. It’s in source/l/freetype. Then look at freetype.SlackBuild. Look for the following lines:
# The line below enables code patented by Microsoft, so don't uncomment it # unless you have a license to use the code and take all legal responsibility # for doing so. # Please see this web site for more details: # http://www.freetype.org/patents.html #zcat $CWD/freetype.subpixel.rendering.diff.gz | patch -p1 --verbose || exit 1
Uncomment the line beginning with zcat.
Change the BUILD parameter at the beginning, so that upgradepkg will see it as a new version:
BUILD=${BUILD:-1subpixel}
Then build yourself a package and use upgradepkg to have it replace your old Freetype package.
Then add the following to /etc/fonts/local.conf:
<match target="font"> <edit mode="assign" name="lcdfilter"> <const>lcddefault</const> </edit> <edit name="hinting" mode="assign"> <bool>true</bool> </edit> <edit name="hintstyle" mode="assign"> <const>hintfull</const> </edit> <edit name="antialias" mode="assign"> <bool>true</bool> </edit> <edit name="autohint" mode="assign"> <bool>false</bool> </edit> </match>
LCD Filter Rendering
Gentoo’s LCD filtering ebuilds are a nice alternative to the default subpixel renderer. Therefore, I’ve ported them to Slackware. You can download them from their GitHub page. There, you’ll also find links to the source tarballs that they build.
By now, you know how to use SlackBuilds. Put the source tarballs into the SlackBuild directories. Then run them, and use upgradepkg to install the resulting packages, in the following order:
- FreeType
- Fontconfig
- libXft
- Cairo
If you’re using a set of fonts that you’ve copied from a Windows (Vista or newer) or OS X installation, then use the local.conf file provided by infinality.net. It works very well with the lcdfilter packages.
Note that this set change four packages, including Cairo. On 32-bit Slackware, this is a problem because Firefox has Cairo statically linked into it, and therefore cannot not see the improvements. The solution is simple. While the 32-bit Firefox package is a tarball from mozilla.org, the 64-bit package is built from source. Therefore, all you have to do is get the Slackware64 Firefox SlackBuild, change its ARCH from x86_64 to i486, and run it. The following (outdated) screenshot shows that the differences are noticeable:
Stock Firefox

Recompiled Firefox

Font Configuration
If /etc/fonts/conf.d contains a filed named 10-no-sub-pixel.conf, remove it.
Use the Lagm LCD test to discover your monitor’s subpixel layout. Mine is RGB.
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. It’s one of the following:
- 10-sub-pixel-bgr.conf
- 10-sub-pixel-rgb.conf
- 10-sub-pixel-vbgr.conf
- 10-sub-pixel-vrgb.conf
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.
Xresources
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 .Xresources file:
Xft.dpi: 96
Xft.antialias: 1
Xft.hinting: 1
Xft.hintstyle: hintfull
Xft.lcdfilter: lcddefault
Xft.rgba: rgb
Xft.autohint: 0
Xft.rgba, of course, is set to the value you found in the subpixel order test.
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.
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 whether you’ve enabled subpixel rendering (and your subpixel order, if you have). Please refer to the Java Fonts – Sun JRE page on Arch Linux’s wiki for directions.