On 3/24/06, Dan Nicholson <[EMAIL PROTECTED]> wrote:
> It's time to finally finish this off.

OK, here's the first cut.  All comments are welcome, from the
technical type to the typo/formatting type.  There are surely errors
in here.  CC'ing Alexander to make sure he sees this.

There's a rendered copy in my home directory on anduin:

http://anduin.linuxfromscratch.org/~dnicholson/blfs/

Affected pages are:
x/installing.html
x/xorg7.html
x/xfree86.html
x/xfree86-setup.html (a lot of changes)
general/fontconfig.html

I'm attaching the XML diff.

Two things I didn't address:
1. GTK+-1 fixes.  I'll put these in if wanted, but it's getting harder
and harder to care about GTK+-1.

2. Using Xft fonts with xterm.  I'm thinking about putting some info
on the xterm page about this.

Thoughts?  Comments?

--
Dan
Index: trunk/BOOK/x/installing/x-setup.xml
===================================================================
--- trunk/BOOK/x/installing/x-setup.xml (revision 5745)
+++ trunk/BOOK/x/installing/x-setup.xml (working copy)
@@ -59,44 +59,16 @@
 <!-- ================================================== -->
 
   <sect2 id='fonts'>
-    <title>Adding TrueType Fonts to X</title>
+    <title>Setting up Fonts</title>
 
-    <para><application>TrueType</application> font support is built into
-    <application>X</application>. The following items need to be
-    completed to make the fonts available. Each item is described in
-    detail after the list.</para>
+    <para>There are two font systems in the X Window System.  The first is the
+    core X font protocol, and the second is Xft.  Toolkits that use the core
+    X font protocol include Xt, Xaw, Motif clones and GTK+-1.2.  Toolkits that
+    use Xft include GTK+-2 and Qt and use Fontconfig for control.  Both font
+    systems should be configured for proper font coverage in the X Window
+    System.</para>
 
     <indexterm zone="x-setup fonts">
-      <primary sortas="g-truetype">TrueType</primary>
-    </indexterm>
-
-    <itemizedlist>
-      <listitem>
-        <para>Establish a directory for the fonts and move any
-        <application>TrueType</application> fonts you want into that
-        directory. Ensure that any fonts you install are world readable.
-        Incorrect permissions on fonts have been known to cause problems
-        with some <application>X</application> applications.</para>
-      </listitem>
-      <listitem>
-        <para>Download the fonts.</para>
-      </listitem>
-      <listitem>
-        <para>Create the <filename>fonts.scale</filename> and
-        <filename>fonts.dir</filename> files in the
-        <application>TrueType</application> font directory.</para>
-      </listitem>
-      <listitem>
-        <para>Ensure the <application>TrueType</application> module is
-        loaded in the <filename>XF86Config</filename> or
-        <filename>xorg.conf</filename>.</para>
-      </listitem>
-      <listitem>
-        <para>Update the font cache files</para>
-      </listitem>
-    </itemizedlist>
-
-    <indexterm zone="x-setup fonts">
       <primary sortas="e-etc-X11-xorg-conf">/etc/X11/xorg.conf</primary>
     </indexterm>
 
@@ -105,134 +77,223 @@
     </indexterm>
 
     <sect3>
-      <title>Establish a TrueType Font Directory</title>
+      <title>Core X Font Protocol</title>
 
-      <para>The build of <application>X</application> as given above
-      automatically creates a <application>TrueType</application> font
-      directory: <filename
-      class="directory">/usr/share/fonts/TTF</filename>. This
-      directory already has some <application>TrueType</application>
-      fonts and is set up correctly. If this directory is satisfactory,
-      copy any other <application>TrueType</application> fonts you want
-      into that directory. If not, create a new directory, preferably
-      in the <filename
-      class="directory">/usr/share/fonts/</filename> directory
-      and put your <application>TrueType</application> fonts there.</para>
+      <indexterm zone="x-setup fonts">
+        <primary sortas="g-core-x-font">Core X Font Protocol</primary>
+      </indexterm>
 
