Comments, corrections, additions and critiques are always welcome. You can reach the author at <hal@foobox.net>. Contributions are also welcomed. Especially anyone who really stays current with KDE and/or GNOME issues! (So I guess nobody uses these since the silence is deafening?)
If this keeps up, this document will have to be renamed the Font Beautification HOWTO ;-).
2.01: October 03, 2002. Update links for obtaining the MS web fonts (TrueType fonts of choice). There are two Sourceforge projects with these fonts available, including. http://sourceforge.net/projects/font-tool/.
Add section to Mozilla configuration to include info on Xft and anti-aliasing.
2.00: September 12, 2002. Wow, MS has taken down their webfonts page :( Not good news. Installing TrueType is a key ingredient to better living through nice fonts.
Major re-organization by moving the font server section to the appendix, since any recent distro is already installing these, or they are not any longer needed.
Some clarifications on gdkxft and font anti-aliasing. Finally, add Aristotle Pagaltzis's perl script for converting fonts.dir to fonts.alias. Include interesting example of using anti-aliased TrueType fonts in xterm. Note that GNOME 2 is out. Fix the usual assorted broken links.
Clarifications on dpi settings, and add tip about unbalanced dpi causing major trouble with fonts.
1.95: February 11, 2002. A few corrections. Removed the section on Fonts in KDE since this has to have changed, and I don't know anything about KDE (does anyone want to help here?). Added a brief section on gdkxft, which adds anti-aliasing support for GTK+ 1.2 applications.
1.9: November 5, 2001. A few new links and some minor catch ups only.
1.8: June 25, 2001: Included a new section on Anti-aliasing and Xft from Danny Tholen <obiwan@mailmij.org>. Many thanks on this not so well documented subject. Also, Sebastiano Vigna's neat little package for downloading and installing MS webfonts: http://freshmeat.net/webFonts4Linux. A few other odds and ends.
1.70: April 18, 2001: Added links for converting Mac TrueType Fonts (thanks to Karl A. Krueger), links to Unicode TrueType fonts (thanks to Tzafrir Cohen for suggestions and URLs), and added a section on anti-aliasing with X 4.0.2 (or greater). Also, included a reference to cabextract, a utility that is now available for extracting Win32 Fonts (among other things) from a Window's "cab" archive.
1.60: March 21, 2001: A few very minor changes. Most notable news is anti-aliasing support now in XFree 4.02 (referenced in the Notes section only). Chinese translation URL added.
The pre-release versions of this document can be found at http://feenix.burgiss.net/ldp/fdu/index.html.
Original author: Doug Holland.
Email: meldroc@frii.com
WWW: http://www.frii.com/~meldroc/
Updated and maintained by Hal Burgiss.
Email: hal@foobox.net
WWW: http://feenix.burgiss.net/ldp/fdu/
Special thanks go to:
The developers of the XFree86 Project, for all the hard work and time they have given. Also, Juliusz Chroboczek for his work with xfsft, and XFree86 4.x to help bring TrueType to the hungry masses. And Keith Packard for his anti-aliasing, and other work. This is not to slight the many, many other XFree86 volunteers.
Font wizard Kristin Aanestad, whose legwork and insight on much of the xfs, TrueType, Netscape, and especially, the fonts.alias sections are much appreciated. More from Kristin at Some Linux for Beginners on a wide range of topics.
Danny Tholen <obiwan@mailmij.org> is responsible for the nice Xft section, and examples.
The folks at comp.os.linux.x who gave me a hand in figuring all of this out in the first place.
The Linux community in general who made all of this possible in the first place. Especially those who have offered suggestions and comments that help to make this HOWTO a better resource. Keep those cards and letters coming ;-)
There are a few simple configuration tweaks that will help X do its job better.
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
This much should be the same, or at least similar, for both XFree86 3.x and 4.x. The FontPath tells X where to find the fonts it uses to render text on your display. Order is important -- when an X application asks X to render some text, the X server usually has some leeway to choose the font that is used. The X server then goes through the FontPath and grabs the first font it sees that matches the X client's criteria, and then displays it. (Note that Red Hat's xfs for versions 6.x and later has a different way of setting the FontPath. See the Section A.2 below for more on xfs.)
If the 100dpi fonts are not listed, they probably did not get installed for whatever reason, so you may want install them now. Default installations may put 75dpi fonts before the 100dpi fonts. If you have a high resolution display (1024x768 or higher), this means very tiny fonts. If this is the case, the first tweak you'll use is to switch the 75dpi and 100dpi FontPath lines:
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
Next, specify that you prefer to use unscaled bitmap fonts. If you've ever used Netscape or any other program that displays titles using big fonts, you might have noticed that those fonts were pixelized. This is ugly and needs to be corrected. So add :unscaled to the ends of the misc, 100dpi and 75dpi fonts. You can even use both unscaled and scaled fonts if you want, just put the unscaled FontPath lines first to tell X you prefer unscaled fonts if possible:
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
After making these changes, restart X (and your font server, if installed). Doesn't the desktop look better already?
$ xdpyinfo | grep resolution
resolution: 111x111 dots per inch
If you start X from the console command prompt, type:
$ startx -- -dpi 100 -depth 16 # v4.x syntax
Or these options can be stored in ~/.xserverrc. See the startx and xinit man pages for more on this.
:0 local /usr/X11R6/bin/X -dpi 100 -gamma 1.6
You want to specify a value that is compatible with your monitor's output.
More information is in the X, Xserver, xdm, xinit, and startx man pages.
Let's start with the fonts first. Any TrueType font included with the various MS Windows incarnations should work. Don't forget word processors and other apps that may include their own fonts. MacOS fonts will only work if converted to a usable format. (See the links section for converter packages.) There are also some 'free' TrueType fonts available for download if you have already nuked that CD (see links section).
Many distributions are now bundling tools for automating the process of including quality TrueType fonts. SuSE, Debian, and Mandrake do (Red Hat 7.x does not at this time). See what packages you might have for this as this will be the most painless way to go. Essentially, these tools help migrate fonts from a Windows installation, or download those available from Microsoft [note 08/15/02 MS has recently removed these fonts!] , and then handle the installation and configuration all in one neat utility. If you do have such a utility, the below information may not be necessary!
In order to use TrueType, the fonts will have to be always accessible to X. This means they will have to be on a filesystem that is always mounted. This can conceivably be a Windows partition on a dual boot system. Alternately, the fonts can be copied to Linux. First su to root:
# su -
# mkdir -p /usr/local/share/fonts/ttfonts
Now, change to the new font directory:
# cd /usr/local/share/fonts/ttfonts
Then, add the fonts to this directory, either by copying them from your Windows system:
# cp /mnt/<path_to_fonts>/*ttf .
or by downloading those available directly from Microsoft: http://www.microsoft.com/typography/fontpack/default.htm. Note 08/17/02: Microsoft has recently discontinued this page. At this time, the following pages (may!) still have these fonts available (or google search for them):
| ����http://nuoriso.hel.fi/__files/ms_truetype_core_fonts_for_the_web/Win95-98-NT/index.html |
| ����http://web.archive.org/web/20000420210719/http://www.microsoft.com/opentype/fontpack/default.htm |
These can be unarchived under Linux with cabextract, which can be found http://www.kyz.uklinux.net/cabextract.php3. This would now seem to be the best way to go at this time.
A slick solution to this from Sebastiano Vigna is his http://freshmeat.net/webFonts4Linux, which automates the downloading, extracting and installation of the Microsoft fonts all in one neat package. A utility designed primarily for Red Hat can be found: http://sourceforge.net/projects/font-tool/, which includes all the core MS web fonts, plus relevant system configuration. There is a tarball, as well as RPMs (both require cabextract).
You can also get an RPM of WebFonts that contains some of the MS Web fonts from ftp://ftp.rpmfind.net/linux/contrib/noarch/noarch/webfonts-1-3.noarch.rpm. This has enough basic fonts to keep Mozilla and other web browsers happy. Something similar for Debian is http://packages.debian.org/unstable/graphics/msttcorefonts.html. This does not include the actual fonts, but facilitates the installation.
If doing it yourself, you will also have to include the new TrueType directory(s) in the X server's fontpath. So with your text editor of choice add the line(s) as appropriate:
FontPath "/usr/local/share/fonts/ttfonts"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
This configuration is for "core X font" support. For additional configuration relating to the new Xft rendering engine, see the sections below on XFT and anti-aliasing.
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
And very simply, make this small change:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER |
%define without_bytecode_interpreter 1 |
%define without_bytecode_interpreter 0 |
Other vendors may have a similar, easy-to-use mechanism.
Note that "hinting", "anti-aliasing", and "sub-pixel rendering" are separate concepts (see the section on Xft below for more). Again, this is not a cure-all for "ugly" fonts, but one more piece in the puzzle of font "beautification".
Su to root, and change to the directory where the TrueType fonts are.
# su -
# cd /usr/local/share/fonts/ttfonts
If there are any upper case font names, you can use the following script to convert all names to lower case:
#!/bin/sh
#
## -------- convert upper to lower case ---------
ls * | while read f
do
if [ -f $f ]; then
if [ "$f" != "`echo \"$f\" | tr A-Z a-z`" ]; then
#Note that 'This' will overwrite 'this'!
mv -iv "$f" "`echo \"$f\" | tr A-Z a-z`"
fi
fi
done
## eof
Note the punctuation -- the backquotes are important! Remove any spaces from font names too. Once the TrueType fonts are properly installed, you must create both fonts.dir and fonts.scale files. The following commands do this:
# ttmkfdir -o fonts.scale
# mkfontdir
If you don't have ttmkfdir installed, check your distribution's repository, or it can be downloaded from: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz. This is necessary!
As of Red Hat 7.1, the above commands are run from the xfs init script. So restarting xfs (/etc/rc.d/init.d/xfs restart) will accomplish the same thing for Red Hat users. Other distros may have similar shortcuts.
You should now have fonts.dir and fonts.scale files in your TrueType font directory. ttmkfdir is in the Freetype RPM for Red Hat users, and must be run before mkfontdir. With Debian based distros, there is a similar utility called mkttfdir, and is in the fttools Deb package. Though this apparently does not generate as many encodings as ttmkfdir. These commands may not always report errors, so verify that they were created and are not empty files:
$ ls -l fonts.*
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.dir
-rw-r--r-- 1 root root 11657 Aug 17 10:31 fonts.scale
If you encounter any problems, try ttmkfdir with the - m switch. This will discard bad characters from the font file. Specify a number such as 50 or l00 (ttmkfdir -m 50). The files themselves are text files. Have a look:
$ less fonts.dir
114
webdings.ttf -microsoft-Webdings-medium-r-normal--0-0-0-0-p-0-microsoft-symbol
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-ascii-0
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-fcd8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-15
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-9
verdanaz.ttf -microsoft-Verdana-bold-i-normal--0-0-0-0-p-0-iso8859-1
[...]
If ttmkfdir is persistently giving problems by not generating a proper output file, there may be one or more "bad" fonts (ie fonts it can't handle). In that case, just start with a few common ones, like Arial and Verdana. If this works, then add a few at a time.
Now be sure the new fonts are included in the FontPath. And either restart X (Ctrl-Alt-BS), or the font server (if using one). You could also try refreshing the FontPath:
# xset fp rehash
Red Hat 6.x/7.x users can update the FontPath and xfs:
# chkfontpath --add /usr/local/share/fonts/ttfonts
# /etc/rc.d/init.d/xfs restart
You should now be in business. You can check which fonts are available to X:
$ xlsfonts | less
or check them out further with xfontsel, or gfontsel. If they are visible to xlsfonts, then they are available to X and vice versa. If they are not there, try restarting X with Ctrl-Alt-BS.
This gets you as far as X knows about your new fonts. Individual applications will need to be configured to use them. GNOME and KDE will require additional steps as well (see the respective docs). You will also want to configure Xft (see below), if using XFree86 v4.x or later.
Historically, font servers were used to serve fonts over a network. Font resources could then reside on one host, and clients could access them as needed. But, the developers have enhanced these to include features such as the ability to render TrueType fonts. XFree86 4.x does have built in support for TrueType (see Section 4), making a font server not a necessity, though some distros default to using a font server for other reasons now.
XFree86 3.x does not come with built in TrueType support, so you'll have to add it yourself if you are using a 3.x version. This will mean installing a supplemental font server that does support TrueType. And, of course, installing the fonts themselves (see above). See the Appendix for font server installation, and related tips.
Any recent distro will have one or more font servers included, and the important configuration should be done by the installation program.
fixed -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
fixed is the 'alias' here. Any time this is requested, we actually get the font definition from the second column. Font too small? Just change the definition. (Warning: this is a critical file, at least on Red Hat.) The same principle applies to all fonts, including TrueType. In fact, if you don't have TrueType, you could conceivably use this trick to have a comparable Type 1, or other, font aliased as a TrueType.
fonts.alias is important for some applications that don't handle the data provided by fonts.scale well. Most notably here is Netscape. Without a fonts.alias you will find that Netscape will only show point sizes of 0 and 12 available. fonts.alias fixes this. You might also find that if you a specify another size with the scalable font option under Preferences, Netscape will not remember this setting. Annoying! This is also fixed. So we really need this file. Sample excerpt from a fonts.scale:
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-ascii-0
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-fcd8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-15
arial.ttf -monotype-Arial-medium-r-normal--0-0-0-0-p-0-iso8859-1
These are scalable so we don't get any predefined point sizes. We will need to create our fonts.alias something like this excerpt for Arial:
-monotype-Arial-medium-r-normal--6-60-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--7-70-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--9-90-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--8-80-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--10-100-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--9-90-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--11-110-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--10-100-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--11-110-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--12-120-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--12-120-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--13-130-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--13-130-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--14-140-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--14-140-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--15-150-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--15-150-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--18-180-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--18-180-75-75-p-0-iso8859-1
-monotype-Arial-medium-r-normal--24-240-0-0-p-0-iso8859-1 \
-monotype-Arial-medium-r-normal--24-240-75-75-p-0-iso8859-1
(Please note that I have split each line for readability. There should be two columns all on one line, without the "\", and separated by at least one space.) This will keep Netscape happy. Also, if font names should have embedded spaces, then you should enclose the filename in quotes. You might also note the pointsize discrepancy between the first and second columns of the first few rows. The first column of the first entry has a '6', whereas this is aliased to a '9' in the second column, and thus '9' point. This is by design and is an excellent way to overcome the Netscape 'damn tiny fonts' syndrome. Adjust to suit your tastes, resolution, and eyesight.
This file can be created manually with a text editor, or conceivably with some fancy sed or awk scripting. There is an excellent discussion of this file, and other font related topics at Kristin Aanestad's site at http://home.c2i.net/dark/linux.html. There is also a link to a python script which can reportedly automatically generate a fonts.alias file at this same site. A perl version of this script is re-printed in the Appendix. Thanks to Kristin whose work and insight was the inspiration for this section!
Another potential use of fonts.alias would be to map one font to something quite different. Say you don't have TrueType fonts, and didn't want to install Microsoft's. You could alias nice, scalable Type 1 fonts to a TrueType. That way when the system (or some web page) wants a TrueType, you'd get something of comparable quality instead of bitmap that doesn't scale well.
Note that with XFree86 4.0.2 and greater, there are new font handling mechanisms available via the Xft extensions. Font aliasing is done in Xft's own configuration file: XftConfig. This is the preferred method where anti-aliasing, and the other new rendering features are desired. See the Anti-aliasing Section for more on this and de-mystification. This is only true where the application (i.e. the toolkit, e.g QT) itself supports the new extensions! At this time, not all do (yet).
XFree86 4.0 introduced native support for TrueType fonts, along with other new features. The enhanced font support is based on xfsft from Juliusz Chroboczek, which in turn is based on the FreeType font library originally from Mark Leisher, so the configuration is similar to xfsft and Red Hat's patched xfs which use the same rendering engine. As of 4.0.2, XFree86 begins to support anti-aliasing which is a technique for smoothing font outlines (see section below).
The FontPath is still in XF86Config, as always. For Red Hat 6/7 using a stock XFree86 4.x (i.e. NOT the Red Hat 7.x supplied version), this will mean moving the Red Hat xfs FontPath from /etc/X11/fs/config back to XF86Config. A separate font server is no longer needed just for TrueType support. You may disable it, unless it is needed to serve fonts to other clients in a network environment. Or you may want to still use it since there may be a very small performance gain in some situations (at the cost of more memory utilized). See the section below for Red Hat 7.x specific configuration issues.
Section "Files"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/share/fonts/default/Type1"
FontPath "/usr/local/share/fonts/ttfonts"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
EndSection
In order to use TrueType, you must also specify which font module the X server should be using in the "Module" section:
Section "Module"
Load "freetype"
Load "speedo"
Load "type1"
<load other modules....>
EndSection
Note that there can be only one 'Module' section, so include any other modules here as well. Again, this is the kind of configuration that your distro should be doing during installation, and may not be necessary, unless you are upgrading, or want to make manual changes yourself.
You also must have a fonts.scale and fonts.dir file for each TrueType font directory, just like for xfsft and Red Hat's xfs (see Appendix). ttmkfdir, http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz, will come in handy for fonts.scale if it is not already installed. See the Configuration section above for more details and examples.
xtt is another available TrueType module that is best known for supporting ideographic (Oriental) type fonts. You can use either, but only one at a time.
Most X server command line options are still the same as previous versions of X:
$ startx -- -dpi 100
As mentioned, the new font handling improvements are the result of the development work behind Xft. Xft is an on-going effort to improve and modernize X's font handling. The end result will be radically different from the traditional X font handling (known as "core X fonts").
What we have now is essentially two different systems: one that has been around since the dawn of time (or even before :), and one that is radically new and still evolving! I emphasize this, since the "still evolving" part is likely to cause some confusion until the dust settles.
The initial release of Xft v1.0 with XFree86 4.0.2 is controlled by its configuration file, XftConfig. This changes with later versions, where the font configuration is handled by the fontconfig library, with its main configuration typically located /etc/fonts/fonts.conf. Of course, additional development has brought other improvements as well. For more on the Xft and Fontconfig, see the Fontconfig home page, http://fontconfig.org/.
What we, as end users, will notice and appreciate most, is the anti-aliasing support and other rendering enhancements we get from Xft. Though this is not the only benefit.
Minimum requirements for Anti-Aliasing:
The Freetype2 library available from http://www.freetype.org, and also now bundled with XFree86. XFree needs to be linked against this, so install and build first if building from scratch. Your distro should have Freetype packages as well. Just make sure it is freetype-2.
TrueType fonts are best for display purposes. Type 1 is also good, but may not render quite as well. See above sections.
For KDE users, KDE supports anti-aliasing as of 2.x. This will require QT-2.3.0 or later, and built with Xft support. A nice font HOWTO from Troll Tech for KDE and QT can be found: http://trolls.troll.no/lars/fonts/qt-fonts-HOWTO.html.
GNOME 1.x does not support anti-aliasing. GNOME 2.0 has recently been released and does have native support for anti-aliasing.
Applications that "know" about anti-aliasing. Not necessarily at the individual application level, but the libraries and toolkits (GTK, TK, etc.) that the application are built against, must be able to use the new features. At this time, not all do. KDE/QT is first out of the box and has good support. Also, xterm (yes, xterm!) supports the new extensions. An interesting example scavenged off usenet:
From torvalds@penguin.transmeta.com Sun Apr 28 02:09:28 2002
From: torvalds@penguin.transmeta.com (Linus Torvalds)
Newsgroups: comp.os.linux.x
Subject: Re: X font recommendation
Organization: Transmeta Corporation
Lines: 24
Message-ID: <aa4ijq$259$1@penguin.transmeta.com>
Cache-Post-Path: palladium.transmeta.com!unknown@penguin.transmeta.com
Date: Tue, 23 Apr 2002 21:10:18 +0000 (UTC)
X-Trace: news.sjc.globix.net 1019596253 63.209.4.196 (Tue, 23 Apr 2002 14:10:53 PDT)
NNTP-Posting-Date: Tue, 23 Apr 2002 14:10:53 PDT
In article <aa492r$7hc5u$2@ID-99293.news.dfncis.de>,
William Park <opengeometry@NOSPAM.yahoo.ca> wrote:
>Peter Karlsson <root@localhost.localdomain> wrote:
>> What's wrong with "fixed"? :-)
>>
>> xterm -sb -sl 10000 -fg yellow -bg black -geometry 120x40 -fn fixed -bc
>
>This will load the default 6x13 fonts, aka.
> -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
>A bit too small, though it has correct proportions. If there is bigger
>size (8x16, 10x20, 12x24) of that fonts, then that would be ideal.
If you like anti-aliased fonts, the command line I prefer happens to be
xterm -geometry 100x40 -fa andale:size=11:charwidth=6
I think that font is from the MS free fontpack.
In order for it to work for you, you need to have the anti-aliasing
truetype fonts working well, and probably a good monitor (and some
people _hate_ that rounded look from anti-aliasing, and find it fuzzy
even then).
Linus
|
You might have to experiment with the size and charwidth values to get reasonable results.
The new rendering extensions configuration file, XftConfig, must be configured for the fonts you want to use. Note that as of Xft2, this changes to /etc/fonts/fonts.conf.
The new extensions supplant much of what we have been doing with font servers like xfs. fonts.alias and similar configuration files, for instance, are not used for fonts that are being controlled by the new extensions. Essentially, this gives us two separate font handling engines: the traditional, "core" font engine, and the new, Xft engine. The core engine is still used in some situations.
Keith Packard has a very brief summary of the steps required for building, installing and configuring from source at http://www.xfree86.org/~keithp/render/aafont.txt. No need to reprint it here.
Newer distro releases are likely to have the foundation support for anti-aliasing available now. Red Hat, for instance, has it available as of Red Hat 7.1.
To verify the necessary components, first make sure the "freetype" module (and any others) are loaded. Check the X server output:
(II) LoadModule: "freetype"
(II) Loading /usr/X11R6/lib/modules/fonts/libfreetype.a
(II) Module freetype: vendor="The XFree86 Project"
compiled for 4.0.3, module version = 1.1.9
Module class: XFree86 Font Renderer
ABI class: XFree86 Font Renderer, version 0.2
(II) Loading font FreeType
Then verify if the "RENDER" extension is available, either check with xdpyinfo, or check the X server log, typically /var/log/XFree86.0.log:
(II) Initializing built-in extension MIT-SHM
(II) Initializing built-in extension XInputExtension
(II) Initializing built-in extension XTEST
(II) Initializing built-in extension XKEYBOARD
(II) Initializing built-in extension LBX
(II) Initializing built-in extension XC-APPGROUP
(II) Initializing built-in extension SECURITY
(II) Initializing built-in extension XINERAMA
(II) Initializing built-in extension XFree86-Bigfont
(II) Initializing built-in extension RENDER
If "RENDER" is there, anti-aliasing and the other advanced rendering extensions should be available. If not, the system should gracefully fall back to the core X fonts engine.
By Danny Tholen <obiwan@mailmij.org>
Xft is an interface to the freetype rasterizer written by Keith Packard, member of the XFree86 Project, Inc. It allows applications to use fonts from the new X render extension using a unified font naming scheme. In /etc/X11/XftConfig (or /usr/X11R6/lib/X11/XftConfig) you will find a configuration file which can be adapted to suit your personal taste. In this section I will explain the syntax and demonstrate some things you can do with this file.
The following information is based on 4.0.3. 4.1 is just released, and there may be a few new wrinkles not touched on here. Future versions are sure to bring even more radical changes.
Note that Xft2 makes radical changes to Xft configuration. XftConfig is obsoleted and replaced by the new fontconfig libraries. Red Hat 8.x users should read the Red Hat 8.0 Differences section first. Many of the principles described still apply, but the configuration is radically different. FYI.
family: "Arial"
size: 12
encoding: "iso8859-1"
A size 12 arial font in latin-1 encoding. The Xft extension will now try to patch this pattern to all of the fonts available in the system. And selecting the one with the best score. Before the matching is done Xft looks in XftConfig. The requested pattern can here be extended before use. An example is:
match any family == "Arial" edit antialias = true;
This will enable anti-aliasing for all fonts of the family Arial.
Also, the X server is queried to list all of its fonts; the XLFD contains just enough information to match fonts roughly.
Here's a list of attributes used in matching fonts (in priority order, this may not be up to date anymore!):
foundry font foundry (string, like "monotype")
encoding font encoding (string, like "iso8859-1")
spacing font spacing (integers or proportional (0), mono (100),
charcell (110))
bold is the font bold? (boolean)
italic is the font italic? (boolean)
antialias is the font anti-aliased? (boolean)
family font family (string)
size font size (double)
style font style (string, like "Bold Italic")
slant font slant (roman, italic, oblique)
weight font weight ( integers or light, medium (100), demi-bold,
bold, black)
rasterizer not yet used (probably "TrueType", "Type1", ...)
outline are outlines available? (boolean)
match qual FIELD-NAME COMPARE CONSTANT
where qual is either any (matches one specific font) or all (matches all fonts). An example:
match all foundry==�monotype�
which will match (and edit) all fonts belonging to the foundry "monotype".
match any family==�arial�
will match (and edit) one specific font with the family name "arial".
FIELD-NAME is any one of the properties found in the above section Structure, or additionally:
pixelsize font size in pixels (integer)
charspace character space (integer)
minspace minimal spacing (integer)
rgba color hinting (string �rgb� or �bgr� and
vertical hinting �vrgb� �vbgr�), aka sub-pixel hinting
xlfd x server font (string, type xlsfonts to
see a list of your xlfd strings)
file the font file (string)
core use X core fonts? (boolean)
render use render fonts? (boolean)
index I have no idea what this does:)
scalable is the font scalable (boolean)
scale scale the font (integer)
charwidth character width (integer)
charheight character height (integer)
matrix no idea (not really at least)
COMPARE can be <, >, or ==.
CONSTANT is the value of the field-name in the appropriate type (see above section Structure).
You can use multiple matches before you use the "edit" statement:
edit FIELD-NAME ASSIGN EXPR SEMI
Where ASSIGN can be one of =, += or =+. With =, the matching value in the pattern will be replaced by the given expression. += or =+ will prepend/append a new value to the list of values for the indicated field.
EXPR sets the FIELD-NAME to a value.
SEMI is a semicolon (;). You can use multiple instructions, separated by a semicolon. See below for examples if this is confusing.
How do I make fonts available to Xft?
List your Type 1 and TrueType font directories with "dir". On my system (Mandrake 7.2) this becomes:
dir "/usr/X11R6/lib/X11/fonts/Type1"
dir "/usr/X11R6/lib/X11/fonts/drakfont"
How do I use a user specific XftConfig file?
Put an .xftconfig file in your user directory and add:
to your standard XftConfig. This will enable a user specific configuration file, but it will not complain if there is no such file.
How do I make aliases for my fonts?
Anti-aliasing my fonts are blurry and makes me dizzy!
Use the following in your XftConfig to anti-alias only fonts of specific sizes:
match
any size > 8
any size < 15
edit
antialias = false;
My fixed fonts do not appear or look _very_ wrong in the KDE konsole or similar programs!
match
any family == "mono"
edit
spacing = mono;
My Symbol, Webdings, etc. fonts do not show up!
A useful way of figuring out these things is to activate debugging with:
export XFT_DEBUG=1024
This will generate a lot of output, especially if you have many fonts, because it lists the properties and scores of every font available. You can also use other values. For a nice summary of what happens (requested font, XftConfig substitutions, X server additions and the finally matched font), you can use XFT_DEBUG=2.
I have a LCD screen on my laptop, can I use sub-pixel hinting instead of normal anti-aliasing?
or use rgb if you have a different type of monitor. For vertical AA you can try vbgr and vbgr.
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
to:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
and rebuild with this modified source. See the freetype2 README file for details. Adobe Courier looks terrible on my system, so I made an alias so that Lucida console is displayed instead. If anyone can get it to display nicely I would appreciate knowing about it.
There is also the gdkxft project available at http://sourceforge.net/projects/gdkxft/. This will add anti-aliasing support to GTK+ 1.2 applications (only!). This is a stand-alone library and not a patch. It will only effect GTK+ 1.x widgets (many of them but not all). There are some limitations, but mostly it works as advertized. Read the included README closely, and follow the instructions. An initial installation provides a good starting point. I added some font families to /etc/gdkxft.conf and I used some of Danny's suggestions above, and it seems to work mostly. It's a bit of a kludge, but quite a nice kludge ;-) Note, sadly this project seems to be no longer maintained.
There is also a couple of ways to get this working with Mozilla! On the same page above is a replacement library that can be substituted for the Mozilla library of the same name. Just a drop in replacement. But, this did not work here (on Red Hat 7.2), it segfaulted. But building Mozilla from source with the patch listed, did indeed work nicely! This step requires gdkxft to be working as well. So it's a two step process to get Mozilla working, but worth the effort if you want the best looking pages IMHO. There are also development versions of Mozilla available from ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/ that have Xft/TrueType support (see the section on Mozilla below). Native Mozilla Xft support is probably working its way into mainstream releases. [Note: This should happen with Mozilla 1.2.]
You can also turn on Xft debugging:
Then start apps from that same terminal. This will tell if anti-aliasing is active for each font as its processed. This also gives some insight into how Xft understands font names and other details.
One final point: anti-aliasing and TrueType are completely separate issues. One does not depend on the other, though both together can can enhance appearance significantly. Especially, with good quality TrueType fonts! But any font can potentially be anti-aliased.
Assuming you have TrueType working, from the Netscape menu select Edit -> Preferences -> Fonts. Open the Variable Width Font droplist on the right side of the window. Your TrueTypes should be there along with other fonts. Choose which ever one suits your fancy as the default. Check the Allow Scaling checkbox too. If the available point sizes are 0 and 12, you can go down and, and enter your desired point size in the box to the right and click on the OK button. The down-side to this is that Netscape will not remember these settings, and you will have to do this each time you start Netscape. Unless -- you have fonts.alias set up already. Then this will solve these problems. See Section 3.5 for more on fonts.alias.
You might consider experimenting with some ~/.Xdefaults (or perhaps it's~/.Xresources on your system) settings too:
Netscape*DocumentFonts.sizeIncrement: 10
Netscape*documentFonts.maximumPoints: 240
Netscape*documentFonts.xResolution*iso-8859-1: 120
Netscape*documentFonts.yResolution*iso-8859-1: 120
The 'sizeIncrement' controls how much of a jump Netscape makes when different 'basefont' sizes are specified ala:
<basefont size=7>
for instance. The default is '20', which is a pretty good jump. Changing this can help Netscape from scaling to too large and too small of a font. The x and y resolutions are roughly equivalent to 'dpi' settings. Any random number within reason can be used here. Experiment. Note: Mozilla does not use this kind of configuration!
Then run:
$ xrdb -merge ~/.Xdefaults
(or .Xresources as the case may be) and restart Netscape. There are many settings that can be tweaked or altered this way. Look at the Netscape.ad (app defaults) file that should be included with Netscape packages.
If this approach does not get the job done as far as the 'tiny fonts' problem in Netscape, then see the fonts.alias section above. You can really fine tune many things with this approach.
// Don't ever show me a font smaller than this: some samples.
user_pref("font.min-size.variable.", 12);
user_pref("font.min-size.variable.x-western", 12);
user_pref("font.min-size.fixed.x-western", 12);
|
More info is available from the Mozilla developers: http://www.mozilla.org/unix/customizing.html.
It is also possbible to have anti-aliasing of fonts with Mozilla now. This might be a bit of work to get going at this time (Aug 2002), but it is possible. See the next section.
There are many builds of Mozilla available, and it is not so easy to know which have Xft support. There are tips for knowing if your installed version does have this support, and then how to enable it here: http://www.mozilla.org/projects/fonts/unix/enabling_truetype.html. Worse comes to worse, you can download experimental versions from: ftp://ftp.mozilla.org/pub/mozilla/nightly/experimental/xft/.
For whatever reason, Mozilla has its own Xft configuration, that is independent of other system components. You must turn it on, and configure it (unless your vendor has done this already)! I know what you are saying, "one more place to configure fonts, sigh ...".
The above page explains rather tersely how to do this. The highlights:
Requirements:
| �����XFree86 4.x with Xft support. |
| �����FreeType2 libraries. |
| �����Mozilla with Xft support. |
| �����TrueType fonts. |
Configuration:
You will need to hand edit the relevant unix.js file, which is typically installed as /usr/lib/mozilla-*/defaults/pref/unix.js, or a similar location.
You will need to enable FreeType2 (and possibly define the version), and then list the directories that contain your TrueType fonts (each listing must be uniquely identified, see example). Sample excerpt:
// TrueType ///////////////////////////////////////////
pref("font.FreeType2.enable", true);
pref("font.freetype2.shared-library", "libfreetype.so.6");
// if libfreetype was built without hinting compiled in
// it is best to leave hinting off. try it both ways to see.
pref("font.FreeType2.autohinted", true);
pref("font.FreeType2.unhinted", false);
// below a certian pixel size anti-aliased fonts produce poor results
pref("font.antialias.min", 10);
pref("font.embedded_bitmaps.max", 1000000);
pref("font.scale.tt_bitmap.dark_text.min", 64);
pref("font.scale.tt_bitmap.dark_text.gain", "0.8");
// sample prefs for TrueType font dirs
//pref("font.directory.truetype.1", "/u/sam/tt_font");
//pref("font.directory.truetype.2", "/u/sam/other/tt_font");
pref("font.directory.truetype.1", "/usr/share/fonts/truetype");
|
The // characters are comments. Then restart Mozilla. You should see it processing each font in the directories you specified (if started from the command line). You then need to go into the Mozilla font configuration (Edit -> Preferences -> Appearance -> Fonts), and select the appropriate fonts — these must be the ones that are listed with the first letter as upper cased:
Afga-monotype-arial-iso8859-1 |
This should now give you TrueType fonts with anti-aliasing! Quite nice!
You should experiment with the "hinting" preferences. Having hinting enabled made a significant improvement here.
Though not discussed here, Type 1 fonts provide many of the same benefits as TrueType and are historically better supported in the Unix world, especially for printing. XFree86 still seems to render TrueType somewhat better than Type 1. You likely have many of these installed already. Unfortunately however, Type 1 are not a web standard like TrueType. But they are suitable for many other purposes. They are where it's at for printing. See ghostscript for more on this.
While it is possible to specify a default point size for the xfs font server, very few applications will actually use this value.
Abiword comes with a suite of fonts, called 'Abisuite'. Apparently, some of these fonts have the same names as some of the well known MS TrueType fonts: Arial, etc. And apparently, these are not as good quality. And because of the way X searches for fonts, it may find these first and use these, even if the 'real' ones are installed and may be the preferred choice. The solution is to either make sure your preferred fonts come first in the FontPath or maybe to uninstall 'Abisuite' if it's not needed.
The new Xft rendering extensions of XFree86 4.x will mostly supplant similar features as provided by xfs, and older XFree86 extensions. For instance, font aliasing should be done in XftConfig if the new extensions are being used. This would only be true where the application is built against a toolkit (like QT or GTK) that supports the new extensions. This is still not universally supported.
XFree86 Project, the guys and gals who do an incredible amount of work to give us a killer GUI environment. An overview of XFree86 fonts: XFree86 4.x. And an explanation of Xft: http://www.keithp.com/~keithp/render/Xft.tutorial.
The Fontconfig home page is http://fontconfig.org, for all the latest news on Xft and fontconfig (the future of X font handling).
The Video Timings HOWTO, the ins and outs of getting the most from your monitor. (Applicable only to XFree86 v.3.x for the most part.)
Font HOWTO Many good tips for installing fonts and for applications such as StarOffice, Applixware, Wordperfect, Ghostscript, TeX/LaTeX.
A TrueType HOWTO, good tips for printing, and a few application specific tips.
xfsft Homepage, TrueType font support for X. This is the origin of the "freetype" font module for XFree86 4.x, and Red Hat's xfs. Good site, and good links to other information related to fonts and TrueType.
Some Linux for Beginners. Great font site, and other Linux topics. Covers many of the topics discussed here in more detail. Some font and other tips for Mozilla: http://home.c2i.net/dark/My_Mozilla_FAQ.html.
Two guides specifically for Debian from Paul D. Smith: http://www.paulandlesley.org/linux/xfree4_tt.html and for 3.3.x: http://www.paulandlesley.org/linux/debian_tt.html.
X-TrueType Homepage, and yet another TrueType Font server, especially good for Japanese, Chinese and Korean character sets. [Note: link is bad 08/18/02.]
Tips on font size problems from Netscape.
Wordperfect for Linux -- Fonts and Printers by Rod Smith, the author of Using Corel Wordperfect 8 for Linux from Que. Excellent information on Wordperfect and where TrueType fits in.
http://sourceforge.net/projects/font-tool/, contains the core MS TrueTyep fonts suitable for web browsing. http://packages.debian.org/unstable/graphics/msttcorefonts.html is a similar package for Debian.
Sebastiano Vigna's http://gongolo.usr.dsi.unimi.it/~vigna/webFonts4Linux/ automates the downloading, extracting and installation of the Microsoft fonts all in one neat package.
Freeware Connection -- Free Fonts Sites lots of links to lots of sites.
Bitstream's Geometric Slabserif TrueType Font.
Two converters for converting a Mac Font "suitcase" to a *nix compatible font: http://www.macinsearch.com/infomac2/font/util/tt-converter-15.html and http://www.netmagic.net/~evan/shareware/#TTFontConvert
The Unicode HOWTO: http://linuxdoc.org/HOWTO/Unicode-HOWTO.html
Two sources of 'free' TrueType fonts with large Unicode support are Bitstream Cyberbit, which covers Roman, Cyrillic, Greek, Hebrew, Arabic, combining diacritical marks, Chinese, Korean, Japanese, and more, and is available from ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/Cyberbit.ZIP. And Lucida Sans Unicode, which is included in IBM's JDK 1.3.0beta for Linux, and covers Roman, Cyrillic, Greek, Hebrew, combining diacritical marks. This can be downloaded from ftp://ftp.maths.tcd.ie/Linux/opt/IBMJava2-13/jre/lib/fonts/ as LucidaSansRegular.ttf and LucidaSansOblique.ttf. Thanks to Tzafrir Cohen for these references. He also has a nice page on Hebrew fonts and related topics at http://www.iglu.org.il/faq/?file=133.
One such font server is xfstt. xfstt was designed specifically with TrueType fonts in mind.
xfstt is very easy to install and configure. If it isn't already installed, you'll want to download the tarball, or check your CD. The most current version can be found at http://metalab.unc.edu/pub/Linux/X11/fonts/
Once you have the tarball, unpack it:
$ tar -zxvf xfstt-*tgz
Then build and install it. Read the INSTALL file for quick instructions, but it's a no brainer.
From the xfstt directory is all you have to do.
# make
# make install
Then start xfstt with:
# xfstt --sync # updates xfstt's font database
# xfstt & # runs xfstt in the background.
xfstt should be started before the X server starts. Once you have this working correctly, you can add the above lines to /etc/rc.d/rc.local, or other suitable start up file. Then type:
$ xset +fp unix/:7101 # tells X about xfstt, and where to look for fonts.
or add:
FontPath "unix/:7101"
to your XF86Config to tell X about the font server. Rerun xfstt --sync any time the FontPath, or contents, change.
Now xfs will start every time you boot.
FontPath "unix/:-1"
This is changed for Red Hat 7.x to:
FontPath "unix/:7100"
At least for a default configurations. This is a reference to the socket where xfs is listening. You may include additional FontPaths, but these will be handled by the X server, and not xfs. A clean install of Red Hat 6/7 should have this already set up, but if you are upgrading from an older version, you may have to change this yourself!
xfs then has its own, separate FontPath stored in /etc/X11/fs/config. This is where it will look to find fonts. This is over and above the X server's FontPath in XF86Config. You can either add the new path(s) with a text editor, or use the chkfontpath command:
# chkfontpath --add /new/font/path
The FontPath must exist before running chkfontpath. The relevant section of /etc/X11/fs/config should now look something like this:
catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,
/usr/X11R6/lib/X11/fonts/100dpi:unscaled,
/usr/X11R6/lib/X11/fonts/75dpi:unscaled,
/usr/X11R6/lib/X11/fonts/Type1,
/usr/X11R6/lib/X11/fonts/Speedo,
/usr/X11R6/lib/X11/fonts/misc,
/usr/X11R6/lib/X11/fonts/100dpi,
/usr/X11R6/lib/X11/fonts/75dpi,
/new/font/path
When adding a new FontPath for TrueType fonts, you will want to do this step after installing and preparing the fonts. See the next section.
Installation and configuration is the same as for other "freetype" based font renderers (e.g. XFree86-4.x freetype module). See the above Configuration section for details. Actually, you should just be able to install the fonts, include the new font directory to the FontPath with the chkfontpath utility, and then reload xfs:
# service xfs reload
xfsft is a TrueType solution from Juliusz Chroboczek. xfsft is based on the FreeType font library as developed by Mark Leisher and others. It is essentially is a patch for XFree86's xfs and related libraries -- xfs + ft. Red Hat's xfs is essentially xfsft with a few minor modifications. Also, XFree86 4.x includes the freetype font module which is also the result of Juliusz's work, and is one of the TrueType solutions available for XFree86 4.x.
Building xfsft requires having at least some of the XFree86 source available, in addition to xfsft itself, so this is not for the faint of heart. Instructions for building and configuring xfsft are in the tarball, so I won't go into details here. They are pretty straight forward. There are links to binaries available at the xfsft home page (see above).
Note that you must also create fonts.scale and fonts.dir files for xfsft. fonts.scale can be created manually (ugh!), or with the ttmkfdir utility. This is not included with xfsft but you can get it here: http://www.joerg-pommnitz.de/TrueType/ttmkfdir.tar.gz, or probably on many Linux archives sites too. Red Hat has this as part of the Freetype RPM. And for Debian it is called mkttfdir and is in the fttools package.
You will also need a configuration file. Here is a sample:
-----------------------------------------------------
clone-self = off
use-syslog = off
client-limit = 20
catalogue = /usr/local/share/font/ttfonts
error-file = /home/jec/fonts/xfs.errors
# in decipoints
default-point-size = 120
# x,y
default-resolutions = 100,100,75,75
-----------------------------------------------------
You can then run start xfsft:
# xfs -port 7100 -config /path/to/your/config/file &
You can then add xfsft to the X server's FontPath:
$ xset +fp tcp/localhost:7100
If all goes well, you could then add this FontPath to XF86Config.
#!/usr/bin/perl -w
# This utility is a direct translation right down to the comments
# from mkfontalias.py written by Roman Sulzhyk to assist people
# in de-uglification of their true type fonts. It creates a
# fonts.alias file from the fonts.dir file found in the directory.
# It supports all of the Python script's features:
#
# - maps the following MS webfonts:
# Verdana, Tahoma, Impact, Arial Black,
# Comic Sans MS, Georgia, Trebuchet MS
#
# - cheats by mapping 6, 7 and 8pt to 9pt fonts
#
# (c)2002 Aristotle Pagaltzis, licensed under the GPL
# http://www.gnu.org/copyleft/gpl.html
use strict;
my $infile = "fonts.dir";
my $outfile = "fonts.alias";
my @res = (75, 75);
my %cheat_map = (6 => 9, 7 => 9, 8 => 9);
my @font_sizes = (6..16, 18, 24);
my %font_map = (
"Arial" => "Arial",
"Times New Roman" => "Times New Roman",
"Verdana" => "Verdana",
"Tahoma" => "Tahoma",
"Impact" => "Impact",
"Arial Black" => "Arial Black",
"Comic Sans MS" => "Comic Sans MS",
"Georgia" => "Georgia",
"Trebuchet MS" => "Trebuchet MS",
"Courier New" => "Courier New"
);
# Read in the fonts.
open(THEFILE, "<", $infile) or die "Cannot read $infile: $! - are you sure you are in the fonts directory?\n";
my @fontdir = splice @{[ <THEFILE> ]}, 1; # Strip the first line
close THEFILE;
# Now, create the output
my @aliases;
foreach (@fontdir) {
# Get rid of the first entry, but mind that other may have
# spaces in them
my $font = join(" ", splice @{[ split ]}, 1) or die "Cannot parse $infile line: $_\n";
my @entries = split "-", $font;
die "Invalid font: $font\n" unless @entries == 15;
my $mapped_font = $font_map{$entries[2]} or next;
# Create a bunch of aliases, for each size
for my $size (@font_sizes) {
# Do the "cheating" - fallback to size if not in the cheat map
my $real_size = $cheat_map{$size} || $size;
# Add the entry to the aliases
push @aliases, join(
" ",
join("-", @entries[0..6], $real_size, $real_size * 10, @entries[9..14]),
join("-", @entries[0..1], $mapped_font, @entries[3..6], $size, $size * 10, @res, @entries[11..14])
);
}
}
# Boast
print "Created ", scalar(@aliases), " aliases\n";
# Backup the existing file
if(-e $outfile) {
my $bakfile = "$outfile.bak";
my $errormsg = "Cannot backup $outfile to $bakfile:";
die "$errormsg file exists\n" if -e $bakfile;
rename $outfile, $bakfile or die "$errormsg $!\n"
}
# Ok, write the file
open(THEFILE, ">", $outfile) or die "Cannot open $outfile for writing: $!\n";
print THEFILE map "$_\n", @aliases;
close THEFILE;
print "Wrote ", scalar(@aliases), " aliases to $outfile\n";
|