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