The default fonts that ship with
X11 are less than ideal for typical
desktop publishing applications. Large presentation fonts show up
jagged and unprofessional looking, and small fonts in
Netscape® are almost completely unintelligible.
However, there are several free, high quality Type1 (PostScript®) fonts
available which can be readily used
with X11. For instance, the URW font collection
(x11-fonts/urwfonts
) includes
high quality versions of standard type1 fonts (Times Roman®,
Helvetica®, Palatino® and others). The Freefonts collection
(x11-fonts/freefonts
) includes
many more fonts, but most of them are intended for use in
graphics software such as the Gimp, and are not
complete enough to serve as screen fonts. In addition,
X11 can be configured to use
TrueType® fonts with a minimum of effort. For more details on
this, see the X(7) manual page or the
section on TrueType® fonts.
To install the above Type1 font collections from the ports collection, run the following commands:
#
cd /usr/ports/x11-fonts/urwfonts
#
make install clean
And likewise with the freefont or other collections. To have the X
server detect these fonts, add an appropriate line to the
X server configuration file (/etc/X11/xorg.conf
),
which reads:
Alternatively, at the command line in the X session run:
%
xset fp+ /usr/local/lib/X11/fonts/URW
%
xset fp rehash
This will work but will be lost when the X session is closed,
unless it is added to the startup file (~/.xinitrc
for a normal startx
session,
or ~/.xsession
when logging in through a
graphical login manager like XDM).
A third way is to use the new
/usr/local/etc/fonts/local.conf
file: see the
section on anti-aliasing.
Xorg has built in support
for rendering TrueType® fonts. There are two different modules
that can enable this functionality. The freetype module is used
in this example because it is more consistent with the other font
rendering back-ends. To enable the freetype module just add the
following line to the "Module"
section of the
/etc/X11/xorg.conf
file.
Now make a directory for the TrueType® fonts (for example,
/usr/local/lib/X11/fonts/TrueType
)
and copy all of the TrueType® fonts into this directory. Keep in
mind that TrueType® fonts cannot be directly taken from a
Macintosh®; they must be in UNIX®/MS-DOS®/Windows® format for use by
X11. Once the files have been
copied into this directory, use
ttmkfdir to create a
fonts.dir
file, so that the X font renderer
knows that these new files have been installed.
ttmkfdir
is available from the FreeBSD
Ports Collection as
x11-fonts/ttmkfdir
.
#
cd /usr/local/lib/X11/fonts/TrueType
#
ttmkfdir -o fonts.dir
Now add the TrueType® directory to the font path. This is just the same as described above for Type1 fonts, that is, use
%
xset fp+ /usr/local/lib/X11/fonts/TrueType
%
xset fp rehash
or add a FontPath
line to the
xorg.conf
file.
That's it. Now Netscape®, Gimp, StarOffice™, and all of the other X applications should now recognize the installed TrueType® fonts. Extremely small fonts (as with text in a high resolution display on a web page) and extremely large fonts (within StarOffice™) will look much better now.
Anti-aliasing has been available in X11 since
XFree86™ 4.0.2. However, font
configuration was cumbersome before the introduction of
XFree86™ 4.3.0.
Beginning with
XFree86™ 4.3.0, all fonts in X11
that are found
in /usr/local/lib/X11/fonts/
and
~/.fonts/
are automatically
made available for anti-aliasing to Xft-aware applications. Not
all applications are Xft-aware, but many have received Xft support.
Examples of Xft-aware applications include Qt 2.3 and higher (the
toolkit for the KDE desktop),
GTK+ 2.0 and higher (the toolkit for the
GNOME desktop), and
Mozilla 1.2 and higher.
In order to control which fonts are anti-aliased, or to
configure anti-aliasing properties, create (or edit, if it
already exists) the file
/usr/local/etc/fonts/local.conf
. Several
advanced features of the Xft font system can be tuned using
this file; this section describes only some simple
possibilities. For more details, please see
fonts-conf(5).
This file must be in XML format. Pay careful attention to
case, and make sure all tags are properly closed. The file
begins with the usual XML header followed by a DOCTYPE
definition, and then the <fontconfig>
tag:
As previously stated, all fonts in
/usr/local/lib/X11/fonts/
as well as
~/.fonts/
are already made available to
Xft-aware applications. If you wish to add another directory
outside of these two directory trees, add a line similar to the
following to
/usr/local/etc/fonts/local.conf
:
After adding new fonts, and especially new font directories, you should run the following command to rebuild the font caches:
#
fc-cache -f
Anti-aliasing makes borders slightly fuzzy, which makes very small text more readable and removes “staircases” from large text, but can cause eyestrain if applied to normal text. To exclude font sizes smaller than 14 point from anti-aliasing, include these lines:
Spacing for some monospaced fonts may also be inappropriate with anti-aliasing. This seems to be an issue with KDE, in particular. One possible fix for this is to force the spacing for such fonts to be 100. Add the following lines:
(this aliases the other common names for fixed fonts as
"mono"
), and then add:
Certain fonts, such as Helvetica, may have a problem when
anti-aliased. Usually this manifests itself as a font that
seems cut in half vertically. At worst, it may cause
applications such as Mozilla to
crash. To avoid this, consider adding the following to
local.conf
:
Once you have finished editing
local.conf
make sure you end the file
with the </fontconfig>
tag. Not doing this will cause
your changes to be ignored.
The default font set that comes with
X11 is not very
desirable when it comes to anti-aliasing. A much better
set of default fonts can be found in the
x11-fonts/bitstream-vera
port. This port will install a
/usr/local/etc/fonts/local.conf
file
if one does not exist already. If the file does exist,
the port will create a /usr/local/etc/fonts/local.conf-vera
file. Merge the contents of this file into
/usr/local/etc/fonts/local.conf
, and the
Bitstream fonts will automatically replace the default
X11 Serif, Sans Serif, and Monospaced
fonts.
Finally, users can add their own settings via their personal
.fonts.conf
files. To do this, each user should
simply create a ~/.fonts.conf
. This file must
also be in XML format.
One last point: with an LCD screen, sub-pixel sampling may be
desired. This basically treats the (horizontally separated)
red, green and blue components separately to improve the horizontal
resolution; the results can be dramatic. To enable this, add the
line somewhere in the local.conf
file:
Depending on the sort of display,
rgb
may need to be changed to bgr
,
vrgb
or vbgr
: experiment and
see which works best.
Anti-aliasing should be enabled the next time the X
server is started. However, programs must know how to take
advantage of it. At present, the Qt toolkit does,
so the entire KDE environment can
use anti-aliased fonts.
GTK+ and
GNOME can also be made to use
anti-aliasing via the “Font” capplet (see 節 5.7.1.3, “Anti-aliased Fonts with GNOME” for details). By default,
Mozilla 1.2 and greater will
automatically use anti-aliasing. To disable this, rebuild
Mozilla with the
-DWITHOUT_XFT
flag.
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。