fontconfig-user.txt revision a4e54154
1a32e9e42Smrg fonts-conf 22c393a42Smrg 32c393a42SmrgName 42c393a42Smrg 5a32e9e42Smrg fonts.conf -- Font configuration files 62c393a42Smrg 72c393a42SmrgSynopsis 82c393a42Smrg 9a32e9e42Smrg /etc/fonts/fonts.conf 10a32e9e42Smrg /etc/fonts/fonts.dtd 11a32e9e42Smrg /etc/fonts/conf.d 12a32e9e42Smrg $XDG_CONFIG_HOME/fontconfig/conf.d 13a32e9e42Smrg $XDG_CONFIG_HOME/fontconfig/fonts.conf 14a32e9e42Smrg ~/.fonts.conf.d 15a32e9e42Smrg ~/.fonts.conf 162c393a42Smrg 172c393a42SmrgDescription 182c393a42Smrg 19ca08ab68Smrg Fontconfig is a library designed to provide system-wide font 20ca08ab68Smrg configuration, customization and application access. 212c393a42Smrg 222c393a42SmrgFunctional Overview 232c393a42Smrg 24a32e9e42Smrg Fontconfig contains two essential modules, the configuration module which 25a32e9e42Smrg builds an internal configuration from XML files and the matching module 26a32e9e42Smrg which accepts font patterns and returns the nearest matching font. 27a32e9e42Smrg 28a32e9e42Smrg Font Configuration 29a32e9e42Smrg 30a32e9e42Smrg The configuration module consists of the FcConfig datatype, libexpat and 31a32e9e42Smrg FcConfigParse which walks over an XML tree and amends a configuration with 32a32e9e42Smrg data found within. From an external perspective, configuration of the 33a32e9e42Smrg library consists of generating a valid XML tree and feeding that to 34a32e9e42Smrg FcConfigParse. The only other mechanism provided to applications for 35a32e9e42Smrg changing the running configuration is to add fonts and directories to the 36a32e9e42Smrg list of application-provided font files. 37a32e9e42Smrg 38a32e9e42Smrg The intent is to make font configurations relatively static, and shared by 39a32e9e42Smrg as many applications as possible. It is hoped that this will lead to more 40a32e9e42Smrg stable font selection when passing names from one application to another. 41a32e9e42Smrg XML was chosen as a configuration file format because it provides a format 42a32e9e42Smrg which is easy for external agents to edit while retaining the correct 43ca08ab68Smrg structure and syntax. 44ca08ab68Smrg 45a32e9e42Smrg Font configuration is separate from font matching; applications needing to 46a32e9e42Smrg do their own matching can access the available fonts from the library and 47a32e9e42Smrg perform private matching. The intent is to permit applications to pick and 48a32e9e42Smrg choose appropriate functionality from the library instead of forcing them 49a32e9e42Smrg to choose between this library and a private configuration mechanism. The 50a32e9e42Smrg hope is that this will ensure that configuration of fonts for all 51a32e9e42Smrg applications can be centralized in one place. Centralizing font 52a32e9e42Smrg configuration will simplify and regularize font installation and 53a32e9e42Smrg customization. 54a32e9e42Smrg 55a32e9e42Smrg Font Properties 56a32e9e42Smrg 57a32e9e42Smrg While font patterns may contain essentially any properties, there are some 58a32e9e42Smrg well known properties with associated types. Fontconfig uses some of these 59a32e9e42Smrg properties for font matching and font completion. Others are provided as a 60a32e9e42Smrg convenience for the applications' rendering mechanism. 61a32e9e42Smrg 62953daebaSmrg Property Type Description 63953daebaSmrg -------------------------------------------------------------- 64953daebaSmrg family String Font family names 65953daebaSmrg familylang String Languages corresponding to each family 66953daebaSmrg style String Font style. Overrides weight and slant 67953daebaSmrg stylelang String Languages corresponding to each style 68953daebaSmrg fullname String Font full names (often includes style) 69953daebaSmrg fullnamelang String Languages corresponding to each fullname 70953daebaSmrg slant Int Italic, oblique or roman 71953daebaSmrg weight Int Light, medium, demibold, bold or black 72953daebaSmrg size Double Point size 73953daebaSmrg width Int Condensed, normal or expanded 74953daebaSmrg aspect Double Stretches glyphs horizontally before hinting 75953daebaSmrg pixelsize Double Pixel size 76a32e9e42Smrg spacing Int Proportional, dual-width, monospace or charcell 77953daebaSmrg foundry String Font foundry name 78953daebaSmrg antialias Bool Whether glyphs can be antialiased 79953daebaSmrg hinting Bool Whether the rasterizer should use hinting 80953daebaSmrg hintstyle Int Automatic hinting style 81953daebaSmrg verticallayout Bool Use vertical layout 82953daebaSmrg autohint Bool Use autohinter instead of normal hinter 83953daebaSmrg globaladvance Bool Use font global advance data (deprecated) 84953daebaSmrg file String The filename holding the font 85953daebaSmrg index Int The index of the font within the file 86953daebaSmrg ftface FT_Face Use the specified FreeType face object 87953daebaSmrg rasterizer String Which rasterizer is in use (deprecated) 88953daebaSmrg outline Bool Whether the glyphs are outlines 89953daebaSmrg scalable Bool Whether glyphs can be scaled 90953daebaSmrg color Bool Whether any glyphs have color 91a32e9e42Smrg scale Double Scale factor for point->pixel conversions (deprecated) 92953daebaSmrg dpi Double Target dots per inch 93953daebaSmrg rgba Int unknown, rgb, bgr, vrgb, vbgr, 94953daebaSmrg none - subpixel geometry 95953daebaSmrg lcdfilter Int Type of LCD filter 96953daebaSmrg minspace Bool Eliminate leading from line spacing 97953daebaSmrg charset CharSet Unicode chars encoded by the font 98953daebaSmrg lang String List of RFC-3066-style languages this 99953daebaSmrg font supports 100953daebaSmrg fontversion Int Version number of the font 101953daebaSmrg capability String List of layout capabilities in the font 102953daebaSmrg fontformat String String name of the font format 103a32e9e42Smrg embolden Bool Rasterizer should synthetically embolden the font 104953daebaSmrg embeddedbitmap Bool Use the embedded bitmap instead of the outline 105953daebaSmrg decorative Bool Whether the style is a decorative variant 106a32e9e42Smrg fontfeatures String List of the feature tags in OpenType to be enabled 107a32e9e42Smrg namelang String Language name to be used for the default value of 108953daebaSmrg familylang, stylelang, and fullnamelang 109953daebaSmrg prgname String String Name of the running program 110953daebaSmrg postscriptname String Font family name in PostScript 111a4e54154Smrg fonthashint Bool Whether the font has hinting 112a4e54154Smrg order Int Order number of the font 113953daebaSmrg 114953daebaSmrg 115a32e9e42Smrg Font Matching 116953daebaSmrg 117a32e9e42Smrg Fontconfig performs matching by measuring the distance from a provided 118a32e9e42Smrg pattern to all of the available fonts in the system. The closest matching 119a32e9e42Smrg font is selected. This ensures that a font will always be returned, but 120a32e9e42Smrg doesn't ensure that it is anything like the requested pattern. 121a32e9e42Smrg 122a32e9e42Smrg Font matching starts with an application constructed pattern. The desired 123a32e9e42Smrg attributes of the resulting font are collected together in a pattern. Each 124a32e9e42Smrg property of the pattern can contain one or more values; these are listed 125a32e9e42Smrg in priority order; matches earlier in the list are considered "closer" 126a32e9e42Smrg than matches later in the list. 127ca08ab68Smrg 128ca08ab68Smrg The initial pattern is modified by applying the list of editing 129a32e9e42Smrg instructions specific to patterns found in the configuration; each 130a32e9e42Smrg consists of a match predicate and a set of editing operations. They are 131a32e9e42Smrg executed in the order they appeared in the configuration. Each match 132a32e9e42Smrg causes the associated sequence of editing operations to be applied. 133a32e9e42Smrg 134a32e9e42Smrg After the pattern has been edited, a sequence of default substitutions are 135a32e9e42Smrg performed to canonicalize the set of available properties; this avoids the 136a32e9e42Smrg need for the lower layers to constantly provide default values for various 137a32e9e42Smrg font properties during rendering. 138a32e9e42Smrg 139a32e9e42Smrg The canonical font pattern is finally matched against all available fonts. 140a32e9e42Smrg The distance from the pattern to the font is measured for each of several 141a32e9e42Smrg properties: foundry, charset, family, lang, spacing, pixelsize, style, 142a32e9e42Smrg slant, weight, antialias, rasterizer and outline. This list is in priority 143a32e9e42Smrg order -- results of comparing earlier elements of this list weigh more 144a32e9e42Smrg heavily than later elements. 145a32e9e42Smrg 146a32e9e42Smrg There is one special case to this rule; family names are split into two 147a32e9e42Smrg bindings; strong and weak. Strong family names are given greater 148a32e9e42Smrg precedence in the match than lang elements while weak family names are 149a32e9e42Smrg given lower precedence than lang elements. This permits the document 150a32e9e42Smrg language to drive font selection when any document specified font is 151a32e9e42Smrg unavailable. 152a32e9e42Smrg 153a32e9e42Smrg The pattern representing that font is augmented to include any properties 154a32e9e42Smrg found in the pattern but not found in the font itself; this permits the 155a32e9e42Smrg application to pass rendering instructions or any other data through the 156a32e9e42Smrg matching system. Finally, the list of editing instructions specific to 157a32e9e42Smrg fonts found in the configuration are applied to the pattern. This modified 158a32e9e42Smrg pattern is returned to the application. 159a32e9e42Smrg 160a32e9e42Smrg The return value contains sufficient information to locate and rasterize 161a32e9e42Smrg the font, including the file name, pixel size and other rendering data. As 162a32e9e42Smrg none of the information involved pertains to the FreeType library, 163a32e9e42Smrg applications are free to use any rasterization engine or even to take the 164a32e9e42Smrg identified font file and access it directly. 165a32e9e42Smrg 166a32e9e42Smrg The match/edit sequences in the configuration are performed in two passes 167a32e9e42Smrg because there are essentially two different operations necessary -- the 168a32e9e42Smrg first is to modify how fonts are selected; aliasing families and adding 169a32e9e42Smrg suitable defaults. The second is to modify how the selected fonts are 170a32e9e42Smrg rasterized. Those must apply to the selected font, not the original 171a32e9e42Smrg pattern as false matches will often occur. 172a32e9e42Smrg 173a32e9e42Smrg Font Names 174a32e9e42Smrg 175a32e9e42Smrg Fontconfig provides a textual representation for patterns that the library 176a32e9e42Smrg can both accept and generate. The representation is in three parts, first 177a32e9e42Smrg a list of family names, second a list of point sizes and finally a list of 178a32e9e42Smrg additional properties: 179a32e9e42Smrg 180a32e9e42Smrg <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>... 181a32e9e42Smrg 182a32e9e42Smrg 183a32e9e42Smrg Values in a list are separated with commas. The name needn't include 184a32e9e42Smrg either families or point sizes; they can be elided. In addition, there are 185a32e9e42Smrg symbolic constants that simultaneously indicate both a name and a value. 186a32e9e42Smrg Here are some examples: 187a32e9e42Smrg 188a32e9e42Smrg Name Meaning 189a32e9e42Smrg ---------------------------------------------------------- 190a32e9e42Smrg Times-12 12 point Times Roman 191a32e9e42Smrg Times-12:bold 12 point Times Bold 192a32e9e42Smrg Courier:italic Courier Italic in the default size 193a32e9e42Smrg Monospace:matrix=1 .1 0 1 The users preferred monospace font 194a32e9e42Smrg with artificial obliquing 195a32e9e42Smrg 196a32e9e42Smrg 197a32e9e42Smrg The '\', '-', ':' and ',' characters in family names must be preceded by a 198a32e9e42Smrg '\' character to avoid having them misinterpreted. Similarly, values 199a32e9e42Smrg containing '\', '=', '_', ':' and ',' must also have them preceded by a 200a32e9e42Smrg '\' character. The '\' characters are stripped out of the family name and 201a32e9e42Smrg values as the font name is read. 2022c393a42Smrg 2032c393a42SmrgDebugging Applications 2042c393a42Smrg 205a32e9e42Smrg To help diagnose font and applications problems, fontconfig is built with 206a32e9e42Smrg a large amount of internal debugging left enabled. It is controlled by 207a32e9e42Smrg means of the FC_DEBUG environment variable. The value of this variable is 208a32e9e42Smrg interpreted as a number, and each bit within that value controls different 209a32e9e42Smrg debugging messages. 210a32e9e42Smrg 211a32e9e42Smrg Name Value Meaning 212a32e9e42Smrg --------------------------------------------------------- 213a32e9e42Smrg MATCH 1 Brief information about font matching 214a32e9e42Smrg MATCHV 2 Extensive font matching information 215a32e9e42Smrg EDIT 4 Monitor match/test/edit execution 216a32e9e42Smrg FONTSET 8 Track loading of font information at startup 217a32e9e42Smrg CACHE 16 Watch cache files being written 218a32e9e42Smrg CACHEV 32 Extensive cache file writing information 219a32e9e42Smrg PARSE 64 (no longer in use) 220a32e9e42Smrg SCAN 128 Watch font files being scanned to build caches 221a32e9e42Smrg SCANV 256 Verbose font file scanning information 222a32e9e42Smrg MEMORY 512 Monitor fontconfig memory usage 223a32e9e42Smrg CONFIG 1024 Monitor which config files are loaded 224a32e9e42Smrg LANGSET 2048 Dump char sets used to construct lang values 225a32e9e42Smrg MATCH2 4096 Display font-matching transformation in patterns 226a32e9e42Smrg 227a32e9e42Smrg 228a32e9e42Smrg Add the value of the desired debug levels together and assign that (in 229a32e9e42Smrg base 10) to the FC_DEBUG environment variable before running the 230a32e9e42Smrg application. Output from these statements is sent to stdout. 2312c393a42Smrg 2322c393a42SmrgLang Tags 2332c393a42Smrg 234a32e9e42Smrg Each font in the database contains a list of languages it supports. This 235a32e9e42Smrg is computed by comparing the Unicode coverage of the font with the 236a32e9e42Smrg orthography of each language. Languages are tagged using an RFC-3066 237a32e9e42Smrg compatible naming and occur in two parts -- the ISO 639 language tag 238a32e9e42Smrg followed a hyphen and then by the ISO 3166 country code. The hyphen and 239a32e9e42Smrg country code may be elided. 240a6844aabSmrg 241a32e9e42Smrg Fontconfig has orthographies for several languages built into the library. 242a32e9e42Smrg No provision has been made for adding new ones aside from rebuilding the 243a32e9e42Smrg library. It currently supports 122 of the 139 languages named in ISO 244a32e9e42Smrg 639-1, 141 of the languages with two-letter codes from ISO 639-2 and 245a32e9e42Smrg another 30 languages with only three-letter codes. Languages with both two 246a32e9e42Smrg and three letter codes are provided with only the two letter code. 247a6844aabSmrg 248a32e9e42Smrg For languages used in multiple territories with radically different 249a32e9e42Smrg character sets, fontconfig includes per-territory orthographies. This 250a32e9e42Smrg includes Azerbaijani, Kurdish, Pashto, Tigrinya and Chinese. 2512c393a42Smrg 252a32e9e42SmrgConfiguration File Format 2532c393a42Smrg 254a32e9e42Smrg Configuration files for fontconfig are stored in XML format; this format 255a32e9e42Smrg makes external configuration tools easier to write and ensures that they 256a32e9e42Smrg will generate syntactically correct configuration files. As XML files are 257a32e9e42Smrg plain text, they can also be manipulated by the expert user using a text 258a32e9e42Smrg editor. 259a32e9e42Smrg 260a32e9e42Smrg The fontconfig document type definition resides in the external entity 261a32e9e42Smrg "fonts.dtd"; this is normally stored in the default font configuration 262a32e9e42Smrg directory (/etc/fonts). Each configuration file should contain the 263a32e9e42Smrg following structure: 264a32e9e42Smrg 265a32e9e42Smrg <?xml version="1.0"?> 266a4e54154Smrg <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> 267a32e9e42Smrg <fontconfig> 268a32e9e42Smrg ... 269a32e9e42Smrg </fontconfig> 270a32e9e42Smrg 271a32e9e42Smrg 272a32e9e42Smrg <fontconfig> 273a32e9e42Smrg 274a32e9e42Smrg This is the top level element for a font configuration and can contain 275a32e9e42Smrg <dir>, <cachedir>, <include>, <match> and <alias> elements in any order. 276a32e9e42Smrg 277a4e54154Smrg <dir prefix="default" salt=""> 278a32e9e42Smrg 279a32e9e42Smrg This element contains a directory name which will be scanned for font 280a4e54154Smrg files to include in the set of available fonts. 281a4e54154Smrg 282a4e54154Smrg If 'prefix' is set to "default" or "cwd", the current working directory 283a4e54154Smrg will be added as the path prefix prior to the value. If 'prefix' is set to 284a32e9e42Smrg "xdg", the value in the XDG_DATA_HOME environment variable will be added 285a32e9e42Smrg as the path prefix. please see XDG Base Directory Specification for more 286a4e54154Smrg details. If 'prefix' is set to "relative", the path of current file will 287a4e54154Smrg be added prior to the value. 288a4e54154Smrg 289a4e54154Smrg 'salt' property affects to determine cache filename. this is useful for 290a4e54154Smrg example when having different fonts sets on same path at container and 291a4e54154Smrg share fonts from host on different font path. 292a32e9e42Smrg 293a32e9e42Smrg <cachedir prefix="default"> 294a32e9e42Smrg 295a32e9e42Smrg This element contains a directory name that is supposed to be stored or 296a32e9e42Smrg read the cache of font information. If multiple elements are specified in 297a32e9e42Smrg the configuration file, the directory that can be accessed first in the 298a32e9e42Smrg list will be used to store the cache files. If it starts with '~', it 299a32e9e42Smrg refers to a directory in the users home directory. If 'prefix' is set to 300a32e9e42Smrg "xdg", the value in the XDG_CACHE_HOME environment variable will be added 301a32e9e42Smrg as the path prefix. please see XDG Base Directory Specification for more 302a32e9e42Smrg details. The default directory is ``$XDG_CACHE_HOME/fontconfig'' and it 303a32e9e42Smrg contains the cache files named ``<hash 304a32e9e42Smrg value>-<architecture>.cache-<version>'', where <version> is the fontconfig 305a32e9e42Smrg cache file version number (currently 7). 306a32e9e42Smrg 307a32e9e42Smrg <include ignore_missing="no" prefix="default"> 308a32e9e42Smrg 309a32e9e42Smrg This element contains the name of an additional configuration file or 310a32e9e42Smrg directory. If a directory, every file within that directory starting with 311a32e9e42Smrg an ASCII digit (U+0030 - U+0039) and ending with the string ``.conf'' will 312a32e9e42Smrg be processed in sorted order. When the XML datatype is traversed by 313a32e9e42Smrg FcConfigParse, the contents of the file(s) will also be incorporated into 314a32e9e42Smrg the configuration by passing the filename(s) to FcConfigLoadAndParse. If 315a32e9e42Smrg 'ignore_missing' is set to "yes" instead of the default "no", a missing 316a32e9e42Smrg file or directory will elicit no warning message from the library. If 317a32e9e42Smrg 'prefix' is set to "xdg", the value in the XDG_CONFIG_HOME environment 318a32e9e42Smrg variable will be added as the path prefix. please see XDG Base Directory 319ca08ab68Smrg Specification for more details. 320ca08ab68Smrg 321a32e9e42Smrg <config> 322a32e9e42Smrg 323a32e9e42Smrg This element provides a place to consolidate additional configuration 324a32e9e42Smrg information. <config> can contain <blank> and <rescan> elements in any 325a32e9e42Smrg order. 326a32e9e42Smrg 327a4e54154Smrg <description domain="fontconfig-conf"> 328a4e54154Smrg 329a4e54154Smrg This element is supposed to hold strings which describe what a config is 330a4e54154Smrg used for. This string can be translated through gettext. 'domain' needs to 331a4e54154Smrg be set the proper name to apply then. fontconfig will tries to retrieve 332a4e54154Smrg translations with 'domain' from gettext. 333a4e54154Smrg 334a32e9e42Smrg <blank> 335a32e9e42Smrg 336a32e9e42Smrg Fonts often include "broken" glyphs which appear in the encoding but are 337a32e9e42Smrg drawn as blanks on the screen. Within the <blank> element, place each 338a32e9e42Smrg Unicode characters which is supposed to be blank in an <int> element. 339a32e9e42Smrg Characters outside of this set which are drawn as blank will be elided 340a32e9e42Smrg from the set of characters supported by the font. 341a32e9e42Smrg 342a4e54154Smrg <remap-dir prefix="default" as-path="" salt=""> 343a4e54154Smrg 344a4e54154Smrg This element contains a directory name where will be mapped as the path 345a4e54154Smrg 'as-path' in cached information. This is useful if the directory name is 346a4e54154Smrg an alias (via a bind mount or symlink) to another directory in the system 347a4e54154Smrg for which cached font information is likely to exist. 348a4e54154Smrg 349a4e54154Smrg 'salt' property affects to determine cache filename as same as <dir> 350a4e54154Smrg element. 351a4e54154Smrg 352a4e54154Smrg <reset-dirs /> 353a4e54154Smrg 354a4e54154Smrg This element removes all of fonts directories where added by <dir> 355a4e54154Smrg elements. This is useful to override fonts directories from system to own 356a4e54154Smrg fonts directories only. 357a4e54154Smrg 358a32e9e42Smrg <rescan> 359a32e9e42Smrg 360a32e9e42Smrg The <rescan> element holds an <int> element which indicates the default 361a32e9e42Smrg interval between automatic checks for font configuration changes. 362a32e9e42Smrg Fontconfig will validate all of the configuration files and directories 363a32e9e42Smrg and automatically rebuild the internal datastructures when this interval 364a32e9e42Smrg passes. 365a32e9e42Smrg 366a32e9e42Smrg <selectfont> 367a32e9e42Smrg 368a32e9e42Smrg This element is used to black/white list fonts from being listed or 369a32e9e42Smrg matched against. It holds acceptfont and rejectfont elements. 370a32e9e42Smrg 371a32e9e42Smrg <acceptfont> 372a32e9e42Smrg 373a32e9e42Smrg Fonts matched by an acceptfont element are "whitelisted"; such fonts are 374a32e9e42Smrg explicitly included in the set of fonts used to resolve list and match 375a32e9e42Smrg requests; including them in this list protects them from being 376a32e9e42Smrg "blacklisted" by a rejectfont element. Acceptfont elements include glob 377a32e9e42Smrg and pattern elements which are used to match fonts. 378a32e9e42Smrg 379a32e9e42Smrg <rejectfont> 380953daebaSmrg 381a32e9e42Smrg Fonts matched by an rejectfont element are "blacklisted"; such fonts are 382a32e9e42Smrg excluded from the set of fonts used to resolve list and match requests as 383a32e9e42Smrg if they didn't exist in the system. Rejectfont elements include glob and 384a32e9e42Smrg pattern elements which are used to match fonts. 385953daebaSmrg 386a32e9e42Smrg <glob> 387ca08ab68Smrg 388a32e9e42Smrg Glob elements hold shell-style filename matching patterns (including ? and 389a32e9e42Smrg *) which match fonts based on their complete pathnames. This can be used 390a32e9e42Smrg to exclude a set of directories (/usr/share/fonts/uglyfont*), or 391a32e9e42Smrg particular font file types (*.pcf.gz), but the latter mechanism relies 392a32e9e42Smrg rather heavily on filenaming conventions which can't be relied upon. Note 393a32e9e42Smrg that globs only apply to directories, not to individual fonts. 394ca08ab68Smrg 395a32e9e42Smrg <pattern> 396ca08ab68Smrg 397a32e9e42Smrg Pattern elements perform list-style matching on incoming fonts; that is, 398a32e9e42Smrg they hold a list of elements and associated values. If all of those 399a32e9e42Smrg elements have a matching value, then the pattern matches the font. This 400a32e9e42Smrg can be used to select fonts based on attributes of the font (scalable, 401a32e9e42Smrg bold, etc), which is a more reliable mechanism than using file extensions. 402a32e9e42Smrg Pattern elements include patelt elements. 4032c393a42Smrg 404a32e9e42Smrg <patelt name="property"> 4052c393a42Smrg 406a32e9e42Smrg Patelt elements hold a single pattern element and list of values. They 407a32e9e42Smrg must have a 'name' attribute which indicates the pattern element name. 408a32e9e42Smrg Patelt elements include int, double, string, matrix, bool, charset and 409a32e9e42Smrg const elements. 410a32e9e42Smrg 411a32e9e42Smrg <match target="pattern"> 412a32e9e42Smrg 413a32e9e42Smrg This element holds first a (possibly empty) list of <test> elements and 414a32e9e42Smrg then a (possibly empty) list of <edit> elements. Patterns which match all 415a32e9e42Smrg of the tests are subjected to all the edits. If 'target' is set to "font" 416a32e9e42Smrg instead of the default "pattern", then this element applies to the font 417a32e9e42Smrg name resulting from a match rather than a font pattern to be matched. If 418a32e9e42Smrg 'target' is set to "scan", then this element applies when the font is 419a32e9e42Smrg scanned to build the fontconfig database. 420a32e9e42Smrg 421a32e9e42Smrg <test qual="any" name="property" target="default" compare="eq"> 422a32e9e42Smrg 423a32e9e42Smrg This element contains a single value which is compared with the target 424a32e9e42Smrg ('pattern', 'font', 'scan' or 'default') property "property" (substitute 425a32e9e42Smrg any of the property names seen above). 'compare' can be one of "eq", 426a32e9e42Smrg "not_eq", "less", "less_eq", "more", "more_eq", "contains" or 427a32e9e42Smrg "not_contains". 'qual' may either be the default, "any", in which case the 428a32e9e42Smrg match succeeds if any value associated with the property matches the test 429a32e9e42Smrg value, or "all", in which case all of the values associated with the 430a32e9e42Smrg property must match the test value. 'ignore-blanks' takes a boolean value. 431a32e9e42Smrg if 'ignore-blanks' is set "true", any blanks in the string will be ignored 432a32e9e42Smrg on its comparison. this takes effects only when compare="eq" or 433a32e9e42Smrg compare="not_eq". When used in a <match target="font"> element, the 434a32e9e42Smrg target= attribute in the <test> element selects between matching the 435a32e9e42Smrg original pattern or the font. "default" selects whichever target the outer 436a32e9e42Smrg <match> element has selected. 437a32e9e42Smrg 438a32e9e42Smrg <edit name="property" mode="assign" binding="weak"> 439a32e9e42Smrg 440a32e9e42Smrg This element contains a list of expression elements (any of the value or 441a32e9e42Smrg operator elements). The expression elements are evaluated at run-time and 442a32e9e42Smrg modify the property "property". The modification depends on whether 443a32e9e42Smrg "property" was matched by one of the associated <test> elements, if so, 444a32e9e42Smrg the modification may affect the first matched value. Any values inserted 445a32e9e42Smrg into the property are given the indicated binding ("strong", "weak" or 446a32e9e42Smrg "same") with "same" binding using the value from the matched pattern 447a32e9e42Smrg element. 'mode' is one of: 448a32e9e42Smrg 449a32e9e42Smrg Mode With Match Without Match 450a32e9e42Smrg --------------------------------------------------------------------- 451a32e9e42Smrg "assign" Replace matching value Replace all values 452a32e9e42Smrg "assign_replace" Replace all values Replace all values 453a32e9e42Smrg "prepend" Insert before matching Insert at head of list 454a32e9e42Smrg "prepend_first" Insert at head of list Insert at head of list 455a32e9e42Smrg "append" Append after matching Append at end of list 456a32e9e42Smrg "append_last" Append at end of list Append at end of list 457a32e9e42Smrg "delete" Delete matching value Delete all values 458a32e9e42Smrg "delete_all" Delete all values Delete all values 459a32e9e42Smrg 460a32e9e42Smrg 461a32e9e42Smrg <int>, <double>, <string>, <bool> 462a32e9e42Smrg 463a32e9e42Smrg These elements hold a single value of the indicated type. <bool> elements 464a32e9e42Smrg hold either true or false. An important limitation exists in the parsing 465a32e9e42Smrg of floating point numbers -- fontconfig requires that the mantissa start 466a32e9e42Smrg with a digit, not a decimal point, so insert a leading zero for purely 467a32e9e42Smrg fractional values (e.g. use 0.5 instead of .5 and -0.5 instead of -.5). 468a32e9e42Smrg 469a32e9e42Smrg <matrix> 470a32e9e42Smrg 471a32e9e42Smrg This element holds four numerical expressions of an affine transformation. 472a32e9e42Smrg At their simplest these will be four <double> elements but they can also 473a32e9e42Smrg be more involved expressions. 474a32e9e42Smrg 475a32e9e42Smrg <range> 476a32e9e42Smrg 477a32e9e42Smrg This element holds the two <int> elements of a range representation. 478a32e9e42Smrg 479a32e9e42Smrg <charset> 480a32e9e42Smrg 481a32e9e42Smrg This element holds at least one <int> element of an Unicode code point or 482a32e9e42Smrg more. 483a32e9e42Smrg 484a32e9e42Smrg <langset> 485a32e9e42Smrg 486a32e9e42Smrg This element holds at least one <string> element of a RFC-3066-style 487a32e9e42Smrg languages or more. 488a32e9e42Smrg 489a32e9e42Smrg <name> 490a32e9e42Smrg 491a32e9e42Smrg Holds a property name. Evaluates to the first value from the property of 492a32e9e42Smrg the pattern. If the 'target' attribute is not present, it will default to 493a32e9e42Smrg 'default', in which case the property is returned from the font pattern 494a32e9e42Smrg during a target="font" match, and to the pattern during a target="pattern" 495a32e9e42Smrg match. The attribute can also take the values 'font' or 'pattern' to 496a32e9e42Smrg explicitly choose which pattern to use. It is an error to use a target of 497a32e9e42Smrg 'font' in a match that has target="pattern". 498a32e9e42Smrg 499a32e9e42Smrg <const> 500a32e9e42Smrg 501a32e9e42Smrg Holds the name of a constant; these are always integers and serve as 502a32e9e42Smrg symbolic names for common font values: 503a32e9e42Smrg 504a32e9e42Smrg Constant Property Value 505a32e9e42Smrg ------------------------------------- 506a32e9e42Smrg thin weight 0 507a32e9e42Smrg extralight weight 40 508a32e9e42Smrg ultralight weight 40 509a32e9e42Smrg light weight 50 510a32e9e42Smrg demilight weight 55 511a32e9e42Smrg semilight weight 55 512a32e9e42Smrg book weight 75 513a32e9e42Smrg regular weight 80 514a32e9e42Smrg normal weight 80 515a32e9e42Smrg medium weight 100 516a32e9e42Smrg demibold weight 180 517a32e9e42Smrg semibold weight 180 518a32e9e42Smrg bold weight 200 519a32e9e42Smrg extrabold weight 205 520a32e9e42Smrg black weight 210 521a32e9e42Smrg heavy weight 210 522a32e9e42Smrg roman slant 0 523a32e9e42Smrg italic slant 100 524a32e9e42Smrg oblique slant 110 525a32e9e42Smrg ultracondensed width 50 526a32e9e42Smrg extracondensed width 63 527a32e9e42Smrg condensed width 75 528a32e9e42Smrg semicondensed width 87 529a32e9e42Smrg normal width 100 530a32e9e42Smrg semiexpanded width 113 531a32e9e42Smrg expanded width 125 532a32e9e42Smrg extraexpanded width 150 533a32e9e42Smrg ultraexpanded width 200 534a32e9e42Smrg proportional spacing 0 535a32e9e42Smrg dual spacing 90 536a32e9e42Smrg mono spacing 100 537a32e9e42Smrg charcell spacing 110 538a32e9e42Smrg unknown rgba 0 539a32e9e42Smrg rgb rgba 1 540a32e9e42Smrg bgr rgba 2 541a32e9e42Smrg vrgb rgba 3 542a32e9e42Smrg vbgr rgba 4 543a32e9e42Smrg none rgba 5 544a32e9e42Smrg lcdnone lcdfilter 0 545a32e9e42Smrg lcddefault lcdfilter 1 546a32e9e42Smrg lcdlight lcdfilter 2 547a32e9e42Smrg lcdlegacy lcdfilter 3 548a32e9e42Smrg hintnone hintstyle 0 549a32e9e42Smrg hintslight hintstyle 1 550a32e9e42Smrg hintmedium hintstyle 2 551a32e9e42Smrg hintfull hintstyle 3 552a32e9e42Smrg 553a32e9e42Smrg 554a32e9e42Smrg <or>, <and>, <plus>, <minus>, <times>, <divide> 555a32e9e42Smrg 556a32e9e42Smrg These elements perform the specified operation on a list of expression 557a32e9e42Smrg elements. <or> and <and> are boolean, not bitwise. 558a32e9e42Smrg 559a32e9e42Smrg <eq>, <not_eq>, <less>, <less_eq>, <more>, <more_eq>, <contains>, 560a32e9e42Smrg <not_contains 5612c393a42Smrg 562ca08ab68Smrg These elements compare two values, producing a boolean result. 5632c393a42Smrg 564a32e9e42Smrg <not> 5652c393a42Smrg 566ca08ab68Smrg Inverts the boolean sense of its one expression element 5672c393a42Smrg 568a32e9e42Smrg <if> 5692c393a42Smrg 570a32e9e42Smrg This element takes three expression elements; if the value of the first is 571a32e9e42Smrg true, it produces the value of the second, otherwise it produces the value 572a32e9e42Smrg of the third. 5732c393a42Smrg 574a32e9e42Smrg <alias> 5752c393a42Smrg 576a32e9e42Smrg Alias elements provide a shorthand notation for the set of common match 577a32e9e42Smrg operations needed to substitute one font family for another. They contain 578a32e9e42Smrg a <family> element followed by optional <prefer>, <accept> and <default> 579a32e9e42Smrg elements. Fonts matching the <family> element are edited to prepend the 580a32e9e42Smrg list of <prefer>ed families before the matching <family>, append the 581a32e9e42Smrg <accept>able families after the matching <family> and append the <default> 582a32e9e42Smrg families to the end of the family list. 583ca08ab68Smrg 584a32e9e42Smrg <family> 585ca08ab68Smrg 586ca08ab68Smrg Holds a single font family name 587ca08ab68Smrg 588a32e9e42Smrg <prefer>, <accept>, <default> 589ca08ab68Smrg 590a32e9e42Smrg These hold a list of <family> elements to be used by the <alias> element. 5912c393a42Smrg 5922c393a42SmrgEXAMPLE CONFIGURATION FILE 5932c393a42Smrg 594a32e9e42Smrg System configuration file 5952c393a42Smrg 596ca08ab68Smrg This is an example of a system-wide configuration file 597a32e9e42Smrg 5982c393a42Smrg<?xml version="1.0"?> 599a4e54154Smrg<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> 6002c393a42Smrg<!-- /etc/fonts/fonts.conf file to configure system font access --> 6012c393a42Smrg<fontconfig> 6022c393a42Smrg<!-- 6032c393a42Smrg Find fonts in these directories 6042c393a42Smrg--> 6052c393a42Smrg<dir>/usr/share/fonts</dir> 6062c393a42Smrg<dir>/usr/X11R6/lib/X11/fonts</dir> 6072c393a42Smrg 6082c393a42Smrg<!-- 6092c393a42Smrg Accept deprecated 'mono' alias, replacing it with 'monospace' 6102c393a42Smrg--> 6112c393a42Smrg<match target="pattern"> 6122c393a42Smrg <test qual="any" name="family"><string>mono</string></test> 613a32e9e42Smrg <edit name="family" mode="assign"><string>monospace</string></edit> 6142c393a42Smrg</match> 6152c393a42Smrg 6162c393a42Smrg<!-- 617ca08ab68Smrg Names not including any well known alias are given 'sans-serif' 6182c393a42Smrg--> 6192c393a42Smrg<match target="pattern"> 620a32e9e42Smrg <test qual="all" name="family" compare="not_eq"><string>sans-serif</string></test> 621a32e9e42Smrg <test qual="all" name="family" compare="not_eq"><string>serif</string></test> 622a32e9e42Smrg <test qual="all" name="family" compare="not_eq"><string>monospace</string></test> 623a32e9e42Smrg <edit name="family" mode="append_last"><string>sans-serif</string></edit> 6242c393a42Smrg</match> 6252c393a42Smrg 6262c393a42Smrg<!-- 6272c393a42Smrg Load per-user customization file, but don't complain 6282c393a42Smrg if it doesn't exist 6292c393a42Smrg--> 630a32e9e42Smrg<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> 6312c393a42Smrg 6322c393a42Smrg<!-- 6332c393a42Smrg Load local customization files, but don't complain 6342c393a42Smrg if there aren't any 6352c393a42Smrg--> 6362c393a42Smrg<include ignore_missing="yes">conf.d</include> 6372c393a42Smrg<include ignore_missing="yes">local.conf</include> 6382c393a42Smrg 6392c393a42Smrg<!-- 6402c393a42Smrg Alias well known font names to available TrueType fonts. 6412c393a42Smrg These substitute TrueType faces for similar Type1 6422c393a42Smrg faces to improve screen appearance. 6432c393a42Smrg--> 6442c393a42Smrg<alias> 6452c393a42Smrg <family>Times</family> 6462c393a42Smrg <prefer><family>Times New Roman</family></prefer> 6472c393a42Smrg <default><family>serif</family></default> 6482c393a42Smrg</alias> 6492c393a42Smrg<alias> 6502c393a42Smrg <family>Helvetica</family> 6512c393a42Smrg <prefer><family>Arial</family></prefer> 6522c393a42Smrg <default><family>sans</family></default> 6532c393a42Smrg</alias> 6542c393a42Smrg<alias> 6552c393a42Smrg <family>Courier</family> 6562c393a42Smrg <prefer><family>Courier New</family></prefer> 6572c393a42Smrg <default><family>monospace</family></default> 6582c393a42Smrg</alias> 6592c393a42Smrg 6602c393a42Smrg<!-- 6612c393a42Smrg Provide required aliases for standard names 6622c393a42Smrg Do these after the users configuration file so that 6632c393a42Smrg any aliases there are used preferentially 6642c393a42Smrg--> 6652c393a42Smrg<alias> 6662c393a42Smrg <family>serif</family> 6672c393a42Smrg <prefer><family>Times New Roman</family></prefer> 6682c393a42Smrg</alias> 6692c393a42Smrg<alias> 6702c393a42Smrg <family>sans</family> 6712c393a42Smrg <prefer><family>Arial</family></prefer> 6722c393a42Smrg</alias> 6732c393a42Smrg<alias> 6742c393a42Smrg <family>monospace</family> 6752c393a42Smrg <prefer><family>Andale Mono</family></prefer> 6762c393a42Smrg</alias> 677ca08ab68Smrg 678ca08ab68Smrg<-- 679ca08ab68Smrg The example of the requirements of OR operator; 680ca08ab68Smrg If the 'family' contains 'Courier New' OR 'Courier' 681ca08ab68Smrg add 'monospace' as the alternative 682ca08ab68Smrg--> 683ca08ab68Smrg<match target="pattern"> 684a32e9e42Smrg <test name="family" compare="eq"> 685ca08ab68Smrg <string>Courier New</string> 686ca08ab68Smrg </test> 687ca08ab68Smrg <edit name="family" mode="prepend"> 688ca08ab68Smrg <string>monospace</string> 689ca08ab68Smrg </edit> 690ca08ab68Smrg</match> 691ca08ab68Smrg<match target="pattern"> 692a32e9e42Smrg <test name="family" compare="eq"> 693ca08ab68Smrg <string>Courier</string> 694ca08ab68Smrg </test> 695ca08ab68Smrg <edit name="family" mode="prepend"> 696ca08ab68Smrg <string>monospace</string> 697ca08ab68Smrg </edit> 698ca08ab68Smrg</match> 699ca08ab68Smrg 7002c393a42Smrg</fontconfig> 7012c393a42Smrg 702a6844aabSmrg 703a32e9e42Smrg User configuration file 704ca08ab68Smrg 705a32e9e42Smrg This is an example of a per-user configuration file that lives in 706a32e9e42Smrg $XDG_CONFIG_HOME/fontconfig/fonts.conf 707a32e9e42Smrg 708a32e9e42Smrg <?xml version="1.0"?> 709a4e54154Smrg <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> 710a32e9e42Smrg <!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration --> 711a32e9e42Smrg <fontconfig> 712a32e9e42Smrg 713a32e9e42Smrg <!-- 714a32e9e42Smrg Private font directory 715a32e9e42Smrg --> 716a32e9e42Smrg <dir prefix="xdg">fonts</dir> 717a32e9e42Smrg 718a32e9e42Smrg <!-- 719a32e9e42Smrg use rgb sub-pixel ordering to improve glyph appearance on 720a32e9e42Smrg LCD screens. Changes affecting rendering, but not matching 721a32e9e42Smrg should always use target="font". 722a32e9e42Smrg --> 723a32e9e42Smrg <match target="font"> 724a32e9e42Smrg <edit name="rgba" mode="assign"><const>rgb</const></edit> 725a32e9e42Smrg </match> 726a32e9e42Smrg <!-- 727a32e9e42Smrg use WenQuanYi Zen Hei font when serif is requested for Chinese 728a32e9e42Smrg --> 729a32e9e42Smrg <match> 730a32e9e42Smrg <!-- 731a32e9e42Smrg If you don't want to use WenQuanYi Zen Hei font for zh-tw etc, 732a32e9e42Smrg you can use zh-cn instead of zh. 733a32e9e42Smrg Please note, even if you set zh-cn, it still matches zh. 734a32e9e42Smrg if you don't like it, you can use compare="eq" 735a32e9e42Smrg instead of compare="contains". 736a32e9e42Smrg --> 737a32e9e42Smrg <test name="lang" compare="contains"> 738a32e9e42Smrg <string>zh</string> 739a32e9e42Smrg </test> 740a32e9e42Smrg <test name="family"> 741a32e9e42Smrg <string>serif</string> 742a32e9e42Smrg </test> 743a32e9e42Smrg <edit name="family" mode="prepend"> 744a32e9e42Smrg <string>WenQuanYi Zen Hei</string> 745a32e9e42Smrg </edit> 746a32e9e42Smrg </match> 747a32e9e42Smrg <!-- 748a32e9e42Smrg use VL Gothic font when sans-serif is requested for Japanese 749a32e9e42Smrg --> 750a32e9e42Smrg <match> 751a32e9e42Smrg <test name="lang" compare="contains"> 752a32e9e42Smrg <string>ja</string> 753a32e9e42Smrg </test> 754a32e9e42Smrg <test name="family"> 755a32e9e42Smrg <string>sans-serif</string> 756a32e9e42Smrg </test> 757a32e9e42Smrg <edit name="family" mode="prepend"> 758a32e9e42Smrg <string>VL Gothic</string> 759a32e9e42Smrg </edit> 760a32e9e42Smrg </match> 761a32e9e42Smrg </fontconfig> 7622c393a42Smrg 763a6844aabSmrg 764ca08ab68SmrgFiles 7652c393a42Smrg 766a32e9e42Smrg fonts.conf contains configuration information for the fontconfig library 767a32e9e42Smrg consisting of directories to look at for font information as well as 768a32e9e42Smrg instructions on editing program specified font patterns before attempting 769a32e9e42Smrg to match the available fonts. It is in XML format. 7702c393a42Smrg 771ca08ab68Smrg conf.d is the conventional name for a directory of additional 772a32e9e42Smrg configuration files managed by external applications or the local 773a32e9e42Smrg administrator. The filenames starting with decimal digits are sorted in 774a32e9e42Smrg lexicographic order and used as additional configuration files. All of 775a32e9e42Smrg these files are in XML format. The master fonts.conf file references this 776a32e9e42Smrg directory in an <include> directive. 777a32e9e42Smrg 778a32e9e42Smrg fonts.dtd is a DTD that describes the format of the configuration files. 779a32e9e42Smrg 780a32e9e42Smrg $XDG_CONFIG_HOME/fontconfig/conf.d and ~/.fonts.conf.d is the conventional 781a32e9e42Smrg name for a per-user directory of (typically auto-generated) configuration 782a32e9e42Smrg files, although the actual location is specified in the global fonts.conf 783a32e9e42Smrg file. please note that ~/.fonts.conf.d is deprecated now. it will not be 784ca08ab68Smrg read by default in the future version. 785ca08ab68Smrg 786ca08ab68Smrg $XDG_CONFIG_HOME/fontconfig/fonts.conf and ~/.fonts.conf is the 787a32e9e42Smrg conventional location for per-user font configuration, although the actual 788a32e9e42Smrg location is specified in the global fonts.conf file. please note that 789a32e9e42Smrg ~/.fonts.conf is deprecated now. it will not be read by default in the 790a32e9e42Smrg future version. 791a32e9e42Smrg 792a32e9e42Smrg $XDG_CACHE_HOME/fontconfig/*.cache-* and ~/.fontconfig/*.cache-* is the 793a32e9e42Smrg conventional repository of font information that isn't found in the 794a32e9e42Smrg per-directory caches. This file is automatically maintained by fontconfig. 795a32e9e42Smrg please note that ~/.fontconfig/*.cache-* is deprecated now. it will not be 796ca08ab68Smrg read by default in the future version. 7972c393a42Smrg 798ca08ab68SmrgEnvironment variables 7992c393a42Smrg 800a32e9e42Smrg FONTCONFIG_FILE is used to override the default configuration file. 8012c393a42Smrg 802a32e9e42Smrg FONTCONFIG_PATH is used to override the default configuration directory. 8032c393a42Smrg 804a32e9e42Smrg FONTCONFIG_SYSROOT is used to set a default sysroot directory. 805953daebaSmrg 806a32e9e42Smrg FC_DEBUG is used to output the detailed debugging messages. see 807a32e9e42Smrg [1]Debugging Applications section for more details. 808a32e9e42Smrg 809a32e9e42Smrg FC_DBG_MATCH_FILTER is used to filter out the patterns. this takes a 810a32e9e42Smrg comma-separated list of object names and effects only when FC_DEBUG has 811a32e9e42Smrg MATCH2. see [2]Debugging Applications section for more details. 812a32e9e42Smrg 813a32e9e42Smrg FC_LANG is used to specify the default language as the weak binding in the 814a32e9e42Smrg query. if this isn't set, the default language will be determined from 815a32e9e42Smrg current locale. 816a32e9e42Smrg 817a32e9e42Smrg FONTCONFIG_USE_MMAP is used to control the use of mmap(2) for the cache 818a32e9e42Smrg files if available. this take a boolean value. fontconfig will checks if 819a32e9e42Smrg the cache files are stored on the filesystem that is safe to use mmap(2). 820a32e9e42Smrg explicitly setting this environment variable will causes skipping this 821a32e9e42Smrg check and enforce to use or not use mmap(2) anyway. 822a32e9e42Smrg 823a32e9e42Smrg SOURCE_DATE_EPOCH is used to ensure fc-cache(1) generates files in a 824a32e9e42Smrg deterministic manner in order to support reproducible builds. When set to 825a32e9e42Smrg a numeric representation of UNIX timestamp, fontconfig will prefer this 826a32e9e42Smrg value over using the modification timestamps of the input files in order 827a32e9e42Smrg to identify which cache files require regeneration. If SOURCE_DATE_EPOCH 828a32e9e42Smrg is not set (or is newer than the mtime of the directory), the existing 829a32e9e42Smrg behaviour is unchanged. 8302c393a42Smrg 8312c393a42SmrgSee Also 8322c393a42Smrg 833a32e9e42Smrg fc-cat(1), fc-cache(1), fc-list(1), fc-match(1), fc-query(1), 834a32e9e42Smrg [3]SOURCE_DATE_EPOCH. 8352c393a42Smrg 8362c393a42SmrgVersion 8372c393a42Smrg 838a4e54154Smrg Fontconfig version 2.14.0 839a32e9e42Smrg 840a32e9e42SmrgReferences 841a32e9e42Smrg 842a32e9e42Smrg Visible links 843a4e54154Smrg 1. file:///tmp/html-79mk3c#DEBUG 844a4e54154Smrg 2. file:///tmp/html-79mk3c#DEBUG 845a32e9e42Smrg 3. https://reproducible-builds.org/specs/source-date-epoch/ 846