-    </sect3>
+      <para>The core X font protocol finds fonts from the server configuration
+      file (xorg.conf or XF86Config) in addition to an internal hard-coded
+      path.  Assuming the prefix for your X installation is
+      <filename class="directory">/usr/X11R6</filename>, the core fonts will
+      reside in subdirectories of <filename
+      class="directory">/usr/X11R6/lib/X11/fonts</filename>.  For each
+      directory in the path, the server reads three files:</para>
 
-    <sect3>
-      <title>Download the Fonts</title>
+      <itemizedlist>
+        <listitem>
+          <para><filename>fonts.dir</filename> - maps font files to font
+          names&semi; updated with <command>mkfontdir</command></para>
+        </listitem>
+        <listitem>
+          <para><filename>fonts.alias</filename> - defines aliases (such as
+          "9x18") for existing fonts</para>
+        </listitem>
+        <listitem>
+          <para><filename>fonts.scale</filename> - lists scalable fonts&semi;
+          updated with <command>mkfontscale</command></para>
+        </listitem>
+      </itemizedlist>
 
-      <para>There are two known high quality free font resources:
-      <ulink url="ftp://ftp.gnu.org/savannah/files/freefont/"/> and
-      <ulink url="http://corefonts.sourceforge.net/"/>. Copy the fonts
-      (files with the <filename>.ttf</filename> suffix) to the directory
-      you've just created.</para>
+      <para>The core X fonts protocol uses names such as
+      
<systemitem>-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1</systemitem>.
 
+      These fonts are rendered by the X server without antialiasing.  The
+      server itself uses the "cursor" font for painting the mouse cursor,
+      and the protocol specification requires the font "fixed" to be
+      available.</para>
 
-    </sect3>
+      <para>The character set used is part of the font name, e.g. 
"-iso8859-1". 
+      It is important that applications which support a non-English interface
+      specify the character set correctly so that the proper glyphs are used. 
+      This can be controlled through the X resources, which will be described
+      later.</para>
 
-    <sect3 id="fonts-scale-dir">
-      <title>Create 'fonts.scale' and 'fonts.dir'</title>
+      <para>In some cases, applications rely upon the fonts named "fixed" or
+      something like "9x18".  In these cases, it is important that the
+      <filename>fonts.alias</filename> file specifies the correct character
+      set.  Users of ISO-8859-<replaceable>X</replaceable> encodings where
+      <replaceable>X</replaceable> != 1 should modify the
+      <filename>/usr/lib/X11/fonts/misc/fonts.alias</filename> file by
+      replacing the "iso8859-1" string with the proper encoding name.  This is
+      accomplished by running the following command as the <systemitem
+      class="username">root</systemitem> user, substituting the proper value
+      for <replaceable>[X]</replaceable>:</para>
 
-      <indexterm zone="x-setup fonts-scale-dir">
-        <primary sortas="g-fonts.scale">fonts.scale</primary>
-      </indexterm>
+<screen role="root"><userinput>sed -i 's,iso8859-1\( 
\|$\),iso8859-<replaceable>[X]</replaceable>\1,g' \
+    /usr/share/fonts/{75dpi,100dpi,misc}/fonts.alias</userinput></screen>
 
-      <indexterm zone="x-setup fonts-scale-dir">
-        <primary sortas="g-fonts.dir">fonts.dir</primary>
-      </indexterm>
+      <para>Users of Cyrillic fonts have properly defined aliases in
+      <filename>/usr/lib/X11/fonts/cyrillic/fonts.alias</filename>.  However,
+      this file will not be used unless the <filename
+      class="directory">/usr/lib/X11/fonts/cyrillic</filename> directory is
+      first in the font search path.  Otherwise, the
+      <filename>/usr/lib/X11/fonts/misc/fonts.alias</filename> file will be
+      used.</para>
 
-      <para>Now change to the directory where you have your
-      <application>TrueType</application> fonts and run:</para>
+    </sect3>
 
-<screen role="root"><userinput>mkfontscale &amp;&amp;
-mkfontdir</userinput></screen>
+    <sect3>
+      <title>Xft Font Protocol</title>
 
