Changeset 43d8a509


Ignore:
Timestamp:
03/28/2006 02:59:36 PM (18 years ago)
Author:
Dan Nichilson <dnicholson@…>
Branches:
10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 6.2, 6.2.0, 6.2.0-rc1, 6.2.0-rc2, 6.3, 6.3-rc1, 6.3-rc2, 6.3-rc3, 7.10, 7.4, 7.5, 7.6, 7.6-blfs, 7.6-systemd, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, gnome, kde5-13430, kde5-14269, kde5-14686, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, krejzi/svn, lazarus, lxqt, nosym, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, systemd-11177, systemd-13485, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
Children:
e4e85b2
Parents:
18bcaf6
Message:

Reworking of font section in X Window System Components

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@5765 af4574ff-66df-0310-9fd7-8a98e5e911e0

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • introduction/welcome/changelog.xml

    r18bcaf6 r43d8a509  
    4646      <itemizedlist>
    4747        <listitem>
     48          <para>[dnicholson] - Reworked the fonts section of X Window System
     49          Components.  Added detailed description of both font services and
     50          more links to available fonts.</para>
     51        </listitem>
     52        <listitem>
    4853          <para>[dnicholson] - Added commands to make only TrueType fonts
    4954          available to Fontconfig in Xorg-6.9.0, Xorg-7.0.0 and XFree86-4.5.0.
  • x/installing/x-setup.xml

    r18bcaf6 r43d8a509  
    6060
    6161  <sect2 id='fonts'>
    62     <title>Adding TrueType Fonts to X</title>
    63 
    64     <para><application>TrueType</application> font support is built into
    65     <application>X</application>. The following items need to be
    66     completed to make the fonts available. Each item is described in
    67     detail after the list.</para>
    68 
    69     <indexterm zone="x-setup fonts">
    70       <primary sortas="g-truetype">TrueType</primary>
    71     </indexterm>
    72 
    73     <itemizedlist>
    74       <listitem>
    75         <para>Establish a directory for the fonts and move any
    76         <application>TrueType</application> fonts you want into that
    77         directory. Ensure that any fonts you install are world readable.
    78         Incorrect permissions on fonts have been known to cause problems
    79         with some <application>X</application> applications.</para>
    80       </listitem>
    81       <listitem>
    82         <para>Download the fonts.</para>
    83       </listitem>
    84       <listitem>
    85         <para>Create the <filename>fonts.scale</filename> and
    86         <filename>fonts.dir</filename> files in the
    87         <application>TrueType</application> font directory.</para>
    88       </listitem>
    89       <listitem>
    90         <para>Ensure the <application>TrueType</application> module is
    91         loaded in the <filename>XF86Config</filename> or
    92         <filename>xorg.conf</filename>.</para>
    93       </listitem>
    94       <listitem>
    95         <para>Update the font cache files</para>
    96       </listitem>
    97     </itemizedlist>
     62    <title>Setting up Fonts</title>
     63
     64    <para>There are two font systems in the
     65    <application>X Window System</application>.  The first is the
     66    core X font protocol, and the second is Xft.  Toolkits that use the core
     67    X font protocol include Xt, Xaw, Motif clones and GTK+-1.2.  Toolkits that
     68    use Xft include GTK+-2 and Qt and use <application>Fontconfig</application>
     69    for control.  Both font systems should be configured for proper font
     70    coverage in the <application>X Window System</application>.</para>
    9871
    9972    <indexterm zone="x-setup fonts">
     
    10679
    10780    <sect3>
    108       <title>Establish a TrueType Font Directory</title>
    109 
    110       <para>The build of <application>X</application> as given above
    111       automatically creates a <application>TrueType</application> font
    112       directory: <filename
    113       class="directory">/usr/share/fonts/TTF</filename>. This
    114       directory already has some <application>TrueType</application>
    115       fonts and is set up correctly. If this directory is satisfactory,
    116       copy any other <application>TrueType</application> fonts you want
    117       into that directory. If not, create a new directory, preferably
    118       in the <filename
    119       class="directory">/usr/share/fonts/</filename> directory
    120       and put your <application>TrueType</application> fonts there.</para>
    121 
    122     </sect3>
    123 
    124     <sect3>
    125       <title>Download the Fonts</title>
    126 
    127       <para>There are two known high quality free font resources:
    128       <ulink url="ftp://ftp.gnu.org/savannah/files/freefont/"/> and
    129       <ulink url="http://corefonts.sourceforge.net/"/>. Copy the fonts
    130       (files with the <filename>.ttf</filename> suffix) to the directory
    131       you've just created.</para>
    132 
    133     </sect3>
    134 
    135     <sect3 id="fonts-scale-dir">
    136       <title>Create 'fonts.scale' and 'fonts.dir'</title>
    137 
    138       <indexterm zone="x-setup fonts-scale-dir">
    139         <primary sortas="g-fonts.scale">fonts.scale</primary>
     81      <title>Core X Font Protocol</title>
     82
     83      <indexterm zone="x-setup fonts">
     84        <primary sortas="g-core-x-font">Core X Font Protocol</primary>
    14085      </indexterm>
    14186
    142       <indexterm zone="x-setup fonts-scale-dir">
    143         <primary sortas="g-fonts.dir">fonts.dir</primary>
    144       </indexterm>
    145 
    146       <para>Now change to the directory where you have your
    147       <application>TrueType</application> fonts and run:</para>
    148 
    149 <screen role="root"><userinput>mkfontscale &amp;&amp;
    150 mkfontdir</userinput></screen>
    151 
    152       <indexterm zone="x-setup fonts-scale-dir">
    153         <primary sortas="b-mkfontscale">mkfontscale</primary>
    154       </indexterm>
    155 
    156       <indexterm zone="x-setup fonts-scale-dir">
    157         <primary sortas="b-mkfontdir">mkfontdir</primary>
    158       </indexterm>
    159 
    160     </sect3>
    161 
    162     <sect3>
    163       <title>Ensure TrueType is Loaded in 'XF86Config' or 'xorg.conf'</title>
    164 
    165       <para>The "Module" section should look like:</para>
     87      <para>The core X font protocol finds fonts from the server configuration
     88      file (<filename>xorg.conf</filename> or <filename>XF86Config</filename>).
     89      If no font paths exist in the configurations file, the server will fall
     90      back to an internal hard-coded path.  Assuming the prefix for your
     91      <application>X</application> installation is
     92      <filename class="directory">/usr/X11R6</filename>, the core fonts will
     93      reside in subdirectories of <filename
     94      class="directory">/usr/X11R6/lib/X11/fonts</filename>.  For each
     95      directory in the path, the server reads three files:</para>
     96
     97      <itemizedlist>
     98        <listitem>
     99          <para><filename>fonts.dir</filename> - maps font files to font
     100          names&semi; updated with <command>mkfontdir</command></para>
     101        </listitem>
     102        <listitem>
     103          <para><filename>fonts.alias</filename> - defines aliases (such as
     104          "9x18") for existing fonts</para>
     105        </listitem>
     106        <listitem>
     107          <para><filename>fonts.scale</filename> - lists scalable fonts&semi;
     108          updated with <command>mkfontscale</command></para>
     109        </listitem>
     110      </itemizedlist>
     111
     112      <para>The core X fonts protocol uses names such as
     113      <systemitem>-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1</systemitem>.
     114      These fonts are rendered by the <application>X</application> server
     115      without antialiasing.  The server itself uses the "cursor" font for
     116      painting the mouse cursor, and the protocol specification requires the
     117      font "fixed" to be available.</para>
     118
     119      <para>Scalable fonts, such as Type1 and TrueType, are read from
     120      <filename>fonts.scale</filename> files by the server.  The core X font
     121      system uses the "freetype" module for non-antialiased rendering of these
     122      fonts.  Ensure that the "freetype" module is loaded in the
     123      <filename>XF86config</filename> or <filename>xorg.conf</filename>
     124      file by adding it to the "Module" section:</para>
    166125
    167126<screen><literal>Section "Module"
     
    171130EndSection</literal></screen>
    172131
     132      <para>The character set used is part of the font name, e.g. "-iso8859-1".
     133      It is important that applications which support a non-English interface
     134      specify the character set correctly so that the proper glyphs are used.
     135      This can be controlled through the <application>X</application>
     136      resources, which will be described later.</para>
     137
     138      <para>In some cases, applications rely upon the fonts named "fixed" or
     139      something like "9x18".  In these cases, it is important that the
     140      <filename>fonts.alias</filename> file specifies the correct character
     141      set.  Users of ISO-8859-<replaceable>X</replaceable> encodings where
     142      <replaceable>X</replaceable> != 1 should modify the
     143      <filename>/usr/lib/X11/fonts/misc/fonts.alias</filename> file by
     144      replacing the "iso8859-1" string with the proper encoding name.  This is
     145      accomplished by running the following command as the <systemitem
     146      class="username">root</systemitem> user, substituting the proper value
     147      for <replaceable>[X]</replaceable>:</para>
     148
     149<screen role="root"><userinput>sed -i 's,iso8859-1\( \|$\),iso8859-<replaceable>[X]</replaceable>\1,g' \
     150    /usr/share/fonts/{75dpi,100dpi,misc}/fonts.alias</userinput></screen>
     151
     152      <para>Users of Cyrillic fonts have properly defined aliases in
     153      <filename>/usr/lib/X11/fonts/cyrillic/fonts.alias</filename>.  However,
     154      this file will not be used unless the <filename
     155      class="directory">/usr/lib/X11/fonts/cyrillic</filename> directory is
     156      first in the font search path.  Otherwise, the
     157      <filename>/usr/lib/X11/fonts/misc/fonts.alias</filename> file will be
     158      used.</para>
     159
    173160    </sect3>
    174161
    175162    <sect3>
    176       <title>Update the Font Cache Files</title>
    177 
    178       <para>If you decided not to install X windows fonts into
    179       <filename class='directory'>/usr/share/fonts</filename>, then
    180       ensure you have the following directory entries in
    181       <filename>/etc/fonts/local.conf</filename>, inside the &lt;fontconfig&gt;
    182       tags. Create <filename>/etc/fonts/local.conf</filename> using the
    183       following commands:</para>
     163      <title>Xft Font Protocol</title>
    184164
    185165      <indexterm zone="x-setup fonts">
    186         <primary sortas="e-etc-fonts-local.conf">/etc/fonts/local.conf</primary>
     166        <primary sortas="g-truetype">TrueType Fonts</primary>
    187167      </indexterm>
    188168
    189 <screen role="root"><userinput>cat &gt; /etc/fonts/local.conf &lt;&lt; "EOF"
    190 <literal>&lt;?xml version="1.0"?&gt;
    191 &lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
    192 &lt;!-- /etc/fonts/local.conf file for local customizations --&gt;
    193 
    194 &lt;fontconfig&gt;
    195 &lt;dir&gt;/usr/X11R6/lib/X11/fonts/TTF&lt;/dir&gt;
    196 &lt;dir&gt;/usr/X11R6/lib/X11/fonts/Type1&lt;/dir&gt;
    197 &lt;/fontconfig&gt;</literal>
    198 
    199 EOF</userinput></screen>
    200 
     169      <para>Xft provides antialiased font rendering through
     170      <application>Freetype</application>, and fonts are controlled from the
     171      client side using <application>Fontconfig</application>.  The default
     172      search path is <filename class="directory">/usr/share/fonts</filename>
     173      and <filename class="directory">~/.fonts</filename>.
     174      When installing <application>X</application>, symlinks were created from
     175      the <filename class="directory">OTF</filename> and <filename
     176      class="directory">TTF</filename> <application>X</application> font
     177      directories to <filename
     178      class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename>.  This
     179      prevents <application>Fontconfig</application> from using the poorly
     180      rendered Type1 fonts or the non-scalable bitmapped fonts.</para>
     181
     182      <para><application>Fontconfig</application> searches directories in its
     183      path recursively and maintains a cache of the font characteristics in
     184      <filename>fonts.cache-1</filename> files in each directory.  If the cache
     185      appears to be out of date, it is ignored, and information is (slowly)
     186      fetched from the fonts themselves.  This cache
     187      can be regenerated using the <command>fc-cache</command> command at any
     188      time.</para>
     189
     190      <para><application>Fontconfig</application> uses names such as
     191      "Monospace 12" to define fonts.  Applications generally use generic font
     192      names such as "Monospace", "Sans" and "Serif".
     193      <application>Fontconfig</application> resolves these names to a font that
     194      has all characters that cover the orthography of the language indicated
     195      by the locale settings.  Knowledge of these font names is included in
     196      <filename>/etc/fonts/fonts.conf</filename>.</para>
     197
     198      <para>Standard scalable fonts that come with <application>X</application>
     199      provide very poor Unicode coverage.  You may notice in applications that
     200      use <application>Xft</application> that some characters appear as a box
     201      with four binary digits inside.  In this case, a font set with the
     202      available glyphs has not been found.  Other times, applications that
     203      don't use other font families by default and don't accept substitutions
     204      from <application>Fontconfig</application> will display blank lines when
     205      the default font doesn't cover the orthography of the user's language.
     206      This happens, e.g., with <application>Fluxbox</application> in the
     207      ru_RU.KOI8-R locale.</para>
     208
     209      <para>In order to provide greater Unicode coverage, it is recommended
     210      that you install these fonts:</para>
     211
     212      <itemizedlist>
     213        <listitem>
     214          <para><ulink url="http://dejavu.sourceforge.net/">DejaVu fonts</ulink>
     215          - These fonts are replacements for the Bitstream Vera fonts and
     216          provide Latin-based scripts with accents and Cyrillic glyphs.
     217          <application>Fontconfig</application> does not know about the DejaVu
     218          fonts by default, so <filename>/etc/fonts/fonts.conf</filename> will
     219          have to be edited for it to be recognized by the generic names such
     220          as "Sans".  This will be described below.</para>
     221        </listitem>
     222        <listitem>
     223          <para><ulink
     224          url="http://download.savannah.nongnu.org/releases/freefont/">FreeFont</ulink>
     225          - This set of fonts covers nearly every non-CJK character, but is not
     226          visually pleasing.  <application>Fontconfig</application> will use it
     227          as a last resort to substitute generic font family names.</para>
     228        </listitem>
     229        <listitem>
     230          <para><ulink
     231          url="http://corefonts.sourceforge.net/">Microsoft Core fonts</ulink>
     232          - These fonts provide slightly worse Unicode coverage than FreeFont,
     233          but are better hinted.  Be sure to read the license before using
     234          them.  <application>Fontconfig</application> knows about them by
     235          default.</para>
     236        </listitem>
     237        <listitem>
     238          <para><ulink
     239          url="http://cle.linux.org.tw/fonts/FireFly">Firefly New Sung font</ulink>
     240          - This font provides Chinese coverage.  However,
     241          <application>Fontconfig</application>does not know about this font
     242          by default.</para>
     243        </listitem>
     244        <listitem>
     245          <para><ulink
     246          url="http://cle.linux.org.tw/fonts/Arphic">Arphic fonts</ulink> -
     247          A similar set of Chinese fonts to the Firefly New Sung font.
     248          <application>Fontconfig</application> knows about these fonts by
     249          default and will substitute them for generic family names.</para>
     250        </listitem>
     251        <listitem>
     252          <para><ulink
     253          url="http://sourceforge.jp/projects/efont/">Kochi fonts</ulink> -
     254          These provide Japanese characters, and
     255          <application>Fontconfig</application> knows about these fonts by
     256          default.</para>
     257        </listitem>
     258        <listitem>
     259          <para><ulink
     260          url="http://kldp.net/projects/baekmuk/">Baekmuk fonts</ulink>
     261          - These fonts provide Korean coverage, and
     262          <application>Fontconfig</application> knows about these fonts by
     263          default.</para>
     264        </listitem>
     265      </itemizedlist>
     266
     267      <para>The list above will not provide complete Unicode coverage.  For
     268      more information, please visit the <ulink
     269      url="http://unifont.org/fontguide/">Unicode Font Guide</ulink>.</para>
     270
     271      <para>As an example, consider the installation of the DejaVu fonts.  From
     272      the unpacked source directory, run the following commands as the
     273      <systemitem class="username">root</systemitem> user:</para>
     274
     275<screen role="root"><userinput>install -v -d -m755 /usr/share/fonts/dejavu &amp;&amp;
     276install -v -m644 *.ttf /usr/share/fonts/dejavu &amp;&amp;
     277fc-cache -v /usr/share/fonts/dejavu</userinput></screen>
     278
     279      <para>Earlier it was mentioned that <filename>/etc/fonts/fonts.conf</filename>
     280      could be modified to use DejaVu using the default family names.  Since
     281      DejaVu is a replacement for Bitstream Vera fonts, we can substitute it
     282      for that family.  Visually inspect the <filename>fonts.conf</filename> to
     283      see how fonts are grouped together under the generic family names and a
     284      preference list is created.  To replace Bitstream Vera with DejaVu, as the
     285      <systemitem class="username">root</systemitem> user:</para>
     286
     287<screen role="root"><userinput>sed -i 's/&lt;family&gt;Bitstream Vera/&lt;family&gt;DejaVu/' /etc/fonts/fonts.conf</userinput></screen>
     288
     289    </sect3>
    201290
    202291<!--
     
    205294&lt;dir&gt;/usr/X11R6/lib/X11/fonts/Type1&lt;/dir&gt;' /etc/fonts/local.conf</command></userinput></screen>
    206295 -->
    207 
    208       <para>The <command>fc-cache</command> program will automatically
    209       search the above directories and all subdirectories for needed
    210       fonts.</para>
    211 
    212       <para>Finally, to update all the font cache files, run</para>
    213 
    214 <screen role="root"><userinput>fc-cache</userinput></screen>
    215 
    216       <indexterm zone="x-setup fonts">
    217         <primary sortas="b-fc-cache">fc-cache</primary>
    218       </indexterm>
    219 
    220       <para><application>X</application> will now be able to use
    221       <application>TrueType</application> fonts when it is restarted.
    222       You can check to see if the new fonts are available with the
    223       <command>xlsfonts</command>  or <command>xfontsel</command>
    224       program.</para>
    225 
    226       <note>
    227         <para>You should rerun <command>mkfontscale</command> and
    228         <command>mkfontdir</command> any time you add or delete
    229         <application>TrueType</application> fonts.
    230         You should also rerun <command>fc-cache</command> each time
    231         you add or remove any fonts.</para>
    232       </note>
    233 
    234     </sect3>
     296    <bridgehead renderas="sect3" condition="html" role="usernotes">User Notes:
     297    <ulink url='&blfs-wiki;/XWindowSystemComponents'/></bridgehead>
    235298
    236299  </sect2>
     
    259322    combination to switch between keyboard layouts and use the Scroll Lock
    260323    LED to indicate when the second layout is active.</para>
    261 
    262   </sect2>
    263 
    264 <!-- ================================================== -->
    265 
    266   <sect2>
    267     <title>Setting up Fonts</title>
    268 
    269     <para>Users using character sets other than ISO-8859-1 have to make
    270     a few adjustments to their font settings in order to make sure that
    271     fonts with the correct encoding are used for "fixed", "variable",
    272     "10x20" and similar aliases. For ISO-8859-<replaceable>[X]</replaceable>
    273     based locales, use the following command:</para>
    274 
    275 <screen role="root"><userinput>sed -i 's,iso8859-1\( \|$\),iso8859-<replaceable>[X]</replaceable>\1,g' \
    276     /usr/share/fonts/{75dpi,100dpi,misc}/fonts.alias</userinput></screen>
    277 
    278     <para>To use cyrillic fonts with <application>GTK1</application>,
    279     <application>Tk</application>, <application>Xaw</application> and
    280     <application>Motif</application>, put the following line into the top of the
    281     "Files" section in <filename>XF86Config</filename> or
    282     <filename>xorg.conf</filename>. This directory already contains the needed bitmap
    283     fonts and their aliases:</para>
    284 
    285 <screen><literal>FontPath   "/usr/share/fonts/cyrillic/"</literal></screen>
    286324
    287325  </sect2>
Note: See TracChangeset for help on using the changeset viewer.