mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-01-27 09:42:12 +08:00
bee7026aad
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@20282 af4574ff-66df-0310-9fd7-8a98e5e911e0
721 lines
30 KiB
XML
721 lines
30 KiB
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
<!ENTITY % general-entities SYSTEM "../../general.ent">
|
|
%general-entities;
|
|
]>
|
|
|
|
<sect1 id="tuning-fontconfig">
|
|
<?dbhtml filename="tuning-fontconfig.html"?>
|
|
|
|
<sect1info>
|
|
<othername>$LastChangedBy$</othername>
|
|
<date>$Date$</date>
|
|
</sect1info>
|
|
|
|
<title>Tuning Fontconfig</title>
|
|
|
|
<indexterm zone="tuning-fontconfig">
|
|
<primary sortas="g-tuning-fontconfig">Tuning Fontconfig</primary>
|
|
</indexterm>
|
|
|
|
<sect2 id='fontconfig-overview' xreflabel="Overview of Fontconfig">
|
|
<title>Overview of Fontconfig</title>
|
|
|
|
<!-- do not add individual indexterm entries for items within this page, they
|
|
all belong in section G (others) and not only do they add noise in longindex,
|
|
the links all point to the top of the page. -->
|
|
|
|
<para>
|
|
If you only read text in English, and are happy with the common libre
|
|
fonts listed on the next page, you may never need to worry about the
|
|
details of how <application>fontconfig</application> works. But there are
|
|
many things which can be altered if they do not suit your needs.
|
|
</para>
|
|
|
|
<para>
|
|
Although this page is long, it barely scratches the surface and you will
|
|
be able to find many alternative views on the web (but please remember
|
|
that some things have changed over the years, for example the autohinter
|
|
is no longer the default). The aim here is to give you enough information
|
|
to understand the changes you are making.
|
|
</para>
|
|
|
|
<!-- use the existing wiki page for fontconfig -->
|
|
<para condition="html" role="usernotes">User Notes:
|
|
<ulink url='&blfs-wiki;/Fontconfig'/>
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="xft-font-protocol" xreflabel="The Xft Font Protocol">
|
|
<title>The Xft Font Protocol</title>
|
|
|
|
<para>
|
|
The Xft font protocol provides antialiased font rendering through
|
|
<application>freetype</application>, and fonts are controlled from the
|
|
client side using <application>fontconfig</application> (except for
|
|
<xref linkend="rxvt-unicode"/> which can use fonts listed in
|
|
<filename>~/.Xresources</filename>, and <xref linkend="abiword"/> which
|
|
only uses the specified font). The default search path is <filename
|
|
class="directory">/usr/share/fonts</filename> and <filename
|
|
class="directory">~/.local/share/fonts</filename> although for the moment
|
|
the old and deprecated location <filename
|
|
class="directory">~/.fonts</filename> still works.
|
|
<application>Fontconfig</application> searches directories in its path
|
|
recursively and maintains a cache of the font characteristics in each
|
|
directory. If the cache appears to be out of date, it is ignored, and
|
|
information is fetched from the fonts themselves (that can take a few
|
|
seconds if you installed a lot of fonts).
|
|
</para>
|
|
|
|
<para>
|
|
If you've installed <application>Xorg</application> in any prefix
|
|
other than <filename class="directory">/usr</filename>, any
|
|
<application>X</application> fonts were not installed in a
|
|
location known to <application>Fontconfig</application>. Symlinks were
|
|
<!-- fonts-misc-ethiopic installs an OTF directory ! -->
|
|
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 allows
|
|
<application>Fontconfig</application> to use the OpenType and TrueType
|
|
fonts provided by <application>X</application>, although many people will
|
|
prefer to use more modern fonts.
|
|
</para>
|
|
|
|
<para>
|
|
<application>Fontconfig</application> uses names 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.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="useful-commands" xreflabel="Useful Commands">
|
|
<title>Useful Commands</title>
|
|
|
|
<para>
|
|
The following commands may be helpful when working with fontconfig:
|
|
</para>
|
|
|
|
<para>
|
|
<command>fc-list | less</command> : show a list of all available fonts
|
|
(/path/to/filename: Font Name:style). If you installed a font more than
|
|
30 seconds ago but it does not show, then it or one of its directories is
|
|
not readable by your user.
|
|
</para>
|
|
|
|
<para>
|
|
<command>fc-match 'Font Name'</command> : will tell you which font will
|
|
be used if the named font is requested. Typically you would use this to
|
|
see what happens if a font you have not installed is requested, but you
|
|
can also use it if the system is giving you a different font from
|
|
what you expected (perhaps because <application>fontconfig</application>
|
|
does not agree that the font supports your language).
|
|
</para>
|
|
|
|
<para>
|
|
<command>fc-match -a 'Type' | less</command> : will provide a list of all
|
|
fonts which can be used for that type (Monospace, Sans, Serif). Note that
|
|
in-extremis <application>fontconfig</application> will take a glyph from
|
|
any available font, even if it is not of the specified type, and unless it
|
|
knows about the font's type it will assume it is Sans.
|
|
</para>
|
|
|
|
<para>
|
|
If you wish to know which font will be used for a string of text
|
|
(i.e. one or more glyphs, preceded by a space), paste the following
|
|
command and replace the <literal>xyz</literal> by the text you care
|
|
about:
|
|
</para>
|
|
|
|
<para>
|
|
<command>FC_DEBUG=4 pango-view --font=monospace -t xyz | grep
|
|
family</command> : this requires <xref linkend="pango"/> and <xref
|
|
linkend="imagemagick"/> - it will invoke <xref linkend="display"/>
|
|
to show the text in a tiny window, and after closing that the last
|
|
line of the output will show which font was chosen. This is
|
|
particularly useful for CJK languages, and you can also pass a
|
|
language, e.g. PANGO_LANGUAGE=en;ja (English, then assume Japanese)
|
|
or just zh-cn (or other variants - 'zh' on its own is not valid).
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="the-various-files" xreflabel="The various files">
|
|
<title>The various files</title>
|
|
|
|
<para>
|
|
The main files are in <filename class="directory">/etc/fonts/conf.d/</filename>,
|
|
which was intended to be a directory populated by symlinks to some of the files
|
|
in <filename class="directory">/usr/share/fontconfig/conf.avail/</filename>.
|
|
But many people, and some packages, create the files directly. Each file name
|
|
must be in the form of two digits, a dash, somename.conf and they are read in
|
|
sequence.
|
|
</para>
|
|
|
|
<para>
|
|
By convention, the numbers are assigned as follows:
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>00-09 extra font directories</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>10-19 system rendering defaults (antialising etc)</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>20-29 font rendering options</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>30-39 family substitution</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>40-49 map family to generic type</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>50-59 load alternate config files</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>60-69 generic aliases, map generic to family</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>70-79 adjust which fonts are available</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>80-89 match target scan (modify scanned patterns)</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>90-99 font synthesis</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
<para>
|
|
You can also have a personal <filename>fonts.conf</filename> in
|
|
$XDG_CONFIG_HOME which is <filename
|
|
class="directory">~/.config/fontconfig/</filename>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="rules-to-choose-a-font" xreflabel="The rules to choose a font">
|
|
<title>The rules to choose a font</title>
|
|
|
|
<para>
|
|
If the requested font is installed, and provided it contains the
|
|
codepoints <emphasis>required</emphasis> for the current language (in the
|
|
source, see the .orth files in the <filename
|
|
class="directory">fc-lang/</filename> directory), it will be used.
|
|
</para>
|
|
|
|
<para>
|
|
But if the document or page requested a font which is not installed
|
|
(or, occasionally, does not contain all the required codepoints) the
|
|
following rules come into play: First,
|
|
<filename>30-metric-aliases.conf</filename> is used to map aliases for
|
|
some fonts with the same metrics (same size, etc). After that, an
|
|
unknown font will be searched for in <filename>45-latin.conf</filename> -
|
|
if it is found it will be mapped as Serif or Monospace or Sans, otherwise
|
|
it will be assumed to be Sans. Then <filename>50-latin.conf</filename>
|
|
provides ordered lists of the fallbacks - <xref linkend="dejavu-fonts"/>
|
|
will be used if you installed them. Cyrillic and Greek appear to be
|
|
treated in the same way. There are similar files with a 65- prefix for
|
|
Persian and other non-latin writing systems. All of these files prefer
|
|
commercial fonts if they are present, although modern libre fonts are
|
|
often at least their equals.
|
|
</para>
|
|
|
|
<para>
|
|
Since fontconfig-2.12.5 there is also generic family matching for some
|
|
emoji and math fonts, see {45,60}-generic.conf.
|
|
</para>
|
|
|
|
<para>
|
|
In the rare cases where a font does not contain all the expected
|
|
codepoints, see 'Trial the First:' at <xref
|
|
linkend="I-stared-into-the-fontconfig"/> for the long details.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="hinting-and-antialising" xreflabel="Hinting and Anti-aliasing">
|
|
<title>Hinting and Anti-aliasing</title>
|
|
|
|
<para>
|
|
It is possible to change how, or if, fonts are hinted. The following
|
|
example file contains the default settings, but with comments. The
|
|
settings are very much down to the user's preferences and to the choice
|
|
of fonts, so a change which improves some pages may worsen others. The
|
|
preferred location for this file is:
|
|
<filename>~/.config/fontconfig/fonts.conf</filename>
|
|
</para>
|
|
|
|
<para>
|
|
To try out different settings, you may need to exit from Xorg and then
|
|
rerun <command>startx</command> so that all applications use the new
|
|
settings. And if you use Gnome or KDE their desktops can override these
|
|
changes. To explore the possibilities, create a file for your user:
|
|
</para>
|
|
|
|
<screen><userinput>mkdir -pv ~/.config/fontconfig &&
|
|
cat > ~/.config/fontconfig/fonts.conf << "EOF"
|
|
<literal><?xml version='1.0'?>
|
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
|
<fontconfig>
|
|
|
|
<match target="font" >
|
|
<!-- autohint was the old automatic hinter when hinting was patent
|
|
protected, so turn it off to ensure any hinting information in the font
|
|
itself is used, this is the default -->
|
|
<edit mode="assign" name="autohint"> <bool>false</bool></edit>
|
|
|
|
<!-- hinting is enabled by default -->
|
|
<edit mode="assign" name="hinting"> <bool>true</bool></edit>
|
|
|
|
<!-- for the lcdfilter see http://www.spasche.net/files/lcdfiltering/ -->
|
|
<edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
|
|
|
|
<!-- options for hintstyle:
|
|
hintfull: is supposed to give a crisp font that aligns well to the
|
|
character-cell grid but at the cost of its proper shape.
|
|
|
|
hintmedium: poorly documented, maybe a synonym for hintfull.
|
|
hintslight is the default: - supposed to be more fuzzy but retains shape.
|
|
|
|
hintnone: seems to turn hinting off.
|
|
The variations are marginal and results vary with different fonts -->
|
|
<edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
|
|
|
|
<!-- antialiasing is on by default and really helps for faint characters
|
|
and also for 'xft:' fonts used in rxvt-unicode -->
|
|
<edit mode="assign" name="antialias"> <bool>true</bool></edit>
|
|
|
|
<!-- subpixels are usually rgb, see
|
|
http://www.lagom.nl/lcd-test/subpixel.php -->
|
|
<edit mode="assign" name="rgba"> <const>rgb</const></edit>
|
|
|
|
<!-- thanks to the Arch wiki for the lcd and subpixel links -->
|
|
</match>
|
|
|
|
</fontconfig></literal>
|
|
EOF</userinput></screen>
|
|
|
|
<para>
|
|
You will now need to edit the file in your preferred editor.
|
|
</para>
|
|
|
|
<para>
|
|
For more examples see the blfs-support thread which started at <ulink
|
|
url="http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-September/078422.html">/2016-September/078422</ulink>,
|
|
particularly <ulink
|
|
url="http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-September/078425.html">2016-September/078425</ulink>,
|
|
and the original poster's preferred solution at <ulink
|
|
url="http://lists.linuxfromscratch.org/pipermail/blfs-support/2016-November/078658.html">2016-November/078658</ulink>.
|
|
There are other examples in <xref linkend="arch-fontconfig"/> and <xref
|
|
linkend="gentoo-fontconfig"/>.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="disabling-bitmap-fonts" xreflabel="Disabling Bitmap fonts">
|
|
<title>Disabling Bitmap Fonts</title>
|
|
|
|
<para>
|
|
In previous versions of BLFS, the ugly old Xorg bitmap fonts were
|
|
installed. Now, many people will not need to install any of them. But if
|
|
for some reason you have installed one or more bitmap fonts, you can
|
|
prevent them being used by <application>fontconfig</application> by
|
|
creating the following file as the
|
|
<systemitem class="username">root</systemitem> user :
|
|
</para>
|
|
|
|
<screen role="root"><userinput>cat > /etc/fonts/conf.d/70-no-bitmaps.conf << "EOF"
|
|
<literal><?xml version='1.0'?>
|
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
|
<fontconfig>
|
|
<!-- Reject bitmap fonts -->
|
|
<selectfont>
|
|
<rejectfont>
|
|
<pattern>
|
|
<patelt name="scalable"><bool>false</bool></patelt>
|
|
</pattern>
|
|
</rejectfont>
|
|
</selectfont>
|
|
</fontconfig></literal>
|
|
EOF</userinput></screen>
|
|
|
|
</sect2>
|
|
|
|
<sect2 role="configuration" id="adding-extra-directories" xreflabel="Adding extra font directories">
|
|
<title>Adding extra font directories</title>
|
|
|
|
<para>
|
|
Normally, system fonts and user fonts are installed in directories beneath
|
|
the locations specified in <xref linkend="xft-font-protocol"/> and there
|
|
is no obvious reason to put them elsewhere. However, a full BLFS install
|
|
of <xref linkend="texlive"/> puts many fonts in <filename
|
|
class="directory">/opt/texlive/&texlive-year;/texmf-dist/fonts/</filename>
|
|
in the <filename class="directory">opentype/</filename> and <filename
|
|
class="directory">truetype/</filename> subdirectories. Although pulling in
|
|
all of these files may appear useful (it allows you to use them in non
|
|
<application>TeX</application> programs), there are several problems with
|
|
such an approach:
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
There are hundreds of files, which makes selecting the font hard.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Some of the files do odd things, such as displaying semaphore flags
|
|
instead of ASCII letters, or mapping cyrillic codepoints to character
|
|
forms appropriate to Old Church Slavonic instead of the expected
|
|
current shapes: fine if that is what you need, but painful for normal
|
|
use.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Several fonts have multiple sizes and impenetrable short names, which
|
|
both make selecting the correct font even harder.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
When a font is added to CTAN, it is accompanied by TeX packages to use
|
|
it in the old engines (<application>xelatex</application> does not
|
|
normally need this), and then the version is often frozen whilst the
|
|
font is separately maintained. Some of these fonts such as <xref
|
|
linkend="dejavu-fonts"/> are probably already installed on your BLFS
|
|
system in a newer version, and if you have multiple versions of a font
|
|
it is unclear which one will be used by
|
|
<application>fontconfig</application>.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
|
|
<para>
|
|
However, it is sometimes useful to look at these fonts in non-TeX
|
|
applications, if only to see whether you wish to install a current
|
|
version. If you have installed all of <application>texlive</application>,
|
|
the following example will make one of the Arkandis Open Type fonts
|
|
available to other applications, and all three of the ParaType TrueType
|
|
fonts. Adjust or repeat the lines as desired, to either make all the
|
|
<filename class="directory">opentype/</filename> or <filename
|
|
class="directory">truetype</filename>fonts available, or to select
|
|
different font directories. As the <systemitem
|
|
class="username">root</systemitem> user:
|
|
</para>
|
|
|
|
<screen role="root"><userinput>cat > /etc/fonts/conf.d/09-texlive.conf << "EOF"
|
|
<literal><?xml version='1.0'?>
|
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
|
<fontconfig>
|
|
<dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/opentype/arkandis/berenisadf</dir>
|
|
<dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/truetype/paratype</dir>
|
|
</fontconfig></literal>
|
|
EOF</userinput></screen>
|
|
|
|
<para>
|
|
If you do this, remember to change all instances of the year in that file
|
|
when you upgrade <application>texlive</application> to a later release.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 role="configuration" id="preferring-certain-fonts" xreflabel="Preferring certain fonts">
|
|
<title>Preferring certain fonts</title>
|
|
|
|
<para>
|
|
There are many reasons why people may wish to have pages which specify a
|
|
particular font use a different font, or prefer specific fonts in
|
|
Monospace or Sans or Serif. As you will expect, there a number of
|
|
different ways of achieving this.
|
|
</para>
|
|
|
|
<bridgehead renderas="sect3" id="fontconfig-user-docs"
|
|
xreflabel="fontconfig-user-docs">Fontconfig user docs</bridgehead>
|
|
|
|
<para>
|
|
<application>Fontconfig</application> installs user documentation that
|
|
includes an example 'User configuration file' which among other things
|
|
prefers <xref linkend="wenquanyi-zenhei"/> (a Sans font) if a
|
|
<emphasis>Serif</emphasis> font is requested for Chinese (this part
|
|
might be anachronistic unless you have non-free Chinese fonts, because
|
|
in <filename>65-nonlatin.conf</filename> this font is already among the
|
|
preferred fonts when Serif is specified for Chinese) and to prefer the
|
|
modern <xref linkend="VLGothic"/> font if a Sans font is specified on a
|
|
Japanese page (otherwise a couple of other fonts would be preferred if
|
|
they have been installed).
|
|
</para>
|
|
|
|
<para>
|
|
If you have installed the current version, the user documentation is
|
|
available in html, PDF and text versions at <filename
|
|
class="directory">/usr/share/doc/fontconfig-&fontconfig-version;/</filename>
|
|
: change the version if you installed a different one.
|
|
</para>
|
|
|
|
<bridgehead renderas="sect3" id="prefer-a-specific-font"
|
|
xreflabel="fontconfig-prefer-specific-font">Prefer a specific font</bridgehead>
|
|
|
|
<para>
|
|
As an example, if for some reason you wished to use the <ulink
|
|
url="https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus Roman
|
|
No9 L</ulink> font wherever Times New Roman is referenced (it is
|
|
metrically similar, and preferred for Times Roman, but the Serif font
|
|
from <xref linkend="liberation-fonts"/> will be preferred for the Times
|
|
<emphasis>New</emphasis> Roman font if installed), as an individual user
|
|
you could install the font and then create the following file:
|
|
</para>
|
|
|
|
<screen><userinput>mkdir -pv ~/.config/fontconfig/conf.d &&
|
|
cat > ~/.config/fontconfig/conf.d/35-prefer-nimbus-for-timesnew.conf << "EOF"
|
|
<literal><?xml version='1.0'?>
|
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
|
<fontconfig>
|
|
<!-- prefer Nimbus Roman No9 L for Times New Roman as well as for Times,
|
|
without this Tinos and Liberation Serif take precedence for Times New Roman
|
|
before fontconfig falls back to whatever matches Times -->
|
|
<alias binding="same">
|
|
<family>Times New Roman</family>
|
|
<accept>
|
|
<family>Nimbus Roman No9 L</family>
|
|
</accept>
|
|
</alias>
|
|
</fontconfig></literal>
|
|
EOF</userinput></screen>
|
|
|
|
<para>
|
|
This is something you would normally do in an individual user's
|
|
settings, but the file in this case has been prefixed '35-' so that it
|
|
could, if desired, be used system-wide in <filename
|
|
class="directory">/etc/fonts/conf.d/</filename>.
|
|
</para>
|
|
|
|
<bridgehead renderas="sect3" id="prefer-chosen-CJK-fonts"
|
|
xreflabel="Prefer chosen CJK fonts">Prefer chosen CJK fonts</bridgehead>
|
|
|
|
<para>
|
|
The following example of a local configuration (i.e. one that applies
|
|
for all users of the machine) does several things:
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
If a Serif font is specified, it will prefer the <xref
|
|
linkend="UMing"/> variants, so that in the zh-cn, zh-hk and zh-tw
|
|
languages things should look good (also zh-sg which actually uses
|
|
the same settings as zh-cn) <emphasis>without</emphasis> affecting
|
|
Japanese.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
It prefers the Japanese <xref linkend="IPAex"/> if they have been
|
|
installed (although <xref linkend="VLGothic"/> will take precedence
|
|
for (Japanese) Sans if it has also been installed.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
Because <xref linkend="wenquanyi-zenhei"/> covers Korean Hangul
|
|
glyphs and is also preferred for Serif in
|
|
<filename>65-nonlatin.conf</filename>, if installed it will be used
|
|
by default for Korean Serif. To get a proper Serif font, the
|
|
UnBatang font is specified here - change that line if you installed
|
|
a different Serif font from the choice of <xref
|
|
linkend="Korean-fonts"/>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
The Monospace fonts are forced to the preferred Sans fonts. If the
|
|
text is in Korean then <xref linkend="wenquanyi-zenhei"/> will be
|
|
used.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
|
|
<para>
|
|
In a non-CJK locale, the result is that suitable fonts will be used for
|
|
all variants of Chinese, Japanese and Hangul Korean. All other languages
|
|
should already work if a font is present. As the <systemitem
|
|
class="username">root</systemitem> user:
|
|
</para>
|
|
|
|
<screen role="root"><userinput>cat > /etc/fonts/local.conf << "EOF"
|
|
<literal><?xml version='1.0'?>
|
|
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
|
<fontconfig>
|
|
<alias>
|
|
<family>serif</family>
|
|
<prefer>
|
|
<family>AR PL UMing</family>
|
|
<family>IPAexMincho</family>
|
|
<!-- WenQuanYi is preferred as Serif in 65-nonlatin.conf,
|
|
override that so a real Korean font can be used for Serif -->
|
|
<family>UnBatang</family>
|
|
</prefer>
|
|
</alias>
|
|
<alias>
|
|
<family>sans-serif</family>
|
|
<prefer>
|
|
<family>WenQuanYi Zen Hei</family>
|
|
<family>VL Gothic</family>
|
|
<family>IPAexGothic</family>
|
|
</prefer>
|
|
</alias>
|
|
<alias>
|
|
<family>monospace</family>
|
|
<prefer>
|
|
<family>VL Gothic</family>
|
|
<family>IPAexGothic</family>
|
|
<family>WenQuanYi Zen Hei</family>
|
|
</prefer>
|
|
</alias>
|
|
</fontconfig></literal>
|
|
EOF</userinput></screen>
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 role="configuration" id="editing-old-style-conf-files"
|
|
xreflabel="Editing Old-Style conf files">
|
|
<title>Editing Old-style conf files</title>
|
|
|
|
<para>
|
|
Some fonts, particularly Chinese fonts, ship with conf files which can be
|
|
installed in <filename class="directory">/etc/fonts/conf.d</filename>.
|
|
However, if you do that and then use a terminal to run any command which
|
|
uses <application>fontconfig</application> you may see error messages such
|
|
as :
|
|
</para>
|
|
|
|
<para>
|
|
<literal>Fontconfig warning: "/etc/fonts/conf.d/69-odofonts.conf", line
|
|
14: Having multiple <family> in <alias> isn't supported and
|
|
may not work as expected</literal>.
|
|
</para>
|
|
|
|
<para>
|
|
In practice, these old rules do not work. For non-CJK users,
|
|
<application>fontconfig</application> will usually do a good job
|
|
<emphasis>without</emphasis> these rules. Their origin dates back to when
|
|
CJK users needed handcrafted bitmaps to be legible at small sizes, and
|
|
those looked ugly next to antialiased Latin glyphs - they preferred to
|
|
use the same CJK font for the Latin glyphs. There is a side-effect of
|
|
doing this : the (Serif) font is often also used for Sans, and in such a
|
|
situation the (English) text in <application>Gtk</application> menus will
|
|
use this font - compared to system fonts, as well as being serif it is
|
|
both faint and rather small. That can make it uncomfortable to read.
|
|
</para>
|
|
|
|
<para>
|
|
Nevertheless, these old conf files can be fixed if you wish to use them.
|
|
The following example is the first part of
|
|
<filename>64-arphic-uming.conf</filename> from <xref linkend="UMing"/> -
|
|
there are a lot more similar items which also need changing :
|
|
</para>
|
|
|
|
<para>
|
|
<literallayout>
|
|
<match target="pattern">
|
|
<test qual="any" name="lang" compare="contains">
|
|
<string>zh-cn</string>
|
|
<string>zh-sg</string>
|
|
</test>
|
|
<test qual="any" name="family">
|
|
<string>serif</string>
|
|
</test>
|
|
<edit name="family" mode="prepend" binding="strong">
|
|
<string>AR PL UMing CN</string>
|
|
</edit>
|
|
</match></literallayout>
|
|
</para>
|
|
|
|
<para>
|
|
The process to correct this is straightforward but tedious - for every
|
|
item which produces an error message, using your editor (as the
|
|
<systemitem class="username">root</systemitem> user) edit the installed
|
|
file to repeat the whole block as many times as there are multiple
|
|
variables, then reduce each example to have only one of them. You may
|
|
wish to work on one error at a time, save the file after each fix, and
|
|
from a separate term run a command such as <command>fc-list 2>&1 |
|
|
less</command> to see that the fix worked. For the block above, the fixed
|
|
version will be :
|
|
</para>
|
|
|
|
<para>
|
|
<literallayout>
|
|
<match target="pattern">
|
|
<test qual="any" name="lang" compare="contains">
|
|
<string>zh-cn</string>
|
|
</test>
|
|
<test qual="any" name="family">
|
|
<string>serif</string>
|
|
</test>
|
|
<edit name="family" mode="prepend" binding="strong">
|
|
<string>AR PL UMing CN</string>
|
|
</edit>
|
|
</match>
|
|
<match target="pattern">
|
|
<test qual="any" name="lang" compare="contains">
|
|
<string>zh-sg</string>
|
|
</test>
|
|
<test qual="any" name="family">
|
|
<string>serif</string>
|
|
</test>
|
|
<edit name="family" mode="prepend" binding="strong">
|
|
<string>AR PL UMing CN</string>
|
|
</edit>
|
|
</match></literallayout>
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 role="configuration" id="see-also" xreflabel="See Also">
|
|
<title>See Also</title>
|
|
|
|
<bridgehead renderas="sect3" id="I-stared-into-the-fontconfig"
|
|
xreflabel="I stared into the fontconfig">I stared into the fontconfig ...</bridgehead>
|
|
|
|
<para>
|
|
The blog entries by <ulink
|
|
url="https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/">Eevee</ulink>
|
|
are particularly useful if <application>fontconfig</application> does not
|
|
think your chosen font supports your language, and for preferring some
|
|
non-MS Japanese fonts when an ugly MS font is already installed.
|
|
</para>
|
|
|
|
<bridgehead renderas="sect3" id="arch-fontconfig"
|
|
xreflabel="Fontconfig in the Arch wiki">Fontconfig in the Arch wiki</bridgehead>
|
|
|
|
<para>
|
|
Arch has a lot of information in its wiki at <ulink
|
|
url="https://wiki.archlinux.org/index.php/font_configuration">font_configuration</ulink>.
|
|
</para>
|
|
|
|
<bridgehead renderas="sect3" id="gentoo-fontconfig"
|
|
xreflabel="Fontconfig in the Gentoo wiki">Fontconfig in the Gentoo wiki</bridgehead>
|
|
|
|
<para>
|
|
Gentoo has some information in its wiki at <ulink
|
|
url="https://wiki.gentoo.org/wiki/Fontconfig">Fontconfig</ulink> although
|
|
a lot of the details (what to enable, and Infinality) are specific to
|
|
Gentoo.
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
</sect1>
|