-      <indexterm zone="x-setup fonts-scale-dir">
-        <primary sortas="b-mkfontscale">mkfontscale</primary>
+      <indexterm zone="x-setup fonts">
+        <primary sortas="g-truetype">TrueType Fonts</primary>
       </indexterm>
 
-      <indexterm zone="x-setup fonts-scale-dir">
-        <primary sortas="b-mkfontdir">mkfontdir</primary>
-      </indexterm>
+      <para>Xft provides antialiased font rendering through
+      <application>Freetype</application>, and fonts are controlled from the
+      client side using <application>Fontconfig</application>.  The default
+      search path is <filename class="directory">/usr/share/fonts</filename>
+      and <filename class="directory">~/.fonts</filename>. 
+      When installing <application>X</application>, symlinks were created from
+      the <filename class="directory">OTF</filename> and <filename
+      class="directory">TTF</filename> <application>X</application> font
+      directories to <filename
+      class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename>.  This was
+      because we only want <application>Fontconfig</application> to use
+      scalable fonts and not others such as bitmapped or Type1 fonts.</para>
 
-    </sect3>
+      <para>Ensure that the Xft system will be loaded in 'XF86Config' or
+      'xorg.conf'.  The "Module" section should look like:</para>
 
-    <sect3>
-      <title>Ensure TrueType is Loaded in 'XF86Config' or 'xorg.conf'</title>
-
-      <para>The "Module" section should look like:</para>
-
 <screen><literal>Section "Module"
     ...
     Load  "freetype"
     ...
 EndSection</literal></screen>
 
-    </sect3>
+      <para><application>Fontconfig</application>searches directories in its
+      path recursively and maintains a cache of the font characteristics in
+      <filename>fonts.cache-1</filename> files in each directory.  This cache
+      can be regenerated using the <command>fc-cache</command> command at any
+      time.</para>
 
-    <sect3>
-      <title>Update the Font Cache Files</title>
+      <para><application>Fontconfig</application> uses names such as
+      "Monospace 12" to define fonts.  Applications generally use generic font
+      names such as "Monospace", "Sans" and "Serif". 
+      <application>Fontconfig</application> resolves these names to a font that
+      has all characters that cover the orthography of the language indicated
+      by the locale settings.  Knowledge of these font names is included in
+      <filename>/etc/fonts/fonts.conf</filename>.</para>
 
-      <para>If you decided not to install X windows fonts into
-      <filename class='directory'>/usr/share/fonts</filename>, then
-      ensure you have the following directory entries in
-      <filename>/etc/fonts/local.conf</filename>, inside the &lt;fontconfig&gt;
-      tags. Create <filename>/etc/fonts/local.conf</filename> using the
-      following commands:</para>
+      <para>Standard scalable fonts that come with <application>X</application>
+      provide very poort Unicode coverage.  You may notice in applications that
+      use <application>Xft</application> that some characters appear as a box
+      with four binary digits inside.  In this case, a font set with the
+      available glyphs has not been found.  Other times, applications that
+      don't use other font families by default and don't accept subsitutions
+      from <application>Fontconfig</application> will display blank lines when
+      the default font doesn't cover the orhography of the user's language. 
+      This happens, e.g., with <application>Fluxbox</application> in the
+      ru_RU.KOI8-R locale.</para>
 
-      <indexterm zone="x-setup fonts">
-        <primary 
sortas="e-etc-fonts-local.conf">/etc/fonts/local.conf</primary>
-      </indexterm>
+      <para>In order to provide greater Unicode coverage, it is recommended
+      that you install these fonts:</para>
 
