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