Sunteți pe pagina 1din 13

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

Dugan Chen's Homepage


Various Things

Projects

Writings

Optimizing Slackware Linuxs Fonts


Getting Unicode/UTF-8 Support

News June 2011 May 2011 April 2011 Colleagues Karl Romanowski Kevin Smith Lance Jian Proles GitHub Twitter

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 Slackwares components (including the console and X) support UTF-8-encoded characters, but this functionality needs to be turned on. When using Slackwares lilocong (which is run during Slackwares 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. Its as simple as editing /etc/prole.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 les will be an examples directory. In an xterm, go there and cat quickbrown.txt.

1 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

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 rst reading Linux.coms Controlling your locale with environment variables, then using a list of language codes and country codes to gure 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 rst, then rxvt-unicode. Heres what you need to set rxvt-unicode and XTerm up: My .Xresources 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 les in ucs-fonts examples directory again. You should be able to see every Unicode character in those les.

Setting A Console Console Font

The Terminus font is a very nice Unicode font for the Linux

2 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

console. Install it from SlackBuilds.org. Then add the following to your ~/.bashrc (or zshrc, if youre using zsh): if [ $TERM = "linux" ]; then setfont ter-v16n Setting Your X Font Resolution Youll 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: 9696 dots per inch. If your resolution is anything else, youll 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 conguration le and add -dpi 96 to the ends of the /usr/bin/X commands. Under Slackware 13.37, the les are /etc/X11 /xdm/Xservers (for xdm) and /usr/share/cong/kdm/kdmrc (for kdm). In 13.1, the le for xdm was /etc/X11/xinit /Xservers.

Other Congurations

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 Linuxs Font Subsystem

3 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

You need to understand, at this point, what Fontcong is and how its congured. Fontcong is the font subsystem used by almost all recent Linux software, including all GTK2 and Qt applications. Its conguration is stored in /etc/fonts. One directory, /etc/fonts/conf.avail, stores available conguration les. Fontcong does not read from conf.avail. Rather, the les there are symlinked into /etc/fonts/conf.d, which Fontcong does read. After modifying any of those les, or a directory referenced by one of those les, you run fc-cache -f -v as root to refresh Fontcong. For example, symlinking /etc/fonts/conf.avail /10-autohint.conf into /etc/fonts/conf.d enables the autohinter. Removing that le from conf.d disables the autohinter. For another example, adding a font into a directory read by Fontcong will make that font available. Theres a README le 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 <fontcong> and </fontcong> 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 les that belong in /usr/local/share/fonts are the actual font les: .ttf, .otf, .dfont, etc. After

4 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

installing them, run fc-cache -f -v. This way, the individual fonts youve 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 Microsofts 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. Read the instructions, as Slackware (12.1 and newer) has a workaround for not including these fonts.

5 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/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 youre using a non-LCD monitor (such as a CRT), or if youre not running X at its native resolution (which is probably the case if youre running Slackware in a virtual machine).

Rebuilding Your Font Rendering Subsystem

You have two options. You can enable Freetypes default subpixel rendering capabilities, or you can patch Freetype with a custom patchset such as Innality. Default Rendering Download the source directory for Slackwares Freetype package. Its 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.di.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.

6 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

Then add the following to /etc/fonts/local.conf: <match target="font"> <edit mode="assign" name="lcdlter"> <const>lcddefault</const> </edit> </match> Innality Rendering NOTE: As of June 8, 2011, the patches available from innality.nets front page are incompatible with the version of Freetype shipped with Slackware 13.37. I recommend just using the default subpixel patch. It works well. As an alternative, the third party Innality renderer is especially good if youre using a set of fonts that youve copied from a Windows (Vista or newer) or OS X installation. (If you are doing this, then remaining compliant with software licenses is your problem). From Innality.net, download the Subpixel Hinting Patch, Subpixel Hinting Enabling Patch, Entire (Additional) Innality Patchset, Fontcong Settings and Environment Variables As of this writing, the lenames are: Subpixel Hinting Patch freetype-add-subpixel-hinting-innality20101114-1.patch Subpixel Hinting Enabling Patch freetype-enable-subpixel-hinting-innality20100909-1.patch Entire (Additional) Innality Patchset freetype-entire-innality-patchset-20101114-1.patch

7 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

Fontcong Settings local.conf Environment Variables innality-settings As you would to get the default subpixel renderer, edit Freetypes SlackBuild. Only now, add the following patch lines in what I hope is the obvious place: patch -p1 < $CWD/freetype-add-subpixel-hinting-innality-20101114-1.patch || exit 1 patch -p1 < $CWD/freetype-enable-subpixel-hinting-innality-20100909-1.patch || exit 1 patch -p1 < $CWD/freetype-entire-innality-patchset-20101114-1.patch || exit 1 And set the BUILD variable accordingly: BUILD=${BUILD:-1innality} Build the Freetype package and upgrade it. Copy local.conf to /etc/fonts. Edit it so that it sees the fonts in the /usr/local/share/fonts. Rename innality-settings to innalty-settings.sh, make it executable, and copy it to /etc/prole.d: mv innality-settings innality-settings.sh chmod +x innality-settings.sh mv innality-settings.sh /etc/prole.d Then reboot and enjoy. Cleartype Or Ubuntu Rendering Those using earlier versions of Slackware might be interested in the following SlackBuilds. I took the LCD ltering ebuilds (maintained by Gentoos users) and ported them to Slackware. These SlackBuilds built for Ubuntu-style rendering by default. To get Cleartype-style rendering instead, you entered export USE=cleartype before building your packages and unset USE when you were done.

8 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

You erased your /etc/fonts directory. Then you rebuilt and installed the following packages in order: Freetype Source SlackBuild Fontcong Source SlackBuild libXft Source SlackBuild Cairo Source SlackBuild Note that this set changed four packages, including Cairo. On 32-bit Slackware, this was a problem because Firefox had Cairo statically linked into it, and therefore would not see the improvements. The solution was simple. While the 32-bit Firefox package was a tarball from mozilla.org, the 64-bit package was built from source. Therefore, all you had to do was get the Slackware64 Firefox SlackBuild, change its ARCH from x86_64 to i486, and run it. The results were noticeable: Stock Firefox

9 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

Recompiled Firefox

Font Conguration

If /etc/fonts/conf.d contains sub-pixel.conf, remove it.

led

named

10-no-

Use the Lagm LCD test to discover your monitors subpixel layout. Mine is RGB. You may then, in one of two ways, set Fontcongs subpixel layout to match. The rst is to symlink the appropriate le from conf.avail into conf.d. Its one of the following:

10 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

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 Xfces, KDEs, and/or GNOMEs control panel. Remember, you can run xfsettingsd (Xfce 4.6), xfce-mcs-manager (Xfce 4.04.4), or gnome-settingsdaemon to get Xfce or GNOMEs 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 le: Xft.antialias: 1 Xft.dpi: 96 Xft.hinting: 1 Xft.hintstyle: hintfull Xft.lcdlter: lcddefault Xft.rgba: rgb 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 Fontcong. To make your fonts available to the X server, edit /etc/X11/xorg.conf and add /usr/local/share/fonts as a FontPath.

11 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

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 servers resolution.

Java

Text in some Java applications, such as Netbeans, can look particularly bad, especially if youre not running gnomesettings-daemon or xfsettingsd. To x that, add the following to /etc/prole: export _JAVA_OPTIONS='Dawt.useSystemAAFontSettings=lcd_hrgb' The lcd_hrgb setting should be changed as

12 of 13

06/16/2011 06:58 PM

Dugan Chen's Homepage

http://duganchen.ca/writings/slackware/fonts

appropriate, depending on whether youve enabled subpixel rendering (and your subpixel order, if you have). Please refer to the Java Fonts Sun JRE page on Arch Linuxs wiki for directions.

Links
Optimal Use of Fonts on Linux Mozilla Font Sizes / DPI Issues on Unix Beautiful Fonts in 12.1 LinuxQuestions.org [HOWTO]Freetype subpixel font rendering lcd monitors (Gentoo forum thread) LCD Monitor Conguration in X.Org Xorg Font Conguration ArchWiki

Last revised on February 18, 2011 by Dugan Chen (duga...@fastmail.fm).

13 of 13

06/16/2011 06:58 PM

S-ar putea să vă placă și