fontconfig-user.sgml revision a6844aab
12c393a42Smrg<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
22c393a42Smrg<!ENTITY version SYSTEM "version.sgml">
32c393a42Smrg<!ENTITY confdir SYSTEM "confdir.sgml">
42c393a42Smrg]>
52c393a42Smrg<!--
62c393a42Smrg    Copyright © 2003 Keith Packard
72c393a42Smrg   
82c393a42Smrg    Permission to use, copy, modify, distribute, and sell this software and its
92c393a42Smrg    documentation for any purpose is hereby granted without fee, provided that
102c393a42Smrg    the above copyright notice appear in all copies and that both that
112c393a42Smrg    copyright notice and this permission notice appear in supporting
122c393a42Smrg    documentation, and that the name of Keith Packard not be used in
132c393a42Smrg    advertising or publicity pertaining to distribution of the software without
142c393a42Smrg    specific, written prior permission.  Keith Packard makes no
152c393a42Smrg    representations about the suitability of this software for any purpose.  It
162c393a42Smrg    is provided "as is" without express or implied warranty.
172c393a42Smrg   
18a6844aabSmrg    THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
192c393a42Smrg    INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20a6844aabSmrg    EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
212c393a42Smrg    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
222c393a42Smrg    DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
232c393a42Smrg    TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
242c393a42Smrg    PERFORMANCE OF THIS SOFTWARE.
252c393a42Smrg-->
262c393a42Smrg<refentry>
272c393a42Smrg<refmeta>
282c393a42Smrg  <refentrytitle>fonts-conf</refentrytitle>
292c393a42Smrg  <manvolnum>5</manvolnum>
302c393a42Smrg</refmeta>
312c393a42Smrg<refnamediv>
322c393a42Smrg	<refname>fonts.conf</refname>
332c393a42Smrg	<refpurpose>Font configuration files</refpurpose>
342c393a42Smrg</refnamediv>
352c393a42Smrg<refsynopsisdiv>
362c393a42Smrg<synopsis>
372c393a42Smrg   &confdir;/fonts.conf
382c393a42Smrg   &confdir;/fonts.dtd
392c393a42Smrg   &confdir;/conf.d
40a6844aabSmrg   ~/.fonts.conf.d
412c393a42Smrg   ~/.fonts.conf
422c393a42Smrg</synopsis>
432c393a42Smrg</refsynopsisdiv>
442c393a42Smrg<refsect1><title>Description</title>
452c393a42Smrg  <para>
462c393a42SmrgFontconfig is a library designed to provide system-wide font configuration,
472c393a42Smrgcustomization and application access.
482c393a42Smrg  </para>
492c393a42Smrg</refsect1>
502c393a42Smrg<refsect1><title>Functional Overview</title>
512c393a42Smrg  <para>
522c393a42SmrgFontconfig contains two essential modules, the configuration module which
532c393a42Smrgbuilds an internal configuration from XML files and the matching module
542c393a42Smrgwhich accepts font patterns and returns the nearest matching font.
552c393a42Smrg  </para>
562c393a42Smrg  <refsect2><title>Font Configuration</title>
572c393a42Smrg    <para>
582c393a42SmrgThe configuration module consists of the FcConfig datatype, libexpat and
592c393a42SmrgFcConfigParse which walks over an XML tree and amends a configuration with
602c393a42Smrgdata found within.  From an external perspective, configuration of the
612c393a42Smrglibrary consists of generating a valid XML tree and feeding that to
622c393a42SmrgFcConfigParse.  The only other mechanism provided to applications for
632c393a42Smrgchanging the running configuration is to add fonts and directories to the
642c393a42Smrglist of application-provided font files.  
652c393a42Smrg    </para><para>
662c393a42SmrgThe intent is to make font configurations relatively static, and shared by
672c393a42Smrgas many applications as possible.  It is hoped that this will lead to more
682c393a42Smrgstable font selection when passing names from one application to another.
692c393a42SmrgXML was chosen as a configuration file format because it provides a format
702c393a42Smrgwhich is easy for external agents to edit while retaining the correct
712c393a42Smrgstructure and syntax.
722c393a42Smrg    </para><para>
732c393a42SmrgFont configuration is separate from font matching; applications needing to
742c393a42Smrgdo their own matching can access the available fonts from the library and
752c393a42Smrgperform private matching.  The intent is to permit applications to pick and
762c393a42Smrgchoose appropriate functionality from the library instead of forcing them to
772c393a42Smrgchoose between this library and a private configuration mechanism.  The hope
782c393a42Smrgis that this will ensure that configuration of fonts for all applications
792c393a42Smrgcan be centralized in one place.  Centralizing font configuration will
802c393a42Smrgsimplify and regularize font installation and customization.
812c393a42Smrg    </para>
822c393a42Smrg  </refsect2>
832c393a42Smrg  <refsect2>
842c393a42Smrg    <title>Font Properties</title>
852c393a42Smrg    <para>
862c393a42SmrgWhile font patterns may contain essentially any properties, there are some
872c393a42Smrgwell known properties with associated types.  Fontconfig uses some of these
882c393a42Smrgproperties for font matching and font completion.  Others are provided as a
892c393a42Smrgconvenience for the applications' rendering mechanism.
902c393a42Smrg    </para>
912c393a42Smrg    <programlisting>
922c393a42Smrg  Property        Type    Description
932c393a42Smrg  --------------------------------------------------------------
942c393a42Smrg  family          String  Font family names
952c393a42Smrg  familylang      String  Languages corresponding to each family
962c393a42Smrg  style           String  Font style. Overrides weight and slant
972c393a42Smrg  stylelang       String  Languages corresponding to each style
982c393a42Smrg  fullname        String  Font full names (often includes style)
992c393a42Smrg  fullnamelang    String  Languages corresponding to each fullname
1002c393a42Smrg  slant           Int     Italic, oblique or roman
1012c393a42Smrg  weight          Int     Light, medium, demibold, bold or black
1022c393a42Smrg  size            Double  Point size
1032c393a42Smrg  width           Int     Condensed, normal or expanded
1042c393a42Smrg  aspect          Double  Stretches glyphs horizontally before hinting
1052c393a42Smrg  pixelsize       Double  Pixel size
1062c393a42Smrg  spacing         Int     Proportional, dual-width, monospace or charcell
1072c393a42Smrg  foundry         String  Font foundry name
1082c393a42Smrg  antialias       Bool    Whether glyphs can be antialiased
1092c393a42Smrg  hinting         Bool    Whether the rasterizer should use hinting
1102c393a42Smrg  hintstyle       Int     Automatic hinting style
1112c393a42Smrg  verticallayout  Bool    Use vertical layout
1122c393a42Smrg  autohint        Bool    Use autohinter instead of normal hinter
1132c393a42Smrg  globaladvance   Bool    Use font global advance data
1142c393a42Smrg  file            String  The filename holding the font
1152c393a42Smrg  index           Int     The index of the font within the file
1162c393a42Smrg  ftface          FT_Face Use the specified FreeType face object
1172c393a42Smrg  rasterizer      String  Which rasterizer is in use
1182c393a42Smrg  outline         Bool    Whether the glyphs are outlines
1192c393a42Smrg  scalable        Bool    Whether glyphs can be scaled
1202c393a42Smrg  scale           Double  Scale factor for point->pixel conversions
1212c393a42Smrg  dpi             Double  Target dots per inch
1222c393a42Smrg  rgba            Int     unknown, rgb, bgr, vrgb, vbgr,
1232c393a42Smrg                          none - subpixel geometry
1242c393a42Smrg  lcdfilter       Int     Type of LCD filter
1252c393a42Smrg  minspace        Bool    Eliminate leading from line spacing
1262c393a42Smrg  charset         CharSet Unicode chars encoded by the font
1272c393a42Smrg  lang            String  List of RFC-3066-style languages this
1282c393a42Smrg                          font supports
1292c393a42Smrg  fontversion     Int     Version number of the font
1302c393a42Smrg  capability      String  List of layout capabilities in the font
1312c393a42Smrg  embolden        Bool    Rasterizer should synthetically embolden the font
1322c393a42Smrg    </programlisting>
1332c393a42Smrg  </refsect2>
1342c393a42Smrg  <refsect2>
1352c393a42Smrg  <title>Font Matching</title>
1362c393a42Smrg    <para>
1372c393a42SmrgFontconfig performs matching by measuring the distance from a provided
1382c393a42Smrgpattern to all of the available fonts in the system.  The closest matching
1392c393a42Smrgfont is selected.  This ensures that a font will always be returned, but
1402c393a42Smrgdoesn't ensure that it is anything like the requested pattern.
1412c393a42Smrg    </para><para> 
1422c393a42SmrgFont matching starts with an application constructed pattern.  The desired
1432c393a42Smrgattributes of the resulting font are collected together in a pattern.  Each
1442c393a42Smrgproperty of the pattern can contain one or more values; these are listed in
1452c393a42Smrgpriority order; matches earlier in the list are considered "closer" than
1462c393a42Smrgmatches later in the list.
1472c393a42Smrg    </para><para>
1482c393a42SmrgThe initial pattern is modified by applying the list of editing instructions
1492c393a42Smrgspecific to patterns found in the configuration; each consists of a match
1502c393a42Smrgpredicate and a set of editing operations.  They are executed in the order
1512c393a42Smrgthey appeared in the configuration.  Each match causes the associated
1522c393a42Smrgsequence of editing operations to be applied.
1532c393a42Smrg    </para><para>
1542c393a42SmrgAfter the pattern has been edited, a sequence of default substitutions are
1552c393a42Smrgperformed to canonicalize the set of available properties; this avoids the
1562c393a42Smrgneed for the lower layers to constantly provide default values for various
1572c393a42Smrgfont properties during rendering.
1582c393a42Smrg    </para><para>
1592c393a42SmrgThe canonical font pattern is finally matched against all available fonts.
1602c393a42SmrgThe distance from the pattern to the font is measured for each of several
1612c393a42Smrgproperties: foundry, charset, family, lang, spacing, pixelsize, style,
1622c393a42Smrgslant, weight, antialias, rasterizer and outline.  This list is in priority
1632c393a42Smrgorder -- results of comparing earlier elements of this list weigh more
1642c393a42Smrgheavily than later elements.
1652c393a42Smrg    </para><para>
1662c393a42SmrgThere is one special case to this rule; family names are split into two
1672c393a42Smrgbindings; strong and weak.  Strong family names are given greater precedence
1682c393a42Smrgin the match than lang elements while weak family names are given lower
1692c393a42Smrgprecedence than lang elements.  This permits the document language to drive
1702c393a42Smrgfont selection when any document specified font is unavailable.
1712c393a42Smrg    </para><para>
1722c393a42SmrgThe pattern representing that font is augmented to include any properties
1732c393a42Smrgfound in the pattern but not found in the font itself; this permits the
1742c393a42Smrgapplication to pass rendering instructions or any other data through the
1752c393a42Smrgmatching system.  Finally, the list of editing instructions specific to
1762c393a42Smrgfonts found in the configuration are applied to the pattern.  This modified
1772c393a42Smrgpattern is returned to the application.
1782c393a42Smrg    </para><para>
1792c393a42SmrgThe return value contains sufficient information to locate and rasterize the
1802c393a42Smrgfont, including the file name, pixel size and other rendering data.  As
1812c393a42Smrgnone of the information involved pertains to the FreeType library,
1822c393a42Smrgapplications are free to use any rasterization engine or even to take
1832c393a42Smrgthe identified font file and access it directly.
1842c393a42Smrg    </para><para>
1852c393a42SmrgThe match/edit sequences in the configuration are performed in two passes
1862c393a42Smrgbecause there are essentially two different operations necessary -- the
1872c393a42Smrgfirst is to modify how fonts are selected; aliasing families and adding
1882c393a42Smrgsuitable defaults.  The second is to modify how the selected fonts are
1892c393a42Smrgrasterized.  Those must apply to the selected font, not the original pattern
1902c393a42Smrgas false matches will often occur.
1912c393a42Smrg    </para>
1922c393a42Smrg  </refsect2>
1932c393a42Smrg  <refsect2><title>Font Names</title>
1942c393a42Smrg    <para>
1952c393a42SmrgFontconfig provides a textual representation for patterns that the library
1962c393a42Smrgcan both accept and generate.  The representation is in three parts, first a
1972c393a42Smrglist of family names, second a list of point sizes and finally a list of
1982c393a42Smrgadditional properties:
1992c393a42Smrg    </para>
2002c393a42Smrg    <programlisting>
2012c393a42Smrg	&lt;families&gt;-&lt;point sizes&gt;:&lt;name1&gt;=&lt;values1&gt;:&lt;name2&gt;=&lt;values2&gt;...
2022c393a42Smrg    </programlisting>
2032c393a42Smrg    <para>
2042c393a42SmrgValues in a list are separated with commas.  The name needn't include either
2052c393a42Smrgfamilies or point sizes; they can be elided.  In addition, there are
2062c393a42Smrgsymbolic constants that simultaneously indicate both a name and a value.
2072c393a42SmrgHere are some examples:
2082c393a42Smrg    </para>
2092c393a42Smrg    <programlisting>
2102c393a42Smrg  Name                            Meaning
2112c393a42Smrg  ----------------------------------------------------------
2122c393a42Smrg  Times-12                        12 point Times Roman
2132c393a42Smrg  Times-12:bold                   12 point Times Bold
2142c393a42Smrg  Courier:italic                  Courier Italic in the default size
2152c393a42Smrg  Monospace:matrix=1 .1 0 1       The users preferred monospace font
2162c393a42Smrg                                  with artificial obliquing
2172c393a42Smrg    </programlisting>
2182c393a42Smrg    <para>
2192c393a42SmrgThe '\', '-', ':' and ',' characters in family names must be preceeded by a
2202c393a42Smrg'\' character to avoid having them misinterpreted. Similarly, values
2212c393a42Smrgcontaining '\', '=', '_', ':' and ',' must also have them preceeded by a
2222c393a42Smrg'\' character. The '\' characters are stripped out of the family name and
2232c393a42Smrgvalues as the font name is read.
2242c393a42Smrg    </para>
2252c393a42Smrg  </refsect2>
2262c393a42Smrg</refsect1>
2272c393a42Smrg<refsect1><title>Debugging Applications</title>
2282c393a42Smrg  <para>
2292c393a42SmrgTo help diagnose font and applications problems, fontconfig is built with a
2302c393a42Smrglarge amount of internal debugging left enabled. It is controlled by means
2312c393a42Smrgof the FC_DEBUG environment variable. The value of this variable is
2322c393a42Smrginterpreted as a number, and each bit within that value controls different
2332c393a42Smrgdebugging messages.
2342c393a42Smrg  </para>
2352c393a42Smrg  <programlisting>
2362c393a42Smrg  Name         Value    Meaning
2372c393a42Smrg  ---------------------------------------------------------
2382c393a42Smrg  MATCH            1    Brief information about font matching
2392c393a42Smrg  MATCHV           2    Extensive font matching information
2402c393a42Smrg  EDIT             4    Monitor match/test/edit execution
2412c393a42Smrg  FONTSET          8    Track loading of font information at startup
2422c393a42Smrg  CACHE           16    Watch cache files being written
2432c393a42Smrg  CACHEV          32    Extensive cache file writing information
2442c393a42Smrg  PARSE           64    (no longer in use)
2452c393a42Smrg  SCAN           128    Watch font files being scanned to build caches
2462c393a42Smrg  SCANV          256    Verbose font file scanning information
2472c393a42Smrg  MEMORY         512    Monitor fontconfig memory usage
2482c393a42Smrg  CONFIG        1024    Monitor which config files are loaded
2492c393a42Smrg  LANGSET       2048    Dump char sets used to construct lang values
2502c393a42Smrg  OBJTYPES      4096    Display message when value typechecks fail
2512c393a42Smrg  </programlisting>
2522c393a42Smrg  <para>
2532c393a42SmrgAdd the value of the desired debug levels together and assign that (in
2542c393a42Smrgbase 10) to the FC_DEBUG environment variable before running the
2552c393a42Smrgapplication. Output from these statements is sent to stdout.
2562c393a42Smrg  </para>
2572c393a42Smrg</refsect1>
2582c393a42Smrg<refsect1><title>Lang Tags</title>
2592c393a42Smrg  <para>
2602c393a42SmrgEach font in the database contains a list of languages it supports.  This is
2612c393a42Smrgcomputed by comparing the Unicode coverage of the font with the orthography
2622c393a42Smrgof each language.  Languages are tagged using an RFC-3066 compatible naming
2632c393a42Smrgand occur in two parts -- the ISO 639 language tag followed a hyphen and then
2642c393a42Smrgby the ISO 3166 country code.  The hyphen and country code may be elided.
2652c393a42Smrg  </para><para>
2662c393a42SmrgFontconfig has orthographies for several languages built into the library.
2672c393a42SmrgNo provision has been made for adding new ones aside from rebuilding the
2682c393a42Smrglibrary.  It currently supports 122 of the 139 languages named in ISO 639-1,
2692c393a42Smrg141 of the languages with two-letter codes from ISO 639-2 and another 30
2702c393a42Smrglanguages with only three-letter codes.  Languages with both two and three
2712c393a42Smrgletter codes are provided with only the two letter code.
2722c393a42Smrg  </para><para>
2732c393a42SmrgFor languages used in multiple territories with radically different
2742c393a42Smrgcharacter sets, fontconfig includes per-territory orthographies.  This
2752c393a42Smrgincludes Azerbaijani, Kurdish, Pashto, Tigrinya and Chinese.
2762c393a42Smrg  </para>
2772c393a42Smrg</refsect1>
2782c393a42Smrg<refsect1><title>Configuration File Format</title>
2792c393a42Smrg  <para>
2802c393a42SmrgConfiguration files for fontconfig are stored in XML format; this
2812c393a42Smrgformat makes external configuration tools easier to write and ensures that
2822c393a42Smrgthey will generate syntactically correct configuration files.  As XML
2832c393a42Smrgfiles are plain text, they can also be manipulated by the expert user using
2842c393a42Smrga text editor.
2852c393a42Smrg  </para><para>
2862c393a42SmrgThe fontconfig document type definition resides in the external entity
2872c393a42Smrg"fonts.dtd"; this is normally stored in the default font configuration
2882c393a42Smrgdirectory (&confdir;).  Each configuration file should contain the
2892c393a42Smrgfollowing structure:
2902c393a42Smrg    <programlisting>
2912c393a42Smrg	&lt;?xml version="1.0"?&gt;
2922c393a42Smrg	&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
2932c393a42Smrg	&lt;fontconfig&gt;
2942c393a42Smrg	...
2952c393a42Smrg	&lt;/fontconfig&gt;
2962c393a42Smrg    </programlisting>
2972c393a42Smrg  </para>
2982c393a42Smrg<refsect2><title><literal>&lt;fontconfig&gt;</literal></title><para>
2992c393a42SmrgThis is the top level element for a font configuration and can contain
3002c393a42Smrg<literal>&lt;dir&gt;</literal>, <literal>&lt;cache&gt;</literal>, <literal>&lt;include&gt;</literal>, <literal>&lt;match&gt;</literal> and <literal>&lt;alias&gt;</literal> elements in any order.
3012c393a42Smrg  </para></refsect2>
3022c393a42Smrg  <refsect2><title><literal>&lt;dir&gt;</literal></title><para>
3032c393a42SmrgThis element contains a directory name which will be scanned for font files
3042c393a42Smrgto include in the set of available fonts.
3052c393a42Smrg  </para></refsect2>
3062c393a42Smrg  <refsect2><title><literal>&lt;cache&gt;</literal></title><para>
3072c393a42SmrgThis element contains a file name for the per-user cache of font
3082c393a42Smrginformation.  If it starts with '~', it refers to a file in the users
3092c393a42Smrghome directory.  This file is used to hold information about fonts that
3102c393a42Smrgisn't present in the per-directory cache files.  It is automatically
3112c393a42Smrgmaintained by the fontconfig library.  The default for this file 
3122c393a42Smrgis ``~/.fonts.cache-<literal>&lt;version&gt;</literal>'', where <literal>&lt;version&gt;</literal> is the font configuration
3132c393a42Smrgfile version number (currently 2).
3142c393a42Smrg  </para></refsect2>
3152c393a42Smrg  <refsect2><title><literal>&lt;include ignore_missing="no"&gt;</literal></title><para>
3162c393a42SmrgThis element contains the name of an additional configuration file or
3172c393a42Smrgdirectory.  If a directory, every file within that directory starting with an
3182c393a42SmrgASCII digit (U+0030 - U+0039) and ending with the string ``.conf'' will be processed in sorted order.  When
3192c393a42Smrgthe XML datatype is traversed by FcConfigParse, the contents of the file(s)
3202c393a42Smrgwill also be incorporated into the configuration by passing the filename(s) to
3212c393a42SmrgFcConfigLoadAndParse.  If 'ignore_missing' is set to "yes" instead of the
3222c393a42Smrgdefault "no", a missing file or directory will elicit no warning message from
3232c393a42Smrgthe library.
3242c393a42Smrg  </para></refsect2>
3252c393a42Smrg  <refsect2><title><literal>&lt;config&gt;</literal></title><para>
3262c393a42SmrgThis element provides a place to consolidate additional configuration
3272c393a42Smrginformation.  <literal>&lt;config&gt;</literal> can contain <literal>&lt;blank&gt;</literal> and <literal>&lt;rescan&gt;</literal> elements in any
3282c393a42Smrgorder.
3292c393a42Smrg  </para></refsect2>
3302c393a42Smrg  <refsect2><title><literal>&lt;blank&gt;</literal></title><para>
3312c393a42SmrgFonts often include "broken" glyphs which appear in the encoding but are
3322c393a42Smrgdrawn as blanks on the screen.  Within the <literal>&lt;blank&gt;</literal> element, place each
3332c393a42SmrgUnicode characters which is supposed to be blank in an <literal>&lt;int&gt;</literal> element.
3342c393a42SmrgCharacters outside of this set which are drawn as blank will be elided from
3352c393a42Smrgthe set of characters supported by the font.
3362c393a42Smrg  </para></refsect2>
3372c393a42Smrg  <refsect2><title><literal>&lt;rescan&gt;</literal></title><para>
3382c393a42SmrgThe <literal>&lt;rescan&gt;</literal> element holds an <literal>&lt;int&gt;</literal> element which indicates the default
3392c393a42Smrginterval between automatic checks for font configuration changes.
3402c393a42SmrgFontconfig will validate all of the configuration files and directories and
3412c393a42Smrgautomatically rebuild the internal datastructures when this interval passes.
3422c393a42Smrg  </para></refsect2>
3432c393a42Smrg  <refsect2><title><literal>&lt;selectfont&gt;</literal></title><para>
3442c393a42SmrgThis element is used to black/white list fonts from being listed or matched
3452c393a42Smrgagainst.  It holds acceptfont and rejectfont elements.
3462c393a42Smrg  </para></refsect2>
3472c393a42Smrg  <refsect2><title><literal>&lt;acceptfont&gt;</literal></title><para>
3482c393a42SmrgFonts matched by an acceptfont element are "whitelisted"; such fonts are
3492c393a42Smrgexplicitly included in the set of fonts used to resolve list and match
3502c393a42Smrgrequests; including them in this list protects them from being "blacklisted"
3512c393a42Smrgby a rejectfont element.  Acceptfont elements include glob and pattern
3522c393a42Smrgelements which are used to match fonts.
3532c393a42Smrg  </para></refsect2>
3542c393a42Smrg  <refsect2><title><literal>&lt;rejectfont&gt;</literal></title><para>
3552c393a42SmrgFonts matched by an rejectfont element are "blacklisted"; such fonts are
3562c393a42Smrgexcluded from the set of fonts used to resolve list and match requests as if
3572c393a42Smrgthey didn't exist in the system.  Rejectfont elements include glob and
3582c393a42Smrgpattern elements which are used to match fonts.
3592c393a42Smrg  </para></refsect2>
3602c393a42Smrg  <refsect2><title><literal>&lt;glob&gt;</literal></title><para>
3612c393a42SmrgGlob elements hold shell-style filename matching patterns (including ? and
3622c393a42Smrg*) which match fonts based on their complete pathnames.  This can be used to
3632c393a42Smrgexclude a set of directories (/usr/share/fonts/uglyfont*), or particular
3642c393a42Smrgfont file types (*.pcf.gz), but the latter mechanism relies rather heavily
3652c393a42Smrgon filenaming conventions which can't be relied upon.  Note that globs
3662c393a42Smrgonly apply to directories, not to individual fonts.
3672c393a42Smrg  </para></refsect2>
3682c393a42Smrg  <refsect2><title><literal>&lt;pattern&gt;</literal></title><para>
3692c393a42SmrgPattern elements perform list-style matching on incoming fonts; that is,
3702c393a42Smrgthey hold a list of elements and associated values.  If all of those
3712c393a42Smrgelements have a matching value, then the pattern matches the font.  This can
3722c393a42Smrgbe used to select fonts based on attributes of the font (scalable, bold,
3732c393a42Smrgetc), which is a more reliable mechanism than using file extensions.
3742c393a42SmrgPattern elements include patelt elements.
3752c393a42Smrg  </para></refsect2>
3762c393a42Smrg  <refsect2><title><literal>&lt;patelt name="property"&gt;</literal></title><para>
3772c393a42SmrgPatelt elements hold a single pattern element and list of values.  They must
3782c393a42Smrghave a 'name' attribute which indicates the pattern element name.  Patelt
3792c393a42Smrgelements include int, double, string, matrix, bool, charset and const
3802c393a42Smrgelements.
3812c393a42Smrg  </para></refsect2>
3822c393a42Smrg  <refsect2><title><literal>&lt;match target="pattern"&gt;</literal></title><para>
3832c393a42SmrgThis element holds first a (possibly empty) list of <literal>&lt;test&gt;</literal> elements and then
3842c393a42Smrga (possibly empty) list of <literal>&lt;edit&gt;</literal> elements.  Patterns which match all of the
3852c393a42Smrgtests are subjected to all the edits.  If 'target' is set to "font" instead
3862c393a42Smrgof the default "pattern", then this element applies to the font name
3872c393a42Smrgresulting from a match rather than a font pattern to be matched. If 'target'
3882c393a42Smrgis set to "scan", then this element applies when the font is scanned to
3892c393a42Smrgbuild the fontconfig database.
3902c393a42Smrg  </para></refsect2>
3912c393a42Smrg  <refsect2><title><literal>&lt;test qual="any" name="property" target="default" compare="eq"&gt;</literal></title><para>
3922c393a42SmrgThis element contains a single value which is compared with the target
3932c393a42Smrg('pattern', 'font', 'scan' or 'default') property "property" (substitute any of the property names seen 
3942c393a42Smrgabove). 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", or
3952c393a42Smrg"more_eq".  'qual' may either be the default, "any", in which case the match
3962c393a42Smrgsucceeds if any value associated with the property matches the test value, or
3972c393a42Smrg"all", in which case all of the values associated with the property must
3982c393a42Smrgmatch the test value.  When used in a &lt;match target="font"&gt; element,
3992c393a42Smrgthe target= attribute in the &lt;test&gt; element selects between matching
4002c393a42Smrgthe original pattern or the font.  "default" selects whichever target the
4012c393a42Smrgouter &lt;match&gt; element has selected.
4022c393a42Smrg  </para></refsect2>
4032c393a42Smrg  <refsect2><title><literal>&lt;edit name="property" mode="assign" binding="weak"&gt;</literal></title><para>
4042c393a42SmrgThis element contains a list of expression elements (any of the value or
4052c393a42Smrgoperator elements).  The expression elements are evaluated at run-time and
4062c393a42Smrgmodify the property "property".  The modification depends on whether
4072c393a42Smrg"property" was matched by one of the associated <literal>&lt;test&gt;</literal> elements, if so, the
4082c393a42Smrgmodification may affect the first matched value.  Any values inserted into
4092c393a42Smrgthe property are given the indicated binding ("strong", "weak" or "same")
4102c393a42Smrgwith "same" binding using the value from the matched pattern element.
4112c393a42Smrg'mode' is one of:
4122c393a42Smrg    <programlisting>
4132c393a42Smrg  Mode                    With Match              Without Match
4142c393a42Smrg  ---------------------------------------------------------------------
4152c393a42Smrg  "assign"                Replace matching value  Replace all values
4162c393a42Smrg  "assign_replace"        Replace all values      Replace all values
4172c393a42Smrg  "prepend"               Insert before matching  Insert at head of list
4182c393a42Smrg  "prepend_first"         Insert at head of list  Insert at head of list
4192c393a42Smrg  "append"                Append after matching   Append at end of list
4202c393a42Smrg  "append_last"           Append at end of list   Append at end of list
4212c393a42Smrg    </programlisting>
4222c393a42Smrg  </para></refsect2>
4232c393a42Smrg  <refsect2><title><literal>&lt;int&gt;</literal>, <literal>&lt;double&gt;</literal>, <literal>&lt;string&gt;</literal>, <literal>&lt;bool&gt;</literal></title><para>
4242c393a42SmrgThese elements hold a single value of the indicated type.  <literal>&lt;bool&gt;</literal>
4252c393a42Smrgelements hold either true or false.  An important limitation exists in
4262c393a42Smrgthe parsing of floating point numbers -- fontconfig requires that
4272c393a42Smrgthe mantissa start with a digit, not a decimal point, so insert a leading
4282c393a42Smrgzero for purely fractional values (e.g. use 0.5 instead of .5 and -0.5
4292c393a42Smrginstead of -.5).
4302c393a42Smrg  </para></refsect2>
4312c393a42Smrg  <refsect2><title><literal>&lt;matrix&gt;</literal></title><para>
4322c393a42SmrgThis element holds the four <literal>&lt;double&gt;</literal> elements of an affine
4332c393a42Smrgtransformation.
4342c393a42Smrg  </para></refsect2>
4352c393a42Smrg  <refsect2><title><literal>&lt;name&gt;</literal></title><para>
4362c393a42SmrgHolds a property name.  Evaluates to the first value from the property of
4372c393a42Smrgthe font, not the pattern.
4382c393a42Smrg  </para></refsect2>
4392c393a42Smrg  <refsect2><title><literal>&lt;const&gt;</literal></title><para>
4402c393a42SmrgHolds the name of a constant; these are always integers and serve as
4412c393a42Smrgsymbolic names for common font values:
4422c393a42Smrg    <programlisting>
4432c393a42Smrg  Constant        Property        Value
4442c393a42Smrg  -------------------------------------
4452c393a42Smrg  thin            weight          0
4462c393a42Smrg  extralight      weight          40
4472c393a42Smrg  ultralight      weight          40
4482c393a42Smrg  light           weight          50
4492c393a42Smrg  book            weight          75
4502c393a42Smrg  regular         weight          80
4512c393a42Smrg  normal          weight          80
4522c393a42Smrg  medium          weight          100
4532c393a42Smrg  demibold        weight          180
4542c393a42Smrg  semibold        weight          180
4552c393a42Smrg  bold            weight          200
4562c393a42Smrg  extrabold       weight          205
4572c393a42Smrg  black           weight          210
4582c393a42Smrg  heavy           weight          210
4592c393a42Smrg  roman           slant           0
4602c393a42Smrg  italic          slant           100
4612c393a42Smrg  oblique         slant           110
4622c393a42Smrg  ultracondensed  width           50
4632c393a42Smrg  extracondensed  width           63
4642c393a42Smrg  condensed       width           75
4652c393a42Smrg  semicondensed   width           87
4662c393a42Smrg  normal          width           100
4672c393a42Smrg  semiexpanded    width           113
4682c393a42Smrg  expanded        width           125
4692c393a42Smrg  extraexpanded   width           150
4702c393a42Smrg  ultraexpanded   width           200
4712c393a42Smrg  proportional    spacing         0
4722c393a42Smrg  dual            spacing         90
4732c393a42Smrg  mono            spacing         100
4742c393a42Smrg  charcell        spacing         110
4752c393a42Smrg  unknown         rgba            0
4762c393a42Smrg  rgb             rgba            1
4772c393a42Smrg  bgr             rgba            2
4782c393a42Smrg  vrgb            rgba            3
4792c393a42Smrg  vbgr            rgba            4
4802c393a42Smrg  none            rgba            5
4812c393a42Smrg  lcdnone         lcdfilter       0
4822c393a42Smrg  lcddefault      lcdfilter       1
4832c393a42Smrg  lcdlight        lcdfilter       2
4842c393a42Smrg  lcdlegacy       lcdfilter       3
4852c393a42Smrg  hintnone        hintstyle       0
4862c393a42Smrg  hintslight      hintstyle       1
4872c393a42Smrg  hintmedium      hintstyle       2
4882c393a42Smrg  hintfull        hintstyle       3
4892c393a42Smrg    </programlisting>
4902c393a42Smrg      </para>
4912c393a42Smrg    </refsect2>
4922c393a42Smrg  <refsect2>
4932c393a42Smrg      <title><literal>&lt;or&gt;</literal>, <literal>&lt;and&gt;</literal>, <literal>&lt;plus&gt;</literal>, <literal>&lt;minus&gt;</literal>, <literal>&lt;times&gt;</literal>, <literal>&lt;divide&gt;</literal></title>
4942c393a42Smrg      <para>
4952c393a42SmrgThese elements perform the specified operation on a list of expression
4962c393a42Smrgelements.  <literal>&lt;or&gt;</literal> and <literal>&lt;and&gt;</literal> are boolean, not bitwise.
4972c393a42Smrg      </para>
4982c393a42Smrg    </refsect2>
4992c393a42Smrg  <refsect2>
5002c393a42Smrg    <title><literal>&lt;eq&gt;</literal>, <literal>&lt;not_eq&gt;</literal>, <literal>&lt;less&gt;</literal>, <literal>&lt;less_eq&gt;</literal>, <literal>&lt;more&gt;</literal>, <literal>&lt;more_eq&gt;</literal></title>
5012c393a42Smrg    <para>
5022c393a42SmrgThese elements compare two values, producing a boolean result.
5032c393a42Smrg  </para></refsect2>
5042c393a42Smrg  <refsect2><title><literal>&lt;not&gt;</literal></title><para>
5052c393a42SmrgInverts the boolean sense of its one expression element
5062c393a42Smrg  </para></refsect2>
5072c393a42Smrg  <refsect2><title><literal>&lt;if&gt;</literal></title><para>
5082c393a42SmrgThis element takes three expression elements; if the value of the first is
5092c393a42Smrgtrue, it produces the value of the second, otherwise it produces the value
5102c393a42Smrgof the third.
5112c393a42Smrg  </para></refsect2>
5122c393a42Smrg  <refsect2><title><literal>&lt;alias&gt;</literal></title><para>
5132c393a42SmrgAlias elements provide a shorthand notation for the set of common match
5142c393a42Smrgoperations needed to substitute one font family for another.  They contain a
5152c393a42Smrg<literal>&lt;family&gt;</literal> element followed by optional <literal>&lt;prefer&gt;</literal>, <literal>&lt;accept&gt;</literal> and <literal>&lt;default&gt;</literal>
5162c393a42Smrgelements.  Fonts matching the <literal>&lt;family&gt;</literal> element are edited to prepend the
5172c393a42Smrglist of <literal>&lt;prefer&gt;</literal>ed families before the matching <literal>&lt;family&gt;</literal>, append the
5182c393a42Smrg<literal>&lt;accept&gt;</literal>able families after the matching <literal>&lt;family&gt;</literal> and append the <literal>&lt;default&gt;</literal>
5192c393a42Smrgfamilies to the end of the family list.
5202c393a42Smrg  </para></refsect2>
5212c393a42Smrg  <refsect2><title><literal>&lt;family&gt;</literal></title><para>
5222c393a42SmrgHolds a single font family name
5232c393a42Smrg  </para></refsect2>
5242c393a42Smrg  <refsect2><title><literal>&lt;prefer&gt;</literal>, <literal>&lt;accept&gt;</literal>, <literal>&lt;default&gt;</literal></title><para>
5252c393a42SmrgThese hold a list of <literal>&lt;family&gt;</literal> elements to be used by the <literal>&lt;alias&gt;</literal> element.
5262c393a42Smrg  </para></refsect2>
5272c393a42Smrg</refsect1>
5282c393a42Smrg<refsect1><title>EXAMPLE CONFIGURATION FILE</title>
5292c393a42Smrg  <refsect2><title>System configuration file</title>
5302c393a42Smrg    <para>
5312c393a42SmrgThis is an example of a system-wide configuration file
5322c393a42Smrg    </para>
5332c393a42Smrg    <programlisting>
5342c393a42Smrg&lt;?xml version="1.0"?&gt;
5352c393a42Smrg&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
5362c393a42Smrg&lt;!-- &confdir;/fonts.conf file to configure system font access --&gt;
5372c393a42Smrg&lt;fontconfig&gt;
5382c393a42Smrg&lt;!-- 
5392c393a42Smrg	Find fonts in these directories
5402c393a42Smrg--&gt;
5412c393a42Smrg&lt;dir&gt;/usr/share/fonts&lt;/dir&gt;
5422c393a42Smrg&lt;dir&gt;/usr/X11R6/lib/X11/fonts&lt;/dir&gt;
5432c393a42Smrg
5442c393a42Smrg&lt;!--
5452c393a42Smrg	Accept deprecated 'mono' alias, replacing it with 'monospace'
5462c393a42Smrg--&gt;
5472c393a42Smrg&lt;match target="pattern"&gt;
5482c393a42Smrg	&lt;test qual="any" name="family"&gt;&lt;string&gt;mono&lt;/string&gt;&lt;/test&gt;
5492c393a42Smrg	&lt;edit name="family" mode="assign"&gt;&lt;string&gt;monospace&lt;/string&gt;&lt;/edit&gt;
5502c393a42Smrg&lt;/match&gt;
5512c393a42Smrg
5522c393a42Smrg&lt;!--
5532c393a42Smrg	Names not including any well known alias are given 'sans'
5542c393a42Smrg--&gt;
5552c393a42Smrg&lt;match target="pattern"&gt;
5562c393a42Smrg	&lt;test qual="all" name="family" mode="not_eq"&gt;sans&lt;/test&gt;
5572c393a42Smrg	&lt;test qual="all" name="family" mode="not_eq"&gt;serif&lt;/test&gt;
5582c393a42Smrg	&lt;test qual="all" name="family" mode="not_eq"&gt;monospace&lt;/test&gt;
5592c393a42Smrg	&lt;edit name="family" mode="append_last"&gt;&lt;string&gt;sans&lt;/string&gt;&lt;/edit&gt;
5602c393a42Smrg&lt;/match&gt;
5612c393a42Smrg
5622c393a42Smrg&lt;!--
5632c393a42Smrg	Load per-user customization file, but don't complain
5642c393a42Smrg	if it doesn't exist
5652c393a42Smrg--&gt;
5662c393a42Smrg&lt;include ignore_missing="yes"&gt;~/.fonts.conf&lt;/include&gt;
5672c393a42Smrg
5682c393a42Smrg&lt;!--
5692c393a42Smrg	Load local customization files, but don't complain
5702c393a42Smrg	if there aren't any
5712c393a42Smrg--&gt;
5722c393a42Smrg&lt;include ignore_missing="yes"&gt;conf.d&lt;/include&gt;
5732c393a42Smrg&lt;include ignore_missing="yes"&gt;local.conf&lt;/include&gt;
5742c393a42Smrg
5752c393a42Smrg&lt;!--
5762c393a42Smrg	Alias well known font names to available TrueType fonts.
5772c393a42Smrg	These substitute TrueType faces for similar Type1
5782c393a42Smrg	faces to improve screen appearance.
5792c393a42Smrg--&gt;
5802c393a42Smrg&lt;alias&gt;
5812c393a42Smrg	&lt;family&gt;Times&lt;/family&gt;
5822c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Times New Roman&lt;/family&gt;&lt;/prefer&gt;
5832c393a42Smrg	&lt;default&gt;&lt;family&gt;serif&lt;/family&gt;&lt;/default&gt;
5842c393a42Smrg&lt;/alias&gt;
5852c393a42Smrg&lt;alias&gt;
5862c393a42Smrg	&lt;family&gt;Helvetica&lt;/family&gt;
5872c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Arial&lt;/family&gt;&lt;/prefer&gt;
5882c393a42Smrg	&lt;default&gt;&lt;family&gt;sans&lt;/family&gt;&lt;/default&gt;
5892c393a42Smrg&lt;/alias&gt;
5902c393a42Smrg&lt;alias&gt;
5912c393a42Smrg	&lt;family&gt;Courier&lt;/family&gt;
5922c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Courier New&lt;/family&gt;&lt;/prefer&gt;
5932c393a42Smrg	&lt;default&gt;&lt;family&gt;monospace&lt;/family&gt;&lt;/default&gt;
5942c393a42Smrg&lt;/alias&gt;
5952c393a42Smrg
5962c393a42Smrg&lt;!--
5972c393a42Smrg	Provide required aliases for standard names
5982c393a42Smrg	Do these after the users configuration file so that
5992c393a42Smrg	any aliases there are used preferentially
6002c393a42Smrg--&gt;
6012c393a42Smrg&lt;alias&gt;
6022c393a42Smrg	&lt;family&gt;serif&lt;/family&gt;
6032c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Times New Roman&lt;/family&gt;&lt;/prefer&gt;
6042c393a42Smrg&lt;/alias&gt;
6052c393a42Smrg&lt;alias&gt;
6062c393a42Smrg	&lt;family&gt;sans&lt;/family&gt;
6072c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Arial&lt;/family&gt;&lt;/prefer&gt;
6082c393a42Smrg&lt;/alias&gt;
6092c393a42Smrg&lt;alias&gt;
6102c393a42Smrg	&lt;family&gt;monospace&lt;/family&gt;
6112c393a42Smrg	&lt;prefer&gt;&lt;family&gt;Andale Mono&lt;/family&gt;&lt;/prefer&gt;
6122c393a42Smrg&lt;/alias&gt;
6132c393a42Smrg&lt;/fontconfig&gt;
6142c393a42Smrg    </programlisting>
6152c393a42Smrg  </refsect2>
6162c393a42Smrg  <refsect2><title>User configuration file</title>
6172c393a42Smrg    <para>
6182c393a42SmrgThis is an example of a per-user configuration file that lives in
6192c393a42Smrg~/.fonts.conf
6202c393a42Smrg    </para>
6212c393a42Smrg    <programlisting>
6222c393a42Smrg&lt;?xml version="1.0"?&gt;
6232c393a42Smrg&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
6242c393a42Smrg&lt;!-- ~/.fonts.conf for per-user font configuration --&gt;
6252c393a42Smrg&lt;fontconfig&gt;
6262c393a42Smrg
6272c393a42Smrg&lt;!--
6282c393a42Smrg	Private font directory
6292c393a42Smrg--&gt;
6302c393a42Smrg&lt;dir&gt;~/.fonts&lt;/dir&gt;
6312c393a42Smrg
6322c393a42Smrg&lt;!--
6332c393a42Smrg	use rgb sub-pixel ordering to improve glyph appearance on
6342c393a42Smrg	LCD screens.  Changes affecting rendering, but not matching
6352c393a42Smrg	should always use target="font".
6362c393a42Smrg--&gt;
6372c393a42Smrg&lt;match target="font"&gt;
6382c393a42Smrg	&lt;edit name="rgba" mode="assign"&gt;&lt;const&gt;rgb&lt;/const&gt;&lt;/edit&gt;
6392c393a42Smrg&lt;/match&gt;
6402c393a42Smrg&lt;/fontconfig&gt;
6412c393a42Smrg    </programlisting>
6422c393a42Smrg  </refsect2>
6432c393a42Smrg</refsect1>
6442c393a42Smrg<refsect1><title>Files</title>
6452c393a42Smrg  <para>
6462c393a42Smrg<emphasis>fonts.conf</emphasis>
6472c393a42Smrgcontains configuration information for the fontconfig library
6482c393a42Smrgconsisting of directories to look at for font information as well as
6492c393a42Smrginstructions on editing program specified font patterns before attempting to
6502c393a42Smrgmatch the available fonts.  It is in xml format.
6512c393a42Smrg  </para>
6522c393a42Smrg  <para>
6532c393a42Smrg<emphasis>conf.d</emphasis>
6542c393a42Smrgis the conventional name for a directory of additional configuration files
6552c393a42Smrgmanaged by external applications or the local administrator.  The
6562c393a42Smrgfilenames starting with decimal digits are sorted in lexicographic order
6572c393a42Smrgand used as additional configuration files.  All of these files are in xml
6582c393a42Smrgformat.  The master fonts.conf file references this directory in an 
6592c393a42Smrg&lt;include&gt; directive.
6602c393a42Smrg  </para>
6612c393a42Smrg  <para>
6622c393a42Smrg<emphasis>fonts.dtd</emphasis>
6632c393a42Smrgis a DTD that describes the format of the configuration files.
6642c393a42Smrg  </para>
6652c393a42Smrg  <para>
666a6844aabSmrg<emphasis>~/.fonts.conf.d</emphasis>
667a6844aabSmrgis the conventional name for a per-user directory of (typically
668a6844aabSmrgauto-generated) configuration files, although the
669a6844aabSmrgactual location is specified in the global fonts.conf file.
670a6844aabSmrg  </para>
671a6844aabSmrg  <para>
6722c393a42Smrg<emphasis>~/.fonts.conf</emphasis>
6732c393a42Smrgis the conventional location for per-user font configuration, although the
6742c393a42Smrgactual location is specified in the global fonts.conf file.
6752c393a42Smrg  </para>
6762c393a42Smrg  <para>
6772c393a42Smrg<emphasis> ~/.fonts.cache-*</emphasis>
6782c393a42Smrgis the conventional repository of font information that isn't found in the
6792c393a42Smrgper-directory caches.  This file is automatically maintained by fontconfig.
6802c393a42Smrg  </para>
6812c393a42Smrg</refsect1>
6822c393a42Smrg<refsect1><title>See Also</title>
6832c393a42Smrg  <para>
684a6844aabSmrgfc-cat(1), fc-cache(1), fc-list(1), fc-match(1), fc-query(1)
6852c393a42Smrg  </para>
6862c393a42Smrg</refsect1>
6872c393a42Smrg<refsect1><title>Version</title>
6882c393a42Smrg	    <para>
6892c393a42SmrgFontconfig version &version;
6902c393a42Smrg	    </para>
6912c393a42Smrg</refsect1>
6922c393a42Smrg</refentry>
693