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