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. This adds the following kernel option: “vt.default_utf8=1”
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 A Console Console Font
The Terminus font, which is included with Slackware, is a very nice Unicode font for the Linux console. Add the following to your ~/.bashrc.
if [ $TERM = "linux" ]; then setfont ter-v16n fi
Other shells of course have other startup files. ZSH uses ~/.zshrc, for example.
Setting Your X Font Resolution
Your X dots-per-inch resolution is, by default, queried from the display device. In some cases, you might prefer to specify a font DPI to get larger or smaller fonts, or if you feel that a specific DPI gives you better-proportioned typography. Those used to Windows might be used to the 96 DPI resolution that Windows uses by default. If your Slackware box is an HTPC, you might set it to 120dpi so that the fonts become large enough to comfortably see.
To see your font DPI, enter xdpyinfo | grep resolution. You’ll get back: resolution: 96×96 dots per inch. This is just an example; your actual value might not be 96×96. If you’d like, you can set it manually.
If you start X with startx, edit /usr/bin/startx and change
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. In Slackware 14.1, the KDM configuration file is /etc/kde/kdm/kdmrc. 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.
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. I recommend not enabling the autohinter; the bytecode interpreter that is used by default gives good results.
There’s a README file in /etc/fonts/conf.d with more.
Adding More Fonts
You can then install new fonts by putting them in ~/.local/share/fonts. The files that belong in ~/.local/share/fonts are the actual font files: .ttf, .otf, .dfont, etc. After installing them, run fc-cache -f -v.
Use the fc-list command to see which fonts your user account has available.
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.
To get coverage for the many characters used in the world’s languages, just go to the Google Noto Fonts page. Install the fonts in the package that you get when you choose “Download All Fonts.”
To display emoji, install the Symbola font. The homepage (Unicode Fonts for Ancient Scripts) is currently closed, but you can still get it from the Arch Linux page for its package, ttf-symbola. Extract the .ttf file from the tarball and install it.
Adobe’s user interface and monospace fonts, Source Sans Pro and Source Code Pro, are available on SlackBuilds.org and highly recommended.
Firefox OS Fonts
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).
Download the source directory for Slackware’s Freetype package. It’s in source/l/freetype. I’ve provided a patch for the SlackBuild. It enables FreeType’s subpixel rendering and hinting options.
Use it to patch the entire SlackBuild directory:
cd freetype path -p1 < /path/to/freetype_subpixel_slackbuild.diff
Edit the SlackBuild itself. Change the BUILD parameter at the beginning, so that upgradepkg will see it as a new version:
Then build yourself a package and use upgradepkg to have it replace your old Freetype package.
Then symlink /etc/fonts/conf.avail/11-lcdfilter-default.conf into /etc/fonts/conf.d.
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:
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.
If you want to override which fonts your system alias (such as “sans”) map to, start by removing the following symbolic link:
Then create ~/.config/fontconfig/fonts.conf and override the aliases there.
You can refer to an example fonts.conf that does that, and also sets the Microsoft fonts to full hinting and the other fonts to slight hinting. This is consistent with the fact that Windows uses full hinting and OS X uses slight hinting.
To test whether your overriding worked, use fc-match. For example:
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.rgba, of course, is set to the value you found in the subpixel order test.
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:
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:
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.
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:
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.