-<screen role="root"><userinput>cat &gt; /etc/fonts/local.conf &lt;&lt; "EOF"
-<literal>&lt;?xml version="1.0"?&gt;
-&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
-&lt;!-- /etc/fonts/local.conf file for local customizations --&gt;
+      <itemizedlist>
+        <listitem>
+          <para><ulink url="http://dejavu.sourceforge.net/";>DejaVu 
fonts</ulink>
+          - These fonts are replacements for the Bitstream Vera fonts and
+          provide Latin-based scripts with accents and Cyrillic glyphs.
+          <application>Fontconfig</application> does not know about the DejaVu
+          fonts by default, so <filename>/etc/fonts/fonts.conf</filename> will
+          have to be edited for it to be recognized by the generic names such
+          as "Sans".  This will be described below.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          
url="http://download.savannah.nongnu.org/releases/freefont/";>FreeFont</ulink>
+          - This set of fonts covers nearly every non-CJK character, but is not
+          visually pleasing.  <application>Fontconfig</application> will use it
+          as a last resort to substitute generic font family names.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          url="http://corefonts.sourceforge.net/";>Microsoft Core fonts</ulink>
+          - These fonts provide slightly worse Unicode coverage than FreeFont,
+          but are better hinted.  Be sure to read the license before using
+          them.  <application>Fontconfig</application> knows about them by
+          default.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          url="http://cle.linux.org.tw/fonts/FireFly";>Firefly New Sung 
font</ulink>
+          - This font provides Chinese coverage.  However,
+          <application>Fontconfig</application>does not know about this font
+          by default.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          url="http://cle.linux.org.tw/fonts/Arphic";>Arphic fonts</ulink> -
+          A similar set of Chinese fonts to the Firefly New Sung font.
+          <application>Fontconfig</application> knows about these fonts by
+          default and will substitute them for generic family names.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          url="http://osdn.dl.sourceforge.jp/efont/4845/";>Kochi fonts</ulink> -
+          These provide Japanese characters, and
+          <application>Fontconfig</application> knows about these fonts by
+          default.</para>
+        </listitem>
+        <listitem>
+          <para><ulink
+          
url="http://kldp.net/frs/download.php/1429/baekmuk-ttf-2.2.tar.gz";>Baekmuk 
fonts</ulink>
+          - These fonts provide Korean coverage, and
+          <application>Fontconfig</application> knows about these fonts by
+          default.</para>
+        </listitem>
+      </itemizedlist>
 
-&lt;fontconfig&gt;
-&lt;dir&gt;/usr/X11R6/lib/X11/fonts/TTF&lt;/dir&gt;
-&lt;dir&gt;/usr/X11R6/lib/X11/fonts/Type1&lt;/dir&gt;
-&lt;/fontconfig&gt;</literal>
+      <para>The list above will not provide complete Unicode coverage.  For
+      more information, please visit the <ulink
+      url="http://unifont.org/fontguide/";>Unicode Font Guide</ulink>.</para>
 
-EOF</userinput></screen>
+      <para>As an example, consider the installation of the DejaVu fonts.  From
+      the unpacked source directory, run the following commands as the
+      <systemitem class="username">root</systemitem> user:</para>
 
+<screen role="root"><userinput>install -v -d -m755 /usr/share/fonts/dejavu 
&amp;&amp;
+install -v -m644 *.ttf /usr/share/fonts/dejavu &amp;&amp;
+fc-cache -v /usr/share/fonts/dejavu</userinput></screen>
 
+      <para>Earlier it was mentioned that 
<filename>/etc/fonts/fonts.conf</filename>
+      could be modified to use DejaVu using the default family names.  Since
+      DejaVu is a replacement for Bitstream Vera fonts, we can substitute it
+      for that family.  Visually inspect the <filename>fonts.conf</filename> to
+      see how fonts are grouped together under the generic family names and a
+      preference list is created.  To replace Bitstream Vera with DejaVu, as 
the
+      <systemitem class="username">root</systemitem> user:</para>
+
+<screen role="root"><userinput>sed -i 's/&lt;family&gt;Bitstream 
Vera/&lt;family&gt;DejaVu/' /etc/fonts/fonts.conf</userinput></screen>
+
+      <para>More information about configuring
+      <application>Fontconfig</application> can be found in the user's manual
+      at <ulink url="http://fontconfig.org/fontconfig-user.html"/>.  There are
+      additional configuration files shipped with
+      <application>Fontconfig</application> in <filename
+      class="directory">/etc/fonts/conf.d</filename> that will be enabled
+      if their names begin with 2 numbers, e.g.,
+      <filename>/etc/fonts/conf.d/10-autohint.conf</filename>.</para>
+
+    </sect3>
+
 <!--
 <screen><userinput><command>sed -i -e '/^&lt;\/fontconfig&gt;/i\
 &lt;dir&gt;/usr/X11R6/lib/X11/fonts/TTF&lt;/dir&gt;\
 &lt;dir&gt;/usr/X11R6/lib/X11/fonts/Type1&lt;/dir&gt;' 
