📄 x-fonts.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Using Fonts in X11</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="The X Window System" href="x11.html" /><link rel="PREVIOUS" title="X11 Configuration" href="x-config.html" /><link rel="NEXT" title="The X Display Manager" href="x-xdm.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="x-config.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 5 The X Window System</td><td width="10%" align="right" valign="bottom"><a href="x-xdm.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="X-FONTS" name="X-FONTS">5.5 Using Fonts in X11</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Murray Stokely.</i> <div class="SECT2"><h2 class="SECT2"><a id="TYPE1" name="TYPE1">5.5.1 Type1 Fonts</a></h2><p>The default fonts that ship with X11 are less than ideal for typical desktoppublishing applications. Large presentation fonts show up jagged and unprofessionallooking, and small fonts in <b class="APPLICATION"><spanclass="TRADEMARK">Netscape</span>®</b> are almost completely unintelligible. However,there are several free, high quality Type1 (<spanclass="TRADEMARK">PostScript</span>®) fonts available which can be readily used withX11. For instance, the URW font collection (<ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/x11-fonts/urwfonts/pkg-descr"><ttclass="FILENAME">x11-fonts/urwfonts</tt></a>) includes high quality versions of standardtype1 fonts (<span class="TRADEMARK">Times Roman</span>®, <spanclass="TRADEMARK">Helvetica</span>®, <span class="TRADEMARK">Palatino</span>® andothers). The Freefonts collection (<ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/x11-fonts/freefonts/pkg-descr"><ttclass="FILENAME">x11-fonts/freefonts</tt></a>) includes many more fonts, but most of themare intended for use in graphics software such as the <b class="APPLICATION">Gimp</b>,and are not complete enough to serve as screen fonts. In addition, X11 can be configuredto use <span class="TRADEMARK">TrueType</span>® fonts with a minimum of effort. Formore details on this, see the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=X&sektion=7&manpath=XFree86+4.4.0"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">X</span>(7)</span></a> manual page orthe <a href="x-fonts.html#TRUETYPE">section on <span class="TRADEMARK">TrueType</span>fonts</a>.</p><p>To install the above Type1 font collections from the ports collection, run thefollowing commands:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">cd /usr/ports/x11-fonts/urwfonts</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make install clean</kbd></pre><p>And likewise with the freefont or other collections. To have the X server detect thesefonts, add an appropriate line to the X server configuration file in <ttclass="FILENAME">/etc/X11/</tt> (<tt class="FILENAME">xorg.conf</tt> for <bclass="APPLICATION">Xorg</b> and <tt class="FILENAME">XF86Config</tt> for <bclass="APPLICATION"><span class="TRADEMARK">XFree86</span>™</b>), which reads:</p><pre class="PROGRAMLISTING">FontPath "/usr/X11R6/lib/X11/fonts/URW/"</pre><p>Alternatively, at the command line in the X session run:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">xset fp+ /usr/X11R6/lib/X11/fonts/URW</kbd><samp class="PROMPT">%</samp> <kbd class="USERINPUT">xset fp rehash</kbd></pre><p>This will work but will be lost when the X session is closed, unless it is added tothe startup file (<tt class="FILENAME">~/.xinitrc</tt> for a normal <ttclass="COMMAND">startx</tt> session, or <tt class="FILENAME">~/.xsession</tt> whenlogging in through a graphical login manager like <b class="APPLICATION">XDM</b>). Athird way is to use the new <tt class="FILENAME">/usr/X11R6/etc/fonts/local.conf</tt>file: see the section on <a href="x-fonts.html#ANTIALIAS">anti-aliasing</a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="TRUETYPE" name="TRUETYPE">5.5.2 <spanclass="TRADEMARK">TrueType</span>® Fonts</a></h2><p>Both <b class="APPLICATION"><span class="TRADEMARK">XFree86</span> 4.X</b> and <bclass="APPLICATION">Xorg</b> have built in support for rendering <spanclass="TRADEMARK">TrueType</span> fonts. There are two different modules that can enablethis functionality. The freetype module is used in this example because it is moreconsistent with the other font rendering back-ends. To enable the freetype module justadd the following line to the <var class="LITERAL">"Module"</var> section of the <ttclass="FILENAME">/etc/X11/xorg.conf</tt> or <tt class="FILENAME">/etc/X11/XF86Config</tt>file.</p><pre class="PROGRAMLISTING">Load "freetype"</pre><p>For <b class="APPLICATION"><span class="TRADEMARK">XFree86</span> 3.3.X</b>, aseparate <span class="TRADEMARK">TrueType</span> font server is needed. <bclass="APPLICATION">Xfstt</b> is commonly used for this purpose. To install <bclass="APPLICATION">Xfstt</b>, simply install the port <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/x11-servers/Xfstt/pkg-descr"><ttclass="FILENAME">x11-servers/Xfstt</tt></a>.</p><p>Now make a directory for the <span class="TRADEMARK">TrueType</span> fonts (forexample, <tt class="FILENAME">/usr/X11R6/lib/X11/fonts/TrueType</tt>) and copy all of the<span class="TRADEMARK">TrueType</span> fonts into this directory. Keep in mind that<span class="TRADEMARK">TrueType</span> fonts cannot be directly taken from a <spanclass="TRADEMARK">Macintosh</span>®; they must be in <spanclass="TRADEMARK">UNIX</span>®/<span class="TRADEMARK">MS-DOS</span>®/<spanclass="TRADEMARK">Windows</span>® format for use by X11. Once the files have beencopied into this directory, use <b class="APPLICATION">ttmkfdir</b> to create a <ttclass="FILENAME">fonts.dir</tt> file, so that the X font renderer knows that these newfiles have been installed. <tt class="COMMAND">ttmkfdir</tt> is available from theFreeBSD Ports Collection as <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/x11-fonts/ttmkfdir/pkg-descr"><ttclass="FILENAME">x11-fonts/ttmkfdir</tt></a>.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">cd /usr/X11R6/lib/X11/fonts/TrueType</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ttmkfdir > fonts.dir</kbd></pre><p>Now add the <span class="TRADEMARK">TrueType</span> directory to the font path. Thisis just the same as described above for <a href="x-fonts.html#TYPE1">Type1</a> fonts,that is, use</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">xset fp+ /usr/X11R6/lib/X11/fonts/TrueType</kbd><samp class="PROMPT">%</samp> <kbd class="USERINPUT">xset fp rehash</kbd></pre><p>or add a <var class="LITERAL">FontPath</var> line to the <ttclass="FILENAME">xorg.conf</tt> (or <tt class="FILENAME">XF86Config</tt>) file.</p><p>That's it. Now <b class="APPLICATION"><span class="TRADEMARK">Netscape</span></b>, <bclass="APPLICATION">Gimp</b>, <b class="APPLICATION"><spanclass="TRADEMARK">StarOffice</span>™</b>, and all of the other X applicationsshould now recognize the installed <span class="TRADEMARK">TrueType</span> fonts.Extremely small fonts (as with text in a high resolution display on a web page) andextremely large fonts (within <b class="APPLICATION"><spanclass="TRADEMARK">StarOffice</span></b>) will look much better now.</p></div><div class="SECT2"><h2 class="SECT2"><a id="ANTIALIAS" name="ANTIALIAS">5.5.3 Anti-Aliased Fonts</a></h2><i class="AUTHORGROUP"><span class="CONTRIB">Updated by</span> Joe Marcus Clarke.</i> <p>Anti-aliasing has been available in X11 since <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span></b> 4.0.2. However, font configuration was cumbersomebefore the introduction of <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span></b> 4.3.0. Beginning with <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span></b> 4.3.0, all fonts in X11 that are found in <ttclass="FILENAME">/usr/X11R6/lib/X11/fonts/</tt> and <tt class="FILENAME">~/.fonts/</tt>are automatically made available for anti-aliasing to Xft-aware applications. Not allapplications are Xft-aware, but many have received Xft support. Examples of Xft-awareapplications include Qt 2.3 and higher (the toolkit for the <bclass="APPLICATION">KDE</b> desktop), GTK+ 2.0 and higher (the toolkit for the <bclass="APPLICATION">GNOME</b> desktop), and <b class="APPLICATION">Mozilla</b> 1.2 andhigher.</p><p>In order to control which fonts are anti-aliased, or to configure anti-aliasingproperties, create (or edit, if it already exists) the file <ttclass="FILENAME">/usr/X11R6/etc/fonts/local.conf</tt>. Several advanced features of theXft font system can be tuned using this file; this section describes only some simplepossibilities. For more details, please see <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=fonts-conf&sektion=5&manpath=XFree86+4.4.0"><span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">fonts-conf</span>(5)</span></a>.</p><p>This file must be in XML format. Pay careful attention to case, and make sure all tags
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -