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