/etc/fonts/local.conf</command></userinput></screen>
  -->
 
-      <para>The <command>fc-cache</command> program will automatically
-      search the above directories and all subdirectories for needed
-      fonts.</para>
-
-      <para>Finally, to update all the font cache files, run</para>
-
-<screen role="root"><userinput>fc-cache</userinput></screen>
-
-      <indexterm zone="x-setup fonts">
-        <primary sortas="b-fc-cache">fc-cache</primary>
-      </indexterm>
-
-      <para><application>X</application> will now be able to use
-      <application>TrueType</application> fonts when it is restarted.
-      You can check to see if the new fonts are available with the
-      <command>xlsfonts</command>  or <command>xfontsel</command>
-      program.</para>
-
-      <note>
-        <para>You should rerun <command>mkfontscale</command> and
-        <command>mkfontdir</command> any time you add or delete
-        <application>TrueType</application> fonts.
-        You should also rerun <command>fc-cache</command> each time
-        you add or remove any fonts.</para>
-      </note>
-
-    </sect3>
-
   </sect2>
 
 <!-- ================================================== -->
@@ -263,31 +324,6 @@
 
 <!-- ================================================== -->
 
-  <sect2>
-    <title>Setting up Fonts</title>
-
-    <para>Users using character sets other than ISO-8859-1 have to make
-    a few adjustments to their font settings in order to make sure that
-    fonts with the correct encoding are used for "fixed", "variable",
-    "10x20" and similar aliases. For ISO-8859-<replaceable>[X]</replaceable>
-    based locales, use the following command:</para>
-
-<screen role="root"><userinput>sed -i 's,iso8859-1\( 
\|$\),iso8859-<replaceable>[X]</replaceable>\1,g' \
-    /usr/share/fonts/{75dpi,100dpi,misc}/fonts.alias</userinput></screen>
-
-    <para>To use cyrillic fonts with <application>GTK1</application>,
-    <application>Tk</application>, <application>Xaw</application> and
-    <application>Motif</application>, put the following line into the top of 
the
-    "Files" section in <filename>XF86Config</filename> or
-    <filename>xorg.conf</filename>. This directory already contains the needed 
bitmap
-    fonts and their aliases:</para>
-
-<screen><literal>FontPath   "/usr/share/fonts/cyrillic/"</literal></screen>
-
-  </sect2>
-
-<!-- ================================================== -->
-
   <sect2 id='xdm'>
     <title>Setting up XDM</title>
 
Index: trunk/BOOK/x/installing/xorg7.xml
===================================================================
--- trunk/BOOK/x/installing/xorg7.xml   (revision 5745)
+++ trunk/BOOK/x/installing/xorg7.xml   (working copy)
@@ -461,6 +461,17 @@
 
 <screen><userinput role="root">make install</userinput></screen>
 
+      <para>When all of the fonts have been installed, the system must be
+      configured so that <application>Fontconfig</application> can find the
+      TrueType fonts since they are outside of the default search path of
+      <filename class="directory">/usr/share/fonts</filename>.  Make symlinks
+      to the <application>Xorg</application> TrueType font directories by
+      running the following commands as the
+      <systemitem class="username">root</systemitem> user:</para>
+
+<screen><userinput role="root">ln -svn $XORG_PREFIX/lib/X11/fonts/OTF 
/usr/share/fonts/X11-OTF &amp;&amp;
+ln -svn $XORG_PREFIX/lib/X11/fonts/TTF 
/usr/share/fonts/X11/TTF</userinput></screen>
+
       <note>
         <para>If you haven't done so, and intend to install
         <application>luit</application>, do so now.</para>
