Debian Codegraph @

subprojects/fontconfig/doc/fontconfig-user.sgml

raw
1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
2 <!ENTITY cacheversion SYSTEM "cache-version.sgml">
3 <!ENTITY version SYSTEM "version.sgml">
4 <!ENTITY confdir SYSTEM "confdir.sgml">
5 ]>
6 <!--
7 Copyright © 2003 Keith Packard
8
9 Permission to use, copy, modify, distribute, and sell this software and its
10 documentation for any purpose is hereby granted without fee, provided that
11 the above copyright notice appear in all copies and that both that
12 copyright notice and this permission notice appear in supporting
13 documentation, and that the name of the author(s) not be used in
14 advertising or publicity pertaining to distribution of the software without
15 specific, written prior permission. The authors make no
16 representations about the suitability of this software for any purpose. It
17 is provided "as is" without express or implied warranty.
18
19 THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
21 EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 PERFORMANCE OF THIS SOFTWARE.
26 -->
27 <refentry>
28 <refmeta>
29 <refentrytitle>fonts-conf</refentrytitle>
30 <manvolnum>5</manvolnum>
31 </refmeta>
32 <refnamediv>
33 <refname>fonts.conf</refname>
34 <refpurpose>Font configuration files</refpurpose>
35 </refnamediv>
36 <refsynopsisdiv>
37 <synopsis>
38 &confdir;/fonts.conf
39 &confdir;/fonts.dtd
40 &confdir;/conf.d
41 $XDG_CONFIG_HOME/fontconfig/conf.d
42 $XDG_CONFIG_HOME/fontconfig/fonts.conf
43 ~/.fonts.conf.d
44 ~/.fonts.conf
45 </synopsis>
46 </refsynopsisdiv>
47 <refsect1><title>Description</title>
48 <para>
49 Fontconfig is a library designed to provide system-wide font configuration,
50 customization and application access.
51 </para>
52 </refsect1>
53 <refsect1><title>Functional Overview</title>
54 <para>
55 Fontconfig contains two essential modules, the configuration module which
56 builds an internal configuration from XML files and the matching module
57 which accepts font patterns and returns the nearest matching font.
58 </para>
59 <refsect2><title>Font Configuration</title>
60 <para>
61 The configuration module consists of the FcConfig datatype, libexpat and
62 FcConfigParse which walks over an XML tree and amends a configuration with
63 data found within. From an external perspective, configuration of the
64 library consists of generating a valid XML tree and feeding that to
65 FcConfigParse. The only other mechanism provided to applications for
66 changing the running configuration is to add fonts and directories to the
67 list of application-provided font files.
68 </para><para>
69 The intent is to make font configurations relatively static, and shared by
70 as many applications as possible. It is hoped that this will lead to more
71 stable font selection when passing names from one application to another.
72 XML was chosen as a configuration file format because it provides a format
73 which is easy for external agents to edit while retaining the correct
74 structure and syntax.
75 </para><para>
76 Font configuration is separate from font matching; applications needing to
77 do their own matching can access the available fonts from the library and
78 perform private matching. The intent is to permit applications to pick and
79 choose appropriate functionality from the library instead of forcing them to
80 choose between this library and a private configuration mechanism. The hope
81 is that this will ensure that configuration of fonts for all applications
82 can be centralized in one place. Centralizing font configuration will
83 simplify and regularize font installation and customization.
84 </para>
85 </refsect2>
86 <refsect2>
87 <title>Font Properties</title>
88 <para>
89 While font patterns may contain essentially any properties, there are some
90 well known properties with associated types. Fontconfig uses some of these
91 properties for font matching and font completion. Others are provided as a
92 convenience for the applications' rendering mechanism.
93 </para>
94 <programlisting>
95 Property Type Description
96 --------------------------------------------------------------
97 family String Font family names
98 familylang String Languages corresponding to each family
99 style String Font style. Overrides weight and slant
100 stylelang String Languages corresponding to each style
101 fullname String Font full names (often includes style)
102 fullnamelang String Languages corresponding to each fullname
103 slant Int Italic, oblique or roman
104 weight Int Light, medium, demibold, bold or black
105 width Int Condensed, normal or expanded
106 size Double Point size
107 aspect Double Stretches glyphs horizontally before hinting
108 pixelsize Double Pixel size
109 spacing Int Proportional, dual-width, monospace or charcell
110 foundry String Font foundry name
111 antialias Bool Whether glyphs can be antialiased
112 hintstyle Int Automatic hinting style
113 hinting Bool Whether the rasterizer should use hinting
114 verticallayout Bool Use vertical layout
115 autohint Bool Use autohinter instead of normal hinter
116 globaladvance Bool Use font global advance data (deprecated)
117 file String The filename holding the font
118 index Int The index of the font within the file
119 ftface FT_Face Use the specified FreeType face object
120 rasterizer String Which rasterizer is in use (deprecated)
121 outline Bool Whether the glyphs are outlines
122 scalable Bool Whether the glyphs are outlines or have color
123 dpi Double Target dots per inch
124 rgba Int unknown, rgb, bgr, vrgb, vbgr,
125 none - subpixel geometry
126 scale Double Scale factor for point->pixel conversions
127 (deprecated)
128 minspace Bool Eliminate leading from line spacing
129 charset CharSet Unicode chars encoded by the font
130 lang String List of RFC-3066-style languages this
131 font supports
132 fontversion Int Version number of the font
133 capability String List of layout capabilities in the font
134 fontformat String String name of the font format
135 embolden Bool Rasterizer should synthetically embolden the font
136 embeddedbitmap Bool Use the embedded bitmap instead of the outline
137 decorative Bool Whether the style is a decorative variant
138 lcdfilter Int Type of LCD filter
139 namelang String Language name to be used for the default value of
140 familylang, stylelang, and fullnamelang
141 fontfeatures String List of the feature tags in OpenType to be enabled
142 prgname String String Name of the running program
143 postscriptname String Font family name in PostScript
144 color Bool Whether any glyphs have color
145 symbol Bool Whether font uses MS symbol-font encoding
146 fontvariations String comma-separated string of axes in variable font
147 variable Bool Wheter font is Variable Font
148 fonthashint Bool Whether the font has hinting
149 order Int Order number of the font
150 desktop String Current desktop name
151 namedinstance Bool Whether font is a named instance
152 fontwarapper String The font wrapper format, current values are WOFF, WOFF2,
153 SFNT for any other SFNT font, and CFF for standalone
154 CFF fonts.
155 </programlisting>
156 </refsect2>
157 <refsect2>
158 <title>Font Matching</title>
159 <para>
160 Fontconfig performs matching by measuring the distance from a provided
161 pattern to all of the available fonts in the system. The closest matching
162 font is selected. This ensures that a font will always be returned, but
163 doesn't ensure that it is anything like the requested pattern.
164 </para><para>
165 Font matching starts with an application constructed pattern. The desired
166 attributes of the resulting font are collected together in a pattern. Each
167 property of the pattern can contain one or more values; these are listed in
168 priority order; matches earlier in the list are considered "closer" than
169 matches later in the list.
170 </para><para>
171 The initial pattern is modified by applying the list of editing instructions
172 specific to patterns found in the configuration; each consists of a match
173 predicate and a set of editing operations. They are executed in the order
174 they appeared in the configuration. Each match causes the associated
175 sequence of editing operations to be applied.
176 </para><para>
177 After the pattern has been edited, a sequence of default substitutions are
178 performed to canonicalize the set of available properties; this avoids the
179 need for the lower layers to constantly provide default values for various
180 font properties during rendering.
181 </para><para>
182 The canonical font pattern is finally matched against all available fonts.
183 The distance from the pattern to the font is measured for each of several
184 properties: foundry, charset, family, lang, spacing, pixelsize, style,
185 slant, weight, antialias, rasterizer and outline. This list is in priority
186 order -- results of comparing earlier elements of this list weigh more
187 heavily than later elements.
188 </para><para>
189 There is one special case to this rule; family names are split into two
190 bindings; strong and weak. Strong family names are given greater precedence
191 in the match than lang elements while weak family names are given lower
192 precedence than lang elements. This permits the document language to drive
193 font selection when any document specified font is unavailable.
194 </para><para>
195 The pattern representing that font is augmented to include any properties
196 found in the pattern but not found in the font itself; this permits the
197 application to pass rendering instructions or any other data through the
198 matching system. Finally, the list of editing instructions specific to
199 fonts found in the configuration are applied to the pattern. This modified
200 pattern is returned to the application.
201 </para><para>
202 The return value contains sufficient information to locate and rasterize the
203 font, including the file name, pixel size and other rendering data. As
204 none of the information involved pertains to the FreeType library,
205 applications are free to use any rasterization engine or even to take
206 the identified font file and access it directly.
207 </para><para>
208 The match/edit sequences in the configuration are performed in two passes
209 because there are essentially two different operations necessary -- the
210 first is to modify how fonts are selected; aliasing families and adding
211 suitable defaults. The second is to modify how the selected fonts are
212 rasterized. Those must apply to the selected font, not the original pattern
213 as false matches will often occur.
214 </para>
215 </refsect2>
216 <refsect2><title>Font Names</title>
217 <para>
218 Fontconfig provides a textual representation for patterns that the library
219 can both accept and generate. The representation is in three parts, first a
220 list of family names, second a list of point sizes and finally a list of
221 additional properties:
222 </para>
223 <programlisting>
224 &lt;families&gt;-&lt;point sizes&gt;:&lt;name1&gt;=&lt;values1&gt;:&lt;name2&gt;=&lt;values2&gt;...
225 </programlisting>
226 <para>
227 Values in a list are separated with commas. The name needn't include either
228 families or point sizes; they can be elided. In addition, there are
229 symbolic constants that simultaneously indicate both a name and a value.
230 Here are some examples:
231 </para>
232 <programlisting>
233 Name Meaning
234 ----------------------------------------------------------
235 Times-12 12 point Times Roman
236 Times-12:bold 12 point Times Bold
237 Courier:italic Courier Italic in the default size
238 Monospace:matrix=1 .1 0 1 The users preferred monospace font
239 with artificial obliquing
240 </programlisting>
241 <para>
242 The '\', '-', ':' and ',' characters in family names must be preceded by a
243 '\' character to avoid having them misinterpreted. Similarly, values
244 containing '\', '=', '_', ':' and ',' must also have them preceded by a
245 '\' character. The '\' characters are stripped out of the family name and
246 values as the font name is read.
247 </para>
248 </refsect2>
249 </refsect1>
250 <refsect1 id="debug"><title>Debugging Applications</title>
251 <para>
252 To help diagnose font and applications problems, fontconfig is built with a
253 large amount of internal debugging left enabled. It is controlled by means
254 of the FC_DEBUG environment variable. The value of this variable is
255 interpreted as a number, and each bit within that value controls different
256 debugging messages.
257 </para>
258 <programlisting>
259 Name Value Meaning
260 ---------------------------------------------------------
261 MATCH 1 Brief information about font matching
262 MATCHV 2 Extensive font matching information
263 EDIT 4 Monitor match/test/edit execution
264 FONTSET 8 Track loading of font information at startup
265 CACHE 16 Watch cache files being written
266 CACHEV 32 Extensive cache file writing information
267 PARSE 64 (no longer in use)
268 SCAN 128 Watch font files being scanned to build caches
269 SCANV 256 Verbose font file scanning information
270 MEMORY 512 Monitor fontconfig memory usage
271 CONFIG 1024 Monitor which config files are loaded
272 LANGSET 2048 Dump char sets used to construct lang values
273 MATCH2 4096 Display font-matching transformation in patterns
274 </programlisting>
275 <para>
276 Add the value of the desired debug levels together and assign that (in
277 base 10) to the FC_DEBUG environment variable before running the
278 application. Output from these statements is sent to stdout.
279 </para>
280 </refsect1>
281 <refsect1><title>Lang Tags</title>
282 <para>
283 Each font in the database contains a list of languages it supports. This is
284 computed by comparing the Unicode coverage of the font with the orthography
285 of each language. Languages are tagged using an RFC-3066 compatible naming
286 and occur in two parts -- the ISO 639 language tag followed a hyphen and then
287 by the ISO 3166 country code. The hyphen and country code may be elided.
288 </para><para>
289 Fontconfig has orthographies for several languages built into the library.
290 No provision has been made for adding new ones aside from rebuilding the
291 library. It currently supports 122 of the 139 languages named in ISO 639-1,
292 141 of the languages with two-letter codes from ISO 639-2 and another 30
293 languages with only three-letter codes. Languages with both two and three
294 letter codes are provided with only the two letter code.
295 </para><para>
296 For languages used in multiple territories with radically different
297 character sets, fontconfig includes per-territory orthographies. This
298 includes Azerbaijani, Kurdish, Pashto, Tigrinya and Chinese.
299 </para>
300 </refsect1>
301 <refsect1><title>Configuration File Format</title>
302 <para>
303 Configuration files for fontconfig are stored in XML format; this
304 format makes external configuration tools easier to write and ensures that
305 they will generate syntactically correct configuration files. As XML
306 files are plain text, they can also be manipulated by the expert user using
307 a text editor.
308 </para><para>
309 The fontconfig document type definition resides in the external entity
310 "fonts.dtd"; this is normally stored in the default font configuration
311 directory (&confdir;). Each configuration file should contain the
312 following structure:
313 <programlisting>
314 &lt;?xml version="1.0"?&gt;
315 &lt;!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"&gt;
316 &lt;fontconfig&gt;
317 ...
318 &lt;/fontconfig&gt;
319 </programlisting>
320 </para>
321 <refsect2><title><literal>&lt;fontconfig&gt;</literal></title><para>
322 This is the top level element for a font configuration and can contain
323 <literal>&lt;dir&gt;</literal>, <literal>&lt;cachedir&gt;</literal>, <literal>&lt;include&gt;</literal>, <literal>&lt;match&gt;</literal> and <literal>&lt;alias&gt;</literal> elements in any order.
324 </para></refsect2>
325 <refsect2><title><literal>&lt;dir prefix="default" salt=""&gt;</literal></title><para>
326 This element contains a directory name which will be scanned for font files
327 to include in the set of available fonts.
328 </para><para>
329 If 'prefix' is set to "default" or "cwd", the current working directory will be added as the path prefix prior to the value. If 'prefix' is set to "xdg", the value in the XDG_DATA_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details. If 'prefix' is set to "relative", the path of current file will be added prior to the value.
330 </para><para>
331 'salt' property affects to determine cache filename. this is useful for example when having different fonts sets on same path at container and share fonts from host on different font path.
332 </para></refsect2>
333 <refsect2><title><literal>&lt;cachedir prefix="default"&gt;</literal></title><para>
334 This element contains a directory name that is supposed to be stored or read
335 the cache of font information. If multiple elements are specified in
336 the configuration file, the directory that can be accessed first in the list
337 will be used to store the cache files. If it starts with '~', it refers to
338 a directory in the users home directory. If 'prefix' is set to "xdg", the value in the XDG_CACHE_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details.
339 The default directory is ``$XDG_CACHE_HOME/fontconfig'' and it contains the cache files
340 named ``<literal>&lt;hash value&gt;</literal>-<literal>&lt;architecture&gt;</literal>.cache-<literal>&lt;version&gt;</literal>'',
341 where <literal>&lt;version&gt;</literal> is the fontconfig cache file
342 version number (currently &cacheversion;).
343 </para></refsect2>
344 <refsect2><title><literal>&lt;include ignore_missing="no" prefix="default"&gt;</literal></title><para>
345 This element contains the name of an additional configuration file or
346 directory. If a directory, every file within that directory starting with an
347 ASCII digit (U+0030 - U+0039) and ending with the string ``.conf'' will be processed in sorted order. When
348 the XML datatype is traversed by FcConfigParse, the contents of the file(s)
349 will also be incorporated into the configuration by passing the filename(s) to
350 FcConfigLoadAndParse. If 'ignore_missing' is set to "yes" instead of the
351 default "no", a missing file or directory will elicit no warning message from
352 the library. If 'prefix' is set to "xdg", the value in the XDG_CONFIG_HOME environment variable will be added as the path prefix. please see XDG Base Directory Specification for more details.
353 </para></refsect2>
354 <refsect2><title><literal>&lt;config&gt;</literal></title><para>
355 This element provides a place to consolidate additional configuration
356 information. <literal>&lt;config&gt;</literal> can contain <literal>&lt;blank&gt;</literal> and <literal>&lt;rescan&gt;</literal> elements in any
357 order.
358 </para></refsect2>
359 <refsect2><title><literal>&lt;description domain="fontconfig-conf"&gt;</literal></title><para>
360 This element is supposed to hold strings which describe what a config is used for.
361 This string can be translated through gettext. 'domain' needs to be set the proper name to apply then.
362 fontconfig will tries to retrieve translations with 'domain' from gettext.
363 </para></refsect2>
364 <refsect2><title><literal>&lt;blank&gt;</literal></title><para>
365 Fonts often include "broken" glyphs which appear in the encoding but are
366 drawn as blanks on the screen. Within the <literal>&lt;blank&gt;</literal> element, place each
367 Unicode characters which is supposed to be blank in an <literal>&lt;int&gt;</literal> element.
368 Characters outside of this set which are drawn as blank will be elided from
369 the set of characters supported by the font.
370 </para></refsect2>
371 <refsect2><title><literal>&lt;remap-dir prefix="default" as-path="" salt=""&gt;</literal></title><para>
372 This element contains a directory name where will be mapped
373 as the path 'as-path' in cached information.
374 This is useful if the directory name is an alias
375 (via a bind mount or symlink) to another directory in the system for
376 which cached font information is likely to exist.
377 </para><para>
378 'salt' property affects to determine cache filename as same as <literal>&lt;dir&gt;</literal> element.
379 </para></refsect2>
380 <refsect2><title><literal>&lt;reset-dirs /&gt;</literal></title><para>
381 This element removes all of fonts directories where added by <literal>&lt;dir&gt;</literal> elements.
382 This is useful to override fonts directories from system to own fonts directories only.
383 </para></refsect2>
384 <refsect2><title><literal>&lt;rescan&gt;</literal></title><para>
385 The <literal>&lt;rescan&gt;</literal> element holds an <literal>&lt;int&gt;</literal> element which indicates the default
386 interval between automatic checks for font configuration changes.
387 Fontconfig will validate all of the configuration files and directories and
388 automatically rebuild the internal datastructures when this interval passes.
389 </para></refsect2>
390 <refsect2><title><literal>&lt;selectfont&gt;</literal></title><para>
391 This element is used to deny/allow list fonts from being listed or matched
392 against. It holds acceptfont and rejectfont elements. This list is applied
393 only once when caches is loaded. So if you want to filter out by some patterns,
394 patterns is evaluated with something in cache only.
395 In other words, target patterns except "scan" won't takes any effects.
396 </para></refsect2>
397 <refsect2><title><literal>&lt;acceptfont&gt;</literal></title><para>
398 Fonts matched by an acceptfont element are "allowlisted"; such fonts are
399 explicitly included in the set of fonts used to resolve list and match
400 requests; including them in this list protects them from being "denylisted"
401 by a rejectfont element. Acceptfont elements include glob and pattern
402 elements which are used to match fonts.
403 </para></refsect2>
404 <refsect2><title><literal>&lt;rejectfont&gt;</literal></title><para>
405 Fonts matched by an rejectfont element are "denylisted"; such fonts are
406 excluded from the set of fonts used to resolve list and match requests as if
407 they didn't exist in the system. Rejectfont elements include glob and
408 pattern elements which are used to match fonts.
409 </para></refsect2>
410 <refsect2><title><literal>&lt;glob&gt;</literal></title><para>
411 Glob elements hold shell-style filename matching patterns (including ? and
412 *) which match fonts based on their complete pathnames. If it starts with '~',
413 it refers to a directory in the users home directory. This can be used to
414 exclude a set of directories (/usr/share/fonts/uglyfont*), or particular
415 font file types (*.pcf.gz), but the latter mechanism relies rather heavily
416 on filenaming conventions which can't be relied upon. Note that globs
417 only apply to directories, not to individual fonts.
418 </para></refsect2>
419 <refsect2><title><literal>&lt;pattern&gt;</literal></title><para>
420 Pattern elements perform list-style matching on incoming fonts; that is,
421 they hold a list of elements and associated values. If all of those
422 elements have a matching value, then the pattern matches the font. This can
423 be used to select fonts based on attributes of the font (scalable, bold,
424 etc), which is a more reliable mechanism than using file extensions.
425 Pattern elements include patelt elements.
426 </para></refsect2>
427 <refsect2><title><literal>&lt;patelt name="property"&gt;</literal></title><para>
428 Patelt elements hold a single pattern element and list of values. They must
429 have a 'name' attribute which indicates the pattern element name. Patelt
430 elements include int, double, string, matrix, bool, charset and const
431 elements.
432 </para></refsect2>
433 <refsect2><title><literal>&lt;match target="pattern"&gt;</literal></title><para>
434 This element holds first a (possibly empty) list of <literal>&lt;test&gt;</literal> elements and then
435 a (possibly empty) list of <literal>&lt;edit&gt;</literal> elements. Patterns which match all of the
436 tests are subjected to all the edits. If 'target' is set to "font" instead
437 of the default "pattern", then this element applies to the font name
438 resulting from a match rather than a font pattern to be matched. If 'target'
439 is set to "scan", then this element applies when the font is scanned to
440 build the fontconfig database.
441 </para></refsect2>
442 <refsect2><title><literal>&lt;test qual="any" name="property" target="default" compare="eq"&gt;</literal></title><para>
443 This element contains a single value which is compared with the target
444 ('pattern', 'font', 'scan' or 'default') property "property" (substitute any of the property names seen
445 above). 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", "more_eq", "contains" or
446 "not_contains". 'qual' may either be the default, "any", in which case the match
447 succeeds if any value associated with the property matches the test value, or
448 "all", in which case all of the values associated with the property must
449 match the test value. 'ignore-blanks' takes a boolean value. if 'ignore-blanks' is set "true", any blanks in the string will be ignored on its comparison. this takes effects only when compare="eq" or compare="not_eq".
450 When used in a &lt;match target="font"&gt; element,
451 the target= attribute in the &lt;test&gt; element selects between matching
452 the original pattern or the font. "default" selects whichever target the
453 outer &lt;match&gt; element has selected.
454 </para></refsect2>
455 <refsect2><title><literal>&lt;edit name="property" mode="assign" binding="weak"&gt;</literal></title><para>
456 This element contains a list of expression elements (any of the value or
457 operator elements). The expression elements are evaluated at run-time and
458 modify the property "property". The modification depends on whether
459 "property" was matched by one of the associated <literal>&lt;test&gt;</literal> elements, if so, the
460 modification may affect the first matched value. Any values inserted into
461 the property are given the indicated binding ("strong", "weak" or "same")
462 with "same" binding using the value from the matched pattern element.
463 'mode' is one of:
464 <programlisting>
465 Mode With Match Without Match
466 ---------------------------------------------------------------------
467 "assign" Replace matching value Replace all values
468 "assign_replace" Replace all values Replace all values
469 "prepend" Insert before matching Insert at head of list
470 "prepend_first" Insert at head of list Insert at head of list
471 "append" Append after matching Append at end of list
472 "append_last" Append at end of list Append at end of list
473 "delete" Delete matching value Delete all values
474 "delete_all" Delete all values Delete all values
475 </programlisting>
476 </para></refsect2>
477 <refsect2><title><literal>&lt;int&gt;</literal>, <literal>&lt;double&gt;</literal>, <literal>&lt;string&gt;</literal>, <literal>&lt;bool&gt;</literal></title><para>
478 These elements hold a single value of the indicated type. <literal>&lt;bool&gt;</literal>
479 elements hold either true or false. An important limitation exists in
480 the parsing of floating point numbers -- fontconfig requires that
481 the mantissa start with a digit, not a decimal point, so insert a leading
482 zero for purely fractional values (e.g. use 0.5 instead of .5 and -0.5
483 instead of -.5).
484 </para></refsect2>
485 <refsect2><title><literal>&lt;matrix&gt;</literal></title><para>
486 This element holds four numerical expressions of an affine transformation.
487 At their simplest these will be four <literal>&lt;double&gt;</literal> elements
488 but they can also be more involved expressions.
489 </para></refsect2>
490 <refsect2><title><literal>&lt;range&gt;</literal></title><para>
491 This element holds the two <literal>&lt;int&gt;</literal> elements of a range
492 representation.
493 </para></refsect2>
494 <refsect2><title><literal>&lt;charset&gt;</literal></title><para>
495 This element holds at least one <literal>&lt;int&gt;</literal> element of
496 an Unicode code point or more.
497 </para></refsect2>
498 <refsect2><title><literal>&lt;langset&gt;</literal></title><para>
499 This element holds at least one <literal>&lt;string&gt;</literal> element of
500 a RFC-3066-style languages or more.
501 </para></refsect2>
502 <refsect2><title><literal>&lt;name&gt;</literal></title><para>
503 Holds a property name. Evaluates to the first value from the property of
504 the pattern. If the 'target' attribute is not present, it will default to
505 'default', in which case the property is returned from the font pattern
506 during a target="font" match, and to the pattern during a target="pattern"
507 match. The attribute can also take the values 'font' or 'pattern' to
508 explicitly choose which pattern to use. It is an error to use a target
509 of 'font' in a match that has target="pattern".
510 </para></refsect2>
511 <refsect2><title><literal>&lt;const&gt;</literal></title><para>
512 Holds the name of a constant; these are always integers and serve as
513 symbolic names for common font values:
514 <programlisting>
515 Constant Property Value
516 -------------------------------------
517 thin weight 0
518 extralight weight 40
519 ultralight weight 40
520 light weight 50
521 demilight weight 55
522 semilight weight 55
523 book weight 75
524 regular weight 80
525 normal weight 80
526 medium weight 100
527 demibold weight 180
528 semibold weight 180
529 bold weight 200
530 extrabold weight 205
531 ultrabold weight 205
532 black weight 210
533 heavy weight 210
534 extrablack weight 215
535 ultrablack weight 215
536 roman slant 0
537 italic slant 100
538 oblique slant 110
539 ultracondensed width 50
540 extracondensed width 63
541 condensed width 75
542 semicondensed width 87
543 normal width 100
544 semiexpanded width 113
545 expanded width 125
546 extraexpanded width 150
547 ultraexpanded width 200
548 proportional spacing 0
549 dual spacing 90
550 mono spacing 100
551 charcell spacing 110
552 unknown rgba 0
553 rgb rgba 1
554 bgr rgba 2
555 vrgb rgba 3
556 vbgr rgba 4
557 none rgba 5
558 lcdnone lcdfilter 0
559 lcddefault lcdfilter 1
560 lcdlight lcdfilter 2
561 lcdlegacy lcdfilter 3
562 hintnone hintstyle 0
563 hintslight hintstyle 1
564 hintmedium hintstyle 2
565 hintfull hintstyle 3
566 </programlisting>
567 </para>
568 </refsect2>
569 <refsect2>
570 <title><literal>&lt;or&gt;</literal>, <literal>&lt;and&gt;</literal>, <literal>&lt;plus&gt;</literal>, <literal>&lt;minus&gt;</literal>, <literal>&lt;times&gt;</literal>, <literal>&lt;divide&gt;</literal></title>
571 <para>
572 These elements perform the specified operation on a list of expression
573 elements. <literal>&lt;or&gt;</literal> and <literal>&lt;and&gt;</literal> are boolean, not bitwise.
574 </para>
575 </refsect2>
576 <refsect2>
577 <title><literal>&lt;eq&gt;</literal>, <literal>&lt;not_eq&gt;</literal>, <literal>&lt;less&gt;</literal>, <literal>&lt;less_eq&gt;</literal>, <literal>&lt;more&gt;</literal>, <literal>&lt;more_eq&gt;</literal>, <literal>&lt;contains&gt;</literal>, <literal>&lt;not_contains</literal></title>
578 <para>
579 These elements compare two values, producing a boolean result.
580 </para></refsect2>
581 <refsect2><title><literal>&lt;not&gt;</literal></title><para>
582 Inverts the boolean sense of its one expression element
583 </para></refsect2>
584 <refsect2><title><literal>&lt;if&gt;</literal></title><para>
585 This element takes three expression elements; if the value of the first is
586 true, it produces the value of the second, otherwise it produces the value
587 of the third.
588 </para></refsect2>
589 <refsect2><title><literal>&lt;alias&gt;</literal></title><para>
590 Alias elements provide a shorthand notation for the set of common match
591 operations needed to substitute one font family for another. They contain a
592 <literal>&lt;family&gt;</literal> element followed by optional <literal>&lt;prefer&gt;</literal>, <literal>&lt;accept&gt;</literal> and <literal>&lt;default&gt;</literal>
593 elements. Fonts matching the <literal>&lt;family&gt;</literal> element are edited to prepend the
594 list of <literal>&lt;prefer&gt;</literal>ed families before the matching <literal>&lt;family&gt;</literal>, append the
595 <literal>&lt;accept&gt;</literal>able families after the matching <literal>&lt;family&gt;</literal> and append the <literal>&lt;default&gt;</literal>
596 families to the end of the family list.
597 </para></refsect2>
598 <refsect2><title><literal>&lt;family&gt;</literal></title><para>
599 Holds a single font family name
600 </para></refsect2>
601 <refsect2><title><literal>&lt;prefer&gt;</literal>, <literal>&lt;accept&gt;</literal>, <literal>&lt;default&gt;</literal></title><para>
602 These hold a list of <literal>&lt;family&gt;</literal> elements to be used by the <literal>&lt;alias&gt;</literal> element.
603 </para></refsect2>
604 </refsect1>
605 <refsect1><title>EXAMPLE CONFIGURATION FILE</title>
606 <refsect2><title>System configuration file</title>
607 <para>
608 This is an example of a system-wide configuration file
609 </para>
610 <programlisting>
611 &lt;?xml version="1.0"?&gt;
612 &lt;!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"&gt;
613 &lt;!-- &confdir;/fonts.conf file to configure system font access --&gt;
614 &lt;fontconfig&gt;
615 &lt;!--
616 Find fonts in these directories
617 --&gt;
618 &lt;dir&gt;/usr/share/fonts&lt;/dir&gt;
619 &lt;dir&gt;/usr/X11R6/lib/X11/fonts&lt;/dir&gt;
620
621 &lt;!--
622 Accept deprecated 'mono' alias, replacing it with 'monospace'
623 --&gt;
624 &lt;match target="pattern"&gt;
625 &lt;test qual="any" name="family"&gt;
626 &lt;string&gt;mono&lt;/string&gt;
627 &lt;/test&gt;
628 &lt;edit name="family" mode="assign"&gt;
629 &lt;string&gt;monospace&lt;/string&gt;
630 &lt;/edit&gt;
631 &lt;/match&gt;
632
633 &lt;!--
634 Names not including any well known alias are given 'sans-serif'
635 --&gt;
636 &lt;match target="pattern"&gt;
637 &lt;test qual="all" name="family" compare="not_eq"&gt;
638 &lt;string&gt;sans-serif&lt;/string&gt;
639 &lt;/test&gt;
640 &lt;test qual="all" name="family" compare="not_eq"&gt;
641 &lt;string&gt;serif&lt;/string&gt;
642 &lt;/test&gt;
643 &lt;test qual="all" name="family" compare="not_eq"&gt;
644 &lt;string&gt;monospace&lt;/string&gt;
645 &lt;/test&gt;
646 &lt;edit name="family" mode="append_last"&gt;
647 &lt;string&gt;sans-serif&lt;/string&gt;
648 &lt;/edit&gt;
649 &lt;/match&gt;
650
651 &lt;!--
652 Load per-user customization file, but don't complain
653 if it doesn't exist
654 --&gt;
655 &lt;include ignore_missing="yes" prefix="xdg"&gt;
656 fontconfig/fonts.conf
657 &lt;/include&gt;
658
659 &lt;!--
660 Load local customization files, but don't complain
661 if there aren't any
662 --&gt;
663 &lt;include ignore_missing="yes"&gt;conf.d&lt;/include&gt;
664 &lt;include ignore_missing="yes"&gt;local.conf&lt;/include&gt;
665
666 &lt;!--
667 Alias well known font names to available TrueType fonts.
668 These substitute TrueType faces for similar Type1
669 faces to improve screen appearance.
670 --&gt;
671 &lt;alias&gt;
672 &lt;family&gt;Times&lt;/family&gt;
673 &lt;prefer&gt;
674 &lt;family&gt;Times New Roman&lt;/family&gt;
675 &lt;/prefer&gt;
676 &lt;default&gt;
677 &lt;family&gt;serif&lt;/family&gt;
678 &lt;/default&gt;
679 &lt;/alias&gt;
680 &lt;alias&gt;
681 &lt;family&gt;Helvetica&lt;/family&gt;
682 &lt;prefer&gt;
683 &lt;family&gt;Arial&lt;/family&gt;
684 &lt;/prefer&gt;
685 &lt;default&gt;
686 &lt;family&gt;sans-serif&lt;/family&gt;
687 &lt;/default&gt;
688 &lt;/alias&gt;
689 &lt;alias&gt;
690 &lt;family&gt;Courier&lt;/family&gt;
691 &lt;prefer&gt;
692 &lt;family&gt;Courier New&lt;/family&gt;
693 &lt;/prefer&gt;
694 &lt;default&gt;
695 &lt;family&gt;monospace&lt;/family&gt;
696 &lt;/default&gt;
697 &lt;/alias&gt;
698
699 &lt;!--
700 Provide required aliases for standard names
701 Do these after the users configuration file so that
702 any aliases there are used preferentially
703 --&gt;
704 &lt;alias&gt;
705 &lt;family&gt;serif&lt;/family&gt;
706 &lt;prefer&gt;
707 &lt;family&gt;Times New Roman&lt;/family&gt;
708 &lt;/prefer&gt;
709 &lt;/alias&gt;
710 &lt;alias&gt;
711 &lt;family&gt;sans-serif&lt;/family&gt;
712 &lt;prefer&gt;
713 &lt;family&gt;Arial&lt;/family&gt;
714 &lt;/prefer&gt;
715 &lt;/alias&gt;
716 &lt;alias&gt;
717 &lt;family&gt;monospace&lt;/family&gt;
718 &lt;prefer&gt;
719 &lt;family&gt;Andale Mono&lt;/family&gt;
720 &lt;/prefer&gt;
721 &lt;/alias&gt;
722
723 &lt;--
724 The example of the requirements of OR operator;
725 If the 'family' contains 'Courier New' OR 'Courier'
726 add 'monospace' as the alternative
727 --&gt;
728 &lt;match target="pattern"&gt;
729 &lt;test name="family" compare="eq"&gt;
730 &lt;string&gt;Courier New&lt;/string&gt;
731 &lt;/test&gt;
732 &lt;edit name="family" mode="prepend"&gt;
733 &lt;string&gt;monospace&lt;/string&gt;
734 &lt;/edit&gt;
735 &lt;/match&gt;
736 &lt;match target="pattern"&gt;
737 &lt;test name="family" compare="eq"&gt;
738 &lt;string&gt;Courier&lt;/string&gt;
739 &lt;/test&gt;
740 &lt;edit name="family" mode="prepend"&gt;
741 &lt;string&gt;monospace&lt;/string&gt;
742 &lt;/edit&gt;
743 &lt;/match&gt;
744
745 &lt;/fontconfig&gt;
746 </programlisting>
747 </refsect2>
748 <refsect2><title>User configuration file</title>
749 <para>
750 This is an example of a per-user configuration file that lives in
751 $XDG_CONFIG_HOME/fontconfig/fonts.conf
752 </para>
753 <programlisting>
754 &lt;?xml version="1.0"?&gt;
755 &lt;!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"&gt;
756 &lt;!--
757 $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration
758 --&gt;
759 &lt;fontconfig&gt;
760
761 &lt;!--
762 Private font directory
763 --&gt;
764 &lt;dir prefix="xdg"&gt;fonts&lt;/dir&gt;
765
766 &lt;!--
767 use rgb sub-pixel ordering to improve glyph appearance on
768 LCD screens. Changes affecting rendering, but not matching
769 should always use target="font".
770 --&gt;
771 &lt;match target="font"&gt;
772 &lt;edit name="rgba" mode="assign"&gt;
773 &lt;const&gt;rgb&lt;/const&gt;
774 &lt;/edit&gt;
775 &lt;/match&gt;
776 &lt;!--
777 use WenQuanYi Zen Hei font when serif is requested for Chinese
778 --&gt;
779 &lt;match&gt;
780 &lt;!--
781 If you don't want to use WenQuanYi Zen Hei font for zh-tw etc,
782 you can use zh-cn instead of zh.
783 Please note, even if you set zh-cn, it still matches zh.
784 if you don't like it, you can use compare="eq"
785 instead of compare="contains".
786 --&gt;
787 &lt;test name="lang" compare="contains"&gt;
788 &lt;string&gt;zh&lt;/string&gt;
789 &lt;/test&gt;
790 &lt;test name="family"&gt;
791 &lt;string&gt;serif&lt;/string&gt;
792 &lt;/test&gt;
793 &lt;edit name="family" mode="prepend"&gt;
794 &lt;string&gt;WenQuanYi Zen Hei&lt;/string&gt;
795 &lt;/edit&gt;
796 &lt;/match&gt;
797 &lt;!--
798 use VL Gothic font when sans-serif is requested for Japanese
799 --&gt;
800 &lt;match&gt;
801 &lt;test name="lang" compare="contains"&gt;
802 &lt;string&gt;ja&lt;/string&gt;
803 &lt;/test&gt;
804 &lt;test name="family"&gt;
805 &lt;string&gt;sans-serif&lt;/string&gt;
806 &lt;/test&gt;
807 &lt;edit name="family" mode="prepend"&gt;
808 &lt;string&gt;VL Gothic&lt;/string&gt;
809 &lt;/edit&gt;
810 &lt;/match&gt;
811 &lt;/fontconfig&gt;
812 </programlisting>
813 </refsect2>
814 </refsect1>
815 <refsect1><title>Files</title>
816 <para>
817 <emphasis>fonts.conf</emphasis>
818 contains configuration information for the fontconfig library
819 consisting of directories to look at for font information as well as
820 instructions on editing program specified font patterns before attempting to
821 match the available fonts. It is in XML format.
822 </para>
823 <para>
824 <emphasis>conf.d</emphasis>
825 is the conventional name for a directory of additional configuration files
826 managed by external applications or the local administrator. The
827 filenames starting with decimal digits are sorted in lexicographic order
828 and used as additional configuration files. All of these files are in XML
829 format. The master fonts.conf file references this directory in an
830 &lt;include&gt; directive.
831 </para>
832 <para>
833 <emphasis>fonts.dtd</emphasis>
834 is a DTD that describes the format of the configuration files.
835 </para>
836 <para>
837 <emphasis>$XDG_CONFIG_HOME/fontconfig/conf.d</emphasis> and <emphasis>~/.fonts.conf.d</emphasis>
838 is the conventional name for a per-user directory of (typically
839 auto-generated) configuration files, although the
840 actual location is specified in the global fonts.conf file. please note that ~/.fonts.conf.d is deprecated now. it will not be read by default in the future version.
841 </para>
842 <para>
843 <emphasis>$XDG_CONFIG_HOME/fontconfig/fonts.conf</emphasis> and <emphasis>~/.fonts.conf</emphasis>
844 is the conventional location for per-user font configuration, although the
845 actual location is specified in the global fonts.conf file. please note that ~/.fonts.conf is deprecated now. it will not be read by default in the future version.
846 </para>
847 <para>
848 <emphasis>$XDG_CACHE_HOME/fontconfig/*.cache-*</emphasis> and <emphasis> ~/.fontconfig/*.cache-*</emphasis>
849 is the conventional repository of font information that isn't found in the
850 per-directory caches. This file is automatically maintained by fontconfig. please note that ~/.fontconfig/*.cache-* is deprecated now. it will not be read by default in the future version.
851 </para>
852 </refsect1>
853 <refsect1><title>Environment variables</title>
854 <para>
855 <emphasis>FONTCONFIG_FILE</emphasis>
856 is used to override the default configuration file.
857 </para>
858 <para>
859 <emphasis>FONTCONFIG_PATH</emphasis>
860 is used to override the default configuration directory.
861 </para>
862 <para>
863 <emphasis>FONTCONFIG_SYSROOT</emphasis>
864 is used to set a default sysroot directory.
865 </para>
866 <para>
867 <emphasis>FC_DEBUG</emphasis>
868 is used to output the detailed debugging messages. see <link linkend="debug">Debugging Applications</link> section for more details.
869 </para>
870 <para>
871 <emphasis>FC_DBG_MATCH_FILTER</emphasis>
872 is used to filter out the patterns. this takes a comma-separated list of object names and effects only when FC_DEBUG has MATCH2. see <link linkend="debug">Debugging Applications</link> section for more details.
873 </para>
874 <para>
875 <emphasis>FC_LANG</emphasis>
876 is used to specify the default language as the weak binding in the query. if this isn't set, the default language will be determined from current locale.
877 </para>
878 <para>
879 <emphasis>FONTCONFIG_USE_MMAP</emphasis>
880 is used to control the use of mmap(2) for the cache files if available. this take a boolean value. fontconfig will checks if the cache files are stored on the filesystem that is safe to use mmap(2). explicitly setting this environment variable will causes skipping this check and enforce to use or not use mmap(2) anyway.
881 </para>
882 <para>
883 <emphasis>SOURCE_DATE_EPOCH</emphasis>
884 is used to ensure <literal>fc-cache(1)</literal> generates files in a deterministic manner in order to support reproducible builds. When set to a numeric representation of UNIX timestamp, fontconfig will prefer this value over using the modification timestamps of the input files in order to identify which cache files require regeneration. If <literal>SOURCE_DATE_EPOCH</literal> is not set (or is newer than the mtime of the directory), the existing behaviour is unchanged.
885 </para>
886 </refsect1>
887 <refsect1><title>See Also</title>
888 <para>
889 fc-cat(1), fc-cache(1), fc-list(1), fc-match(1), fc-query(1), <ulink url="https://reproducible-builds.org/specs/source-date-epoch/">SOURCE_DATE_EPOCH</ulink>.
890 </para>
891 </refsect1>
892 <refsect1><title>Version</title>
893 <para>
894 Fontconfig version &version;
895 </para>
896 </refsect1>
897 </refentry>