[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Configuration File Format

Configuration files for fontconfig are stored in XML format; this format makes external configuration tools easier to write and ensures that they will generate syntactically correct configuration files. As XML files are plain text, they can also be manipulated by the expert user using a text editor.

The fontconfig document type definition resides in the external entity `fonts.dtd'; this is normally stored in the default font configuration directory (`/etc/fonts'). Each configuration file should contain the following structure:

 
	<?xml version="1.0"?>
	<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
	<fontconfig>
	...
	</fontconfig>

`<fontconfig>'
This is the top level element for a font configuration and can contain `<dir>', `<cache>', `<include>', `<match>' and `<alias>' elements in any order.

`<dir>'
This element contains a directory name which will be scanned for font files to include in the set of available fonts. The scan does not recurse into subdirectories.

`<cache>'
This element contains a file name for the per-user cache of font information. If it starts with '~', it refers to a file in the users home directory. This file is used to hold information about fonts that isn't present in the per-directory cache files. It is automatically maintained by the fontconfig library. The default for this file is "~/.fonts.cache-<version>", where <version> is the font configuration file version number (currently 1).

`<include ignore_missing="no">'
This element contains the name of an additional configuration file. When the XML datatype is traversed by FcConfigParse, the contents of the file will also be incorporated into the configuration by passing the filename to FcConfigLoadAndParse. If 'ignore_missing' is set to "yes" instead of the default "no", a missing file will elicit no warning message from the library.

`<config>'
This element provides a place to consolidate additional configuration information. `<config>' can contain `<blank>' and `<rescan>' elements in any order.

`<blank>'
Fonts often include "broken" glyphs which appear in the encoding but are drawn as blanks on the screen. Within the `<blank>' element, place each Unicode characters which is supposed to be blank in an `<int>' element. Characters outside of this set which are drawn as blank will be elided from the set of characters supported by the font.

`<rescan>'
The `<rescan>' element holds an `<int>' element which indicates the default interval between automatic checks for font configuration changes. Fontconfig will validate all of the configuration files and directories and automatically rebuild the internal datastructures when this interval passes.

`<match target="pattern">'
This element holds first a (possibly empty) list of `<test>' elements and then a (possibly empty) list of `<edit>' elements. Patterns which match all of the tests are subjected to all the edits. If 'target' is set to "font" instead of the default "pattern", then this element applies to the font name resulting from a match rather than a font pattern to be matched.

`<test qual="any" name="property" compare="eq">'
This element contains a single value which is compared with the pattern property "property" (substitute any of the property names seen above). 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", or "more_eq". 'qual' may either be the default, "any", in which case the match succeeds if any value associated with the property matches the test value, or "all", in which case all of the values associated with the property must match the test value.

`<edit name="property" mode="assign" binding="weak">'
This element contains a list of expression elements (any of the value or operator elements). The expression elements are evaluated at run-time and modify the property "property". The modification depends on whether "property" was matched by one of the associated `<test>' elements, if so, the modification may affect the first matched value. Any values inserted into the property are given the indicated binding. 'mode' is one of:

 
Mode	Operation with match	Operation without match

"assign"	Replace matching value		Replace all values
"assign_replace"	Replace all values	Replace all values
"prepend"	Insert before matching value	Insert at head of list
"prepend_first"	Insert at head of list		Insert at head of list
"append"	Append after matching value	Append at end of list
"append_last"	Append at end of list		Append at end of list

`<int>'
`<double>'
`<string>'
`<bool>'
These elements hold a single value of the indicated type. `<bool>' elements hold either true or false.

`<matrix>'

This element holds the four `<double>' elements of an affine transformation.

`<name>'
Holds a property name. Evaluates to the first value from the property of the font, not the pattern.

`<const>'
Holds the name of a constant; these are always integers and serve as symbolic names for common font values:

 
Constant        Property        CPP symbol

light           weight          FC_WEIGHT_LIGHT
medium          weight          FC_WEIGHT_MEDIUM
demibold        weight          FC_WEIGHT_DEMIBOLD
bold            weight          FC_WEIGHT_BOLD
black           weight          FC_WEIGHT_BLACK
roman           slant           FC_SLANT_ROMAN
italic          slant           FC_SLANT_ITALIC
oblique         slant           FC_SLANT_OBLIQUE
proportional    spacing         FC_PROPORTIONAL
mono            spacing         FC_MONO
charcell        spacing         FC_CHARCELL
unknown         rgba            FC_RGBA_UNKNOWN
rgb             rgba            FC_RGBA_RGB
bgr             rgba            FC_RGBA_BGR
vrgb            rgba            FC_RGBA_VRGB
vbgr            rgba            FC_RGBA_VBGR
none            rgba            FC_RGBA_NONE

`<or>'
`<and>'
`<plus>'
`<minus>'
`<times>'
`<divide>'
These elements perform the specified operation on a list of expression elements. `<or>' and `<and>' are boolean, not bitwise.

`<eq>'
`<not_eq>'
`<less>'
`<less_eq>'
`<more>'
`<more_eq>'
These elements compare two values, producing a boolean result.

`<not>'
Inverts the boolean sense of its one expression element

`<if>'
This element takes three expression elements; if the value of the first is true, it produces the value of the second, otherwise it produces the value of the third.

`<alias>'
Alias elements provide a shorthand notation for the set of common match operations needed to substitute one font family for another. They contain a `<family>' element followed by optional `<prefer>', `<accept>' and `<default>' elements. Fonts matching the `<family>' element are edited to prepend the list of `<prefer>'ed families before the matching `<family>', append the `<accept>'able families after the matching `<family>' and append the `<default>' families to the end of the family list.

`<family>'
Holds a single font family name

`<prefer>'
`<accept>'
`<default>'
These each hold a list of `<family>' elements to be used by the `<alias>' element.

4.1 Example System Configuration File  
4.2 Example User Configuration File  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Example System Configuration File

This is an example of a system-wide configuration file:

 
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<!-- 
	Find fonts in these directories
-->
<dir>/usr/X11R6/lib/X11/fonts/truetype</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir>

<!--
	Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
	<test qual="any" name="family"><string>mono</string></test>
	<edit name="family" mode="assign"><string>monospace</string></edit>
</match>

<!--
	Names not including any well known alias are given 'sans'
-->
<match target="pattern">
	<test qual="all" name="family" mode="not_eq">sans</test>
	<test qual="all" name="family" mode="not_eq">serif</test>
	<test qual="all" name="family" mode="not_eq">monospace</test>
	<edit name="family" mode="append_last"><string>sans</string></edit>
</match>

<!--
	Load per-user customization file, but don't complain
	if it doesn't exist
-->
<include ignore_missing="yes">~/.fonts.conf</include>

<!--
	Alias well known font names to available TrueType fonts.
	These substitute TrueType faces for similar Type1
	faces to improve screen appearance.
-->
<alias>
	<family>Times</family>
	<prefer><family>Times New Roman</family></prefer>
	<default><family>serif</family></default>
</alias>
<alias>
	<family>Helvetica</family>
	<prefer><family>Verdana</family></prefer>
	<default><family>sans</family></default>
</alias>
<alias>
	<family>Courier</family>
	<prefer><family>Courier New</family></prefer>
	<default><family>monospace</family></default>
</alias>

<!--
	Provide required aliases for standard names
	Do these after the users configuration file so that
	any aliases there are used preferentially
-->
<alias>
	<family>serif</family>
	<prefer><family>Times New Roman</family></prefer>
</alias>
<alias>
	<family>sans</family>
	<prefer><family>Verdana</family></prefer>
</alias>
<alias>
	<family>monospace</family>
	<prefer><family>Andale Mono</family></prefer>
</alias>
</fontconfig>


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Example User Configuration File

This is an example of a per-user configuration file that lives in `~/.fonts.conf':

 
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>

<!--
	Private font directory
-->
<dir>~/misc/fonts</dir>

<!--
	use rgb sub-pixel ordering to improve glyph appearance on
	LCD screens.  Changes affecting rendering, but not matching,
	should always use target="font".
-->
<match target="font">
	<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
</fontconfig>


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.