Index: trunk/BOOK/x/installing/xfree86.xml
===================================================================
--- trunk/BOOK/x/installing/xfree86.xml (revision 5745)
+++ trunk/BOOK/x/installing/xfree86.xml (working copy)
@@ -382,6 +382,18 @@
 ln -v -sf ../X11R6/lib/X11 /usr/lib/X11 &amp;&amp;
 ln -v -sf ../X11R6/include/X11 /usr/include/X11</userinput></screen>
 
+      <para>The <application>XFree86</application> fonts have been installed
+      outside of <application>Fontconfig</application>'s default search path
+      of <filename class="directory">/usr/share/fonts</filename>.  In order
+      for <application>Fontconfig</application> to find the installed TrueType
+      fonts, you should make symlinks to their directories.  Assuming you've
+      installed <application>XFree86</application> in the default prefix, run 
the
+      following commands as the <systemitem class="username">root</systemitem>
+      user:</para>
+
+<screen role="root"><userinput>ln -svn /usr/X11R6/lib/X11/fonts/OTF 
/usr/share/fonts/X11-OTF &amp;&amp;
+ln -svn /usr/X11R6/lib/X11/fonts/TTF 
/usr/share/fonts/X11-TTF</userinput></screen>
+
       <para><application>XFree86</application> installs the
       <application>XRender</application> and
       <application>XExtensions</application> extension libraries but does not
Index: trunk/BOOK/x/installing/xorg.xml
===================================================================
--- trunk/BOOK/x/installing/xorg.xml    (revision 5745)
+++ trunk/BOOK/x/installing/xorg.xml    (working copy)
@@ -373,6 +373,18 @@
 ln -v -s ../X11R6/lib/X11 /usr/lib/X11 &amp;&amp;
 ln -v -s ../X11R6/include/X11 /usr/include/X11</userinput></screen>
 
+      <para>The <application>Xorg</application> fonts have been installed
+      outside of <application>Fontconfig</application>'s default search path
+      of <filename class="directory">/usr/share/fonts</filename>.  In order
+      for <application>Fontconfig</application> to find the installed TrueType
+      fonts, you should make symlinks to their directories.  Assuming you've
+      installed <application>Xorg</application> in the default prefix, run the
+      following commands as the <systemitem class="username">root</systemitem>
+      user:</para>
+
+<screen role="root"><userinput>ln -svn /usr/X11R6/lib/X11/fonts/OTF 
/usr/share/fonts/X11-OTF &amp;&amp;
+ln -svn /usr/X11R6/lib/X11/fonts/TTF 
/usr/share/fonts/X11-TTF</userinput></screen>
+
     </sect3>
 
   </sect2>
Index: trunk/BOOK/general/graphlib/fontconfig.xml
===================================================================
--- trunk/BOOK/general/graphlib/fontconfig.xml  (revision 5745)
+++ trunk/BOOK/general/graphlib/fontconfig.xml  (working copy)
@@ -90,8 +90,9 @@
     <para>Install <application>Fontconfig</application> by running the 
following
     commands:</para>
 
-<screen><userinput>./configure --prefix=/usr --sysconfdir=/etc --disable-docs \
-    --with-docdir=/usr/share/doc/fontconfig-&fontconfig-version; &amp;&amp;
+<screen><userinput>./configure --prefix=/usr --sysconfdir=/etc \
+    --disable-docs --without-add-fonts \
+    --with-docdir=/usr/share/doc/fontconfig-&fontconfig-version;&amp;&amp;
 make</userinput></screen>
 
     <para>To test the results, issue: <command>make check</command>.</para>
@@ -117,6 +118,10 @@
     the documentation (the release tarball includes pre-generated
     documentation).</para>
 
+    <para><parameter>--without-add-fonts</parameter>: This switch disables
+    the automatic search for X Window System fonts which, if found, may
+    confuse some applications.</para>
+
     
<para><parameter>--with-docdir=/usr/share/doc/fontconfig-&fontconfig-version;</parameter>:
     Though this parameter seems counter-intuitive following the preceding
     parameter to the <command>configure</command> command, it is used so that
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to