[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
|
---|
[82ea9e2] | 28 | details of how <application>Fontconfig</application> works. But there are
|
---|
[e180a646] | 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
|
---|
[abbf9a3] | 37 | to understand the changes you are making, why they may not always work,
|
---|
| 38 | and to identify online information which is no-longer appropriate.
|
---|
| 39 | </para>
|
---|
| 40 |
|
---|
| 41 | <para>
|
---|
| 42 | Unfortunately, some of the terminology is ambiguous (e.g. 'font face' can
|
---|
[82ea9e2] | 43 | mean a name known to Fontconfig, <emphasis>or</emphasis> the ordinary,
|
---|
[abbf9a3] | 44 | condensed, etc variations of a font).
|
---|
[e180a646] | 45 | </para>
|
---|
| 46 |
|
---|
[9d8ea23] | 47 | <para>The following links are to assist navigation in this page.</para>
|
---|
| 48 | <itemizedlist>
|
---|
| 49 | <listitem>
|
---|
| 50 | <para><xref linkend="xft-font-protocol"/></para>
|
---|
| 51 | </listitem>
|
---|
| 52 | <listitem>
|
---|
| 53 | <para><xref linkend="useful-commands"/></para>
|
---|
| 54 | </listitem>
|
---|
| 55 | <listitem>
|
---|
| 56 | <para><xref linkend="the-various-files"/></para>
|
---|
| 57 | </listitem>
|
---|
| 58 | <listitem>
|
---|
| 59 | <para><xref linkend="rules-to-choose-a-font"/></para>
|
---|
| 60 | </listitem>
|
---|
| 61 | <listitem>
|
---|
| 62 | <para><xref linkend="hinting-and-antialiasing"/></para>
|
---|
| 63 | </listitem>
|
---|
| 64 | <listitem>
|
---|
| 65 | <para><xref linkend="disabling-bitmap-fonts"/></para>
|
---|
| 66 | </listitem>
|
---|
[fc07c4bc] | 67 | <listitem>
|
---|
| 68 | <para><xref linkend="synthetic-changes"/></para>
|
---|
| 69 | </listitem>
|
---|
[9d8ea23] | 70 | <listitem>
|
---|
| 71 | <para><xref linkend="adding-extra-directories"/></para>
|
---|
| 72 | </listitem>
|
---|
| 73 | <listitem>
|
---|
| 74 | <para><xref linkend="preferring-certain-fonts"/></para>
|
---|
| 75 | </listitem>
|
---|
| 76 | <listitem>
|
---|
| 77 | <para><xref linkend="fontconfig-user-docs"/></para>
|
---|
| 78 | </listitem>
|
---|
| 79 | <listitem>
|
---|
| 80 | <para><xref linkend="prefer-a-specific-font"/></para>
|
---|
| 81 | </listitem>
|
---|
| 82 | <listitem>
|
---|
| 83 | <para><xref linkend="prefer-chosen-CJK-fonts"/></para>
|
---|
| 84 | </listitem>
|
---|
| 85 | <listitem>
|
---|
| 86 | <para><xref linkend="editing-old-style-conf-files"/></para>
|
---|
| 87 | </listitem>
|
---|
[b52945a] | 88 | <listitem>
|
---|
| 89 | <para><xref linkend="font-weights"/></para>
|
---|
| 90 | </listitem>
|
---|
[dcc1b92] | 91 | <listitem>
|
---|
| 92 | <para><xref linkend="items-which-can-override-fontconfig"/></para>
|
---|
| 93 | </listitem>
|
---|
[9d8ea23] | 94 | <listitem>
|
---|
[ac35d3b] | 95 | <para><xref linkend="external-links"/></para>
|
---|
[9d8ea23] | 96 | </listitem>
|
---|
| 97 | </itemizedlist>
|
---|
| 98 |
|
---|
[e180a646] | 99 | </sect2>
|
---|
| 100 |
|
---|
| 101 | <sect2 role="configuration" id="xft-font-protocol" xreflabel="The Xft Font Protocol">
|
---|
| 102 | <title>The Xft Font Protocol</title>
|
---|
| 103 |
|
---|
| 104 | <para>
|
---|
| 105 | The Xft font protocol provides antialiased font rendering through
|
---|
| 106 | <application>freetype</application>, and fonts are controlled from the
|
---|
[82ea9e2] | 107 | client side using <application>Fontconfig</application> (except for
|
---|
[e180a646] | 108 | <xref linkend="rxvt-unicode"/> which can use fonts listed in
|
---|
| 109 | <filename>~/.Xresources</filename>, and <xref linkend="abiword"/> which
|
---|
[8251b48] | 110 | only uses the specified font). The default search path is <filename
|
---|
[e180a646] | 111 | class="directory">/usr/share/fonts</filename> and <filename
|
---|
[8251b48] | 112 | class="directory">~/.local/share/fonts</filename>, although for the moment
|
---|
[e180a646] | 113 | the old and deprecated location <filename
|
---|
| 114 | class="directory">~/.fonts</filename> still works.
|
---|
| 115 | <application>Fontconfig</application> searches directories in its path
|
---|
| 116 | recursively and maintains a cache of the font characteristics in each
|
---|
[8251b48] | 117 | directory. If the cache appears to be out of date, it is ignored, and
|
---|
[e180a646] | 118 | information is fetched from the fonts themselves (that can take a few
|
---|
[8251b48] | 119 | seconds if you have a lot of fonts installed).
|
---|
[e180a646] | 120 | </para>
|
---|
| 121 |
|
---|
| 122 | <para>
|
---|
| 123 | If you've installed <application>Xorg</application> in any prefix
|
---|
| 124 | other than <filename class="directory">/usr</filename>, any
|
---|
| 125 | <application>X</application> fonts were not installed in a
|
---|
| 126 | location known to <application>Fontconfig</application>. Symlinks were
|
---|
| 127 | <!-- fonts-misc-ethiopic installs an OTF directory ! -->
|
---|
| 128 | created from the <filename class="directory">OTF</filename> and <filename
|
---|
| 129 | class="directory">TTF</filename> <application>X</application> font
|
---|
| 130 | directories to <filename
|
---|
| 131 | class="directory">/usr/share/fonts/X11-{OTF,TTF}</filename>. This allows
|
---|
| 132 | <application>Fontconfig</application> to use the OpenType and TrueType
|
---|
| 133 | fonts provided by <application>X</application>, although many people will
|
---|
| 134 | prefer to use more modern fonts.
|
---|
| 135 | </para>
|
---|
| 136 |
|
---|
| 137 | <para>
|
---|
| 138 | <application>Fontconfig</application> uses names to define fonts.
|
---|
| 139 | Applications generally use generic font names such as "Monospace", "Sans"
|
---|
| 140 | and "Serif". <application>Fontconfig</application> resolves these names
|
---|
| 141 | to a font that has all characters that cover the orthography of the
|
---|
| 142 | language indicated by the locale settings.
|
---|
| 143 | </para>
|
---|
| 144 |
|
---|
| 145 | </sect2>
|
---|
| 146 |
|
---|
| 147 | <sect2 role="configuration" id="useful-commands" xreflabel="Useful Commands">
|
---|
| 148 | <title>Useful Commands</title>
|
---|
| 149 |
|
---|
| 150 | <para>
|
---|
[82ea9e2] | 151 | The following commands may be helpful when working with Fontconfig,
|
---|
[9d8ea23] | 152 | particularly if you are interested in overriding which font will be
|
---|
| 153 | chosen. 'TYPE' should be one of serif, sans-serif or monospace.
|
---|
[e180a646] | 154 | </para>
|
---|
| 155 |
|
---|
| 156 | <para>
|
---|
[8251b48] | 157 | <command>fc-list | less</command> : shows a list of all available fonts
|
---|
[e180a646] | 158 | (/path/to/filename: Font Name:style). If you installed a font more than
|
---|
| 159 | 30 seconds ago but it does not show, then it or one of its directories is
|
---|
| 160 | not readable by your user.
|
---|
| 161 | </para>
|
---|
| 162 |
|
---|
| 163 | <para>
|
---|
[8251b48] | 164 | <command>fc-match 'Font Name'</command> : tells you which font will
|
---|
[e180a646] | 165 | be used if the named font is requested. Typically you would use this to
|
---|
| 166 | see what happens if a font you have not installed is requested, but you
|
---|
| 167 | can also use it if the system is giving you a different font from
|
---|
[82ea9e2] | 168 | what you expected (perhaps because <application>Fontconfig</application>
|
---|
[8251b48] | 169 | does not think that the font supports your language).
|
---|
[e180a646] | 170 | </para>
|
---|
| 171 |
|
---|
| 172 | <para>
|
---|
[9d8ea23] | 173 | <command>fc-match -a <replaceable>Type</replaceable> | less</command> :
|
---|
| 174 | provides a list of all fonts which can be used for that type (Monospace,
|
---|
[82ea9e2] | 175 | Sans Sans-serif, Serif <emphasis>(capital letters optional)</emphasis>).
|
---|
| 176 | Note that in-extremis <application>Fontconfig</application> will take a
|
---|
[9d8ea23] | 177 | glyph from any available font, even if it is not of the specified type,
|
---|
| 178 | and unless it knows about the font's type it will assume it is Sans.
|
---|
[e180a646] | 179 | </para>
|
---|
| 180 |
|
---|
[92924fb8] | 181 | <para>
|
---|
| 182 | <command>fc-match 'Serif :lang=ja:weight=bold'</command> will tell you
|
---|
| 183 | which font and weight will be chosen for Japanese text in bold weight.
|
---|
| 184 | It does not mean that the reported font will necessarily be able to show
|
---|
| 185 | Japanese ideograms, so a fallback might be used, or some glyphs may be
|
---|
[9d8ea23] | 186 | missing. For language codes use ISO-639 value such as 'fr', 'ja', 'zh-cn'.
|
---|
| 187 | Note that an unrecognized value such as just 'zh' will not return any
|
---|
| 188 | match. To illustrate the fallback, on a system wherei both Noto Sans Mono
|
---|
| 189 | and DejaVu Sans Mono are installed, <command>fc-match 'monospace
|
---|
| 190 | :lang=en</command> shows Noto Sans Mono will be used, but if the lang is
|
---|
| 191 | changed to 'ar' (arabic) DejaVu Sans will be used.
|
---|
[92924fb8] | 192 | </para>
|
---|
| 193 |
|
---|
[e73a0309] | 194 | <para>
|
---|
| 195 | If you want to determine if a font file has hinting (many older fonts do not,
|
---|
| 196 | because it was patented) use <command>fc-query
|
---|
| 197 | <replaceable>/path/to/fontfile</replaceable> | grep 'fonthashint:'</command>:
|
---|
| 198 | which will report 'True(s)' or 'False(s)'.
|
---|
| 199 | </para>
|
---|
| 200 |
|
---|
[e180a646] | 201 | <para>
|
---|
| 202 | If you wish to know which font will be used for a string of text
|
---|
| 203 | (i.e. one or more glyphs, preceded by a space), paste the following
|
---|
| 204 | command and replace the <literal>xyz</literal> by the text you care
|
---|
| 205 | about:
|
---|
| 206 | </para>
|
---|
| 207 |
|
---|
| 208 | <para>
|
---|
| 209 | <command>FC_DEBUG=4 pango-view --font=monospace -t xyz | grep
|
---|
| 210 | family</command> : this requires <xref linkend="pango"/> and <xref
|
---|
| 211 | linkend="imagemagick"/> - it will invoke <xref linkend="display"/>
|
---|
| 212 | to show the text in a tiny window, and after closing that the last
|
---|
| 213 | line of the output will show which font was chosen. This is
|
---|
| 214 | particularly useful for CJK languages, and you can also pass a
|
---|
| 215 | language, e.g. PANGO_LANGUAGE=en;ja (English, then assume Japanese)
|
---|
[9d8ea23] | 216 | or just zh-cn (or other variants such as zh-sg or zh-tw).
|
---|
[e180a646] | 217 | </para>
|
---|
| 218 |
|
---|
| 219 | </sect2>
|
---|
| 220 |
|
---|
[9d8ea23] | 221 | <sect2 role="configuration" id="the-various-files" xreflabel="The configuration files">
|
---|
[3ff7901] | 222 | <title>The configuration files</title>
|
---|
[e180a646] | 223 |
|
---|
| 224 | <para>
|
---|
[bee7026] | 225 | The main files are in <filename class="directory">/etc/fonts/conf.d/</filename>,
|
---|
| 226 | which was intended to be a directory populated by symlinks to some of the files
|
---|
| 227 | in <filename class="directory">/usr/share/fontconfig/conf.avail/</filename>.
|
---|
| 228 | But many people, and some packages, create the files directly. Each file name
|
---|
[e180a646] | 229 | must be in the form of two digits, a dash, somename.conf and they are read in
|
---|
| 230 | sequence.
|
---|
| 231 | </para>
|
---|
| 232 |
|
---|
| 233 | <para>
|
---|
| 234 | By convention, the numbers are assigned as follows:
|
---|
| 235 | </para>
|
---|
| 236 |
|
---|
| 237 | <itemizedlist>
|
---|
| 238 | <listitem>
|
---|
[71df408] | 239 | <para>
|
---|
| 240 | 00-09 extra font directories
|
---|
| 241 | </para>
|
---|
[e180a646] | 242 | </listitem>
|
---|
| 243 | <listitem>
|
---|
[71df408] | 244 | <para>
|
---|
[8251b48] | 245 | 10-19 system rendering defaults (such as antialiasing)
|
---|
[71df408] | 246 | </para>
|
---|
[e180a646] | 247 | </listitem>
|
---|
| 248 | <listitem>
|
---|
[71df408] | 249 | <para>
|
---|
| 250 | 20-29 font rendering options
|
---|
| 251 | </para>
|
---|
[e180a646] | 252 | </listitem>
|
---|
| 253 | <listitem>
|
---|
[71df408] | 254 | <para>
|
---|
| 255 | 30-39 family substitution
|
---|
| 256 | </para>
|
---|
[e180a646] | 257 | </listitem>
|
---|
| 258 | <listitem>
|
---|
[71df408] | 259 | <para>
|
---|
| 260 | 40-49 map family to generic type
|
---|
| 261 | </para>
|
---|
[e180a646] | 262 | </listitem>
|
---|
| 263 | <listitem>
|
---|
[71df408] | 264 | <para>
|
---|
| 265 | 50-59 load alternate config files
|
---|
| 266 | </para>
|
---|
[e180a646] | 267 | </listitem>
|
---|
| 268 | <listitem>
|
---|
[71df408] | 269 | <para>
|
---|
| 270 | 60-69 generic aliases, map generic to family
|
---|
| 271 | </para>
|
---|
[e180a646] | 272 | </listitem>
|
---|
| 273 | <listitem>
|
---|
[71df408] | 274 | <para>
|
---|
| 275 | 70-79 adjust which fonts are available
|
---|
| 276 | </para>
|
---|
[e180a646] | 277 | </listitem>
|
---|
| 278 | <listitem>
|
---|
[71df408] | 279 | <para>
|
---|
| 280 | 80-89 match target scan (modify scanned patterns)
|
---|
| 281 | </para>
|
---|
[e180a646] | 282 | </listitem>
|
---|
| 283 | <listitem>
|
---|
[71df408] | 284 | <para>
|
---|
| 285 | 90-99 font synthesis
|
---|
| 286 | </para>
|
---|
[e180a646] | 287 | </listitem>
|
---|
| 288 | </itemizedlist>
|
---|
| 289 |
|
---|
| 290 | <para>
|
---|
| 291 | You can also have a personal <filename>fonts.conf</filename> in
|
---|
[8251b48] | 292 | $XDG_CONFIG_HOME (which is <filename
|
---|
| 293 | class="directory">~/.config/fontconfig/</filename>).
|
---|
[e180a646] | 294 | </para>
|
---|
| 295 |
|
---|
| 296 | </sect2>
|
---|
| 297 |
|
---|
| 298 | <sect2 role="configuration" id="rules-to-choose-a-font" xreflabel="The rules to choose a font">
|
---|
| 299 | <title>The rules to choose a font</title>
|
---|
| 300 |
|
---|
| 301 | <para>
|
---|
| 302 | If the requested font is installed, and provided it contains the
|
---|
| 303 | codepoints <emphasis>required</emphasis> for the current language (in the
|
---|
| 304 | source, see the .orth files in the <filename
|
---|
| 305 | class="directory">fc-lang/</filename> directory), it will be used.
|
---|
| 306 | </para>
|
---|
| 307 |
|
---|
| 308 | <para>
|
---|
[8251b48] | 309 | However, if the document or page requested a font which is not installed
|
---|
[e180a646] | 310 | (or, occasionally, does not contain all the required codepoints) the
|
---|
| 311 | following rules come into play: First,
|
---|
| 312 | <filename>30-metric-aliases.conf</filename> is used to map aliases for
|
---|
[1f9b99f] | 313 | some fonts with the same metrics (same size, etc). Note that there are
|
---|
| 314 | both weak and strong aliases so that aliases for one form such as
|
---|
[18024d6] | 315 | Helvetica or Times New Roman can be satisfied by the other style, i.e.
|
---|
[f101c437] | 316 | anything which is an alias of Arial or Times in those examples. some
|
---|
[3d1f9716] | 317 | examples of Latin fonts with the same metrics can be found in the
|
---|
| 318 | 'Substitutes' PDFs at <ulink
|
---|
| 319 | url="http://zarniwhoop.uk/files/PDF-substitutes/">zarniwhoop.uk.)</ulink>
|
---|
[f101c437] | 320 | </para>
|
---|
| 321 |
|
---|
| 322 | <para>
|
---|
[1f9b99f] | 323 | After that, an unknown font will be searched for in
|
---|
| 324 | <filename>45-latin.conf</filename>:
|
---|
[d1d1e5d] | 325 | 'Latin' covers Cyrillic and Greek, and now also maps system-ui fonts which
|
---|
| 326 | are used for User Interface messages in other alphabets. If the font
|
---|
[fe9d1b1d] | 327 | is found it will be mapped as serif, sans-serif, monospace, fantasy,
|
---|
| 328 | cursive, or system-ui. Otherwise, 49-sansserif.conf will assume it is
|
---|
[1f9b99f] | 329 | Sans.
|
---|
| 330 | </para>
|
---|
| 331 | <para>
|
---|
| 332 | Then <filename>60-latin.conf</filename>
|
---|
| 333 | provides ordered lists of the fallbacks - <xref linkend="noto-fonts"/>
|
---|
[e180a646] | 334 | will be used if you installed them. Cyrillic and Greek appear to be
|
---|
[3ff7901] | 335 | treated in the same way.All of these files prefer
|
---|
[e180a646] | 336 | commercial fonts if they are present, although modern libre fonts are
|
---|
[1f9b99f] | 337 | often at least equal. Finally, if a codepoint is still not found it can
|
---|
| 338 | be taken from any available system font. The following details only
|
---|
| 339 | mention freely available fonts.
|
---|
| 340 | </para>
|
---|
| 341 |
|
---|
| 342 | <para>
|
---|
[3ff7901] | 343 | Default Persion fonts are dealt with in
|
---|
| 344 | <filename>65-fonts-persian.conf</filename>. It looks as if all the listed
|
---|
| 345 | fonts are commercial. Using fonts that support Persian (which has its own
|
---|
| 346 | variant of the arabic alphabet, and its own font styles) is outside the
|
---|
| 347 | skills of the BLFS editors.
|
---|
| 348 | </para>
|
---|
| 349 |
|
---|
| 350 | <para>
|
---|
[82ea9e2] | 351 | All remaining scripts for which Fontconfig has preferences (CJK scripts,
|
---|
[3ff7901] | 352 | Indic scripts) are dealt with in <filename>65-nonlatin.conf</filename>.
|
---|
| 353 | These are again nominally grouped as Serif, Sans-Serif, Monospace. Of the
|
---|
| 354 | free fonts, WenQuanYi Zen Hei (Pan-CJK Sans) comes first for both Serif
|
---|
| 355 | and for Sans. Therefore, if you install this as a fallback but want to
|
---|
| 356 | use different fonts for Japanese or Korean you will need to set up a
|
---|
| 357 | preference. Similarly, the old fireflysung Serif font is also listed for
|
---|
| 358 | Sans.
|
---|
| 359 | </para>
|
---|
| 360 |
|
---|
| 361 | <para>
|
---|
| 362 | After Pan-CJK and Chinese fonts come several Japanese fonts and then
|
---|
| 363 | several Korean fonts (both split appropriately between Sans and Serif).
|
---|
| 364 | Finally come the various Lohit Indic families (one font file per script),
|
---|
| 365 | labelled as both Sans and Serif.
|
---|
| 366 | </para>
|
---|
| 367 |
|
---|
| 368 | <para>
|
---|
| 369 | The Monospace fonts listed in <filename>65-nonlatin.conf</filename> do
|
---|
| 370 | not include WenQuanYi Zen Hei although that will be available as a
|
---|
| 371 | fallback if installed. Several Japanese Gothic fonts are listed, followed
|
---|
| 372 | by AR PL KaitiM GB (a zh-sc 'Brush' font), AR PL Serif fonts for zh-sc
|
---|
| 373 | (SungtiL) and zh-tw (Mingti2L), some Korean Sans fonts and the various
|
---|
| 374 | Lohit Indic families.
|
---|
| 375 | </para>
|
---|
| 376 |
|
---|
| 377 | <para>
|
---|
| 378 | For UI fonts, various Noto Sans UI fonts are the only listed free fonts.
|
---|
| 379 | </para>
|
---|
| 380 |
|
---|
| 381 | <para>
|
---|
| 382 | The various Noto CJK fonts are <emphasis>not</emphasis> among the listed
|
---|
| 383 | fonts, possibly the RedHat developers preferred other fonts. These now
|
---|
| 384 | come in many variations, probably anyone who uses these will not install
|
---|
| 385 | any other CJK fonts.
|
---|
| 386 | </para>
|
---|
| 387 |
|
---|
| 388 | <para>
|
---|
[82ea9e2] | 389 | Before Fontconfig-2.14, the first preferred Latin font family was Bitstream
|
---|
[1f9b99f] | 390 | Vera. In practice that was rarely used because it covered so little. After
|
---|
| 391 | that, DejaVu was the next preferred family, so people were recommended to
|
---|
| 392 | install that. That has now changed, Bitstream Vera has been replaced by the
|
---|
| 393 | relevant Noto fonts (Serif, Sans, Sans Mono), so these will be preferred if
|
---|
| 394 | they have been installed, followed by DejaVu.
|
---|
| 395 | </para>
|
---|
| 396 |
|
---|
| 397 | <para>
|
---|
| 398 | For serif, Times New Roman could have been aliased from Liberation Serif or
|
---|
| 399 | Tinos, and Times from TeX Gyre Termes, so although the named fonts are not
|
---|
| 400 | free, the metric-compatilbe fonts can be used. Ignoring other non-free fonts,
|
---|
| 401 | the remaining order for serif is: Times New Roman, Luxi Serif, Nimbus Roman
|
---|
| 402 | No9 L, Times. In practice, that means those fonts at the end of the list
|
---|
| 403 | are unlikely to be used unless a web page asks for them.
|
---|
| 404 | </para>
|
---|
| 405 |
|
---|
| 406 | <para>
|
---|
| 407 | For sans-serif, the remaining order is anything mapped to Arial, Luxi Sans,
|
---|
| 408 | Nimbus Sans L, anything mapped to Helvetica.
|
---|
| 409 | </para>
|
---|
| 410 |
|
---|
| 411 | <para>
|
---|
| 412 | The remaining alternatives for monospace are Inconsolata, anything mapped
|
---|
| 413 | to Courier New, Luxi Mono, Nimbus Mono, anything mapped to Courier.
|
---|
| 414 | </para>
|
---|
| 415 |
|
---|
| 416 | <para>
|
---|
[82ea9e2] | 417 | For 'fantasy' there are no free fonts, so Fontconfig will fall back to
|
---|
[1f9b99f] | 418 | sans-serif.
|
---|
| 419 | </para>
|
---|
| 420 |
|
---|
| 421 | <para>
|
---|
| 422 | For 'cursive', the only free font is TeX Gyre Chorus as an alias for
|
---|
[82ea9e2] | 423 | ITC Zapf chancery, otherwise Fontconfig will again fall back to sans-serif.
|
---|
[1f9b99f] | 424 | </para>
|
---|
| 425 |
|
---|
| 426 | <para>
|
---|
| 427 | The system-ui category is unusual. It is for interface messages, so some
|
---|
[d1d1e5d] | 428 | scripts need special versions to fit in the available space. For Latin,
|
---|
[18024d6] | 429 | Greek and Cyrillic an ordinary sans font should fit without problems. However,
|
---|
[1f9b99f] | 430 | the first preferred font is Cantarell, followed by Noto Sans UI. Cantarell
|
---|
[d1d1e5d] | 431 | started as a Latin sans-serif font, that has been forked in Gnome under
|
---|
[1f9b99f] | 432 | the same name but they only provide the source. The Noto Sans UI fonts are
|
---|
| 433 | for other languages.
|
---|
[e180a646] | 434 | </para>
|
---|
| 435 |
|
---|
[c068b99] | 436 | <para>
|
---|
[82ea9e2] | 437 | Since Fontconfig-2.12.5, there is also generic family matching for some
|
---|
[8251b48] | 438 | emoji and math fonts, please see {45,60}-generic.conf.
|
---|
[c068b99] | 439 | </para>
|
---|
| 440 |
|
---|
[e180a646] | 441 | <para>
|
---|
| 442 | In the rare cases where a font does not contain all the expected
|
---|
| 443 | codepoints, see 'Trial the First:' at <xref
|
---|
| 444 | linkend="I-stared-into-the-fontconfig"/> for the long details.
|
---|
| 445 | </para>
|
---|
| 446 |
|
---|
| 447 | </sect2>
|
---|
| 448 |
|
---|
[3470d743] | 449 | <sect2 role="configuration" id="hinting-and-antialiasing" xreflabel="Hinting and Anti-aliasing">
|
---|
[e180a646] | 450 | <title>Hinting and Anti-aliasing</title>
|
---|
| 451 |
|
---|
| 452 | <para>
|
---|
| 453 | It is possible to change how, or if, fonts are hinted. The following
|
---|
| 454 | example file contains the default settings, but with comments. The
|
---|
| 455 | settings are very much down to the user's preferences and to the choice
|
---|
| 456 | of fonts, so a change which improves some pages may worsen others. The
|
---|
| 457 | preferred location for this file is:
|
---|
| 458 | <filename>~/.config/fontconfig/fonts.conf</filename>
|
---|
| 459 | </para>
|
---|
| 460 |
|
---|
| 461 | <para>
|
---|
| 462 | To try out different settings, you may need to exit from Xorg and then
|
---|
[8251b48] | 463 | run <command>startx</command> again so that all applications use the new
|
---|
[dcc1b92] | 464 | settings. Several things can override the fontconfig settings, see
|
---|
| 465 | <xref linkend="items-which-can-override-fontconfig"/> below. To explore
|
---|
| 466 | the possibilities, create a file for your user:
|
---|
[e180a646] | 467 | </para>
|
---|
| 468 |
|
---|
[6bc10a26] | 469 | <screen><userinput>mkdir -pv ~/.config/fontconfig &&
|
---|
[e180a646] | 470 | cat > ~/.config/fontconfig/fonts.conf << "EOF"
|
---|
| 471 | <literal><?xml version='1.0'?>
|
---|
| 472 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 473 | <fontconfig>
|
---|
| 474 |
|
---|
| 475 | <match target="font" >
|
---|
| 476 | <!-- autohint was the old automatic hinter when hinting was patent
|
---|
| 477 | protected, so turn it off to ensure any hinting information in the font
|
---|
| 478 | itself is used, this is the default -->
|
---|
[6bc10a26] | 479 | <edit mode="assign" name="autohint"> <bool>false</bool></edit>
|
---|
[024b208] | 480 |
|
---|
[e180a646] | 481 | <!-- hinting is enabled by default -->
|
---|
| 482 | <edit mode="assign" name="hinting"> <bool>true</bool></edit>
|
---|
[8558044] | 483 |
|
---|
[87fc185] | 484 | <!-- for the lcdfilter see https://www.spasche.net/files/lcdfiltering/ -->
|
---|
[e180a646] | 485 | <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
|
---|
[8558044] | 486 |
|
---|
[e180a646] | 487 | <!-- options for hintstyle:
|
---|
| 488 | hintfull: is supposed to give a crisp font that aligns well to the
|
---|
[f072b06f] | 489 | character-cell grid but at the cost of its proper shape. However, anything
|
---|
| 490 | using Pango >= 1.44 will not support full hinting, Pango now uses harfbuzz
|
---|
| 491 | for hinting. Apps which use Skia (e.g. Chromium, Firefox) should not be
|
---|
| 492 | affected by this. <!-- https://github.com/harfbuzz/harfbuzz/issues/2394 -->
|
---|
[024b208] | 493 |
|
---|
[f98db52] | 494 | hintmedium: is reported to be broken.
|
---|
[e180a646] | 495 | hintslight is the default: - supposed to be more fuzzy but retains shape.
|
---|
[8558044] | 496 |
|
---|
[e180a646] | 497 | hintnone: seems to turn hinting off.
|
---|
| 498 | The variations are marginal and results vary with different fonts -->
|
---|
| 499 | <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
|
---|
[8558044] | 500 |
|
---|
[e180a646] | 501 | <!-- antialiasing is on by default and really helps for faint characters
|
---|
| 502 | and also for 'xft:' fonts used in rxvt-unicode -->
|
---|
| 503 | <edit mode="assign" name="antialias"> <bool>true</bool></edit>
|
---|
[8558044] | 504 |
|
---|
[e180a646] | 505 | <!-- subpixels are usually rgb, see
|
---|
| 506 | http://www.lagom.nl/lcd-test/subpixel.php -->
|
---|
| 507 | <edit mode="assign" name="rgba"> <const>rgb</const></edit>
|
---|
[8558044] | 508 |
|
---|
[e180a646] | 509 | <!-- thanks to the Arch wiki for the lcd and subpixel links -->
|
---|
| 510 | </match>
|
---|
| 511 |
|
---|
| 512 | </fontconfig></literal>
|
---|
| 513 | EOF</userinput></screen>
|
---|
| 514 |
|
---|
| 515 | <para>
|
---|
[f98db52] | 516 | You will now need to edit the file in your preferred editor. Many of the
|
---|
| 517 | different settings give very subtle differences and the results may differ
|
---|
| 518 | for some of the fonts you use.
|
---|
[e180a646] | 519 | </para>
|
---|
| 520 |
|
---|
[f98db52] | 521 | <note>
|
---|
| 522 | <para>
|
---|
| 523 | Hinting, if enabled, is done in <application>FreeType</application>.
|
---|
| 524 | Since FreeType-2.7 the default TrueType interpreter is v40. The
|
---|
| 525 | original v35 hinter could be enabled by an environment variable, but
|
---|
| 526 | is only really appropriate to original Microsoft TTF fonts (Arial, etc).
|
---|
| 527 | The v38 hinter (Infinality) is not built by default and all the options
|
---|
| 528 | to tune it have been removed. For full details see <xref
|
---|
| 529 | linkend="subpixel-hinting"/> (Spoiler: there is NO sub-pixel hinting,
|
---|
| 530 | the code simply ignores <emphasis>all</emphasis> horizontal hinting
|
---|
| 531 | instructions.
|
---|
| 532 | </para>
|
---|
[9fc45066] | 533 |
|
---|
| 534 | <para>
|
---|
| 535 | Xorg assumes screens have 96 dots per inch (DPI). Most LCD screens are
|
---|
| 536 | close to this, but some people detect colour fringing if their screen
|
---|
| 537 | diverges from that size. See <xref linkend="calc-dpi"/>.
|
---|
| 538 | </para>
|
---|
| 539 |
|
---|
| 540 | <para>
|
---|
| 541 | If you have a High DPI screen (often described as '4K' or larger) you
|
---|
| 542 | will probably use larger font sizes and benefit from disabling hinting.
|
---|
| 543 | </para>
|
---|
[f98db52] | 544 | </note>
|
---|
| 545 |
|
---|
[e180a646] | 546 | <para>
|
---|
| 547 | For more examples see the blfs-support thread which started at <ulink
|
---|
[6679bb0] | 548 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00128.html">2016-09/00128</ulink>,
|
---|
[e180a646] | 549 | particularly <ulink
|
---|
[6679bb0] | 550 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00137.html">2016-09/00137</ulink>,
|
---|
[e180a646] | 551 | and the original poster's preferred solution at <ulink
|
---|
[6679bb0] | 552 | url="https://lists.linuxfromscratch.org/sympa/arc/blfs-support/2016-09/msg00147.html">2016-09/00147</ulink>.
|
---|
[e180a646] | 553 | There are other examples in <xref linkend="arch-fontconfig"/> and <xref
|
---|
| 554 | linkend="gentoo-fontconfig"/>.
|
---|
| 555 | </para>
|
---|
| 556 |
|
---|
| 557 | </sect2>
|
---|
| 558 |
|
---|
| 559 | <sect2 role="configuration" id="disabling-bitmap-fonts" xreflabel="Disabling Bitmap fonts">
|
---|
| 560 | <title>Disabling Bitmap Fonts</title>
|
---|
| 561 |
|
---|
| 562 | <para>
|
---|
| 563 | In previous versions of BLFS, the ugly old Xorg bitmap fonts were
|
---|
| 564 | installed. Now, many people will not need to install any of them. But if
|
---|
| 565 | for some reason you have installed one or more bitmap fonts, you can
|
---|
[82ea9e2] | 566 | prevent them from being used by <application>Fontconfig</application> by
|
---|
[8251b48] | 567 | creating the following file as the &root; user :
|
---|
[e180a646] | 568 | </para>
|
---|
| 569 |
|
---|
| 570 | <screen role="root"><userinput>cat > /etc/fonts/conf.d/70-no-bitmaps.conf << "EOF"
|
---|
| 571 | <literal><?xml version='1.0'?>
|
---|
| 572 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 573 | <fontconfig>
|
---|
| 574 | <!-- Reject bitmap fonts -->
|
---|
| 575 | <selectfont>
|
---|
| 576 | <rejectfont>
|
---|
| 577 | <pattern>
|
---|
| 578 | <patelt name="scalable"><bool>false</bool></patelt>
|
---|
| 579 | </pattern>
|
---|
| 580 | </rejectfont>
|
---|
| 581 | </selectfont>
|
---|
| 582 | </fontconfig></literal>
|
---|
| 583 | EOF</userinput></screen>
|
---|
| 584 |
|
---|
| 585 | </sect2>
|
---|
| 586 |
|
---|
[fc07c4bc] | 587 | <sect2 role="configuration" id="synthetic-changes" xreflabel="Synthetic changes">
|
---|
| 588 | <title>Synthetic changes</title>
|
---|
| 589 |
|
---|
| 590 | <para>
|
---|
| 591 | In <filename>90-synthetic.conf</filename> there are examples of applying
|
---|
| 592 | synthetic slanting and emboldening to a font. The synthetic emboldening can
|
---|
| 593 | be applied to a visibly faint font, but the results are not always as
|
---|
| 594 | expected: With just the embolden, <application>epiphany</application> showed
|
---|
| 595 | darker font, <application>firefox</application> did not - so although
|
---|
| 596 | <application>cairo</application> is now used by
|
---|
| 597 | <application>firefox</application> the comment about setting Weight is still
|
---|
| 598 | valid. But setting both, <application>epiphany</application> will show bold text
|
---|
| 599 | by default, but heavy text if markup for bold is used. In both cases, neither
|
---|
| 600 | <application>libreOffice</application> nor <application>falkon</application>
|
---|
| 601 | showed bolder text.
|
---|
| 602 | </para>
|
---|
| 603 |
|
---|
| 604 | </sect2>
|
---|
| 605 |
|
---|
[e180a646] | 606 | <sect2 role="configuration" id="adding-extra-directories" xreflabel="Adding extra font directories">
|
---|
| 607 | <title>Adding extra font directories</title>
|
---|
| 608 |
|
---|
| 609 | <para>
|
---|
| 610 | Normally, system fonts and user fonts are installed in directories beneath
|
---|
| 611 | the locations specified in <xref linkend="xft-font-protocol"/> and there
|
---|
| 612 | is no obvious reason to put them elsewhere. However, a full BLFS install
|
---|
| 613 | of <xref linkend="texlive"/> puts many fonts in <filename
|
---|
| 614 | class="directory">/opt/texlive/&texlive-year;/texmf-dist/fonts/</filename>
|
---|
| 615 | in the <filename class="directory">opentype/</filename> and <filename
|
---|
| 616 | class="directory">truetype/</filename> subdirectories. Although pulling in
|
---|
| 617 | all of these files may appear useful (it allows you to use them in non
|
---|
| 618 | <application>TeX</application> programs), there are several problems with
|
---|
| 619 | such an approach:
|
---|
| 620 | </para>
|
---|
| 621 |
|
---|
| 622 | <orderedlist>
|
---|
| 623 | <listitem>
|
---|
| 624 | <para>
|
---|
[8251b48] | 625 | There are hundreds of files, which makes selecting fonts difficult.
|
---|
[e180a646] | 626 | </para>
|
---|
| 627 | </listitem>
|
---|
| 628 | <listitem>
|
---|
| 629 | <para>
|
---|
| 630 | Some of the files do odd things, such as displaying semaphore flags
|
---|
| 631 | instead of ASCII letters, or mapping cyrillic codepoints to character
|
---|
| 632 | forms appropriate to Old Church Slavonic instead of the expected
|
---|
| 633 | current shapes: fine if that is what you need, but painful for normal
|
---|
| 634 | use.
|
---|
| 635 | </para>
|
---|
| 636 | </listitem>
|
---|
| 637 | <listitem>
|
---|
| 638 | <para>
|
---|
| 639 | Several fonts have multiple sizes and impenetrable short names, which
|
---|
[8251b48] | 640 | both make selecting the correct font even more difficult.
|
---|
[e180a646] | 641 | </para>
|
---|
| 642 | </listitem>
|
---|
| 643 | <listitem>
|
---|
| 644 | <para>
|
---|
| 645 | When a font is added to CTAN, it is accompanied by TeX packages to use
|
---|
| 646 | it in the old engines (<application>xelatex</application> does not
|
---|
| 647 | normally need this), and then the version is often frozen whilst the
|
---|
| 648 | font is separately maintained. Some of these fonts such as <xref
|
---|
| 649 | linkend="dejavu-fonts"/> are probably already installed on your BLFS
|
---|
| 650 | system in a newer version, and if you have multiple versions of a font
|
---|
| 651 | it is unclear which one will be used by
|
---|
[82ea9e2] | 652 | <application>Fontconfig</application>.
|
---|
[e180a646] | 653 | </para>
|
---|
| 654 | </listitem>
|
---|
| 655 | </orderedlist>
|
---|
| 656 |
|
---|
| 657 | <para>
|
---|
| 658 | However, it is sometimes useful to look at these fonts in non-TeX
|
---|
| 659 | applications, if only to see whether you wish to install a current
|
---|
| 660 | version. If you have installed all of <application>texlive</application>,
|
---|
| 661 | the following example will make one of the Arkandis Open Type fonts
|
---|
| 662 | available to other applications, and all three of the ParaType TrueType
|
---|
| 663 | fonts. Adjust or repeat the lines as desired, to either make all the
|
---|
| 664 | <filename class="directory">opentype/</filename> or <filename
|
---|
| 665 | class="directory">truetype</filename>fonts available, or to select
|
---|
| 666 | different font directories. As the <systemitem
|
---|
| 667 | class="username">root</systemitem> user:
|
---|
| 668 | </para>
|
---|
| 669 |
|
---|
| 670 | <screen role="root"><userinput>cat > /etc/fonts/conf.d/09-texlive.conf << "EOF"
|
---|
| 671 | <literal><?xml version='1.0'?>
|
---|
| 672 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 673 | <fontconfig>
|
---|
| 674 | <dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/opentype/arkandis/berenisadf</dir>
|
---|
| 675 | <dir>/opt/texlive/&texlive-year;/texmf-dist/fonts/truetype/paratype</dir>
|
---|
| 676 | </fontconfig></literal>
|
---|
| 677 | EOF</userinput></screen>
|
---|
| 678 |
|
---|
| 679 | <para>
|
---|
| 680 | If you do this, remember to change all instances of the year in that file
|
---|
| 681 | when you upgrade <application>texlive</application> to a later release.
|
---|
| 682 | </para>
|
---|
| 683 |
|
---|
| 684 | </sect2>
|
---|
| 685 |
|
---|
| 686 | <sect2 role="configuration" id="preferring-certain-fonts" xreflabel="Preferring certain fonts">
|
---|
| 687 | <title>Preferring certain fonts</title>
|
---|
| 688 |
|
---|
| 689 | <para>
|
---|
[895b457] | 690 | With the exception of web pages which use WOFF fonts and either supply
|
---|
| 691 | them or link to google to download them, web pages have traditionally
|
---|
| 692 | suggested a list of preferred font family names if they cared (e.g.
|
---|
| 693 | Times New Roman, Serif). There are many reasons why people may wish to
|
---|
| 694 | have pages which specify a preferred font use a different font, or
|
---|
| 695 | prefer specific fonts in Monospace or Sans or Serif. As you will expect,
|
---|
| 696 | there a number of different ways of achieving this.
|
---|
[e180a646] | 697 | </para>
|
---|
| 698 |
|
---|
| 699 | <bridgehead renderas="sect3" id="fontconfig-user-docs"
|
---|
[abbf9a3] | 700 | xreflabel="Fontconfig user documentation">Fontconfig user documentation</bridgehead>
|
---|
[e180a646] | 701 |
|
---|
| 702 | <para>
|
---|
| 703 | <application>Fontconfig</application> installs user documentation that
|
---|
| 704 | includes an example 'User configuration file' which among other things
|
---|
[4e207bb] | 705 | prefers <xref linkend="wenquanyi-zenhei"/> (a Sans font) if a
|
---|
[e180a646] | 706 | <emphasis>Serif</emphasis> font is requested for Chinese (this part
|
---|
| 707 | might be anachronistic unless you have non-free Chinese fonts, because
|
---|
| 708 | in <filename>65-nonlatin.conf</filename> this font is already among the
|
---|
| 709 | preferred fonts when Serif is specified for Chinese) and to prefer the
|
---|
| 710 | modern <xref linkend="VLGothic"/> font if a Sans font is specified on a
|
---|
| 711 | Japanese page (otherwise a couple of other fonts would be preferred if
|
---|
| 712 | they have been installed).
|
---|
| 713 | </para>
|
---|
| 714 |
|
---|
| 715 | <para>
|
---|
| 716 | If you have installed the current version, the user documentation is
|
---|
[8251b48] | 717 | available in HTML, PDF, and text versions at <filename
|
---|
[e180a646] | 718 | class="directory">/usr/share/doc/fontconfig-&fontconfig-version;/</filename>
|
---|
| 719 | : change the version if you installed a different one.
|
---|
| 720 | </para>
|
---|
| 721 |
|
---|
| 722 | <bridgehead renderas="sect3" id="prefer-a-specific-font"
|
---|
[abbf9a3] | 723 | xreflabel="Prefer a specific font">Prefer a specific font</bridgehead>
|
---|
[e180a646] | 724 |
|
---|
| 725 | <para>
|
---|
| 726 | As an example, if for some reason you wished to use the <ulink
|
---|
| 727 | url="https://www.fontsquirrel.com/fonts/nimbus-roman-no9-l">Nimbus Roman
|
---|
| 728 | No9 L</ulink> font wherever Times New Roman is referenced (it is
|
---|
| 729 | metrically similar, and preferred for Times Roman, but the Serif font
|
---|
| 730 | from <xref linkend="liberation-fonts"/> will be preferred for the Times
|
---|
| 731 | <emphasis>New</emphasis> Roman font if installed), as an individual user
|
---|
| 732 | you could install the font and then create the following file:
|
---|
| 733 | </para>
|
---|
| 734 |
|
---|
| 735 | <screen><userinput>mkdir -pv ~/.config/fontconfig/conf.d &&
|
---|
| 736 | cat > ~/.config/fontconfig/conf.d/35-prefer-nimbus-for-timesnew.conf << "EOF"
|
---|
| 737 | <literal><?xml version='1.0'?>
|
---|
| 738 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 739 | <fontconfig>
|
---|
| 740 | <!-- prefer Nimbus Roman No9 L for Times New Roman as well as for Times,
|
---|
| 741 | without this Tinos and Liberation Serif take precedence for Times New Roman
|
---|
[82ea9e2] | 742 | before Fontconfig falls back to whatever matches Times -->
|
---|
[e180a646] | 743 | <alias binding="same">
|
---|
| 744 | <family>Times New Roman</family>
|
---|
| 745 | <accept>
|
---|
| 746 | <family>Nimbus Roman No9 L</family>
|
---|
| 747 | </accept>
|
---|
| 748 | </alias>
|
---|
| 749 | </fontconfig></literal>
|
---|
| 750 | EOF</userinput></screen>
|
---|
| 751 |
|
---|
| 752 | <para>
|
---|
| 753 | This is something you would normally do in an individual user's
|
---|
| 754 | settings, but the file in this case has been prefixed '35-' so that it
|
---|
| 755 | could, if desired, be used system-wide in <filename
|
---|
| 756 | class="directory">/etc/fonts/conf.d/</filename>.
|
---|
| 757 | </para>
|
---|
| 758 |
|
---|
| 759 | <bridgehead renderas="sect3" id="prefer-chosen-CJK-fonts"
|
---|
| 760 | xreflabel="Prefer chosen CJK fonts">Prefer chosen CJK fonts</bridgehead>
|
---|
| 761 |
|
---|
| 762 | <para>
|
---|
| 763 | The following example of a local configuration (i.e. one that applies
|
---|
[24975c4] | 764 | for all users of the machine) does several things. It is particularly
|
---|
| 765 | appropriate where no language is specified, or for reading CJK text
|
---|
| 766 | in a non-CJK locale, and where the Japanese forms of the codepoints
|
---|
| 767 | shared with Chinese are preferred. In particular, alternative
|
---|
| 768 | approaches would be to specify a Chinese font ahead of the Japanese
|
---|
| 769 | font, meaning that only Kana symbols will be used from the Japanese
|
---|
| 770 | font, or to not specify DejaVu so that the first font in each set
|
---|
[d1d1e5d] | 771 | of preferences is preferred for text using Latin alphabets.
|
---|
[e180a646] | 772 | </para>
|
---|
| 773 |
|
---|
| 774 | <orderedlist>
|
---|
| 775 | <listitem>
|
---|
| 776 | <para>
|
---|
[24975c4] | 777 | If a Serif font is specified, it prefers <xref linkend="dejavu-fonts"/>.
|
---|
| 778 | If Han codepoints are found, or the Japanese language is specified,
|
---|
| 779 | the Mincho font from <xref linkend="IPAex"/> will be used. If Hangul
|
---|
| 780 | codepoints are found or the Korean language is specified, UnBatang
|
---|
| 781 | (see <xref linkend="Korean-fonts"/>) will be used: Change that line
|
---|
| 782 | If you installed a different Korean serif font. After that,
|
---|
| 783 | <xref linkend="wenquanyi-zenhei"/> (Sans, but a default for Serif
|
---|
| 784 | and monospace) is used. A previous version of this page mentioned
|
---|
[18024d6] | 785 | using UMing which is a Traditional Chinese font that ships
|
---|
[24975c4] | 786 | with an old conf file preferring it for zh-tw and zh-hk language
|
---|
| 787 | codes (and for sans-serif and monospace). But without the conf file,
|
---|
[82ea9e2] | 788 | Fontconfig will only treat it as suitable for zh-hk.
|
---|
[24975c4] | 789 | The conf file needs to be edited to current style and will then be
|
---|
| 790 | prepended, so specifying UMing does not belong in this
|
---|
| 791 | <filename>local.conf</filename> file.
|
---|
[e180a646] | 792 | </para>
|
---|
| 793 | </listitem>
|
---|
| 794 | <listitem>
|
---|
| 795 | <para>
|
---|
[24975c4] | 796 | For Sans Serif preferences again start with <xref linkend="dejavu-fonts"/>,
|
---|
| 797 | then <xref linkend="VLGothic"/> for Japanese before falling back to
|
---|
| 798 | WenQuanYi Zen Hei which is Sans and covers both Chinese and Korean
|
---|
| 799 | Hangul.
|
---|
[e180a646] | 800 | </para>
|
---|
| 801 | </listitem>
|
---|
| 802 | <listitem>
|
---|
| 803 | <para>
|
---|
| 804 | The Monospace fonts are forced to the preferred Sans fonts. If the
|
---|
[24975c4] | 805 | text is in Chinese or Korean then <xref
|
---|
| 806 | linkend="wenquanyi-zenhei"/> will be used.
|
---|
[e180a646] | 807 | </para>
|
---|
| 808 | </listitem>
|
---|
| 809 | </orderedlist>
|
---|
| 810 |
|
---|
| 811 | <para>
|
---|
| 812 | In a non-CJK locale, the result is that suitable fonts will be used for
|
---|
[24975c4] | 813 | all variants of Chinese, Japanese and Hangul Korean (but Japanese variants
|
---|
| 814 | of the glyphs shared with Chinese Han will be used). All other languages
|
---|
[e180a646] | 815 | should already work if a font is present. As the <systemitem
|
---|
| 816 | class="username">root</systemitem> user:
|
---|
| 817 | </para>
|
---|
| 818 |
|
---|
| 819 | <screen role="root"><userinput>cat > /etc/fonts/local.conf << "EOF"
|
---|
| 820 | <literal><?xml version='1.0'?>
|
---|
| 821 | <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
---|
| 822 | <fontconfig>
|
---|
| 823 | <alias>
|
---|
| 824 | <family>serif</family>
|
---|
| 825 | <prefer>
|
---|
[24975c4] | 826 | <family>DejaVu Serif</family>
|
---|
[e180a646] | 827 | <family>IPAexMincho</family>
|
---|
| 828 | <!-- WenQuanYi is preferred as Serif in 65-nonlatin.conf,
|
---|
| 829 | override that so a real Korean font can be used for Serif -->
|
---|
| 830 | <family>UnBatang</family>
|
---|
| 831 | </prefer>
|
---|
| 832 | </alias>
|
---|
| 833 | <alias>
|
---|
| 834 | <family>sans-serif</family>
|
---|
| 835 | <prefer>
|
---|
[24975c4] | 836 | <family>DejaVu Sans</family>
|
---|
[e180a646] | 837 | <family>VL Gothic</family>
|
---|
[24975c4] | 838 | <!-- This assumes WenQuanYi is good enough for Korean Sans -->
|
---|
[e180a646] | 839 | </prefer>
|
---|
| 840 | </alias>
|
---|
| 841 | <alias>
|
---|
| 842 | <family>monospace</family>
|
---|
| 843 | <prefer>
|
---|
[24975c4] | 844 | <family>DejaVu Sans Mono</family>
|
---|
[e180a646] | 845 | <family>VL Gothic</family>
|
---|
[24975c4] | 846 | <!-- This assumes WenQuanYi is good enough for Korean Monospace -->
|
---|
[e180a646] | 847 | </prefer>
|
---|
| 848 | </alias>
|
---|
| 849 | </fontconfig></literal>
|
---|
| 850 | EOF</userinput></screen>
|
---|
| 851 |
|
---|
| 852 | </sect2>
|
---|
| 853 |
|
---|
| 854 |
|
---|
| 855 | <sect2 role="configuration" id="editing-old-style-conf-files"
|
---|
| 856 | xreflabel="Editing Old-Style conf files">
|
---|
[8251b48] | 857 | <title>Editing Old-Style conf files</title>
|
---|
[e180a646] | 858 |
|
---|
| 859 | <para>
|
---|
| 860 | Some fonts, particularly Chinese fonts, ship with conf files which can be
|
---|
| 861 | installed in <filename class="directory">/etc/fonts/conf.d</filename>.
|
---|
| 862 | However, if you do that and then use a terminal to run any command which
|
---|
[82ea9e2] | 863 | uses <application>Fontconfig</application> you may see error messages such
|
---|
[e180a646] | 864 | as :
|
---|
| 865 | </para>
|
---|
| 866 |
|
---|
| 867 | <para>
|
---|
| 868 | <literal>Fontconfig warning: "/etc/fonts/conf.d/69-odofonts.conf", line
|
---|
| 869 | 14: Having multiple <family> in <alias> isn't supported and
|
---|
| 870 | may not work as expected</literal>.
|
---|
| 871 | </para>
|
---|
| 872 |
|
---|
| 873 | <para>
|
---|
| 874 | In practice, these old rules do not work. For non-CJK users,
|
---|
[82ea9e2] | 875 | <application>Fontconfig</application> will usually do a good job
|
---|
[e180a646] | 876 | <emphasis>without</emphasis> these rules. Their origin dates back to when
|
---|
| 877 | CJK users needed handcrafted bitmaps to be legible at small sizes, and
|
---|
| 878 | those looked ugly next to antialiased Latin glyphs - they preferred to
|
---|
| 879 | use the same CJK font for the Latin glyphs. There is a side-effect of
|
---|
| 880 | doing this : the (Serif) font is often also used for Sans, and in such a
|
---|
| 881 | situation the (English) text in <application>Gtk</application> menus will
|
---|
| 882 | use this font - compared to system fonts, as well as being serif it is
|
---|
| 883 | both faint and rather small. That can make it uncomfortable to read.
|
---|
| 884 | </para>
|
---|
| 885 |
|
---|
| 886 | <para>
|
---|
| 887 | Nevertheless, these old conf files can be fixed if you wish to use them.
|
---|
| 888 | The following example is the first part of
|
---|
| 889 | <filename>64-arphic-uming.conf</filename> from <xref linkend="UMing"/> -
|
---|
[8251b48] | 890 | there are many more similar items which also need changing :
|
---|
[e180a646] | 891 | </para>
|
---|
| 892 |
|
---|
| 893 | <para>
|
---|
| 894 | <literallayout>
|
---|
| 895 | <match target="pattern">
|
---|
| 896 | <test qual="any" name="lang" compare="contains">
|
---|
| 897 | <string>zh-cn</string>
|
---|
| 898 | <string>zh-sg</string>
|
---|
| 899 | </test>
|
---|
| 900 | <test qual="any" name="family">
|
---|
| 901 | <string>serif</string>
|
---|
| 902 | </test>
|
---|
| 903 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 904 | <string>AR PL UMing CN</string>
|
---|
| 905 | </edit>
|
---|
| 906 | </match></literallayout>
|
---|
| 907 | </para>
|
---|
| 908 |
|
---|
| 909 | <para>
|
---|
| 910 | The process to correct this is straightforward but tedious - for every
|
---|
[8251b48] | 911 | item which produces an error message, using your editor (as the &root;
|
---|
| 912 | user), edit the installed
|
---|
[e180a646] | 913 | file to repeat the whole block as many times as there are multiple
|
---|
| 914 | variables, then reduce each example to have only one of them. You may
|
---|
| 915 | wish to work on one error at a time, save the file after each fix, and
|
---|
| 916 | from a separate term run a command such as <command>fc-list 2>&1 |
|
---|
| 917 | less</command> to see that the fix worked. For the block above, the fixed
|
---|
| 918 | version will be :
|
---|
| 919 | </para>
|
---|
| 920 |
|
---|
| 921 | <para>
|
---|
| 922 | <literallayout>
|
---|
| 923 | <match target="pattern">
|
---|
| 924 | <test qual="any" name="lang" compare="contains">
|
---|
| 925 | <string>zh-cn</string>
|
---|
| 926 | </test>
|
---|
| 927 | <test qual="any" name="family">
|
---|
| 928 | <string>serif</string>
|
---|
| 929 | </test>
|
---|
| 930 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 931 | <string>AR PL UMing CN</string>
|
---|
| 932 | </edit>
|
---|
| 933 | </match>
|
---|
| 934 | <match target="pattern">
|
---|
| 935 | <test qual="any" name="lang" compare="contains">
|
---|
| 936 | <string>zh-sg</string>
|
---|
| 937 | </test>
|
---|
| 938 | <test qual="any" name="family">
|
---|
| 939 | <string>serif</string>
|
---|
| 940 | </test>
|
---|
| 941 | <edit name="family" mode="prepend" binding="strong">
|
---|
| 942 | <string>AR PL UMing CN</string>
|
---|
| 943 | </edit>
|
---|
| 944 | </match></literallayout>
|
---|
| 945 | </para>
|
---|
| 946 |
|
---|
[b52945a] | 947 | <bridgehead renderas="sect3" id="font-weights"
|
---|
| 948 | xreflabel="About font weights">About font weights</bridgehead>
|
---|
| 949 |
|
---|
| 950 | <para>
|
---|
| 951 | When this page and the next page were first created, Latin fonts came
|
---|
| 952 | with a maximum of two weights - either Regular or Book (Book typically
|
---|
| 953 | has a larger X-height to make it easier to read in large blocks of text),
|
---|
[18024d6] | 954 | and Bold - and perhaps an Italic (or Slant) style. A few fonts also had
|
---|
[b52945a] | 955 | Condensed faces (to fit more text into a line and usually only used when
|
---|
| 956 | specified). Without CSS (Cascading Style Sheets) markup, text used the
|
---|
| 957 | Regular or Book weight except when <b> ... </b> markup was
|
---|
[18024d6] | 958 | used for bold text. Italic styles would be invoked by <i> ... </i>
|
---|
[b52945a] | 959 | markup, along with the bold markup for Bold Italic.
|
---|
| 960 | </para>
|
---|
| 961 |
|
---|
| 962 | <para>
|
---|
[18024d6] | 963 | Some faces now contain up to 9 weights, possibly also with a variable font
|
---|
[b52945a] | 964 | (to save space by including all the alternatives in one file and possibly
|
---|
| 965 | allowing intermediate weights). For most desktop users who do not need this
|
---|
| 966 | wide range of weights for creating content, it is simpler to only install
|
---|
[18024d6] | 967 | one or two weights. If a face has individual weights plus a variable font,
|
---|
| 968 | the variable font is usually in the top level of the supplied directory,
|
---|
[b52945a] | 969 | with individual weights in a <filename class="directory">static/</filename>
|
---|
| 970 | subdirectory. Except when initially reviewing a font, it makes no sense to
|
---|
[18024d6] | 971 | install both static and variable, nor all the possible weights.
|
---|
[b52945a] | 972 | </para>
|
---|
| 973 |
|
---|
| 974 | <para>
|
---|
| 975 | The weights are labelled from 100 (Thin) to 900 (Black or Heavy) in CSS
|
---|
| 976 | terminology, with 400 being normal and 700 bold. The full set of weights
|
---|
| 977 | is described at <xref linkend="css-weights"/>.
|
---|
| 978 | </para>
|
---|
| 979 |
|
---|
| 980 | <para>
|
---|
| 981 | If you have installed a font with a range of weights, you can copy <ulink
|
---|
| 982 | url="https://&lfs-domainname;/~ken/font-weights.html">font-weights.html</ulink>
|
---|
| 983 | to your local machine. As shiped it will use your default Serif font assuming
|
---|
| 984 | you have one. Edit it to point to a specific installed font using the name
|
---|
[82ea9e2] | 985 | known to Fontconfig (also in the *EDITME FONTNAME* text items) and open it
|
---|
[b52945a] | 986 | from your desktop browser. You can also use it to look at a font with only
|
---|
| 987 | two installed weights, e.g. for testing to see if you prefer other weights.
|
---|
| 988 | </para>
|
---|
| 989 |
|
---|
| 990 | <para>
|
---|
| 991 | Despite the details in that Mozilla link, it appears that if only normal and
|
---|
| 992 | bold weights are installed, SemiBold (600) will be shown using bold.
|
---|
| 993 | </para>
|
---|
| 994 |
|
---|
| 995 | <para>
|
---|
| 996 | There seems to be a little scope for changing which weights are used for
|
---|
| 997 | normal and bold <emphasis>if only two weights have been installed</emphasis>.
|
---|
| 998 | Firefox, and probably other browsers, will look for the next weight heavier
|
---|
| 999 | than normal. If that is less than bold (Medium, maybe SemiBold - uncertain)
|
---|
| 1000 | it will be used for normal and then the next higher weight, if any will be
|
---|
| 1001 | used for bold, allowing you to make the fonts slightly darker. Conversely,
|
---|
| 1002 | if only a weight less than normal has been installed, such as Light, that
|
---|
| 1003 | will be used for both normal and bold weights (the upward search happens
|
---|
| 1004 | first).
|
---|
| 1005 | </para>
|
---|
| 1006 |
|
---|
| 1007 | <para>
|
---|
| 1008 | If you remove some weights of a system font, you may need to run
|
---|
| 1009 | <command>fc-cache</command> as the &root; user and then log out completely
|
---|
| 1010 | to clear caches associated with your user.
|
---|
| 1011 | <!-- I don't know for sure that there are user caches retained until you
|
---|
| 1012 | log out, but certainly leaving X and restarting the browser is not always
|
---|
| 1013 | adequate : ken -->
|
---|
| 1014 | </para>
|
---|
| 1015 |
|
---|
[dcc1b92] | 1016 | <bridgehead renderas="sect3" id="items-which-can-override-fontconfig"
|
---|
[82ea9e2] | 1017 | xreflabel="Items which can override fontconfig">Items which can override Fontconfig</bridgehead>
|
---|
[dcc1b92] | 1018 |
|
---|
| 1019 | <para>
|
---|
[82ea9e2] | 1020 | Several desktop environments, as well as some programs, will use Fontconfig
|
---|
[dcc1b92] | 1021 | to find fonts but may override certain things.
|
---|
| 1022 | </para>
|
---|
| 1023 |
|
---|
| 1024 | <para>
|
---|
| 1025 | GNOME: The settings in org.gnome.desktop.interface can be updated with
|
---|
| 1026 | <application>dconf-editor</application>. You can set the fonts to your preference
|
---|
[82ea9e2] | 1027 | and desired point size. To use the fonts chosen by Fontconfig specify e.g.
|
---|
[dcc1b92] | 1028 | 'Sans 12', Serif 11', 'Mono 10' as desired. Also review the antialiasing, hinting
|
---|
| 1029 | and rgba settings.
|
---|
| 1030 | </para>
|
---|
| 1031 |
|
---|
| 1032 | <para>
|
---|
[82ea9e2] | 1033 | LXQt: Change font settings as necessary to match Fontconfig in
|
---|
[dcc1b92] | 1034 | <application>lxqt-config-appearance</application>.
|
---|
| 1035 | </para>
|
---|
| 1036 |
|
---|
| 1037 | <para>
|
---|
| 1038 | KDE Plasma: The settings can be adjusted in <application>System
|
---|
| 1039 | Settings</application> under Appearance -> Fonts. This will create or modify
|
---|
| 1040 | <filename>~/.config/fontconfig/fonts.conf</filename> although
|
---|
| 1041 | <filename>~/.config/fontconfig/fonts.conf</filename>, if installed, can
|
---|
| 1042 | override that.
|
---|
| 1043 | </para>
|
---|
| 1044 |
|
---|
| 1045 | <para>
|
---|
| 1046 | Xfce desktop: The settings can be adjusted in
|
---|
| 1047 | <application>Settings</application> Appearance -> Fonts. Specify your
|
---|
[18024d6] | 1048 | preferred fonts, e.g. 'Sans Regular' (to use the normal face and weight
|
---|
[dcc1b92] | 1049 | rather than Bold and/or Italic) and adjust the point size in the option.
|
---|
| 1050 | Review the Rendering and DPI options.
|
---|
| 1051 | </para>
|
---|
| 1052 |
|
---|
| 1053 | <para>
|
---|
| 1054 | Firefox: This browser allows you to specify its default fonts. For the 115esr
|
---|
| 1055 | series, use the 'Hamburger' menu to got to Preferences, General, and under Fonts
|
---|
| 1056 | -> Advanced select Sans Serif, Serif, Monospace as appropriate if you wish to use
|
---|
[82ea9e2] | 1057 | the fonts which match Fontconfig. Set the point sizes as desired. In later
|
---|
[dcc1b92] | 1058 | versions, the settings are at Preferences -> Fonts.
|
---|
| 1059 | <!-- FIXME : Ken - when merging, add note in packages to update this when next ESR
|
---|
| 1060 | series is used -->
|
---|
| 1061 | </para>
|
---|
[e180a646] | 1062 |
|
---|
[dcc1b92] | 1063 | <para>
|
---|
| 1064 | Libreoffice: Tests using English text with an old Japanese font (HanaMinA)
|
---|
| 1065 | which supports several European languages but had only one weight and no
|
---|
[fc07c4bc] | 1066 | italics or slant showed that although <application>libreoffice</application>
|
---|
[82ea9e2] | 1067 | uses Fontconfig to find the font, it created its own bold or slanted text.
|
---|
[dcc1b92] | 1068 | It is not clear if it will do the same where a font actually has bold weight
|
---|
[18024d6] | 1069 | or an italic style. Also, documentation shows that libreoffice has its own
|
---|
[dcc1b92] | 1070 | substitution rules for when a codepoint is not found in the selected font,
|
---|
[82ea9e2] | 1071 | but is unclear if those rules apply on Linux using Fontconfig.
|
---|
[dcc1b92] | 1072 | </para>
|
---|
| 1073 |
|
---|
| 1074 | <para>
|
---|
| 1075 | Pango: as noted in the example <filename>~/.config/fontconfig</filename>
|
---|
| 1076 | above, anything using Pango-1.44 (from 2019) or later now uses Harfbuzz for
|
---|
| 1077 | hinting, not FreeType, and <literal>hintfull</literal> is not supported.
|
---|
| 1078 | </para>
|
---|
| 1079 |
|
---|
| 1080 | </sect2>
|
---|
[e180a646] | 1081 |
|
---|
[ac35d3b] | 1082 | <sect2 role="configuration" id="external-links" xreflabel="External Links">
|
---|
| 1083 | <title>External Links</title>
|
---|
[e180a646] | 1084 |
|
---|
| 1085 | <bridgehead renderas="sect3" id="I-stared-into-the-fontconfig"
|
---|
| 1086 | xreflabel="I stared into the fontconfig">I stared into the fontconfig ...</bridgehead>
|
---|
| 1087 |
|
---|
| 1088 | <para>
|
---|
| 1089 | The blog entries by <ulink
|
---|
| 1090 | url="https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/">Eevee</ulink>
|
---|
[82ea9e2] | 1091 | are particularly useful if <application>Fontconfig</application> does not
|
---|
[e180a646] | 1092 | think your chosen font supports your language, and for preferring some
|
---|
| 1093 | non-MS Japanese fonts when an ugly MS font is already installed.
|
---|
| 1094 | </para>
|
---|
| 1095 |
|
---|
[f98db52] | 1096 | <bridgehead renderas="sect3" id="subpixel-hinting"
|
---|
| 1097 | xreflabel="subpixel-hinting">subpixel-hinting</bridgehead>
|
---|
| 1098 |
|
---|
| 1099 | <para>The documentation of the FreeType v40 interpreter at <ulink
|
---|
| 1100 | url="https://freetype.org/freetype2/docs/hinting/subpixel-hinting.html">freetype
|
---|
| 1101 | docs</ulink>
|
---|
| 1102 | explains how the current hinter works, and why the previous (slow) Infinality
|
---|
| 1103 | interpreter was replaced.
|
---|
| 1104 | </para>
|
---|
| 1105 |
|
---|
[9fc45066] | 1106 | <bridgehead renderas="sect3" id="calc-dpi"
|
---|
| 1107 | xreflabel="calc-dpi">Calculating DPI</bridgehead>
|
---|
| 1108 |
|
---|
| 1109 | <para>An old answer at <ulink
|
---|
| 1110 | url="https://askubuntu.com/questions/197828/how-to-find-and-change-the-screen-dpi/">askubuntu</ulink>
|
---|
| 1111 | gives some detail on calculating a screen's dots per inch, but essentailly
|
---|
| 1112 | you just measure the width and height of the visible panel, convert to
|
---|
| 1113 | inches if using metric measurements, and divide by the number of pixels.
|
---|
| 1114 | You can then pass <option>-dpi <replaceable>90</replaceable></option> when
|
---|
| 1115 | you start Xorg, using your own value.
|
---|
| 1116 | </para>
|
---|
| 1117 |
|
---|
[b52945a] | 1118 | <bridgehead renderas="sect3" id="css-weights"
|
---|
| 1119 | xreflabel="Table of CSS font weights">Table of CSS font weights</bridgehead>
|
---|
| 1120 |
|
---|
| 1121 | <para>Perhaps more than you ever wished to know is at <ulink
|
---|
| 1122 | url="https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight">Mozilla
|
---|
| 1123 | CSS docs</ulink>.
|
---|
| 1124 | </para>
|
---|
| 1125 |
|
---|
[690b50d] | 1126 | <bridgehead renderas="sect3" id="ttfautohint"
|
---|
| 1127 | xreflabel="Applying autohinting to a font">Applying autohinting to a font</bridgehead>
|
---|
| 1128 |
|
---|
| 1129 | <para>
|
---|
| 1130 | If you are using hinting and have a TTF (not OTF) font which lacks hints
|
---|
| 1131 | but permits you to fork it, you might be able to apply hints using <ulink
|
---|
| 1132 | url="https://freetype.org/ttfautohint/">ttfautohint</ulink> which is based
|
---|
| 1133 | on the old autohinter. As of version 1.8.4 it fails to build without Qt5.
|
---|
| 1134 | <!-- switch exists, configure passes but build fails -->
|
---|
| 1135 | </para>
|
---|
| 1136 |
|
---|
[e180a646] | 1137 | <bridgehead renderas="sect3" id="arch-fontconfig"
|
---|
| 1138 | xreflabel="Fontconfig in the Arch wiki">Fontconfig in the Arch wiki</bridgehead>
|
---|
| 1139 |
|
---|
| 1140 | <para>
|
---|
| 1141 | Arch has a lot of information in its wiki at <ulink
|
---|
| 1142 | url="https://wiki.archlinux.org/index.php/font_configuration">font_configuration</ulink>.
|
---|
| 1143 | </para>
|
---|
| 1144 |
|
---|
| 1145 | <bridgehead renderas="sect3" id="gentoo-fontconfig"
|
---|
| 1146 | xreflabel="Fontconfig in the Gentoo wiki">Fontconfig in the Gentoo wiki</bridgehead>
|
---|
| 1147 |
|
---|
| 1148 | <para>
|
---|
| 1149 | Gentoo has some information in its wiki at <ulink
|
---|
| 1150 | url="https://wiki.gentoo.org/wiki/Fontconfig">Fontconfig</ulink> although
|
---|
| 1151 | a lot of the details (what to enable, and Infinality) are specific to
|
---|
| 1152 | Gentoo.
|
---|
| 1153 | </para>
|
---|
| 1154 |
|
---|
| 1155 | </sect2>
|
---|
| 1156 |
|
---|
| 1157 | </sect1>
|
---|