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