|
|
||
Installing TrueType Fonts on GNU/Linux© Copyright Darrell Anderson. Before I settled on Slackware as my preferred GNU/Linux distro, I used the Mandrake 9.x distro for a while. After trying to use Mandrake’s font installer program, I decided to dispense with that utility and learn to manually install my TrueType font collection. I found the Mandrake utility clumsy and I did not like the idea that I could not figure out how to install the fonts to a directory of my choice. I wanted my TrueType Font collection installed to my /usr/local partition so I would not have to reinstall fonts whenever I performed a clean reinstall of Mandrake or I wanted to install additional distros. Through a collection of some outdated on-line How-Tos, some trial-and-error on my part, and some additional research, I devised a punch list for installing TrueType fonts. First select a directory location for installing the fonts. Preferably, select a location that does not need to be reinstalled if you later want to reinstall your GNU/Linux distro or want to install other distros. Typically, the best place is your /usr/local or /opt partitions. These locations should be separate physical partitions that will not be affected by any future reinstallations.
CaveatsI have noticed something on my system that I cannot explain fully. Apparently the KDE Font Installer stalls if the number of font files exceeds a certain threshold. If this happens to you then when you run the Font Installer you might receive the error message “The process for the fonts protocol died unexpectedly.” The root problem seems to be with the mkfontscale program and not the KDE Font Installer. The mkfontscale utility fails to generate a complete list when the number of fonts exceeds approximately 110. This would seem to be a bug. My work-around solution:
X ServerOne area of frustration for many people when installing and rendering fonts is the X server itself. Improper screen resolution will play a role. Without specific auto-configuration instructions from the monitor, the X server will guess the screen resolution dots-per-inch. This sometimes will create a lot of hair-pulling. The best way to avoid this potential problem is forcing X to accept your desired screen resolution. First determine the current screen size and the monitor’s physical screen size: xdpyinfo | grep dimension Next determine the current screen resolution in dots-per-inch: xdpyinfo | grep resolution Notice that physical screen size is listed in millimeters while resolution is listed in inches. To convert, remember that there are 25.4 millimeters in one inch. After running the xdpyinfo command, you might notice that the dots-per-inch number is not square or unbalanced by a pixel or two. That is, the result might be something like 96x95 or 72x71. If this is the case, adding the DisplaySize instruction to xorg.conf will remedy this. In the xorg.conf file, in the Monitor section, add the following X variable: DisplaySize x-width y-height x-width and y-height is the monitor’s physical screen width and height in millimeters. If you have a spec sheet handy from the vendor, then that information might already be included. If not, then grab a ruler or tape measure and actually measure the width (be careful not to scratch your LCD screen). Be patient, don’t worry about perfection, and measure the width and height as close as possible. When you are finished the xorg.conf file will look something this: DisplaySize 338 271 Using the numbers from the actual screen size that X is using, such as 1280x1024, 1024x768, 800x600, etc., mathematically divide the screen size width and height (pixels or dots) by the actual size (millimeters) you measured or found in the spec sheet. The results will be in dots-per-millimeter. For example, divide 1280 (pixels or dots) by 338 (millimeters) and the result is 3.7869. Divide 1024 by 271 and the result is 3.7786. Multiply those results by 25.4 to convert to dots-per-inch. In this example the result is 96.19 dpi x 95.98 dpi. Ignoring the mathematical precision of the calculations, both numbers should be the same. If they are, then add the DisplaySize instruction to xorg.conf. Of course, remember to restart the X server. After modifying xorg.conf and restarting the X server, repeat the xdpyinfo | grep resolution command to verify your efforts. You might need to adjust the DisplaySize numbers by a millimeter or two to finally derive a square dpi resolution. Notice that if you modify the screen size that the dots-per-inch number changes too. This is not magical but mere mathematics. Yes, if you have to resort to this level of fine-tuning X and you conclude that this nonsense is not yet ready for prime time, then you are correct! Other Potential Font ProblemsYou might want to review your /var/log/Xorg.0.log file and note any font related error messages. If some messages exist, then notice the affected font path. Use the console to change directories and run mkfontscale and mkfontdir in each of those directories. After updating all the affected directories in this manner, then again run fc-cache -fv. You must do this even if there are no fonts installed in those directories, but if that is the case, then consider deleting that directory and the reference in xorg.conf too. Another clue that you might not have run mkfontscale and mkfontdir in certain font directories is that KDE will generate a ~/.fonts-cache-1 file in your home directory. Open that file, note the affected directories, and repeat the mkfontscale and mkfontdir process in those directories. Only after ensuring that every font directory list in xorg.conf contains a fonts.scale and fonts.dir file should you then run fc-cache -fv. And only then should you run the KDE Font Installer. A clean installation will reveal no error messages in Xorg.0.log and KDE not generating any .fonts-cache-1 file. Lastly, if using KDE and some GTK-based programs, create a text file named ~/.gtkrc-2.0. Add one sole entry: gtk-font-name = "Arial 12" Modify the font name to match your font choices in KDE. The Final Trick to Nice TrueType FontsIf you want your TrueType fonts looking as nice as they do in Windows, then be sure to install a version of FreeType that enables the Bytecode Interpreter. Some distro providers do this automatically, but some do not. Slackware is packaged without that option enabled. The visual difference is noticeable. For Slackware users, you can download an updated package from linuxpackages.net. Or, if you possess the source CDs and are comfortable compiling source code, you can recompile that package. After updating that package you then modify /etc/fonts/local.conf:
The local.conf file is global to all users, but individual users can override these settings by creating a ~./fonts.conf file in their home directory. For all of these modifications you might need to log out and log in to notice the changes. You might also need to restart the X server and the font server if you are using one. Also ensure that the FreeType module is loaded in xorg.conf: Load "freetype" ConclusionAre you curious about all the fonts installed on your box? Try this: fc-list | sort | less You know what Porky Pig would say—That’s all folks! (Please add your own version of stuttering.) Sample files: Finis. |
||