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