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