5 fonts.conf -- Font configuration files
12 $XDG_CONFIG_HOME/fontconfig/conf.d
13 $XDG_CONFIG_HOME/fontconfig/fonts.conf
19 Fontconfig is a library designed to provide system-wide font
20 configuration, customization and application access.
24 Fontconfig contains two essential modules, the configuration
25 module which builds an internal configuration from XML files
26 and the matching module which accepts font patterns and returns
27 the nearest matching font.
31 The configuration module consists of the FcConfig datatype,
32 libexpat and FcConfigParse which walks over an XML tree and
33 amends a configuration with data found within. From an external
34 perspective, configuration of the library consists of
35 generating a valid XML tree and feeding that to FcConfigParse.
36 The only other mechanism provided to applications for changing
37 the running configuration is to add fonts and directories to
38 the list of application-provided font files.
40 The intent is to make font configurations relatively static,
41 and shared by as many applications as possible. It is hoped
42 that this will lead to more stable font selection when passing
43 names from one application to another. XML was chosen as a
44 configuration file format because it provides a format which is
45 easy for external agents to edit while retaining the correct
48 Font configuration is separate from font matching; applications
49 needing to do their own matching can access the available fonts
50 from the library and perform private matching. The intent is to
51 permit applications to pick and choose appropriate
52 functionality from the library instead of forcing them to
53 choose between this library and a private configuration
54 mechanism. The hope is that this will ensure that configuration
55 of fonts for all applications can be centralized in one place.
56 Centralizing font configuration will simplify and regularize
57 font installation and customization.
61 While font patterns may contain essentially any properties,
62 there are some well known properties with associated types.
63 Fontconfig uses some of these properties for font matching and
64 font completion. Others are provided as a convenience for the
65 applications' rendering mechanism.
66 Property Type Description
67 --------------------------------------------------------------
68 family String Font family names
69 familylang String Languages corresponding to each family
70 style String Font style. Overrides weight and slant
71 stylelang String Languages corresponding to each style
72 fullname String Font full names (often includes style)
73 fullnamelang String Languages corresponding to each fullname
74 slant Int Italic, oblique or roman
75 weight Int Light, medium, demibold, bold or black
76 size Double Point size
77 width Int Condensed, normal or expanded
78 aspect Double Stretches glyphs horizontally before hinting
79 pixelsize Double Pixel size
80 spacing Int Proportional, dual-width, monospace or charcel
82 foundry String Font foundry name
83 antialias Bool Whether glyphs can be antialiased
84 hinting Bool Whether the rasterizer should use hinting
85 hintstyle Int Automatic hinting style
86 verticallayout Bool Use vertical layout
87 autohint Bool Use autohinter instead of normal hinter
88 globaladvance Bool Use font global advance data (deprecated)
89 file String The filename holding the font
90 index Int The index of the font within the file
91 ftface FT_Face Use the specified FreeType face object
92 rasterizer String Which rasterizer is in use (deprecated)
93 outline Bool Whether the glyphs are outlines
94 scalable Bool Whether glyphs can be scaled
95 color Bool Whether any glyphs have color
96 scale Double Scale factor for point->pixel conversions
97 dpi Double Target dots per inch
98 rgba Int unknown, rgb, bgr, vrgb, vbgr,
99 none - subpixel geometry
100 lcdfilter Int Type of LCD filter
101 minspace Bool Eliminate leading from line spacing
102 charset CharSet Unicode chars encoded by the font
103 lang String List of RFC-3066-style languages this
105 fontversion Int Version number of the font
106 capability String List of layout capabilities in the font
107 fontformat String String name of the font format
108 embolden Bool Rasterizer should synthetically embolden the f
110 embeddedbitmap Bool Use the embedded bitmap instead of the outline
111 decorative Bool Whether the style is a decorative variant
112 fontfeatures String List of the feature tags in OpenType to be ena
114 namelang String Language name to be used for the default value
116 familylang, stylelang, and fullnamelang
117 prgname String String Name of the running program
118 postscriptname String Font family name in PostScript
122 Fontconfig performs matching by measuring the distance from a
123 provided pattern to all of the available fonts in the system.
124 The closest matching font is selected. This ensures that a font
125 will always be returned, but doesn't ensure that it is anything
126 like the requested pattern.
128 Font matching starts with an application constructed pattern.
129 The desired attributes of the resulting font are collected
130 together in a pattern. Each property of the pattern can contain
131 one or more values; these are listed in priority order; matches
132 earlier in the list are considered "closer" than matches later
135 The initial pattern is modified by applying the list of editing
136 instructions specific to patterns found in the configuration;
137 each consists of a match predicate and a set of editing
138 operations. They are executed in the order they appeared in the
139 configuration. Each match causes the associated sequence of
140 editing operations to be applied.
142 After the pattern has been edited, a sequence of default
143 substitutions are performed to canonicalize the set of
144 available properties; this avoids the need for the lower layers
145 to constantly provide default values for various font
146 properties during rendering.
148 The canonical font pattern is finally matched against all
149 available fonts. The distance from the pattern to the font is
150 measured for each of several properties: foundry, charset,
151 family, lang, spacing, pixelsize, style, slant, weight,
152 antialias, rasterizer and outline. This list is in priority
153 order -- results of comparing earlier elements of this list
154 weigh more heavily than later elements.
156 There is one special case to this rule; family names are split
157 into two bindings; strong and weak. Strong family names are
158 given greater precedence in the match than lang elements while
159 weak family names are given lower precedence than lang
160 elements. This permits the document language to drive font
161 selection when any document specified font is unavailable.
163 The pattern representing that font is augmented to include any
164 properties found in the pattern but not found in the font
165 itself; this permits the application to pass rendering
166 instructions or any other data through the matching system.
167 Finally, the list of editing instructions specific to fonts
168 found in the configuration are applied to the pattern. This
169 modified pattern is returned to the application.
171 The return value contains sufficient information to locate and
172 rasterize the font, including the file name, pixel size and
173 other rendering data. As none of the information involved
174 pertains to the FreeType library, applications are free to use
175 any rasterization engine or even to take the identified font
176 file and access it directly.
178 The match/edit sequences in the configuration are performed in
179 two passes because there are essentially two different
180 operations necessary -- the first is to modify how fonts are
181 selected; aliasing families and adding suitable defaults. The
182 second is to modify how the selected fonts are rasterized.
183 Those must apply to the selected font, not the original pattern
184 as false matches will often occur.
188 Fontconfig provides a textual representation for patterns that
189 the library can both accept and generate. The representation is
190 in three parts, first a list of family names, second a list of
191 point sizes and finally a list of additional properties:
192 <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>...
194 Values in a list are separated with commas. The name needn't
195 include either families or point sizes; they can be elided. In
196 addition, there are symbolic constants that simultaneously
197 indicate both a name and a value. Here are some examples:
199 ----------------------------------------------------------
200 Times-12 12 point Times Roman
201 Times-12:bold 12 point Times Bold
202 Courier:italic Courier Italic in the default size
203 Monospace:matrix=1 .1 0 1 The users preferred monospace font
204 with artificial obliquing
206 The '\', '-', ':' and ',' characters in family names must be
207 preceded by a '\' character to avoid having them
208 misinterpreted. Similarly, values containing '\', '=', '_', ':'
209 and ',' must also have them preceded by a '\' character. The
210 '\' characters are stripped out of the family name and values
211 as the font name is read.
213 Debugging Applications
215 To help diagnose font and applications problems, fontconfig is
216 built with a large amount of internal debugging left enabled.
217 It is controlled by means of the FC_DEBUG environment variable.
218 The value of this variable is interpreted as a number, and each
219 bit within that value controls different debugging messages.
221 ---------------------------------------------------------
222 MATCH 1 Brief information about font matching
223 MATCHV 2 Extensive font matching information
224 EDIT 4 Monitor match/test/edit execution
225 FONTSET 8 Track loading of font information at startup
226 CACHE 16 Watch cache files being written
227 CACHEV 32 Extensive cache file writing information
228 PARSE 64 (no longer in use)
229 SCAN 128 Watch font files being scanned to build caches
230 SCANV 256 Verbose font file scanning information
231 MEMORY 512 Monitor fontconfig memory usage
232 CONFIG 1024 Monitor which config files are loaded
233 LANGSET 2048 Dump char sets used to construct lang values
234 OBJTYPES 4096 Display message when value typechecks fail
236 Add the value of the desired debug levels together and assign
237 that (in base 10) to the FC_DEBUG environment variable before
238 running the application. Output from these statements is sent
243 Each font in the database contains a list of languages it
244 supports. This is computed by comparing the Unicode coverage of
245 the font with the orthography of each language. Languages are
246 tagged using an RFC-3066 compatible naming and occur in two
247 parts -- the ISO 639 language tag followed a hyphen and then by
248 the ISO 3166 country code. The hyphen and country code may be
251 Fontconfig has orthographies for several languages built into
252 the library. No provision has been made for adding new ones
253 aside from rebuilding the library. It currently supports 122 of
254 the 139 languages named in ISO 639-1, 141 of the languages with
255 two-letter codes from ISO 639-2 and another 30 languages with
256 only three-letter codes. Languages with both two and three
257 letter codes are provided with only the two letter code.
259 For languages used in multiple territories with radically
260 different character sets, fontconfig includes per-territory
261 orthographies. This includes Azerbaijani, Kurdish, Pashto,
262 Tigrinya and Chinese.
264 Configuration File Format
266 Configuration files for fontconfig are stored in XML format;
267 this format makes external configuration tools easier to write
268 and ensures that they will generate syntactically correct
269 configuration files. As XML files are plain text, they can also
270 be manipulated by the expert user using a text editor.
272 The fontconfig document type definition resides in the external
273 entity "fonts.dtd"; this is normally stored in the default font
274 configuration directory (/etc/fonts). Each configuration file
275 should contain the following structure:
276 <?xml version="1.0"?>
277 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
284 This is the top level element for a font configuration and can
285 contain <dir>, <cachedir>, <include>, <match> and <alias>
286 elements in any order.
288 <dir prefix="default">
290 This element contains a directory name which will be scanned
291 for font files to include in the set of available fonts. If
292 'prefix' is set to "xdg", the value in the XDG_DATA_HOME
293 environment variable will be added as the path prefix. please
294 see XDG Base Directory Specification for more details.
296 <cachedir prefix="default">
298 This element contains a directory name that is supposed to be
299 stored or read the cache of font information. If multiple
300 elements are specified in the configuration file, the directory
301 that can be accessed first in the list will be used to store
302 the cache files. If it starts with '~', it refers to a
303 directory in the users home directory. If 'prefix' is set to
304 "xdg", the value in the XDG_CACHE_HOME environment variable
305 will be added as the path prefix. please see XDG Base Directory
306 Specification for more details. The default directory is
307 ``$XDG_CACHE_HOME/fontconfig'' and it contains the cache files
308 named ``<hash value>-<architecture>.cache-<version>'', where
309 <version> is the font configureation file version number
312 <include ignore_missing="no" prefix="default">
314 This element contains the name of an additional configuration
315 file or directory. If a directory, every file within that
316 directory starting with an ASCII digit (U+0030 - U+0039) and
317 ending with the string ``.conf'' will be processed in sorted
318 order. When the XML datatype is traversed by FcConfigParse, the
319 contents of the file(s) will also be incorporated into the
320 configuration by passing the filename(s) to
321 FcConfigLoadAndParse. If 'ignore_missing' is set to "yes"
322 instead of the default "no", a missing file or directory will
323 elicit no warning message from the library. If 'prefix' is set
324 to "xdg", the value in the XDG_CONFIG_HOME environment variable
325 will be added as the path prefix. please see XDG Base Directory
326 Specification for more details.
330 This element provides a place to consolidate additional
331 configuration information. <config> can contain <blank> and
332 <rescan> elements in any order.
336 Fonts often include "broken" glyphs which appear in the
337 encoding but are drawn as blanks on the screen. Within the
338 <blank> element, place each Unicode characters which is
339 supposed to be blank in an <int> element. Characters outside of
340 this set which are drawn as blank will be elided from the set
341 of characters supported by the font.
345 The <rescan> element holds an <int> element which indicates the
346 default interval between automatic checks for font
347 configuration changes. Fontconfig will validate all of the
348 configuration files and directories and automatically rebuild
349 the internal datastructures when this interval passes.
353 This element is used to black/white list fonts from being
354 listed or matched against. It holds acceptfont and rejectfont
359 Fonts matched by an acceptfont element are "whitelisted"; such
360 fonts are explicitly included in the set of fonts used to
361 resolve list and match requests; including them in this list
362 protects them from being "blacklisted" by a rejectfont element.
363 Acceptfont elements include glob and pattern elements which are
368 Fonts matched by an rejectfont element are "blacklisted"; such
369 fonts are excluded from the set of fonts used to resolve list
370 and match requests as if they didn't exist in the system.
371 Rejectfont elements include glob and pattern elements which are
376 Glob elements hold shell-style filename matching patterns
377 (including ? and *) which match fonts based on their complete
378 pathnames. This can be used to exclude a set of directories
379 (/usr/share/fonts/uglyfont*), or particular font file types
380 (*.pcf.gz), but the latter mechanism relies rather heavily on
381 filenaming conventions which can't be relied upon. Note that
382 globs only apply to directories, not to individual fonts.
386 Pattern elements perform list-style matching on incoming fonts;
387 that is, they hold a list of elements and associated values. If
388 all of those elements have a matching value, then the pattern
389 matches the font. This can be used to select fonts based on
390 attributes of the font (scalable, bold, etc), which is a more
391 reliable mechanism than using file extensions. Pattern elements
392 include patelt elements.
394 <patelt name="property">
396 Patelt elements hold a single pattern element and list of
397 values. They must have a 'name' attribute which indicates the
398 pattern element name. Patelt elements include int, double,
399 string, matrix, bool, charset and const elements.
401 <match target="pattern">
403 This element holds first a (possibly empty) list of <test>
404 elements and then a (possibly empty) list of <edit> elements.
405 Patterns which match all of the tests are subjected to all the
406 edits. If 'target' is set to "font" instead of the default
407 "pattern", then this element applies to the font name resulting
408 from a match rather than a font pattern to be matched. If
409 'target' is set to "scan", then this element applies when the
410 font is scanned to build the fontconfig database.
412 <test qual="any" name="property" target="default" compare="eq">
414 This element contains a single value which is compared with the
415 target ('pattern', 'font', 'scan' or 'default') property
416 "property" (substitute any of the property names seen above).
417 'compare' can be one of "eq", "not_eq", "less", "less_eq",
418 "more", "more_eq", "contains" or "not_contains". 'qual' may
419 either be the default, "any", in which case the match succeeds
420 if any value associated with the property matches the test
421 value, or "all", in which case all of the values associated
422 with the property must match the test value. 'ignore-blanks'
423 takes a boolean value. if 'ignore-blanks' is set "true", any
424 blanks in the string will be ignored on its comparison. this
425 takes effects only when compare="eq" or compare="not_eq". When
426 used in a <match target="font"> element, the target= attribute
427 in the <test> element selects between matching the original
428 pattern or the font. "default" selects whichever target the
429 outer <match> element has selected.
431 <edit name="property" mode="assign" binding="weak">
433 This element contains a list of expression elements (any of the
434 value or operator elements). The expression elements are
435 evaluated at run-time and modify the property "property". The
436 modification depends on whether "property" was matched by one
437 of the associated <test> elements, if so, the modification may
438 affect the first matched value. Any values inserted into the
439 property are given the indicated binding ("strong", "weak" or
440 "same") with "same" binding using the value from the matched
441 pattern element. 'mode' is one of:
442 Mode With Match Without Match
443 ---------------------------------------------------------------------
444 "assign" Replace matching value Replace all values
445 "assign_replace" Replace all values Replace all values
446 "prepend" Insert before matching Insert at head of list
447 "prepend_first" Insert at head of list Insert at head of list
448 "append" Append after matching Append at end of list
449 "append_last" Append at end of list Append at end of list
450 "delete" Delete matching value Delete all values
451 "delete_all" Delete all values Delete all values
453 <int>, <double>, <string>, <bool>
455 These elements hold a single value of the indicated type.
456 <bool> elements hold either true or false. An important
457 limitation exists in the parsing of floating point numbers --
458 fontconfig requires that the mantissa start with a digit, not a
459 decimal point, so insert a leading zero for purely fractional
460 values (e.g. use 0.5 instead of .5 and -0.5 instead of -.5).
464 This element holds four numerical expressions of an affine
465 transformation. At their simplest these will be four <double>
466 elements but they can also be more involved expressions.
470 This element holds the two <int> elements of a range
475 This element holds at least one <int> element of an Unicode
480 This element holds at least one <string> element of a
481 RFC-3066-style languages or more.
485 Holds a property name. Evaluates to the first value from the
486 property of the pattern. If the 'target' attribute is not
487 present, it will default to 'default', in which case the
488 property is returned from the font pattern during a
489 target="font" match, and to the pattern during a
490 target="pattern" match. The attribute can also take the values
491 'font' or 'pattern' to explicitly choose which pattern to use.
492 It is an error to use a target of 'font' in a match that has
497 Holds the name of a constant; these are always integers and
498 serve as symbolic names for common font values:
499 Constant Property Value
500 -------------------------------------
520 ultracondensed width 50
521 extracondensed width 63
523 semicondensed width 87
525 semiexpanded width 113
527 extraexpanded width 150
528 ultraexpanded width 200
529 proportional spacing 0
540 lcddefault lcdfilter 1
542 lcdlegacy lcdfilter 3
544 hintslight hintstyle 1
545 hintmedium hintstyle 2
548 <or>, <and>, <plus>, <minus>, <times>, <divide>
550 These elements perform the specified operation on a list of
551 expression elements. <or> and <and> are boolean, not bitwise.
553 <eq>, <not_eq>, <less>, <less_eq>, <more>, <more_eq>, <contains>,
556 These elements compare two values, producing a boolean result.
560 Inverts the boolean sense of its one expression element
564 This element takes three expression elements; if the value of
565 the first is true, it produces the value of the second,
566 otherwise it produces the value of the third.
570 Alias elements provide a shorthand notation for the set of
571 common match operations needed to substitute one font family
572 for another. They contain a <family> element followed by
573 optional <prefer>, <accept> and <default> elements. Fonts
574 matching the <family> element are edited to prepend the list of
575 <prefer>ed families before the matching <family>, append the
576 <accept>able families after the matching <family> and append
577 the <default> families to the end of the family list.
581 Holds a single font family name
583 <prefer>, <accept>, <default>
585 These hold a list of <family> elements to be used by the
588 EXAMPLE CONFIGURATION FILE
590 System configuration file
592 This is an example of a system-wide configuration file
593 <?xml version="1.0"?>
594 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
595 <!-- /etc/fonts/fonts.conf file to configure system font access -->
598 Find fonts in these directories
600 <dir>/usr/share/fonts</dir>
601 <dir>/usr/X11R6/lib/X11/fonts</dir>
604 Accept deprecated 'mono' alias, replacing it with 'monospace'
606 <match target="pattern">
607 <test qual="any" name="family"><string>mono</string></test>
608 <edit name="family" mode="assign"><string>monospace</string></ed
613 Names not including any well known alias are given 'sans-serif'
615 <match target="pattern">
616 <test qual="all" name="family" mode="not_eq"><string>sans-serif<
618 <test qual="all" name="family" mode="not_eq"><string>serif</stri
620 <test qual="all" name="family" mode="not_eq"><string>monospace</
622 <edit name="family" mode="append_last"><string>sans-serif</strin
627 Load per-user customization file, but don't complain
630 <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</includ
634 Load local customization files, but don't complain
637 <include ignore_missing="yes">conf.d</include>
638 <include ignore_missing="yes">local.conf</include>
641 Alias well known font names to available TrueType fonts.
642 These substitute TrueType faces for similar Type1
643 faces to improve screen appearance.
646 <family>Times</family>
647 <prefer><family>Times New Roman</family></prefer>
648 <default><family>serif</family></default>
651 <family>Helvetica</family>
652 <prefer><family>Arial</family></prefer>
653 <default><family>sans</family></default>
656 <family>Courier</family>
657 <prefer><family>Courier New</family></prefer>
658 <default><family>monospace</family></default>
662 Provide required aliases for standard names
663 Do these after the users configuration file so that
664 any aliases there are used preferentially
667 <family>serif</family>
668 <prefer><family>Times New Roman</family></prefer>
671 <family>sans</family>
672 <prefer><family>Arial</family></prefer>
675 <family>monospace</family>
676 <prefer><family>Andale Mono</family></prefer>
680 The example of the requirements of OR operator;
681 If the 'family' contains 'Courier New' OR 'Courier'
682 add 'monospace' as the alternative
684 <match target="pattern">
685 <test name="family" mode="eq">
686 <string>Courier New</string>
688 <edit name="family" mode="prepend">
689 <string>monospace</string>
692 <match target="pattern">
693 <test name="family" mode="eq">
694 <string>Courier</string>
696 <edit name="family" mode="prepend">
697 <string>monospace</string>
703 User configuration file
705 This is an example of a per-user configuration file that lives
706 in $XDG_CONFIG_HOME/fontconfig/fonts.conf
707 <?xml version="1.0"?>
708 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
709 <!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configurat
714 Private font directory
716 <dir prefix="xdg">fonts</dir>
719 use rgb sub-pixel ordering to improve glyph appearance on
720 LCD screens. Changes affecting rendering, but not matching
721 should always use target="font".
723 <match target="font">
724 <edit name="rgba" mode="assign"><const>rgb</const></edit>
727 use WenQuanYi Zen Hei font when serif is requested for Chinese
731 If you don't want to use WenQuanYi Zen Hei font for zh-t
733 you can use zh-cn instead of zh.
734 Please note, even if you set zh-cn, it still matches zh.
735 if you don't like it, you can use compare="eq"
736 instead of compare="contains".
738 <test name="lang" compare="contains">
742 <string>serif</string>
744 <edit name="family" mode="prepend">
745 <string>WenQuanYi Zen Hei</string>
749 use VL Gothic font when sans-serif is requested for Japanese
752 <test name="lang" compare="contains">
756 <string>sans-serif</string>
758 <edit name="family" mode="prepend">
759 <string>VL Gothic</string>
766 fonts.conf contains configuration information for the
767 fontconfig library consisting of directories to look at for
768 font information as well as instructions on editing program
769 specified font patterns before attempting to match the
770 available fonts. It is in XML format.
772 conf.d is the conventional name for a directory of additional
773 configuration files managed by external applications or the
774 local administrator. The filenames starting with decimal digits
775 are sorted in lexicographic order and used as additional
776 configuration files. All of these files are in XML format. The
777 master fonts.conf file references this directory in an
780 fonts.dtd is a DTD that describes the format of the
783 $XDG_CONFIG_HOME/fontconfig/conf.d and ~/.fonts.conf.d is the
784 conventional name for a per-user directory of (typically
785 auto-generated) configuration files, although the actual
786 location is specified in the global fonts.conf file. please
787 note that ~/.fonts.conf.d is deprecated now. it will not be
788 read by default in the future version.
790 $XDG_CONFIG_HOME/fontconfig/fonts.conf and ~/.fonts.conf is the
791 conventional location for per-user font configuration, although
792 the actual location is specified in the global fonts.conf file.
793 please note that ~/.fonts.conf is deprecated now. it will not
794 be read by default in the future version.
796 $XDG_CACHE_HOME/fontconfig/*.cache-* and
797 ~/.fontconfig/*.cache-* is the conventional repository of font
798 information that isn't found in the per-directory caches. This
799 file is automatically maintained by fontconfig. please note
800 that ~/.fontconfig/*.cache-* is deprecated now. it will not be
801 read by default in the future version.
803 Environment variables
805 FONTCONFIG_FILE is used to override the default configuration
808 FONTCONFIG_PATH is used to override the default configuration
811 FC_DEBUG is used to output the detailed debugging messages. see
812 Debugging Applications section for more details.
814 FONTCONFIG_USE_MMAP is used to control the use of mmap(2) for
815 the cache files if available. this take a boolean value.
816 fontconfig will checks if the cache files are stored on the
817 filesystem that is safe to use mmap(2). explicitly setting this
818 environment variable will causes skipping this check and
819 enforce to use or not use mmap(2) anyway.
823 fc-cat(1), fc-cache(1), fc-list(1), fc-match(1), fc-query(1)
827 Fontconfig version 2.11.93