1FONTS-CONF(5) FONTS-CONF(5)
2
3
4
6 fonts.conf - Font configuration files
7
9 /etc/fonts/fonts.conf
10 /etc/fonts/fonts.dtd
11 /etc/fonts/conf.d
12 ~/.fonts.conf.d
13 ~/.fonts.conf
14
15
17 Fontconfig is a library designed to provide system-wide font configura‐
18 tion, customization and application access.
19
21 Fontconfig contains two essential modules, the configuration module
22 which builds an internal configuration from XML files and the matching
23 module which accepts font patterns and returns the nearest matching
24 font.
25
26 FONT CONFIGURATION
27 The configuration module consists of the FcConfig datatype, libexpat
28 and FcConfigParse which walks over an XML tree and amends a configura‐
29 tion with data found within. From an external perspective, configura‐
30 tion of the library consists of generating a valid XML tree and feeding
31 that to FcConfigParse. The only other mechanism provided to applica‐
32 tions for changing the running configuration is to add fonts and direc‐
33 tories to the list of application-provided font files.
34
35 The intent is to make font configurations relatively static, and shared
36 by as many applications as possible. It is hoped that this will lead to
37 more stable font selection when passing names from one application to
38 another. XML was chosen as a configuration file format because it pro‐
39 vides a format which is easy for external agents to edit while retain‐
40 ing the correct structure and syntax.
41
42 Font configuration is separate from font matching; applications needing
43 to do their own matching can access the available fonts from the
44 library and perform private matching. The intent is to permit applica‐
45 tions to pick and choose appropriate functionality from the library
46 instead of forcing them to choose between this library and a private
47 configuration mechanism. The hope is that this will ensure that config‐
48 uration of fonts for all applications can be centralized in one place.
49 Centralizing font configuration will simplify and regularize font
50 installation and customization.
51
52 FONT PROPERTIES
53 While font patterns may contain essentially any properties, there are
54 some well known properties with associated types. Fontconfig uses some
55 of these properties for font matching and font completion. Others are
56 provided as a convenience for the applications' rendering mechanism.
57
58 Property Type Description
59 --------------------------------------------------------------
60 family String Font family names
61 familylang String Languages corresponding to each family
62 style String Font style. Overrides weight and slant
63 stylelang String Languages corresponding to each style
64 fullname String Font full names (often includes style)
65 fullnamelang String Languages corresponding to each fullname
66 slant Int Italic, oblique or roman
67 weight Int Light, medium, demibold, bold or black
68 size Double Point size
69 width Int Condensed, normal or expanded
70 aspect Double Stretches glyphs horizontally before hinting
71 pixelsize Double Pixel size
72 spacing Int Proportional, dual-width, monospace or charcell
73 foundry String Font foundry name
74 antialias Bool Whether glyphs can be antialiased
75 hinting Bool Whether the rasterizer should use hinting
76 hintstyle Int Automatic hinting style
77 verticallayout Bool Use vertical layout
78 autohint Bool Use autohinter instead of normal hinter
79 globaladvance Bool Use font global advance data
80 file String The filename holding the font
81 index Int The index of the font within the file
82 ftface FT_Face Use the specified FreeType face object
83 rasterizer String Which rasterizer is in use
84 outline Bool Whether the glyphs are outlines
85 scalable Bool Whether glyphs can be scaled
86 scale Double Scale factor for point->pixel conversions
87 dpi Double Target dots per inch
88 rgba Int unknown, rgb, bgr, vrgb, vbgr,
89 none - subpixel geometry
90 lcdfilter Int Type of LCD filter
91 minspace Bool Eliminate leading from line spacing
92 charset CharSet Unicode chars encoded by the font
93 lang String List of RFC-3066-style languages this
94 font supports
95 fontversion Int Version number of the font
96 capability String List of layout capabilities in the font
97 embolden Bool Rasterizer should synthetically embolden the font
98
99
100
101 FONT MATCHING
102 Fontconfig performs matching by measuring the distance from a provided
103 pattern to all of the available fonts in the system. The closest match‐
104 ing font is selected. This ensures that a font will always be returned,
105 but doesn't ensure that it is anything like the requested pattern.
106
107 Font matching starts with an application constructed pattern. The
108 desired attributes of the resulting font are collected together in a
109 pattern. Each property of the pattern can contain one or more values;
110 these are listed in priority order; matches earlier in the list are
111 considered "closer" than matches later in the list.
112
113 The initial pattern is modified by applying the list of editing
114 instructions specific to patterns found in the configuration; each con‐
115 sists of a match predicate and a set of editing operations. They are
116 executed in the order they appeared in the configuration. Each match
117 causes the associated sequence of editing operations to be applied.
118
119 After the pattern has been edited, a sequence of default substitutions
120 are performed to canonicalize the set of available properties; this
121 avoids the need for the lower layers to constantly provide default val‐
122 ues for various font properties during rendering.
123
124 The canonical font pattern is finally matched against all available
125 fonts. The distance from the pattern to the font is measured for each
126 of several properties: foundry, charset, family, lang, spacing, pixel‐
127 size, style, slant, weight, antialias, rasterizer and outline. This
128 list is in priority order -- results of comparing earlier elements of
129 this list weigh more heavily than later elements.
130
131 There is one special case to this rule; family names are split into two
132 bindings; strong and weak. Strong family names are given greater prece‐
133 dence in the match than lang elements while weak family names are given
134 lower precedence than lang elements. This permits the document language
135 to drive font selection when any document specified font is unavail‐
136 able.
137
138 The pattern representing that font is augmented to include any proper‐
139 ties found in the pattern but not found in the font itself; this per‐
140 mits the application to pass rendering instructions or any other data
141 through the matching system. Finally, the list of editing instructions
142 specific to fonts found in the configuration are applied to the pat‐
143 tern. This modified pattern is returned to the application.
144
145 The return value contains sufficient information to locate and raster‐
146 ize the font, including the file name, pixel size and other rendering
147 data. As none of the information involved pertains to the FreeType
148 library, applications are free to use any rasterization engine or even
149 to take the identified font file and access it directly.
150
151 The match/edit sequences in the configuration are performed in two
152 passes because there are essentially two different operations necessary
153 -- the first is to modify how fonts are selected; aliasing families and
154 adding suitable defaults. The second is to modify how the selected
155 fonts are rasterized. Those must apply to the selected font, not the
156 original pattern as false matches will often occur.
157
158 FONT NAMES
159 Fontconfig provides a textual representation for patterns that the
160 library can both accept and generate. The representation is in three
161 parts, first a list of family names, second a list of point sizes and
162 finally a list of additional properties:
163
164 <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>...
165
166
167
168 Values in a list are separated with commas. The name needn't include
169 either families or point sizes; they can be elided. In addition, there
170 are symbolic constants that simultaneously indicate both a name and a
171 value. Here are some examples:
172
173 Name Meaning
174 ----------------------------------------------------------
175 Times-12 12 point Times Roman
176 Times-12:bold 12 point Times Bold
177 Courier:italic Courier Italic in the default size
178 Monospace:matrix=1 .1 0 1 The users preferred monospace font
179 with artificial obliquing
180
181
182
183 The '\', '-', ':' and ',' characters in family names must be preceeded
184 by a '\' character to avoid having them misinterpreted. Similarly, val‐
185 ues containing '\', '=', '_', ':' and ',' must also have them preceeded
186 by a '\' character. The '\' characters are stripped out of the family
187 name and values as the font name is read.
188
190 To help diagnose font and applications problems, fontconfig is built
191 with a large amount of internal debugging left enabled. It is con‐
192 trolled by means of the FC_DEBUG environment variable. The value of
193 this variable is interpreted as a number, and each bit within that
194 value controls different debugging messages.
195
196 Name Value Meaning
197 ---------------------------------------------------------
198 MATCH 1 Brief information about font matching
199 MATCHV 2 Extensive font matching information
200 EDIT 4 Monitor match/test/edit execution
201 FONTSET 8 Track loading of font information at startup
202 CACHE 16 Watch cache files being written
203 CACHEV 32 Extensive cache file writing information
204 PARSE 64 (no longer in use)
205 SCAN 128 Watch font files being scanned to build caches
206 SCANV 256 Verbose font file scanning information
207 MEMORY 512 Monitor fontconfig memory usage
208 CONFIG 1024 Monitor which config files are loaded
209 LANGSET 2048 Dump char sets used to construct lang values
210 OBJTYPES 4096 Display message when value typechecks fail
211
212
213
214 Add the value of the desired debug levels together and assign that (in
215 base 10) to the FC_DEBUG environment variable before running the appli‐
216 cation. Output from these statements is sent to stdout.
217
219 Each font in the database contains a list of languages it supports.
220 This is computed by comparing the Unicode coverage of the font with the
221 orthography of each language. Languages are tagged using an RFC-3066
222 compatible naming and occur in two parts -- the ISO 639 language tag
223 followed a hyphen and then by the ISO 3166 country code. The hyphen and
224 country code may be elided.
225
226 Fontconfig has orthographies for several languages built into the
227 library. No provision has been made for adding new ones aside from
228 rebuilding the library. It currently supports 122 of the 139 languages
229 named in ISO 639-1, 141 of the languages with two-letter codes from ISO
230 639-2 and another 30 languages with only three-letter codes. Languages
231 with both two and three letter codes are provided with only the two
232 letter code.
233
234 For languages used in multiple territories with radically different
235 character sets, fontconfig includes per-territory orthographies. This
236 includes Azerbaijani, Kurdish, Pashto, Tigrinya and Chinese.
237
239 Configuration files for fontconfig are stored in XML format; this for‐
240 mat makes external configuration tools easier to write and ensures that
241 they will generate syntactically correct configuration files. As XML
242 files are plain text, they can also be manipulated by the expert user
243 using a text editor.
244
245 The fontconfig document type definition resides in the external entity
246 "fonts.dtd"; this is normally stored in the default font configuration
247 directory (/etc/fonts). Each configuration file should contain the fol‐
248 lowing structure:
249
250 <?xml version="1.0"?>
251 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
252 <fontconfig>
253 ...
254 </fontconfig>
255
256
257
258 <FONTCONFIG>
259 This is the top level element for a font configuration and can contain
260 <dir>, <cache>, <include>, <match> and <alias> elements in any order.
261
262 <DIR>
263 This element contains a directory name which will be scanned for font
264 files to include in the set of available fonts.
265
266 <CACHE>
267 This element contains a file name for the per-user cache of font infor‐
268 mation. If it starts with '~', it refers to a file in the users home
269 directory. This file is used to hold information about fonts that isn't
270 present in the per-directory cache files. It is automatically main‐
271 tained by the fontconfig library. The default for this file is
272 ``~/.fonts.cache-<version>'', where <version> is the font configuration
273 file version number (currently 2).
274
275 <INCLUDE IGNORE_MISSING= NO">"
276 This element contains the name of an additional configuration file or
277 directory. If a directory, every file within that directory starting
278 with an ASCII digit (U+0030 - U+0039) and ending with the string
279 ``.conf'' will be processed in sorted order. When the XML datatype is
280 traversed by FcConfigParse, the contents of the file(s) will also be
281 incorporated into the configuration by passing the filename(s) to
282 FcConfigLoadAndParse. If 'ignore_missing' is set to "yes" instead of
283 the default "no", a missing file or directory will elicit no warning
284 message from the library.
285
286 <CONFIG>
287 This element provides a place to consolidate additional configuration
288 information. <config> can contain <blank> and <rescan> elements in any
289 order.
290
291 <BLANK>
292 Fonts often include "broken" glyphs which appear in the encoding but
293 are drawn as blanks on the screen. Within the <blank> element, place
294 each Unicode characters which is supposed to be blank in an <int> ele‐
295 ment. Characters outside of this set which are drawn as blank will be
296 elided from the set of characters supported by the font.
297
298 <RESCAN>
299 The <rescan> element holds an <int> element which indicates the default
300 interval between automatic checks for font configuration changes.
301 Fontconfig will validate all of the configuration files and directories
302 and automatically rebuild the internal datastructures when this inter‐
303 val passes.
304
305 <SELECTFONT>
306 This element is used to black/white list fonts from being listed or
307 matched against. It holds acceptfont and rejectfont elements.
308
309 <ACCEPTFONT>
310 Fonts matched by an acceptfont element are "whitelisted"; such fonts
311 are explicitly included in the set of fonts used to resolve list and
312 match requests; including them in this list protects them from being
313 "blacklisted" by a rejectfont element. Acceptfont elements include glob
314 and pattern elements which are used to match fonts.
315
316 <REJECTFONT>
317 Fonts matched by an rejectfont element are "blacklisted"; such fonts
318 are excluded from the set of fonts used to resolve list and match
319 requests as if they didn't exist in the system. Rejectfont elements
320 include glob and pattern elements which are used to match fonts.
321
322 <GLOB>
323 Glob elements hold shell-style filename matching patterns (including ?
324 and *) which match fonts based on their complete pathnames. This can be
325 used to exclude a set of directories (/usr/share/fonts/uglyfont*), or
326 particular font file types (*.pcf.gz), but the latter mechanism relies
327 rather heavily on filenaming conventions which can't be relied upon.
328 Note that globs only apply to directories, not to individual fonts.
329
330 <PATTERN>
331 Pattern elements perform list-style matching on incoming fonts; that
332 is, they hold a list of elements and associated values. If all of those
333 elements have a matching value, then the pattern matches the font. This
334 can be used to select fonts based on attributes of the font (scalable,
335 bold, etc), which is a more reliable mechanism than using file exten‐
336 sions. Pattern elements include patelt elements.
337
338 <PATELT NAME= PROPERTY">"
339 Patelt elements hold a single pattern element and list of values. They
340 must have a 'name' attribute which indicates the pattern element name.
341 Patelt elements include int, double, string, matrix, bool, charset and
342 const elements.
343
344 <MATCH TARGET= PATTERN">"
345 This element holds first a (possibly empty) list of <test> elements and
346 then a (possibly empty) list of <edit> elements. Patterns which match
347 all of the tests are subjected to all the edits. If 'target' is set to
348 "font" instead of the default "pattern", then this element applies to
349 the font name resulting from a match rather than a font pattern to be
350 matched. If 'target' is set to "scan", then this element applies when
351 the font is scanned to build the fontconfig database.
352
353 <TEST QUAL= ANY" NAME="PROPERTY" TARGET="DEFAULT" COMPARE="EQ">"
354 This element contains a single value which is compared with the target
355 ('pattern', 'font', 'scan' or 'default') property "property" (substi‐
356 tute any of the property names seen above). 'compare' can be one of
357 "eq", "not_eq", "less", "less_eq", "more", or "more_eq". 'qual' may
358 either be the default, "any", in which case the match succeeds if any
359 value associated with the property matches the test value, or "all", in
360 which case all of the values associated with the property must match
361 the test value. When used in a <match target="font"> element, the tar‐
362 get= attribute in the <test> element selects between matching the orig‐
363 inal pattern or the font. "default" selects whichever target the outer
364 <match> element has selected.
365
366 <EDIT NAME= PROPERTY" MODE="ASSIGN" BINDING="WEAK">"
367 This element contains a list of expression elements (any of the value
368 or operator elements). The expression elements are evaluated at run-
369 time and modify the property "property". The modification depends on
370 whether "property" was matched by one of the associated <test> ele‐
371 ments, if so, the modification may affect the first matched value. Any
372 values inserted into the property are given the indicated binding
373 ("strong", "weak" or "same") with "same" binding using the value from
374 the matched pattern element. 'mode' is one of:
375
376 Mode With Match Without Match
377 ---------------------------------------------------------------------
378 "assign" Replace matching value Replace all values
379 "assign_replace" Replace all values Replace all values
380 "prepend" Insert before matching Insert at head of list
381 "prepend_first" Insert at head of list Insert at head of list
382 "append" Append after matching Append at end of list
383 "append_last" Append at end of list Append at end of list
384
385
386
387 <INT>, <DOUBLE>, <STRING>, <BOOL>
388 These elements hold a single value of the indicated type. <bool> ele‐
389 ments hold either true or false. An important limitation exists in the
390 parsing of floating point numbers -- fontconfig requires that the man‐
391 tissa start with a digit, not a decimal point, so insert a leading zero
392 for purely fractional values (e.g. use 0.5 instead of .5 and -0.5
393 instead of -.5).
394
395 <MATRIX>
396 This element holds the four <double> elements of an affine transforma‐
397 tion.
398
399 <NAME>
400 Holds a property name. Evaluates to the first value from the property
401 of the font, not the pattern.
402
403 <CONST>
404 Holds the name of a constant; these are always integers and serve as
405 symbolic names for common font values:
406
407 Constant Property Value
408 -------------------------------------
409 thin weight 0
410 extralight weight 40
411 ultralight weight 40
412 light weight 50
413 book weight 75
414 regular weight 80
415 normal weight 80
416 medium weight 100
417 demibold weight 180
418 semibold weight 180
419 bold weight 200
420 extrabold weight 205
421 black weight 210
422 heavy weight 210
423 roman slant 0
424 italic slant 100
425 oblique slant 110
426 ultracondensed width 50
427 extracondensed width 63
428 condensed width 75
429 semicondensed width 87
430 normal width 100
431 semiexpanded width 113
432 expanded width 125
433 extraexpanded width 150
434 ultraexpanded width 200
435 proportional spacing 0
436 dual spacing 90
437 mono spacing 100
438 charcell spacing 110
439 unknown rgba 0
440 rgb rgba 1
441 bgr rgba 2
442 vrgb rgba 3
443 vbgr rgba 4
444 none rgba 5
445 lcdnone lcdfilter 0
446 lcddefault lcdfilter 1
447 lcdlight lcdfilter 2
448 lcdlegacy lcdfilter 3
449 hintnone hintstyle 0
450 hintslight hintstyle 1
451 hintmedium hintstyle 2
452 hintfull hintstyle 3
453
454
455
456 <OR>, <AND>, <PLUS>, <MINUS>, <TIMES>, <DIVIDE>
457 These elements perform the specified operation on a list of expression
458 elements. <or> and <and> are boolean, not bitwise.
459
460 <EQ>, <NOT_EQ>, <LESS>, <LESS_EQ>, <MORE>, <MORE_EQ>
461 These elements compare two values, producing a boolean result.
462
463 <NOT>
464 Inverts the boolean sense of its one expression element
465
466 <IF>
467 This element takes three expression elements; if the value of the first
468 is true, it produces the value of the second, otherwise it produces the
469 value of the third.
470
471 <ALIAS>
472 Alias elements provide a shorthand notation for the set of common match
473 operations needed to substitute one font family for another. They con‐
474 tain a <family> element followed by optional <prefer>, <accept> and
475 <default> elements. Fonts matching the <family> element are edited to
476 prepend the list of <prefer>ed families before the matching <family>,
477 append the <accept>able families after the matching <family> and append
478 the <default> families to the end of the family list.
479
480 <FAMILY>
481 Holds a single font family name
482
483 <PREFER>, <ACCEPT>, <DEFAULT>
484 These hold a list of <family> elements to be used by the <alias> ele‐
485 ment.
486
488 SYSTEM CONFIGURATION FILE
489 This is an example of a system-wide configuration file
490
491 <?xml version="1.0"?>
492 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
493 <!-- /etc/fonts/fonts.conf file to configure system font access -->
494 <fontconfig>
495 <!--
496 Find fonts in these directories
497 -->
498 <dir>/usr/share/fonts</dir>
499 <dir>/usr/X11R6/lib/X11/fonts</dir>
500
501 <!--
502 Accept deprecated 'mono' alias, replacing it with 'monospace'
503 -->
504 <match target="pattern">
505 <test qual="any" name="family"><string>mono</string></test>
506 <edit name="family" mode="assign"><string>monospace</string></edit>
507 </match>
508
509 <!--
510 Names not including any well known alias are given 'sans'
511 -->
512 <match target="pattern">
513 <test qual="all" name="family" mode="not_eq">sans</test>
514 <test qual="all" name="family" mode="not_eq">serif</test>
515 <test qual="all" name="family" mode="not_eq">monospace</test>
516 <edit name="family" mode="append_last"><string>sans</string></edit>
517 </match>
518
519 <!--
520 Load per-user customization file, but don't complain
521 if it doesn't exist
522 -->
523 <include ignore_missing="yes">~/.fonts.conf</include>
524
525 <!--
526 Load local customization files, but don't complain
527 if there aren't any
528 -->
529 <include ignore_missing="yes">conf.d</include>
530 <include ignore_missing="yes">local.conf</include>
531
532 <!--
533 Alias well known font names to available TrueType fonts.
534 These substitute TrueType faces for similar Type1
535 faces to improve screen appearance.
536 -->
537 <alias>
538 <family>Times</family>
539 <prefer><family>Times New Roman</family></prefer>
540 <default><family>serif</family></default>
541 </alias>
542 <alias>
543 <family>Helvetica</family>
544 <prefer><family>Arial</family></prefer>
545 <default><family>sans</family></default>
546 </alias>
547 <alias>
548 <family>Courier</family>
549 <prefer><family>Courier New</family></prefer>
550 <default><family>monospace</family></default>
551 </alias>
552
553 <!--
554 Provide required aliases for standard names
555 Do these after the users configuration file so that
556 any aliases there are used preferentially
557 -->
558 <alias>
559 <family>serif</family>
560 <prefer><family>Times New Roman</family></prefer>
561 </alias>
562 <alias>
563 <family>sans</family>
564 <prefer><family>Arial</family></prefer>
565 </alias>
566 <alias>
567 <family>monospace</family>
568 <prefer><family>Andale Mono</family></prefer>
569 </alias>
570 </fontconfig>
571
572
573
574 USER CONFIGURATION FILE
575 This is an example of a per-user configuration file that lives in
576 ~/.fonts.conf
577
578 <?xml version="1.0"?>
579 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
580 <!-- ~/.fonts.conf for per-user font configuration -->
581 <fontconfig>
582
583 <!--
584 Private font directory
585 -->
586 <dir>~/.fonts</dir>
587
588 <!--
589 use rgb sub-pixel ordering to improve glyph appearance on
590 LCD screens. Changes affecting rendering, but not matching
591 should always use target="font".
592 -->
593 <match target="font">
594 <edit name="rgba" mode="assign"><const>rgb</const></edit>
595 </match>
596 </fontconfig>
597
598
599
601 fonts.conf contains configuration information for the fontconfig
602 library consisting of directories to look at for font information as
603 well as instructions on editing program specified font patterns before
604 attempting to match the available fonts. It is in xml format.
605
606 conf.d is the conventional name for a directory of additional configu‐
607 ration files managed by external applications or the local administra‐
608 tor. The filenames starting with decimal digits are sorted in lexico‐
609 graphic order and used as additional configuration files. All of these
610 files are in xml format. The master fonts.conf file references this
611 directory in an <include> directive.
612
613 fonts.dtd is a DTD that describes the format of the configuration
614 files.
615
616 ~/.fonts.conf.d is the conventional name for a per-user directory of
617 (typically auto-generated) configuration files, although the actual
618 location is specified in the global fonts.conf file.
619
620 ~/.fonts.conf is the conventional location for per-user font configura‐
621 tion, although the actual location is specified in the global
622 fonts.conf file.
623
624 ~/.fonts.cache-* is the conventional repository of font information
625 that isn't found in the per-directory caches. This file is automati‐
626 cally maintained by fontconfig.
627
629 fc-cat(1), fc-cache(1), fc-list(1), fc-match(1), fc-query(1)
630
632 Fontconfig version 2.8.0
633
634
635
636 18 November 2009 FONTS-CONF(5)