[e180a646] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="tuning-fontconfig">
|
---|
| 9 | <?dbhtml filename="tuning-fontconfig.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <date>$Date$</date>
|
---|
| 13 | </sect1info>
|
---|
| 14 |
|
---|
| 15 | <title>Tuning Fontconfig</title>
|
---|
| 16 |
|
---|
| 17 | <indexterm zone="tuning-fontconfig">
|
---|
| 18 | <primary sortas="g-tuning-fontconfig">Tuning Fontconfig</primary>
|
---|
| 19 | </indexterm>
|
---|
| 20 |
|
---|
| 21 | <sect2 id='fontconfig-overview' xreflabel="Overview of Fontconfig">
|
---|
| 22 | <title>Overview of Fontconfig</title>
|
---|
| 23 |
|
---|
| 24 | <!-- do not add individual indexterm entries for items within this page, they
|
---|
| 25 | all belong in section G (others) and not only do they add noise in longindex,
|
---|
| 26 | the links all point to the top of the page. -->
|
---|
| 27 |
|
---|
| 28 | <para>
|
---|
| 29 | If you only read text in English, and are happy with the common libre
|
---|
| 30 | fonts listed on the next page, you may never need to worry about the
|
---|
| 31 | details of how <application>fontconfig</application> works. But there are
|
---|
| 32 | many things which can be altered if they do not suit your needs.
|
---|
| 33 | </para>
|
---|
| 34 |
|
---|
| 35 | <para>
|
---|
| 36 | Although this page is long, it barely scratches the surface and you will
|
---|
| 37 | be able to find many alternative views on the web (but please remember
|
---|
| 38 | that some things have changed over the years, for example the autohinter
|
---|
| 39 | is no longer the default). The aim here is to give you enough information
|
---|
| 40 | to understand the changes you are making.
|
---|
| 41 | </para>
|
---|
| 42 |
|
---|
| 43 | <!-- use the existing wiki page for fontconfig -->
|
---|
| 44 | <para condition="html" role="usernotes">User Notes:
|
---|
| 45 | <ulink url='&blfs-wiki;/Fontconfig'/>
|
---|
| 46 | </para>
|
---|
| 47 | </sect2>
|
---|
| 48 |
|
---|
| 49 | <sect2 role="configuration" id="xft-font-protocol" xreflabel="The Xft Font Protocol">
|
---|
| 50 | <title>The Xft Font Protocol</title>
|
---|
| 51 |
|
---|
| 52 | <para>
|
---|
| 53 | The Xft font protocol provides antialiased font rendering through
|
---|
| 54 | <application>freetype</application>, and fonts are controlled from the
|
---|
| 55 | client side using <application>fontconfig</application> (except for
|
---|
| 56 | <xref linkend="rxvt-unicode"/> which can use fonts listed in
|
---|
| 57 | <filename>~/.Xresources</filename>, and <xref linkend="abiword"/> which
|
---|
| 58 | only uses the specified font). The default search path is <filename
|
---|
| 59 | class="directory">/usr/share/fonts</filename> and <filename
|
---|
| 60 | class="directory">~/.local/share/fonts</filename> although for the moment
|
---|
| 61 | the old and deprecated location <filename
|
---|
| 62 | class="directory">~/.fonts</filename> still works.
|
---|
| 63 | <application>Fontconfig</application> searches directories in its path
|
---|
| 64 | recursively and maintains a cache of the font characteristics in each
|
---|
| 65 | directory. If the cache appears to be out of date, it is ignored, and
|
---|
| 66 | information is fetched from the fonts themselves (that can take a few
|
---|
| 67 | seconds if you installed a lot of fonts).
|
---|
| 68 | </para>
|
---|
| 69 |
|
---|
| 70 | <para>
|
---|
| 71 | If you've installed <application>Xorg</application> in any prefix
|
---|
| 72 | other than <filename class="directory">/usr</filename>, any
|
---|
| 73 | <application>X</application> fonts were not installed in a
|
---|
| 74 | location known to <application>Fontconfig</application>. Symlinks were
|
---|
| 75 | <!-- fonts-misc-ethiopic installs an OTF directory ! -->
|
---|
| 76 | created from the <filename class="directory">OTF</filename> and <filename
|
---|
| 77 | class="directory">TTF</filename> <application>X</application> font
|
---|
| 78 | directories to <filename
|
---|
| 79 | class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename>. This allows
|
---|
| 80 | <application>Fontconfig</application> to use the OpenType and TrueType
|
---|
| 81 | fonts provided by <application>X</application>, although many people will
|
---|
| 82 | prefer to use more modern fonts.
|
---|
| 83 | </para>
|
---|
| 84 |
|
---|
| 85 | <para>
|
---|
| 86 | <application>Fontconfig</application> uses names to define fonts.
|
---|
| 87 | Applications generally use generic font names such as "Monospace", "Sans"
|
---|
| 88 | and "Serif". <application>Fontconfig</application> resolves these names
|
---|
| 89 | to a font that has all characters that cover the orthography of the
|
---|
| 90 | language indicated by the locale settings.
|
---|
| 91 | </para>
|
---|
| 92 |
|
---|
| 93 | </sect2>
|
---|
| 94 |
|
---|
| 95 | <sect2 role="configuration" id="useful-commands" xreflabel="Useful Commands">
|
---|
| 96 | <title>Useful Commands</title>
|
---|
| 97 |
|
---|
| 98 | <para>
|
---|
| 99 | The following commands may be helpful when working with fontconfig:
|
---|
| 100 | </para>
|
---|
| 101 |
|
---|
| 102 | <para>
|
---|
| 103 | <command>fc-list | less</command> : show a list of all available fonts
|
---|
| 104 | (/path/to/filename: Font Name:style). If you installed a font more than
|
---|
| 105 | 30 seconds ago but it does not show, then it or one of its directories is
|
---|
| 106 | not readable by your user.
|
---|
| 107 | </para>
|
---|
| 108 |
|
---|
| 109 | <para>
|
---|
| 110 | <command>fc-match 'Font Name'</command> : will tell you which font will
|
---|
| 111 | be used if the named font is requested. Typically you would use this to
|
---|
| 112 | see what happens if a font you have not installed is requested, but you
|
---|
| 113 | can also use it if the system is giving you a different font from
|
---|
| 114 | what you expected (perhaps because <application>fontconfig</application>
|
---|
| 115 | does not agree that the font supports your language).
|
---|
| 116 | </para>
|
---|
| 117 |
|
---|
| 118 | <para>
|
---|
| 119 | <command>fc-match -a 'Type' | less</command> : will provide a list of all
|
---|
| 120 | fonts which can be used for that type (Monospace, Sans, Serif). Note that
|
---|
| 121 | in-extremis <application>fontconfig</application> will take a glyph from
|
---|
| 122 | any available font, even if it is not of the specified type, and unless it
|
---|
| 123 | knows about the font's type it will assume it is Sans.
|
---|
| 124 | </para>
|
---|
| 125 |
|
---|
| 126 | <para>
|
---|
| 127 | If you wish to know which font will be used for a string of text
|
---|
| 128 | (i.e. one or more glyphs, preceded by a space), paste the following
|
---|
| 129 | command and replace the <literal>xyz</literal> by the text you care
|
---|
| 130 | about:
|
---|
| 131 | </para>
|
---|
| 132 |
|
---|
| 133 | <para>
|
---|
| 134 | <command>FC_DEBUG=4 pango-view --font=monospace -t xyz | grep
|
---|
| 135 | family</command> : this requires <xref linkend="pango"/> and <xref
|
---|
| 136 | linkend="imagemagick"/> - it will invoke <xref linkend="display"/>
|
---|
| 137 | to show the text in a tiny window, and after closing that the last
|
---|
| 138 | line of the output will show which font was chosen. This is
|
---|
| 139 | particularly useful for CJK languages, and you can also pass a
|
---|
| 140 | language, e.g. PANGO_LANGUAGE=en;ja (English, then assume Japanese)
|
---|
| 141 | or just zh-cn (or other variants - 'zh' on its own is not valid).
|
---|
| 142 | </para>
|
---|
| 143 |
|
---|
| 144 | </sect2>
|
---|
| 145 |
|
---|
| 146 | <sect2 role="configuration" id="the-various-files" xreflabel="The various files">
|
---|
| 147 | <title>The various files</title>
|
---|
| 148 |
|
---|
| 149 | <para>
|
---|
[bee7026] | 150 | The main files are in <filename class="directory">/etc/fonts/conf.d/</filename>,
|
---|
| 151 | which was intended to be a directory populated by symlinks to some of the files
|
---|
| 152 | in <filename class="directory">/usr/share/fontconfig/conf.avail/</filename>.
|
---|
| 153 | But many people, and some packages, create the files directly. Each file name
|
---|
[e180a646] | 154 | must be in the form of two digits, a dash, somename.conf and they are read in
|
---|
| 155 | sequence.
|
---|
| 156 | </para>
|
---|
| 157 |
|
---|
| 158 | <para>
|
---|
| 159 | By convention, the numbers are assigned as follows:
|
---|
| 160 | </para>
|
---|
| 161 |
|
---|
| 162 | <itemizedlist>
|
---|
| 163 | <listitem>
|
---|
[71df408] | 164 | <para>
|
---|
| 165 | 00-09 extra font directories
|
---|
| 166 | </para>
|
---|
[e180a646] | 167 | </listitem>
|
---|
| 168 | <listitem>
|
---|
[71df408] | 169 | <para>
|
---|
[3470d743] | 170 | 10-19 system rendering defaults (antialiasing etc)
|
---|
[71df408] | 171 | </para>
|
---|
[e180a646] | 172 | </listitem>
|
---|
| 173 | <listitem>
|
---|
[71df408] | 174 | <para>
|
---|
| 175 | 20-29 font rendering options
|
---|
| 176 | </para>
|
---|
[e180a646] | 177 | </listitem>
|
---|
| 178 | <listitem>
|
---|
[71df408] | 179 | <para>
|
---|
| 180 | 30-39 family substitution
|
---|
| 181 | </para>
|
---|
[e180a646] | 182 | </listitem>
|
---|
| 183 | <listitem>
|
---|
[71df408] | 184 | <para>
|
---|
| 185 | 40-49 map family to generic type
|
---|
| 186 | </para>
|
---|
[e180a646] | 187 | </listitem>
|
---|
| 188 | <listitem>
|
---|
[71df408] | 189 | <para>
|
---|
| 190 | 50-59 load alternate config files
|
---|
| 191 | </para>
|
---|
[e180a646] | 192 | </listitem>
|
---|
| 193 | <listitem>
|
---|
[71df408] | 194 | <para>
|
---|
| 195 | 60-69 generic aliases, map generic to family
|
---|
| 196 | </para>
|
---|
[e180a646] | 197 | </listitem>
|
---|
| 198 | <listitem>
|
---|
[71df408] | 199 | <para>
|
---|
| 200 | 70-79 adjust which fonts are available
|
---|
| 201 | </para>
|
---|
[e180a646] | 202 | </listitem>
|
---|
| 203 | <listitem>
|
---|
[71df408] | 204 | <para>
|
---|
| 205 | 80-89 match target scan (modify scanned patterns)
|
---|
| 206 | </para>
|
---|
[e180a646] | 207 | </listitem>
|
---|
| 208 | <listitem>
|
---|
[71df408] | 209 | <para>
|
---|
| 210 | 90-99 font synthesis
|
---|
| 211 | </para>
|
---|
[e180a646] | 212 | </listitem>
|
---|
| 213 | </itemizedlist>
|
---|
| 214 |
|
---|
| 215 | <para>
|
---|
| 216 | You can also have a personal <filename>fonts.conf</filename> in
|
---|
| 217 | $XDG_CONFIG_HOME which is <filename
|
---|
| 218 | class="directory">~/.config/fontconfig/</filename>.
|
---|
| 219 | </para>
|
---|
| 220 |
|
---|
| 221 | </sect2>
|
---|
| 222 |
|
---|
| 223 | <sect2 role="configuration" id="rules-to-choose-a-font" xreflabel="The rules to choose a font">
|
---|
| 224 | <title>The rules to choose a font</title>
|
---|
| 225 |
|
---|
| 226 | <para>
|
---|
| 227 | If the requested font is installed, and provided it contains the
|
---|
| 228 | codepoints <emphasis>required</emphasis> for the current language (in the
|
---|
| 229 | source, see the .orth files in the <filename
|
---|
| 230 | class="directory">fc-lang/</filename> directory), it will be used.
|
---|
| 231 | </para>
|
---|
| 232 |
|
---|
| 233 | <para>
|
---|
| 234 | But if the document or page requested a font which is not installed
|
---|
| 235 | (or, occasionally, does not contain all the required codepoints) the
|
---|
| 236 | following rules come into play: First,
|
---|
| 237 | <filename>30-metric-aliases.conf</filename> is used to map aliases for
|
---|
| 238 | some fonts with the same metrics (same size, etc). After that, an
|
---|
| 239 | unknown font will be searched for in <filename>45-latin.conf</filename> -
|
---|
| 240 | if it is found it will be mapped as Serif or Monospace or Sans, otherwise
|
---|
| 241 | it will be assumed to be Sans. Then <filename>50-latin.conf</filename>
|
---|
| 242 | provides ordered lists of the fallbacks - <xref linkend="dejavu-fonts"/>
|
---|
| 243 | will be used if you installed them. Cyrillic and Greek appear to be
|
---|
| 244 | treated in the same way. There are similar files with a 65- prefix for
|
---|
| 245 | Persian and other non-latin writing systems. All of these files prefer
|
---|
| 246 | commercial fonts if they are present, although modern libre fonts are
|
---|
| 247 | often at least their equals.
|
---|
| 248 | </para>
|
---|
| 249 |
|
---|
[c068b99] | 250 | <para>
|
---|
| 251 | Since fontconfig-2.12.5 there is also generic family matching for some
|
---|
| 252 | emoji and math fonts, see {45,60}-generic.conf.
|
---|
| 253 | </para>
|
---|
| 254 |
|
---|
[e180a646] | 255 | <para>
|
---|
| 256 | In the rare cases where a font does not contain all the expected
|
---|
| 257 | codepoints, see 'Trial the First:' at <xref
|
---|
| 258 | linkend="I-stared-into-the-fontconfig"/> for the long details.
|
---|
| 259 | </para>
|
---|
| 260 |
|
---|
| 261 | </sect2>
|
---|
| 262 |
|
---|
[3470d743] | 263 | <sect2 role="configuration" id="hinting-and-antialiasing" xreflabel="Hinting and Anti-aliasing">
|
---|
[e180a646] | 264 | <title>Hinting and Anti-aliasing</title>
|
---|
| 265 |
|
---|
| 266 | <para>
|
---|
| 267 | It is possible to change how, or if, fonts are hinted. The following
|
---|
| 268 | example file contains the default settings, but with comments. The
|
---|
| 269 | settings are very much down to the user's preferences and to the choice
|
---|
| 270 | of fonts, so a change which improves some pages may worsen others. The
|
---|
| 271 | preferred location for this file is:
|
---|
| 272 | <filename>~/.config/fontconfig/fonts.conf</filename>
|
---|
| 273 | </para>
|
---|
| 274 |
|
---|
| 275 | <para>
|
---|
| 276 | To try out different settings, you may need to exit from Xorg and then
|
---|
| 277 | rerun <command>startx</command> so that all applications use the new
|
---|
| 278 | settings. And if you use Gnome or KDE their desktops can override these
|
---|
| 279 | changes. To explore the possibilities, create a file for your user:
|
---|
| 280 | </para>
|
---|
| 281 |
|
---|
[6bc10a26] | 282 | <screen><userinput>mkdir -pv ~/.config/fontconfig &&
|
---|
[e180a646] | 283 | cat > ~/.config/fontconfig/fonts.conf << "EOF"
|
---|
| 284 | <literal><?xml version='1.0'?>
|
---|
| 285 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 286 | <fontconfig>
|
---|
| 287 |
|
---|
| 288 | <match target="font" >
|
---|
| 289 | <!-- autohint was the old automatic hinter when hinting was patent
|
---|
| 290 | protected, so turn it off to ensure any hinting information in the font
|
---|
| 291 | itself is used, this is the default -->
|
---|
[6bc10a26] | 292 | <edit mode="assign" name="autohint"> <bool>false</bool></edit>
|
---|
[024b208] | 293 |
|
---|
[e180a646] | 294 | <!-- hinting is enabled by default -->
|
---|
| 295 | <edit mode="assign" name="hinting"> <bool>true</bool></edit>
|
---|
[8558044] | 296 |
|
---|
[e180a646] | 297 | <!-- for the lcdfilter see http://www.spasche.net/files/lcdfiltering/ -->
|
---|
| 298 | <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
|
---|
[8558044] | 299 |
|
---|
[e180a646] | 300 | <!-- options for hintstyle:
|
---|
| 301 | hintfull: is supposed to give a crisp font that aligns well to the
|
---|
| 302 | character-cell grid but at the cost of its proper shape.
|
---|
[024b208] | 303 |
|
---|
[e180a646] | 304 | hintmedium: poorly documented, maybe a synonym for hintfull.
|
---|
| 305 | hintslight is the default: - supposed to be more fuzzy but retains shape.
|
---|
[8558044] | 306 |
|
---|
[e180a646] | 307 | hintnone: seems to turn hinting off.
|
---|
| 308 | The variations are marginal and results vary with different fonts -->
|
---|
| 309 | <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
|
---|
[8558044] | 310 |
|
---|
[e180a646] | 311 | <!-- antialiasing is on by default and really helps for faint characters
|
---|
| 312 | and also for 'xft:' fonts used in rxvt-unicode -->
|
---|
| 313 | <edit mode="assign" name="antialias"> <bool>true</bool></edit>
|
---|
[8558044] | 314 |
|
---|
[e180a646] | 315 | <!-- subpixels are usually rgb, see
|
---|
| 316 | http://www.lagom.nl/lcd-test/subpixel.php -->
|
---|
| 317 | <edit mode="assign" name="rgba"> <const>rgb</const></edit>
|
---|
[8558044] | 318 |
|
---|
[e180a646] | 319 | <!-- thanks to the Arch wiki for the lcd and subpixel links -->
|
---|
| 320 | </match>
|
---|
| 321 |
|
---|
| 322 | </fontconfig></literal>
|
---|
| 323 | EOF</userinput></screen>
|
---|
| 324 |
|
---|
| 325 | <para>
|
---|
| 326 | You will now need to edit the file in your preferred editor.
|
---|
| 327 | </para>
|
---|
| 328 |
|
---|
| 329 | <para>
|
---|
| 330 | For more examples see the blfs-support thread which started at <ulink
|
---|
[6679bb0] | 331 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00128.html">2016-09/00128</ulink>,
|
---|
[e180a646] | 332 | particularly <ulink
|
---|
[6679bb0] | 333 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00137.html">2016-09/00137</ulink>,
|
---|
[e180a646] | 334 | and the original poster's preferred solution at <ulink
|
---|
[6679bb0] | 335 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00147.html">2016-09/00147</ulink>.
|
---|
[e180a646] | 336 | There are other examples in <xref linkend="arch-fontconfig"/> and <xref
|
---|
| 337 | linkend="gentoo-fontconfig"/>.
|
---|
| 338 | </para>
|
---|
| 339 |
|
---|
| 340 | </sect2>
|
---|
| 341 |
|
---|
| 342 | <sect2 role="configuration" id="disabling-bitmap-fonts" xreflabel="Disabling Bitmap fonts">
|
---|
| 343 | <title>Disabling Bitmap Fonts</title>
|
---|
| 344 |
|
---|
| 345 | <para>
|
---|
| 346 | In previous versions of BLFS, the ugly old Xorg bitmap fonts were
|
---|
| 347 | installed. Now, many people will not need to install any of them. But if
|
---|
| 348 | for some reason you have installed one or more bitmap fonts, you can
|
---|
| 349 | prevent them being used by <application>fontconfig</application> by
|
---|
| 350 | creating the following file as the
|
---|
| 351 | <systemitem class="username">root</systemitem> user :
|
---|
| 352 | </para>
|
---|
| 353 |
|
---|
| 354 | <screen role="root"><userinput>cat > /etc/fonts/conf.d/70-no-bitmaps.conf << "EOF"
|
---|
| 355 | <literal><?xml version='1.0'?>
|
---|
| 356 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 357 | <fontconfig>
|
---|
| 358 | <!-- Reject bitmap fonts -->
|
---|
| 359 | <selectfont>
|
---|
| 360 | <rejectfont>
|
---|
| 361 | <pattern>
|
---|
| 362 | <patelt name="scalable"><bool>false</bool></patelt>
|
---|
| 363 | </pattern>
|
---|
| 364 | </rejectfont>
|
---|
| 365 | </selectfont>
|
---|
| 366 | </fontconfig></literal>
|
---|
| 367 | EOF</userinput></screen>
|
---|
| 368 |
|
---|
| 369 | </sect2>
|
---|
| 370 |
|
---|
| 371 | <sect2 role="configuration" id="adding-extra-directories" xreflabel="Adding extra font directories">
|
---|
| 372 | <title>Adding extra font directories</title>
|
---|
| 373 |
|
---|
| 374 | <para>
|
---|
| 375 | Normally, system fonts and user fonts are installed in directories beneath
|
---|
| 376 | the locations specified in <xref linkend="xft-font-protocol"/> and there
|
---|
| 377 | is no obvious reason to put them elsewhere. However, a full BLFS install
|
---|
| 378 | of <xref linkend="texlive"/> puts many fonts in <filename
|
---|
| 379 | class="directory">/opt/texlive/&texlive-year;/texmf-dist/fonts/</filename>
|
---|
| 380 | in the <filename class="directory">opentype/</filename> and <filename
|
---|
| 381 | class="directory">truetype/</filename> subdirectories. Although pulling in
|
---|
| 382 | all of these files may appear useful (it allows you to use them in non
|
---|
| 383 | <application>TeX</application> programs), there are several problems with
|
---|
| 384 | such an approach:
|
---|
| 385 | </para>
|
---|
| 386 |
|
---|
| 387 | <orderedlist>
|
---|
| 388 | <listitem>
|
---|
| 389 | <para>
|
---|
| 390 | There are hundreds of files, which makes selecting the font hard.
|
---|
| 391 | </para>
|
---|
| 392 | </listitem>
|
---|
| 393 | <listitem>
|
---|
| 394 | <para>
|
---|
| 395 | Some of the files do odd things, such as displaying semaphore flags
|
---|
| 396 | instead of ASCII letters, or mapping cyrillic codepoints to character
|
---|
| 397 | forms appropriate to Old Church Slavonic instead of the expected
|
---|
| 398 | current shapes: fine if that is what you need, but painful for normal
|
---|
| 399 | use.
|
---|
| 400 | </para>
|
---|
| 401 | </listitem>
|
---|
| 402 | <listitem>
|
---|
| 403 | <para>
|
---|
| 404 | Several fonts have multiple sizes and impenetrable short names, which
|
---|
| 405 | both make selecting the correct font even harder.
|
---|
| 406 | </para>
|
---|
| 407 | </listitem>
|
---|
| 408 | <listitem>
|
---|
| 409 | <para>
|
---|
| 410 | When a font is added to CTAN, it is accompanied by TeX packages to use
|
---|
| 411 | it in the old engines (<application>xelatex</application> does not
|
---|
| 412 | normally need this), and then the version is often frozen whilst the
|
---|
| 413 | font is separately maintained. Some of these fonts such as <xref
|
---|
| 414 | linkend="dejavu-fonts"/> are probably already installed on your BLFS
|
---|
| 415 | system in a newer version, and if you have multiple versions of a font
|
---|
| 416 | it is unclear which one will be used by
|
---|
| 417 | <application>fontconfig</application>.
|
---|
| 418 | </para>
|
---|
| 419 | </listitem>
|
---|
| 420 | </orderedlist>
|
---|
| 421 |
|
---|
| 422 | <para>
|
---|
| 423 | However, it is sometimes useful to look at these fonts in non-TeX
|
---|
| 424 | applications, if only to see whether you wish to install a current
|
---|
| 425 | version. If you have installed all of <application>texlive</application>,
|
---|
| 426 | the following example will make one of the Arkandis Open Type fonts
|
---|
| 427 | available to other applications, and all three of the ParaType TrueType
|
---|
| 428 | fonts. Adjust or repeat the lines as desired, to either make all the
|
---|
| 429 | <filename class="directory">opentype/</filename> or <filename
|
---|
| 430 | class="directory">truetype</filename>fonts available, or to select
|
---|
| 431 | different font directories. As the <systemitem
|
---|
| 432 | class="username">root</systemitem> user:
|
---|
| 433 | </para>
|
---|
| 434 |
|
---|
| 435 | <screen role="root"><userinput>cat > /etc/fonts/conf.d/09-texlive.conf << "EOF"
|
---|
| 436 | <literal><?xml version='1.0'?>
|
---|
| 437 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 438 | <fontconfig>
|
---|
| 439 | <dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/opentype/arkandis/berenisadf</dir>
|
---|
| 440 | <dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/truetype/paratype</dir>
|
---|
| 441 | </fontconfig></literal>
|
---|
| 442 | EOF</userinput></screen>
|
---|
| 443 |
|
---|
| 444 | <para>
|
---|
| 445 | If you do this, remember to change all instances of the year in that file
|
---|
| 446 | when you upgrade <application>texlive</application> to a later release.
|
---|
| 447 | </para>
|
---|
| 448 |
|
---|
| 449 | </sect2>
|
---|
| 450 |
|
---|
| 451 |
|
---|
| 452 | <sect2 role="configuration" id="preferring-certain-fonts" xreflabel="Preferring certain fonts">
|
---|
| 453 | <title>Preferring certain fonts</title>
|
---|
| 454 |
|
---|
| 455 | <para>
|
---|
| 456 | There are many reasons why people may wish to have pages which specify a
|
---|
| 457 | particular font use a different font, or prefer specific fonts in
|
---|
| 458 | Monospace or Sans or Serif. As you will expect, there a number of
|
---|
| 459 | different ways of achieving this.
|
---|
| 460 | </para>
|
---|
| 461 |
|
---|
| 462 | <bridgehead renderas="sect3" id="fontconfig-user-docs"
|
---|
| 463 | xreflabel="fontconfig-user-docs">Fontconfig user docs</bridgehead>
|
---|
| 464 |
|
---|
| 465 | <para>
|
---|
| 466 | <application>Fontconfig</application> installs user documentation that
|
---|
| 467 | includes an example 'User configuration file' which among other things
|
---|
| 468 | prefers <xref linkend="wenquanyi-zenhei"/> (a Sans font) if a
|
---|
| 469 | <emphasis>Serif</emphasis> font is requested for Chinese (this part
|
---|
| 470 | might be anachronistic unless you have non-free Chinese fonts, because
|
---|
| 471 | in <filename>65-nonlatin.conf</filename> this font is already among the
|
---|
| 472 | preferred fonts when Serif is specified for Chinese) and to prefer the
|
---|
| 473 | modern <xref linkend="VLGothic"/> font if a Sans font is specified on a
|
---|
| 474 | Japanese page (otherwise a couple of other fonts would be preferred if
|
---|
| 475 | they have been installed).
|
---|
| 476 | </para>
|
---|
| 477 |
|
---|
| 478 | <para>
|
---|
| 479 | If you have installed the current version, the user documentation is
|
---|
| 480 | available in html, PDF and text versions at <filename
|
---|
| 481 | class="directory">/usr/share/doc/fontconfig-&fontconfig-version;/</filename>
|
---|
| 482 | : change the version if you installed a different one.
|
---|
| 483 | </para>
|
---|
| 484 |
|
---|
| 485 | <bridgehead renderas="sect3" id="prefer-a-specific-font"
|
---|
| 486 | xreflabel="fontconfig-prefer-specific-font">Prefer a specific font</bridgehead>
|
---|
| 487 |
|
---|
| 488 | <para>
|
---|
| 489 | As an example, if for some reason you wished to use the <ulink
|
---|
| 490 | url="https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus Roman
|
---|
| 491 | No9 L</ulink> font wherever Times New Roman is referenced (it is
|
---|
| 492 | metrically similar, and preferred for Times Roman, but the Serif font
|
---|
| 493 | from <xref linkend="liberation-fonts"/> will be preferred for the Times
|
---|
| 494 | <emphasis>New</emphasis> Roman font if installed), as an individual user
|
---|
| 495 | you could install the font and then create the following file:
|
---|
| 496 | </para>
|
---|
| 497 |
|
---|
| 498 | <screen><userinput>mkdir -pv ~/.config/fontconfig/conf.d &&
|
---|
| 499 | cat > ~/.config/fontconfig/conf.d/35-prefer-nimbus-for-timesnew.conf << "EOF"
|
---|
| 500 | <literal><?xml version='1.0'?>
|
---|
| 501 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 502 | <fontconfig>
|
---|
| 503 | <!-- prefer Nimbus Roman No9 L for Times New Roman as well as for Times,
|
---|
| 504 | without this Tinos and Liberation Serif take precedence for Times New Roman
|
---|
| 505 | before fontconfig falls back to whatever matches Times -->
|
---|
| 506 | <alias binding="same">
|
---|
| 507 | <family>Times New Roman</family>
|
---|
| 508 | <accept>
|
---|
| 509 | <family>Nimbus Roman No9 L</family>
|
---|
| 510 | </accept>
|
---|
| 511 | </alias>
|
---|
| 512 | </fontconfig></literal>
|
---|
| 513 | EOF</userinput></screen>
|
---|
| 514 |
|
---|
| 515 | <para>
|
---|
| 516 | This is something you would normally do in an individual user's
|
---|
| 517 | settings, but the file in this case has been prefixed '35-' so that it
|
---|
| 518 | could, if desired, be used system-wide in <filename
|
---|
| 519 | class="directory">/etc/fonts/conf.d/</filename>.
|
---|
| 520 | </para>
|
---|
| 521 |
|
---|
| 522 | <bridgehead renderas="sect3" id="prefer-chosen-CJK-fonts"
|
---|
| 523 | xreflabel="Prefer chosen CJK fonts">Prefer chosen CJK fonts</bridgehead>
|
---|
| 524 |
|
---|
| 525 | <para>
|
---|
| 526 | The following example of a local configuration (i.e. one that applies
|
---|
| 527 | for all users of the machine) does several things:
|
---|
| 528 | </para>
|
---|
| 529 |
|
---|
| 530 | <orderedlist>
|
---|
| 531 | <listitem>
|
---|
| 532 | <para>
|
---|
| 533 | If a Serif font is specified, it will prefer the <xref
|
---|
| 534 | linkend="UMing"/> variants, so that in the zh-cn, zh-hk and zh-tw
|
---|
| 535 | languages things should look good (also zh-sg which actually uses
|
---|
| 536 | the same settings as zh-cn) <emphasis>without</emphasis> affecting
|
---|
| 537 | Japanese.
|
---|
| 538 | </para>
|
---|
| 539 | </listitem>
|
---|
| 540 | <listitem>
|
---|
| 541 | <para>
|
---|
| 542 | It prefers the Japanese <xref linkend="IPAex"/> if they have been
|
---|
| 543 | installed (although <xref linkend="VLGothic"/> will take precedence
|
---|
| 544 | for (Japanese) Sans if it has also been installed.
|
---|
| 545 | </para>
|
---|
| 546 | </listitem>
|
---|
| 547 | <listitem>
|
---|
| 548 | <para>
|
---|
| 549 | Because <xref linkend="wenquanyi-zenhei"/> covers Korean Hangul
|
---|
| 550 | glyphs and is also preferred for Serif in
|
---|
| 551 | <filename>65-nonlatin.conf</filename>, if installed it will be used
|
---|
| 552 | by default for Korean Serif. To get a proper Serif font, the
|
---|
| 553 | UnBatang font is specified here - change that line if you installed
|
---|
| 554 | a different Serif font from the choice of <xref
|
---|
| 555 | linkend="Korean-fonts"/>.
|
---|
| 556 | </para>
|
---|
| 557 | </listitem>
|
---|
| 558 | <listitem>
|
---|
| 559 | <para>
|
---|
| 560 | The Monospace fonts are forced to the preferred Sans fonts. If the
|
---|
| 561 | text is in Korean then <xref linkend="wenquanyi-zenhei"/> will be
|
---|
| 562 | used.
|
---|
| 563 | </para>
|
---|
| 564 | </listitem>
|
---|
| 565 | </orderedlist>
|
---|
| 566 |
|
---|
| 567 | <para>
|
---|
| 568 | In a non-CJK locale, the result is that suitable fonts will be used for
|
---|
| 569 | all variants of Chinese, Japanese and Hangul Korean. All other languages
|
---|
| 570 | should already work if a font is present. As the <systemitem
|
---|
| 571 | class="username">root</systemitem> user:
|
---|
| 572 | </para>
|
---|
| 573 |
|
---|
| 574 | <screen role="root"><userinput>cat > /etc/fonts/local.conf << "EOF"
|
---|
| 575 | <literal><?xml version='1.0'?>
|
---|
| 576 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 577 | <fontconfig>
|
---|
| 578 | <alias>
|
---|
| 579 | <family>serif</family>
|
---|
| 580 | <prefer>
|
---|
| 581 | <family>AR PL UMing</family>
|
---|
| 582 | <family>IPAexMincho</family>
|
---|
| 583 | <!-- WenQuanYi is preferred as Serif in 65-nonlatin.conf,
|
---|
| 584 | override that so a real Korean font can be used for Serif -->
|
---|
| 585 | <family>UnBatang</family>
|
---|
| 586 | </prefer>
|
---|
| 587 | </alias>
|
---|
| 588 | <alias>
|
---|
| 589 | <family>sans-serif</family>
|
---|
| 590 | <prefer>
|
---|
| 591 | <family>WenQuanYi Zen Hei</family>
|
---|
| 592 | <family>VL Gothic</family>
|
---|
| 593 | <family>IPAexGothic</family>
|
---|
| 594 | </prefer>
|
---|
| 595 | </alias>
|
---|
| 596 | <alias>
|
---|
| 597 | <family>monospace</family>
|
---|
| 598 | <prefer>
|
---|
| 599 | <family>VL Gothic</family>
|
---|
| 600 | <family>IPAexGothic</family>
|
---|
| 601 | <family>WenQuanYi Zen Hei</family>
|
---|
| 602 | </prefer>
|
---|
| 603 | </alias>
|
---|
| 604 | </fontconfig></literal>
|
---|
| 605 | EOF</userinput></screen>
|
---|
| 606 |
|
---|
| 607 | </sect2>
|
---|
| 608 |
|
---|
| 609 |
|
---|
| 610 | <sect2 role="configuration" id="editing-old-style-conf-files"
|
---|
| 611 | xreflabel="Editing Old-Style conf files">
|
---|
| 612 | <title>Editing Old-style conf files</title>
|
---|
| 613 |
|
---|
| 614 | <para>
|
---|
| 615 | Some fonts, particularly Chinese fonts, ship with conf files which can be
|
---|
| 616 | installed in <filename class="directory">/etc/fonts/conf.d</filename>.
|
---|
| 617 | However, if you do that and then use a terminal to run any command which
|
---|
| 618 | uses <application>fontconfig</application> you may see error messages such
|
---|
| 619 | as :
|
---|
| 620 | </para>
|
---|
| 621 |
|
---|
| 622 | <para>
|
---|
| 623 | <literal>Fontconfig warning: "/etc/fonts/conf.d/69-odofonts.conf", line
|
---|
| 624 | 14: Having multiple <family> in <alias> isn't supported and
|
---|
| 625 | may not work as expected</literal>.
|
---|
| 626 | </para>
|
---|
| 627 |
|
---|
| 628 | <para>
|
---|
| 629 | In practice, these old rules do not work. For non-CJK users,
|
---|
| 630 | <application>fontconfig</application> will usually do a good job
|
---|
| 631 | <emphasis>without</emphasis> these rules. Their origin dates back to when
|
---|
| 632 | CJK users needed handcrafted bitmaps to be legible at small sizes, and
|
---|
| 633 | those looked ugly next to antialiased Latin glyphs - they preferred to
|
---|
| 634 | use the same CJK font for the Latin glyphs. There is a side-effect of
|
---|
| 635 | doing this : the (Serif) font is often also used for Sans, and in such a
|
---|
| 636 | situation the (English) text in <application>Gtk</application> menus will
|
---|
| 637 | use this font - compared to system fonts, as well as being serif it is
|
---|
| 638 | both faint and rather small. That can make it uncomfortable to read.
|
---|
| 639 | </para>
|
---|
| 640 |
|
---|
| 641 | <para>
|
---|
| 642 | Nevertheless, these old conf files can be fixed if you wish to use them.
|
---|
| 643 | The following example is the first part of
|
---|
| 644 | <filename>64-arphic-uming.conf</filename> from <xref linkend="UMing"/> -
|
---|
| 645 | there are a lot more similar items which also need changing :
|
---|
| 646 | </para>
|
---|
| 647 |
|
---|
| 648 | <para>
|
---|
| 649 | <literallayout>
|
---|
| 650 | <match target="pattern">
|
---|
| 651 | <test qual="any" name="lang" compare="contains">
|
---|
| 652 | <string>zh-cn</string>
|
---|
| 653 | <string>zh-sg</string>
|
---|
| 654 | </test>
|
---|
| 655 | <test qual="any" name="family">
|
---|
| 656 | <string>serif</string>
|
---|
| 657 | </test>
|
---|
| 658 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 659 | <string>AR PL UMing CN</string>
|
---|
| 660 | </edit>
|
---|
| 661 | </match></literallayout>
|
---|
| 662 | </para>
|
---|
| 663 |
|
---|
| 664 | <para>
|
---|
| 665 | The process to correct this is straightforward but tedious - for every
|
---|
| 666 | item which produces an error message, using your editor (as the
|
---|
| 667 | <systemitem class="username">root</systemitem> user) edit the installed
|
---|
| 668 | file to repeat the whole block as many times as there are multiple
|
---|
| 669 | variables, then reduce each example to have only one of them. You may
|
---|
| 670 | wish to work on one error at a time, save the file after each fix, and
|
---|
| 671 | from a separate term run a command such as <command>fc-list 2>&1 |
|
---|
| 672 | less</command> to see that the fix worked. For the block above, the fixed
|
---|
| 673 | version will be :
|
---|
| 674 | </para>
|
---|
| 675 |
|
---|
| 676 | <para>
|
---|
| 677 | <literallayout>
|
---|
| 678 | <match target="pattern">
|
---|
| 679 | <test qual="any" name="lang" compare="contains">
|
---|
| 680 | <string>zh-cn</string>
|
---|
| 681 | </test>
|
---|
| 682 | <test qual="any" name="family">
|
---|
| 683 | <string>serif</string>
|
---|
| 684 | </test>
|
---|
| 685 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 686 | <string>AR PL UMing CN</string>
|
---|
| 687 | </edit>
|
---|
| 688 | </match>
|
---|
| 689 | <match target="pattern">
|
---|
| 690 | <test qual="any" name="lang" compare="contains">
|
---|
| 691 | <string>zh-sg</string>
|
---|
| 692 | </test>
|
---|
| 693 | <test qual="any" name="family">
|
---|
| 694 | <string>serif</string>
|
---|
| 695 | </test>
|
---|
| 696 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 697 | <string>AR PL UMing CN</string>
|
---|
| 698 | </edit>
|
---|
| 699 | </match></literallayout>
|
---|
| 700 | </para>
|
---|
| 701 |
|
---|
| 702 | </sect2>
|
---|
| 703 |
|
---|
| 704 |
|
---|
| 705 | <sect2 role="configuration" id="see-also" xreflabel="See Also">
|
---|
| 706 | <title>See Also</title>
|
---|
| 707 |
|
---|
| 708 | <bridgehead renderas="sect3" id="I-stared-into-the-fontconfig"
|
---|
| 709 | xreflabel="I stared into the fontconfig">I stared into the fontconfig ...</bridgehead>
|
---|
| 710 |
|
---|
| 711 | <para>
|
---|
| 712 | The blog entries by <ulink
|
---|
| 713 | url="https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/">Eevee</ulink>
|
---|
| 714 | are particularly useful if <application>fontconfig</application> does not
|
---|
| 715 | think your chosen font supports your language, and for preferring some
|
---|
| 716 | non-MS Japanese fonts when an ugly MS font is already installed.
|
---|
| 717 | </para>
|
---|
| 718 |
|
---|
| 719 | <bridgehead renderas="sect3" id="arch-fontconfig"
|
---|
| 720 | xreflabel="Fontconfig in the Arch wiki">Fontconfig in the Arch wiki</bridgehead>
|
---|
| 721 |
|
---|
| 722 | <para>
|
---|
| 723 | Arch has a lot of information in its wiki at <ulink
|
---|
| 724 | url="https://wiki.archlinux.org/index.php/font_configuration">font_configuration</ulink>.
|
---|
| 725 | </para>
|
---|
| 726 |
|
---|
| 727 | <bridgehead renderas="sect3" id="gentoo-fontconfig"
|
---|
| 728 | xreflabel="Fontconfig in the Gentoo wiki">Fontconfig in the Gentoo wiki</bridgehead>
|
---|
| 729 |
|
---|
| 730 | <para>
|
---|
| 731 | Gentoo has some information in its wiki at <ulink
|
---|
| 732 | url="https://wiki.gentoo.org/wiki/Fontconfig">Fontconfig</ulink> although
|
---|
| 733 | a lot of the details (what to enable, and Infinality) are specific to
|
---|
| 734 | Gentoo.
|
---|
| 735 | </para>
|
---|
| 736 |
|
---|
| 737 | </sect2>
|
---|
| 738 |
|
---|
| 739 | </sect1>
|
---|