Initial Commit
[packages] / xemacs-packages / general-docs / texi / xemacs / fontconfig.texi
1 \input texinfo.tex
2 @c %**start of header
3 @c This @setfilename tells makeinfo to DTRT for the *installed* .texi file.
4 @setfilename fontconfig.info
5 @settitle Fontconfig: Font configuration and customization library
6
7 @set synched-to-pkg-version 1.0
8 @set synched-to-doc-versions Package: @value{synched-to-package-version}
9 @set last-released-month-year October 2003
10 @set last-released-date 20 October 2003
11
12 @footnotestyle separate
13 @paragraphindent 2
14 @c %**end of header
15
16 @dircategory Permissively licensed documentation
17 @direntry
18 * fontconfig::                Managing font metainformation.
19 @end direntry
20
21 @setchapternewpage odd
22
23 @shorttitlepage Fontconfig
24
25 @titlepage
26 @title Fontconfig
27 @subtitle Font configuration and customization library
28 @subtitle A Rendering-Engine-Independent Library
29 @subtitle for Managing Font Metainformation
30
31 @author Keith Packard
32 @author Stephen J. Turnbull
33
34 @end titlepage
35
36 @ifnottex
37 @node Top, Copying, (dir), (dir)
38 @top Fontconfig
39
40 This file documents fontconfig, a rendering-engine-independent library
41 for managing font metainformation (@emph{i.e.}, everything but the glyph
42 data themselves).  It is @emph{not} part of XEmacs.
43
44 Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
45 Copyright © 2003 Stephen J. Turnbull, member of the XEmacs Project
46
47 In the following notice, the term "Authors" refers to the copyright
48 holders listed above, and "Documentation" refers to this version of the
49 documentation supplied by Keith Packard, as adapted to Texinfo by
50 Stephen J. Turnbull.  The fontconfig library itself and the original
51 documentation are covered by a similar license.
52
53 Permission to use, copy, modify, distribute, and sell this Documentation
54 for any purpose is hereby granted without fee, provided that the above
55 copyright notice appear in all copies and that both that copyright
56 notice and this permission notice appear in copies of the Documentation,
57 and that the names of the Authors not be used in advertising or
58 publicity pertaining to distribution of the Documentation without
59 specific, written prior permission.  The Authors make no representations
60 about the suitability of this Documentation for any purpose.  It is
61 provided "as is" without express or implied warranty.
62
63 THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS DOCUMENTATION,
64 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
65 EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
66 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
67 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
68 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69 PERFORMANCE OF THIS DOCUMENTATION.
70
71 @c I believe that this document can legally be distributed under the
72 @c above permission.  rms's opinion is that there is nothing left of
73 @c `texinfo.tex' after processing this document, and therefore nothing
74 @c forces this document to be distributed under GPL.
75
76 @c The original permissively licensed document may be obtained in
77 @c distributions of the fontconfig library available from the CVS
78 @c repository of the XFree86 Project in module xc/extra/fontconfig.
79
80 @end ifnottex
81
82 @menu
83 * Copying::
84 * Overview::
85 * The fontconfig API::
86 * Configuration File Format::
87 * Files::
88 * Authors::
89
90 @detailmenu
91  --- The Detailed Node Listing ---
92
93 Overview
94
95 * Font Configuration::
96 * Font Properties::
97 * Font Matching::
98 * Font List Matching::
99 * Font Names::
100 * LANG Tags::
101
102 The fontconfig API
103
104 * Data Types::
105 * Functions::
106
107 Functions
108
109 * FcMatrix::
110 * FcCharSet::
111 * FcValue::
112 * FcPattern::
113 * FcFontSet::
114 * FcObjectSet::
115 * FcObjectType::
116 * Querying Fonts and Their Properties::
117 * Initialization::
118 * FcAtomic::
119 * FreeType-Specific Functions::
120 * XML-Specific Functions::
121 * File and Directory Routines::
122 * FcStrSet and FcStrList::
123 * String Utilities::
124
125 Configuration File Format
126
127 * Example System Configuration File::
128 * Example User Configuration File::
129
130 @end detailmenu
131 @end menu
132
133 @node Copying, Overview, Top, Top
134 @chapter Copying
135
136 The fontconfig library and the accompanying documentation are covered by
137 the following copyright notice and license, except for this Texinfo
138 version which has additional authors but is otherwise substantially the
139 same.
140
141 Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
142
143 Permission to use, copy, modify, distribute, and sell this software and its
144 documentation for any purpose is hereby granted without fee, provided that
145 the above copyright notice appear in all copies and that both that
146 copyright notice and this permission notice appear in supporting
147 documentation, and that the name of Keith Packard not be used in
148 advertising or publicity pertaining to distribution of the software without
149 specific, written prior permission.  Keith Packard makes no
150 representations about the suitability of this software for any purpose.  It
151 is provided "as is" without express or implied warranty.
152
153 KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
154 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
155 EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
156 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
157 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
158 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
159 PERFORMANCE OF THIS SOFTWARE.
160
161 @node Overview, The fontconfig API, Copying, Top
162 @chapter Overview
163
164 @c DESCRIPTION
165 Fontconfig is a library designed to provide system-wide font
166 configuration, customization and application access.
167
168 This manual describes fontconfig version 1.0.2.
169
170 @c FUNCTIONAL OVERVIEW
171 Fontconfig contains two essential modules, the configuration module which
172 builds an internal configuration from XML files and the matching module
173 which accepts font patterns and returns the nearest matching font.
174
175 @menu
176 * Font Configuration::          
177 * Font Properties::             
178 * Font Matching::               
179 * Font List Matching::          
180 * Font Names::                  
181 * LANG Tags::                   
182 @end menu
183
184 @node Font Configuration, Font Properties, Overview, Overview
185 @section Font Configuration
186
187 The configuration module consists of the FcConfig datatype, libexpat and
188 FcConfigParse which walks over an XML tree and amends a configuration with
189 data found within.  From an external perspective, configuration of the
190 library consists of generating a valid XML tree and feeding that to
191 FcConfigParse.  The only other mechanism provided to applications for
192 changing the running configuration is to add fonts and directories to the
193 list of application-provided font files.  
194
195 The intent is to make font configuration relatively static, and shared by
196 as many applications as possible.  It is hoped that this will lead to more
197 stable font selection when passing names from one application to another.
198 XML was chosen as a configuration file format because it provides a format
199 which is easy for external agents to edit while retaining the correct
200 structure and syntax.
201
202 Font configuration is separate from font matching; applications needing to
203 do their own matching can access the available fonts from the library and
204 perform private matching.  The intent is to permit applications to pick and
205 choose appropriate functionality from the library instead of forcing them to
206 choose between this library and a private configuration mechanism.  The hope
207 is that this will ensure that configuration of fonts for all applications
208 can be centralized in one place.  Centralizing font configuration will
209 simplify and regularize font installation and customization.
210
211 @node Font Properties, Font Matching, Font Configuration, Overview
212 @section Font Properties
213
214 While font patterns may contain essentially any properties, there are some
215 well known properties with associated types.  Fontconfig uses some of these
216 properties for font matching and font completion.  Others are provided as a
217 convenience for the applications rendering mechanism.  Some symbolic
218 constants are provided for common values or enumerated types.
219 @xref{Constants}, for the list of standard properties and values.
220
221
222 @node Font Matching, Font List Matching, Font Properties, Overview
223 @section Font Matching
224
225 Fontconfig performs matching by measuring the distance from a provided
226 pattern to all of the available fonts in the system.  The closest matching
227 font is selected.  This ensures that a font will always be returned, but
228 doesn't ensure that it is anything like the requested pattern.
229
230 Font matching starts with an application constructed pattern.  The desired
231 attributes of the resulting font are collected together in an FcPattern
232 object.  Each property of the pattern can contain one or more values; these
233 are listed in priority order; matches earlier in the list are considered
234 "closer" than matches later in the list.
235
236 The initial pattern is modified by applying the list of editing instructions
237 specific to patterns found in the configuration; each consists of a match
238 predicate and a set of editing operations.  They are executed in the order
239 they appeared in the configuration.  Each match causes the associated
240 sequence of editing operations to be applied.
241
242 After the pattern has been edited, a sequence of default substitutions are
243 performed to canonicalize the set of available properties; this avoids the
244 need for the lower layers to constantly provide default values for various
245 font properties during rendering.
246
247 The canonical font pattern is finally matched against all available fonts.
248 The distance from the pattern to the font is measured for each of several
249 properties: foundry, charset, family, lang, spacing, pixelsize, style,
250 slant, weight, antialias, rasterizer and outline.  This list is in priority
251 order---results of comparing earlier elements of this list weigh more
252 heavily than later elements.
253
254 There is one special case to this rule; family names are split into two
255 bindings; strong and weak.  Strong family names are given greater precedence
256 in the match than lang elements while weak family names are given lower
257 precedence than lang elements.  This permits the document language to drive
258 font selection when any document specified font is unavailable.
259
260 The pattern representing that font is augmented to include any properties
261 found in the pattern but not found in the font itself; this permits the
262 application to pass rendering instructions or any other data through the
263 matching system.  Finally, the list of editing instructions specific to
264 fonts found in the configuration are applied to the pattern.  This modified
265 pattern is returned to the application.
266
267 The return value contains sufficient information to locate and rasterize the
268 font, including the file name, pixel size and other rendering data.  As
269 none of the information involved pertains to the FreeType library,
270 applications are free to use any rasterization engine or even to take
271 the identified font file and access it directly.
272
273 The match/edit sequences in the configuration are performed in two passes
274 because there are essentially two different operations necessary -- the
275 first is to modify how fonts are selected; aliasing families and adding
276 suitable defaults.  The second is to modify how the selected fonts are
277 rasterized.  Those must apply to the selected font, not the original pattern
278 as false matches will often occur.
279
280 @node Font List Matching, Font Names, Font Matching, Overview
281 @section Font List Matching
282
283 While many applications want to locate a single font best matching their
284 search criteria, other applications need to build a set of fonts which can
285 be used to present any Unicode data.  Fontconfig provides an API to generate
286 a list sorted by the nearness of each font to the pattern.  Every font in
287 the system is considered, the best matching fonts are placed first.  The
288 application then can select whether the remaining fonts are unconditionally 
289 included in the list, or whether they are included only if they cover
290 portions of Unicode not covered by any of the preceeding fonts.
291
292 The list resulting from this match is represented by references to the
293 original font patterns and so consumes very little memory.  Using a list
294 entry involves creating a pattern which combines the information from the
295 font with the information from the original pattern and executing the font
296 substitutions.
297
298 @node Font Names, LANG Tags, Font List Matching, Overview
299 @section Font Names
300
301 Fontconfig provides a textual representation for patterns that the library
302 can both accept and generate.  The representation is in three parts, first a
303 list of family names, second a list of point sizes and finally a list of
304 additional properties:
305
306 @example
307         <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>...
308 @end example
309
310 Values in a list are separated with commas.  A hyphen or comma in a family
311 name must be escaped with a backslash.  The name needn't include either
312 families or point sizes; they can be elided.  If the family name only is
313 given, the hyphen may be omitted.  If there are no additional properties,
314 no trailing colon should be used.  In addition, there are
315 symbolic constants that simultaneously indicate both a name and a value.
316 Here are some examples:
317
318 @example
319 Times-12                    12 point Times Roman
320 Times-12:bold               12 point Times Bold
321 Courier:italic              Courier Italic in the default size
322 Monospace:matrix=1 .1 0 1   The users preferred monospace font
323                             with artificial obliquing
324 Mikachan\-PB-16             12 point Mikachan-PB
325 @end example
326
327 @node LANG Tags,  , Font Names, Overview
328 @section LANG Tags
329
330 Each font in the database contains a list of languages it supports.  This is
331 computed by comparing the Unicode coverage of the font with the orthography
332 of each language.  Languages are tagged using an RFC-3066 compatible naming
333 and occur in two parts -- the ISO639 language tag followed a hyphen and then
334 by the ISO 3166 country code.  The hyphen and country code may be elided.
335
336 Fontconfig has orthographies for several languages built into the library.
337 No provision has been made for adding new ones aside from rebuilding the
338 library.  It currently supports 122 of the 139 languages named in ISO 639-1,
339 141 of the languages with two-letter codes from ISO 639-2 and another 30
340 languages with only three-letter codes.
341
342 @node The fontconfig API, Configuration File Format, Overview, Top
343 @chapter The fontconfig API
344
345 @example
346 #include <fontconfig/fontconfig.h>
347 #include <fontconfig/fcfreetype.h>
348 @end example
349
350 @menu
351 * Constants::
352 * Data Types::                   
353 * Functions::                   
354 @end menu
355
356 @node Constants, Data Types, The fontconfig API, The fontconfig API
357
358 While fontconfig is designed to be extensible, it provides a comprehensive
359 set of standard properties and values for fonts.
360
361 The following table gives the list of standard font properties.  The property
362 name is represented as a string.  In C code a C preprocessor symbol may be
363 used to help with typo detection.
364
365 @example
366 Property        CPP symbol      Type    Description
367
368 family          FC_FAMILY       String  Font family name
369 style           FC_STYLE        String  Font style. Overrides weight and slant
370 slant           FC_SLANT        Int     Italic, oblique or roman
371 weight          FC_WEIGHT       Int     Light, medium, demibold, bold or black
372 size            FC_SIZE         Double  Point size
373 aspect          FC_ASPECT       Double  Stretch glyphs horizontally, then hint
374 pixelsize       FC_PIXEL_SIZE   Double  Pixel size
375 spacing         FC_SPACING      Int     Proportional, monospace or charcell
376 foundry         FC_FOUNDRY      String  Font foundry name
377 antialias       FC_ANTIALIAS    Bool    Should glyphs be antialiased?
378 hinting         FC_HINTING      Bool    Should the rasterizer use hinting?
379 verticallayout  FC_VERTICAL_LAYOUT Bool Use vertical layout
380 autohint        FC_AUTOHINT     Bool    Use autohinter instead of normal hinter
381 globaladvance   FC_GLOBAL_ADVANCE Bool  Use font global advance data
382 file            FC_FILE         String  The filename holding the font
383 index           FC_INDEX        Int     The index of the font within the file
384 ftface          FC_FT_FACE      FT_Face Use the specified FreeType face object
385 rasterizer      FC_RASTERIZER   String  Which rasterizer is in use
386 outline         FC_OUTLINE      Bool    Whether the glyphs are outlines
387 scalable        FC_SCALABLE     Bool    Whether glyphs can be scaled
388 scale           FC_SCALE        Double  Point->pixel conversion scale factor
389 dpi             FC_DPI          Double  Target dots per inch
390 rgba            FC_RGBA         Int     unknown, rgb, bgr, vrgb, vbgr, none
391                                         - subpixel geometry
392 source          FC_SOURCE       String  X11, freetype
393 minspace        FC_MINSPACE     Bool    Eliminate leading from line spacing
394 charset         FC_CHARSET      CharSet Unicode chars encoded by the font
395 lang            FC_LANG         String  List of RFC-3066-style languages
396                                         this font supports
397 fontversion     FC_FONTVERSION  Int     From 'head' table
398 @end example
399
400 C code can check the fontconfig version number with the numerical
401 preprocessor constants @code{FC_MAJOR}, @code{FC_MINOR}, and
402 @code{FC_REVISION}, or use the combined constant @code{FC_VERSION}, defined
403 as @code{FC_MAJOR*10000 + FC_MINOR*100 + FC_REVISION}.
404
405 @c fontconfig.h details what FC_CACHE_VERSION is, exactly. 
406 The cache version is given by @code{FC_CACHE_VERSION}, and is a string, not
407 an integer.  This is normally appended to the end of the cache file name, so
408 multiple versions of fontconfig can peacefully co-exist.  The cache file
409 names are defined as @code{FC_DIR_CACHE_FILE} and @code{FC_USER_CACHE_FILE}.
410
411 The Boolean constants are @code{FcFalse} (0) and @code{FcTrue} (1).
412
413 Properties used to control the rasterizer, their preprocessor constants, and
414 their types, include:
415
416 @example
417 charwidth       FC_CHAR_WIDTH   Int
418 charheight      FC_CHAR_HEIGHT  Int
419 matrix          FC_MATRIX       FcMatrix
420 @end example
421
422 Preprocessor constants are defined for common standard font weights.  All are
423 Ints.
424
425 @example
426 FC_WEIGHT_LIGHT     0
427 FC_WEIGHT_MEDIUM    100
428 FC_WEIGHT_DEMIBOLD  180
429 FC_WEIGHT_BOLD      200
430 FC_WEIGHT_BLACK     210
431 @end example
432
433 Preprocessor constants are defined for common standard slants.  All are Ints.
434
435 @example
436 FC_SLANT_ROMAN      0
437 FC_SLANT_ITALIC     100
438 FC_SLANT_OBLIQUE    110
439 @end example
440
441 Preprocessor constants are defined for the three spacing types.  All are
442 Ints, but should be treated as symbolic constants.
443
444 @example
445 FC_PROPORTIONAL     0
446 FC_MONO             100
447 FC_CHARCELL         110
448 @end example
449
450 Preprocessor constants are defined for the subpixel orders.  All are
451 Ints, but should be treated as symbolic constants.
452
453 @example
454 FC_RGBA_UNKNOWN     0
455 FC_RGBA_RGB         1
456 FC_RGBA_BGR         2
457 FC_RGBA_VRGB        3
458 FC_RGBA_VBGR        4
459 FC_RGBA_NONE        5
460 @end example
461
462
463 @node Data Types, Functions, Constants, The fontconfig API
464 @section Data Types
465
466 @table @samp
467 @item FcChar8
468 @itemx FcChar16
469 @itemx FcChar32
470 @itemx FcBool
471 These are primitive data types; the FcChar* types hold precisely the number
472 of bits stated (if supported by the C implementation).  FcBool holds
473 one of two CPP symbols: FcFalse or FcTrue.
474
475 @item FcMatrix
476 An FcMatrix holds an affine transformation, usually used to reshape glyphs.
477 A small set of matrix operations are provided to manipulate these.
478
479 @example
480         typedef struct _FcMatrix @{
481                 double xx, xy, yx, yy;
482         @} FcMatrix;
483 @end example
484
485 @item FcCharSet
486 An FcCharSet is an abstract type that holds the set of encoded unicode chars
487 in a font.  Operations to build and compare these sets are provided.
488
489 @item FcType
490 Tags the kind of data stored in an FcValue.
491
492 @item FcValue
493 An FcValue object holds a single value with one of a number of different
494 types.  The 'type' tag indicates which member is valid.
495
496 @example
497         typedef struct _FcValue @{
498                 FcType type;
499                 union @{
500                         const FcChar8 *s;
501                         int i;
502                         FcBool b;
503                         double d;
504                         const FcMatrix *m;
505                         const FcCharSet *c;
506                         void *f;
507                         const FcPattern *p;
508                         const FcLangSet *l;
509                 @} u;
510         @} FcValue;
511 @end example
512
513 @example
514         type            Union member    Datatype
515
516         FcTypeVoid      (none)          (none)
517         FcTypeInteger   i               int
518         FcTypeDouble    d               double
519         FcTypeString    s               TcChar8 *
520         FcTypeBool      b               b
521         FcTypeMatrix    m               FcMatrix *
522         FcTypeCharSet   c               FcCharSet *
523         FcTypeFTFace    f               void *
524                         p               FcPattern *
525         FcTypeLangSet   l               FcLangSet *
526 @end example
527
528 @item FcPattern
529 holds a set of names with associated value lists; each name refers to a
530 property of a font.  FcPatterns are used as inputs to the matching code as
531 well as holding information about specific fonts.  Each property can hold
532 one or more values; conventionally all of the same type, although the
533 interface doesn't demand that.
534
535 @item FcFontSet
536
537 @example
538         typedef struct _FcFontSet @{
539                 int nfont;
540                 int sfont;
541                 FcPattern **fonts;
542         @} FcFontSet;
543 @end example
544
545 An FcFontSet contains a list of FcPatterns.  Internally fontconfig uses this
546 data structure to hold sets of fonts.  Externally, fontconfig returns the
547 results of listing fonts in this format.  'nfont' holds the number of
548 patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
549 array.
550
551 @item FcStrSet
552 @itemx FcStrList
553 FcStrSet holds a list of strings that can be appended to and enumerated.
554 Its unique characteristic is that the enumeration works even while strings
555 are appended during enumeration.  FcStrList is used during enumeration to
556 safely and correctly walk the list of strings even while that list is edited
557 in the middle of enumeration.
558
559 @item FcObjectSet
560
561 @example
562         typedef struct _FcObjectSet @{
563                 int nobject;
564                 int sobject;
565                 const char **objects;
566         @} FcObjectSet;
567 @end example
568 holds a set of names and is used to specify which fields from fonts are
569 placed in the the list of returned patterns when listing fonts.
570
571 @item FcObjectType
572
573 @example
574         typedef struct _FcObjectType @{
575                 const char *object;
576                 FcType type;
577         @} FcObjectType;
578 @end example
579 marks the type of a pattern element generated when parsing font names.
580 Applications can add new object types so that font names may contain the new
581 elements.
582
583 @item FcConstant
584
585 @example
586         typedef struct _FcConstant @{
587             const FcChar8 *name;
588             const char *object;
589             int value;
590         @} FcConstant;
591 @end example
592 Provides for symbolic constants for new pattern elements.  When 'name' is
593 seen in a font name, an 'object' element is created with value 'value'.
594
595 @item FcBlanks
596 holds a list of Unicode chars which are expected to be blank; unexpectedly
597 blank chars are assumed to be invalid and are elided from the charset
598 associated with the font.
599
600 @item FcFileCache
601 holds the per-user cache information for use while loading the font
602 database. This is built automatically for the current configuration when
603 that is loaded.  Applications must always pass '0' when one is requested.
604
605 @item FcConfig
606 holds a complete configuration of the library; there is one default
607 configuration, other can be constructed from XML data structures.  All
608 public entry points that need global data can take an optional FcConfig*
609 argument; passing 0 uses the default configuration.  FcConfig objects hold two
610 sets of fonts, the first contains those specified by the configuration, the
611 second set holds those added by the application at run-time.  Interfaces
612 that need to reference a particulat set use one of the FcSetName enumerated
613 values.
614
615 @item FcSetName
616 Specifies one of the two sets of fonts available in a configuration;
617 FcSetSystem for those fonts specified in the configuration and
618 FcSetApplication which holds fonts provided by the application.
619
620 @item FcResult
621 Used as a return type for functions manipulating FcPattern objects.
622
623 @example
624 Result code             Meaning
625 FcResultMatch           Object exists with the specified ID
626 FcResultNoMatch         Object doesn't exist at all
627 FcResultTypeMismatch    Object exists, but the type doesn't match
628 FcResultNoId            Object exists, but has fewer values than specified
629 @end example
630
631 @item FcAtomic
632 Used for locking access to config files.  Provides a safe way to update
633 configuration files.
634
635 @item FcMatchKind
636 An enumeration containing @code{FcMatchPattern} and @code{FcMatchFont}.
637
638 @item FcLangResult
639 An enumeration containing @code{FcLangEqual}, @code{FcLangDifferentCountry},
640 and @code{FcLangDifferentLang}.  Presumably @code{FcLangDifferentLang}
641 implies @code{FcLangDifferentCountry}.
642
643 @item FcSetName
644 An enumeration containing @code{FcSetSystem} and @code{FcSetApplication}.
645
646 @item FcEndian
647 An enumeration containing @code{FcEndianBig} and @code{FcEndianLittle}.
648 @end table
649
650 @node Functions,  , Data Types, The fontconfig API
651 @section Functions
652
653 @menu
654 * FcMatrix::
655 * FcCharSet::
656 * FcValue::
657 * FcPattern::
658 * FcFontSet::
659 * FcObjectSet::
660 * FcObjectType::
661 * FcLangSet::
662 * Querying Fonts and Their Properties::
663 * Initialization::
664 * FcAtomic::
665 * FreeType-Specific Functions::
666 * XML-Specific Functions::
667 * File and Directory Routines::
668 * FcStrSet and FcStrList::
669 * String Utilities::
670 @end menu
671
672 @node FcMatrix, FcCharSet, Functions, Functions
673 @subsection FcMatrix
674
675 FcMatrix structures hold an affine transformation in matrix form.
676
677 @example
678 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, (m)->xy = (m)->yx = 0)
679 @end example
680 Initializes a matrix to the identify transformation.
681
682 @deftypefun {FcMatrix *} FcMatrixCopy (const FcMatrix *@var{mat})
683
684 Allocates a new FcMatrix and copies 'mat' into it.
685 @end deftypefun
686
687 @deftypefun FcBool FcMatrixEqual (const FcMatrix *@var{mat1}, const FcMatrix *var{mat2})
688
689 Returns FcTrue if 'mat1' and 'mat2' are equal, else FcFalse.
690 @end deftypefun
691
692 @deftypefun void FcMatrixMultiply (FcMatrix *@var{result}, const FcMatrix *@var{a}, const FcMatrix *var{b})
693
694 Multiplies 'a' and 'b' together, placing the result in 'result'.  'result'
695 may refer to the same matrix as either 'a' or 'b'.
696 @end deftypefun
697
698 @deftypefun void FcMatrixRotate (FcMatrix *m, double c, double s)
699
700 If 'c' is cos(angle) and 's' is sin(angle), FcMatrixRotate rotates the
701 matrix by 'angle'.
702 @end deftypefun
703
704 @deftypefun void FcMatrixScale (FcMatrix *m, double sx, double sy)
705
706 Scales 'm' by 'sx' in the horizontal dimension and 'sy' in the
707 vertical dimension.
708 @end deftypefun
709
710 @deftypefun void FcMatrixShear (FcMatrix *m, double sh, double sv)
711 Shears 'm' by 'sh' in the horizontal direction and 'sv' in the
712 vertical direction.
713 @end deftypefun
714
715 @node FcCharSet, FcValue, FcMatrix, Functions
716 @subsection FcCharSet
717
718 An FcCharSet is a boolean array indicating a set of unicode chars.  Those
719 associated with a font are marked constant and cannot be edited.
720 FcCharSets may be reference counted internally to reduce memory consumption;
721 this may be visible to applications as the result of FcCharSetCopy may
722 return its argument, and that CharSet may remain unmodifiable.
723
724 When represented as a string, an FcCharSet is not a pure bitmap; octet
725 values are limited such that FcCharSet objects, when printed, are valid
726 ASCII characters.
727
728 @deftypefun {FcCharSet *} FcCharSetCreate (void)
729
730 Creates an empty FcCharSet object.
731 @end deftypefun
732
733 @deftypefun void FcCharSetDestroy (FcCharSet *fcs)
734
735 Frees an FcCharSet object.
736 @end deftypefun
737
738 @deftypefun FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4)
739
740 Adds a single unicode char to the set, returning FcFalse on
741 failure, either as a result of a constant set or from running out of memory.
742 @end deftypefun
743
744 @deftypefun {FcCharSet *} FcCharSetCopy (FcCharSet *src)
745
746 Makes a copy of 'src'; note that this may not actually do anything more than
747 increment the reference count on 'src'.
748 @end deftypefun
749
750 @deftypefun FcBool FcCharSetEqual (const FcCharSet *a, const FcCharSet *b)
751
752 Returns whether 'a' and 'b' contain the same set of unicode chars.
753 @end deftypefun
754
755 @deftypefun {FcCharSet *} FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b)
756
757 Returns a set including only those chars found in both 'a' and 'b'.
758 @end deftypefun
759
760 @deftypefun {FcCharSet *} FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
761
762 Returns a set including only those chars found in either 'a' or 'b'.
763 @end deftypefun
764
765 @deftypefun {FcCharSet *} FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b)
766
767 Returns a set including only those chars found in 'a' but not 'b'.
768 @end deftypefun
769
770 @deftypefun FcBool FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4)
771
772 Returns whether 'fcs' contains the char 'ucs4'.
773 @end deftypefun
774
775 @deftypefun FcChar32 FcCharSetCount (const FcCharSet *a)
776
777 Returns the total number of unicode chars in 'a'.
778 @end deftypefun
779
780 @deftypefun FcChar32 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b)
781
782 Returns the number of chars that are in both 'a' and 'b'.
783 @end deftypefun
784
785 @deftypefun FcChar32 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b)
786
787 Returns the number of chars that are in 'a' but not in 'b'.
788 @end deftypefun
789
790 @deftypefun FcBool FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
791
792 Returns whether 'a' is a subset of 'b'.
793 @end deftypefun
794
795 @deftypefun FcChar32 FcCharSetFirstPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
796
797 Builds an array of bits marking the first page of Unicode coverage of 'a'.
798 Returns the base of the array.  'next' contains the next page in the font.
799 @end deftypefun
800
801 @deftypefun FcChar32 FcCharSetNextPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
802
803 Builds an array of bits marking the Unicode coverage of 'a' for page '*next'.
804 Returns the base of the array.  'next' contains the next page in the font.
805 @end deftypefun
806
807 @node FcValue, FcPattern, FcCharSet, Functions
808 @subsection FcValue
809
810 FcValue is a structure containing a type tag and a union of all possible
811 data types.  The tag is an enum of type FcType and is intended to provide
812 a measure of run-time typechecking, although that depends on careful
813 programming.
814
815 @deftypefun void FcValueDestroy (FcValue v)
816
817 Frees any memory referenced by `v'.  Values of type FcTypeString,
818 FcTypeMatrix and FcTypeCharSet reference memory, the other types do not.
819 @end deftypefun
820
821 @deftypefun FcValue FcValueSave (FcValue v)
822
823 Returns a copy of `v' duplicating any object referenced by it so that `v'
824 may be safely destroyed without harming the new value.
825 @end deftypefun
826
827 @deftypefun void FcValuePrint (const FcValue v)
828
829 Prints an easily readable version of the value to stdout.  There is
830 no provision for reparsing data in this format, it's just for diagnostics
831 and debugging.
832 @end deftypefun
833
834
835 @node FcPattern, FcFontSet, FcValue, Functions
836 @subsection FcPattern
837
838 An FcPattern is an opaque type that holds both patterns to match against the
839 available fonts, as well as the information about each font.
840
841 @deftypefun {FcPattern *} FcPatternCreate (void)
842
843 Creates a pattern with no properties; used to build patterns from scratch.
844 @end deftypefun
845
846 @deftypefun void FcPatternDestroy (FcPattern *p)
847
848 Destroys a pattern, in the process destroying all related values.
849 @end deftypefun
850
851 @deftypefun FcBool FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
852
853 Returns whether 'pa' and 'pb' are exactly alike.
854 @end deftypefun
855
856 @deftypefun FcBool FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os)
857
858 Returns whether 'pa' and 'pb' have exactly the same values for all of the
859 objects in 'os'.
860 @end deftypefun
861
862 @deftypefun FcChar32 FcPatternHash (const FcPattern *p)
863
864 Returns a 32-bit number which is the same for any two patterns which are
865 exactly alike.
866 @end deftypefun
867
868 @deftypefun FcBool FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
869
870 Adds a single value to the list of values associated with the property named
871 `object'.  If `append' is FcTrue, the value is added at the end of any
872 existing list, otherwise it is inserted at the begining.  `value' is saved
873 (with FcValueSave) when inserted into the pattern so that the library
874 retains no reference to any application-supplied data structure.
875 @end deftypefun
876
877 @deftypefun FcBool FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append)
878
879 FcPatternAddWeak is essentially the same as FcPatternAdd except that any
880 values added to the list have binding 'weak' instead of 'strong'.
881 @end deftypefun
882
883 @deftypefun FcBool FcPatternAddInteger (FcPattern *p, const char *object, int i)
884 @deftypefunx FcBool FcPatternAddDouble (FcPattern *p, const char *object, double d)
885 @deftypefunx FcBool FcPatternAddString (FcPattern *p, const char *object, const char *s)
886 @deftypefunx FcBool FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s)
887 @deftypefunx FcBool FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c)
888 @deftypefunx FcBool FcPatternAddBool (FcPattern *p, const char *object, FcBool b)
889
890 These are all convenience functions that insert objects of the specified
891 type into the pattern.  Use these in preference to FcPatternAdd as they
892 will provide compile-time typechecking.  These all append values to
893 any existing list of values.
894 @end deftypefun
895
896 @deftypefun FcResult FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
897
898 Returns in `v' the `id'th value associated with the property `object'.
899 The value returned is not a copy, but rather refers to the data stored
900 within the pattern directly.  Applications must not free this value.
901 @end deftypefun
902
903 @deftypefun FcResult FcPatternGetInteger (FcPattern *p, const char *object, int id, int *i);
904 @deftypefunx FcResult FcPatternGetDouble (FcPattern *p, const char *object, int id, double *d);
905 @deftypefunx FcResult FcPatternGetString (FcPattern *p, const char *object, int id, char **const s);
906 @deftypefunx FcResult FcPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **s);
907 @deftypefunx FcResult FcPatternGetCharSet (FcPattern *p, const char *object, int id, FcCharSet **c);
908 @deftypefunx FcResult FcPatternGetBool (FcPattern *p, const char *object, int id, FcBool *b);
909
910 These are convenience functions that call FcPatternGet and verify that the
911 returned data is of the expected type. They return FcResultTypeMismatch if
912 this is not the case.  Note that these (like FcPatternGet) do not make a
913 copy of any data structure referenced by the return value.  Use these
914 in preference to FcPatternGet to provide compile-time typechecking.
915 @end deftypefun
916
917 @deftypefun {FcPattern *} FcPatternBuild (FcPattern *orig, ...);
918 @deftypefunx FcPattern *FcPatternVaBuild (FcPattern *orig, va_list va)
919
920 Builds a pattern using a list of objects, types and values.  Each
921 value to be entered in the pattern is specified with three arguments:
922 @enumerate
923 @item
924 Object name, a string describing the property to be added.
925 @item
926 Object type, one of the FcType enumerated values
927 @item
928 Value, not an FcValue, but the raw type as passed to any of the
929 FcPatternAdd<type> functions.  Must match the type of the second
930 argument.
931 @end enumerate
932
933 The argument list is terminated by a null object name, no object type nor
934 value need be passed for this.  The values are added to `pattern', if
935 `pattern' is null, a new pattern is created.  In either case, the pattern is
936 returned. Example:
937
938 @example
939 pattern = FcPatternBuild (0, FC_FAMILY, FtTypeString, "Times", (char *) 0);
940 @end example
941
942 FcPatternVaBuild is used when the arguments are already in the form of a
943 varargs value.
944 @end deftypefun
945
946 @deftypefun FcBool FcPatternDel (FcPattern *p, const char *object)
947
948 Deletes all values associated with the property `object', returning 
949 whether the property existed or not.
950 @end deftypefun
951
952 @deftypefun void FcPatternPrint (const FcPattern *p)
953
954 Prints an easily readable version of the pattern to stdout.  There is
955 no provision for reparsing data in this format, it's just for diagnostics
956 and debugging.
957 @end deftypefun
958
959 @deftypefun void FcDefaultSubstitute (FcPattern *pattern)
960
961 Supplies default values for underspecified font patterns:
962 @itemize
963 @item
964 Patterns without a specified style or weight are set to Medium
965 @item
966 Patterns without a specified style or slant are set to Roman
967 @item
968 Patterns without a specified pixel size are given one computed from
969 any specified point size (default 12), dpi (default 75) and scale (default
970 1).
971 @end itemize
972 @end deftypefun
973
974 @deftypefun {FcPattern *} FcNameParse (const char *name)
975
976 Converts 'name' from the standard text format described above into a pattern.
977 @end deftypefun
978
979 @deftypefun FcChar8 *FcNameUnparse (FcPattern *pat)
980
981 Converts the given pattern into the standard text format described above.
982 The return value is not static, but instead refers to newly allocated memory
983 which should be freed by the caller.
984 @end deftypefun
985
986 @node FcFontSet, FcObjectSet, FcPattern, Functions
987 @subsection FcFontSet
988
989 An FcFontSet simply holds a list of patterns; these are used to return the
990 results of listing available fonts.
991
992 @deftypefun FcFontSet *FcFontSetCreate (void)
993
994 Creates an empty font set.
995 @end deftypefun
996
997 @deftypefun void FcFontSetDestroy (FcFontSet *s);
998
999 Destroys a font set.  Note that this destroys any referenced patterns as
1000 well.
1001 @end deftypefun
1002
1003 @deftypefun FcBool FcFontSetAdd (FcFontSet *s, FcPattern *font)
1004
1005 Adds a pattern to a font set.  Note that the pattern is not copied before
1006 being inserted into the set.
1007 @end deftypefun
1008
1009 @deftypefun void FcFontSetPrint (const FcFontSet *s)
1010
1011 Prints an easily readable version of the font set to stdout.  There is
1012 no provision for reparsing data in this format, it's just for diagnostics
1013 and debugging.
1014 @end deftypefun
1015
1016
1017 @node FcObjectSet, FcObjectType, FcFontSet, Functions
1018 @subsection FcObjectSet
1019
1020 An FcObjectSet holds a list of pattern property names; it is used to
1021 indicate which properties are to be returned in the patterns from
1022 FcFontList.
1023
1024 @deftypefun FcObjectSet *FcObjectSetCreate (void)
1025
1026 Creates an empty set.
1027 @end deftypefun
1028
1029 @deftypefun FcBool FcObjectSetAdd (FcObjectSet *os, const char *object)
1030
1031 Adds a property name to the set.
1032 @end deftypefun
1033
1034 @deftypefun void FcObjectSetDestroy (FcObjectSet *os)
1035
1036 Destroys an object set.
1037 @end deftypefun
1038
1039 @deftypefun FcObjectSet *FcObjectSetBuild (const char *first, ...)
1040 @deftypefunx FcObjectSet *FcObjectSetVaBuild (const char *first, va_list va)
1041
1042 These build an object set from a null-terminated list of property names.
1043 @end deftypefun
1044
1045 @node FcObjectType, FcLangSet, FcObjectSet, Functions
1046 @subsection FcObjectType
1047
1048 Provides for application-specified font name object types so that new
1049 pattern elements can be generated from font names.
1050
1051 @deftypefun FcBool FcNameRegisterObjectTypes (const FcObjectType *types, int ntype)
1052
1053 Register 'ntype' new object types.
1054 @end deftypefun
1055
1056 @deftypefun FcBool FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype)
1057
1058 Unregister 'ntype' object types.
1059 @end deftypefun
1060
1061 @deftypefun const FcObjectType *FcNameGetObjectType (const char *object)
1062
1063 Return the object type for the pattern element named 'object'.
1064 @end deftypefun
1065
1066 FcConstant
1067
1068 Provides for application-specified symbolic constants for font names.
1069
1070 @deftypefun FcBool FcNameRegisterConstants (const FcConstant *consts, int nconsts)
1071
1072 Register 'nconsts' new symbolic constants.
1073 @end deftypefun
1074
1075 @deftypefun FcBool FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
1076
1077 Unregister 'nconsts' symbolic constants.
1078 @end deftypefun
1079
1080 @deftypefun const FcConstant *FcNameGetConstant (FcChar8 *string)
1081
1082 Return the FcConstant structure related to symbolic constant 'string'.
1083 @end deftypefun
1084
1085 @deftypefun FcBool FcNameConstant (FcChar8 *string, int *result)
1086
1087 Returns whether a symbolic constant with name 'string' is registered,
1088 placing the value of the constant in 'result' if present.
1089 @end deftypefun
1090
1091
1092 @node FcLangSet, Querying Fonts and Their Properties, FcObjectType, Functions
1093 @subsection FcLangSet
1094
1095 An @code{FcLangSet} holds a set of RFC 3066 language tags, @ref{LANG Tags}.
1096 This module provides functions to determine whether a given language is
1097 fully supported by a font.  Partial support can be determined using the
1098 font's character set, @ref{FcCharSet}.
1099
1100 @deftypefun FcLangSet *FcLangSetCreate (void);
1101
1102 Create an empty @code{FcLangSet}.
1103 @end deftypefun
1104
1105 @deftypefun void FcLangSetDestroy (FcLangSet *ls);
1106
1107 Destroy a @code{FcLangSet}, freeing any associated storage.
1108 @end deftypefun
1109
1110 @deftypefun FcLangSet *FcLangSetCopy (const FcLangSet *ls);
1111
1112 Copy @var{ls} to a newly allocated @code{FcLangSet}.
1113 @end deftypefun
1114
1115 @deftypefun FcBool FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang);
1116
1117 Add @var{lang} to @code{FcLangSet} @var{ls}.
1118 @end deftypefun
1119
1120 @deftypefun FcLangResult FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang);
1121
1122 Check whether @var{lang} is a member of @code{FcLangSet} @var{ls}.  Note that
1123 the return value is a @code{FcLangResult}, not a Boolean.
1124 @end deftypefun
1125
1126 @deftypefun FcLangResult FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb);
1127 @c The actual code isn't remotely clear either. And I suspect it's buggy; 
1128 @c cf this in FcLangSetEqual: 
1129 @c
1130 @c  for (i = 0; i < NUM_LANG_SET_MAP; i++)
1131 @c  {
1132 @c     if (lsa->map[i] != lsb->map[i])
1133 @c          return FcFalse;
1134 @c  }
1135 @c
1136 @c vs. this in FcLangSetCompare: 
1137 @c
1138 @c  for (i = 0; i < NUM_LANG_SET_MAP; i++)
1139 @c      if (lsa->map[i] & lsb->map[i])
1140 @c          return FcLangEqual;
1141
1142 #### Document me.
1143 @end deftypefun
1144
1145 @deftypefun FcBool FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb);
1146
1147 Check whether the @code{FcLangSet}s @var{lsa} and @var{lsb} contain the same
1148 members.
1149 @end deftypefun
1150
1151 @deftypefun FcChar32 FcLangSetHash (const FcLangSet *ls);
1152
1153 Return a hash value; two @code{FcLangSet}s which hash to different values
1154 cannot contain the same members.
1155 @end deftypefun
1156
1157
1158 @node Querying Fonts and Their Properties, Initialization, FcLangSet, Functions
1159 @subsection Querying Fonts and Their Properties
1160
1161 An FcBlanks object holds a list of Unicode chars which are expected to
1162 be blank when drawn.  When scanning new fonts, any glyphs which are
1163 empty and not in this list will be assumed to be broken and not placed in
1164 the FcCharSet associated with the font.  This provides a significantly more
1165 accurate CharSet for applications.
1166
1167 @deftypefun FcBlanks *FcBlanksCreate (void)
1168
1169 Creates an empty FcBlanks object.
1170 @end deftypefun
1171
1172 @deftypefun void FcBlanksDestroy (FcBlanks *b)
1173
1174 Destroys an FcBlanks object, freeing any associated memory.
1175 @end deftypefun
1176
1177 @deftypefun FcBool FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
1178
1179 Adds a single character to an FcBlanks object, returning FcFalse
1180 if this process ran out of memory.
1181 @end deftypefun
1182
1183 @deftypefun FcBool FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
1184
1185 Returns whether the specified FcBlanks object contains the indicated Unicode
1186 value.
1187 @end deftypefun
1188
1189 The site or user may specify substitutions for certain font patterns,
1190 for convenience or to get more accurate results for the local
1191 installation or preferences.  These functions execute the substitution
1192 based on a specified configuration.
1193
1194 @deftypefun FcBool FcConfigSubstituteWithPat (FcConfig *config, FcPattern *p, FcPattern *p_pat FcMatchKind kind)
1195
1196 Performs the sequence of pattern modification operations, if 'kind' is
1197 FcMatchPattern, then those tagged as pattern operations are applied, else 
1198 if 'kind' is FcMatchFont, those tagged as font operations are applied and
1199 p_pat is used for <test> elements with target=pattern.
1200 @end deftypefun
1201
1202 @deftypefun FcBool FcConfigSubstitute (FcConfig *config, FcPattern *p, FcMatchKind kind)
1203
1204 Calls FcConfigSubstituteWithPat setting p_pat to NULL.
1205 @end deftypefun
1206
1207 The following functions return fonts that match a certain pattern.
1208 @code{FcFontRenderPrepare} and @code{FcFontMatch} always return a single
1209 best match.  @code{FcFontList} returns the list of fonts that match a a
1210 given pattern on a certain set of properties.  @code{FcFontSort} returns
1211 the entire list of fonts, sorted in order of match quality, possibly
1212 filtering out fonts that do not provide additional characters beyond
1213 those provided by preferred fonts.
1214
1215 @deftypefun {FcPattern *} FcFontRenderPrepare (FcConfig *config, FcPattern *pat, FcPattern *font)
1216
1217 Creates a new pattern consisting of elements of 'font' not appearing
1218 in 'pat', elements of 'pat' not appearing in 'font' and the best matching
1219 value from 'pat' for elements appearing in both.  The result is passed to
1220 FcConfigSubstitute with 'kind' FcMatchFont and then returned.
1221 @end deftypefun
1222
1223 @deftypefun {FcPattern *} FcFontMatch (FcConfig *config, FcPattern *p, FcResult *result)
1224
1225 Returns the font in 'config' most close matching 'p'.  This function
1226 should be called only after FcConfigSubstitute and FcDefaultSubstitute have
1227 been called for 'p'; otherwise the results will not be correct.
1228 @end deftypefun
1229
1230 @deftypefun FcFontSet *FcFontList (FcConfig *config, FcPattern *p, FcObjectSet *os)
1231
1232 Selects fonts matching 'p', creates patterns containing only the objects in
1233 'os' from those fonts, and returns the set of unique such patterns.
1234
1235 The FcFontSet returned by FcFontList is destroyed by calling FcFontSetDestroy.
1236 @end deftypefun
1237
1238 @deftypefun FcFontSet *FcFontSort (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result)
1239
1240 Returns the list of all fonts sorted by closeness to 'p'.  If 'trim' is
1241 FcTrue, elements in the list which don't include Unicode coverage not
1242 provided by earlier elements in the list are elided.  The union of
1243 Unicode coverage of all of the fonts is returned in 'csp', if 'csp' is
1244 not NULL.  This function should be called only after FcConfigSubstitute
1245 and FcDefaultSubstitute have been called for 'p'; otherwise the results
1246 will not be correct.
1247
1248 The returned FcFontSet references FcPattern structures which may be shared
1249 by the return value from multiple FcFontSort calls, applications must not
1250 modify these patterns.  Instead, they should be passed, along with 'p' to
1251 FcFontRenderPrepare which combines them into a complete pattern.
1252
1253 The FcFontSet returned by FcFontSort is destroyed by calling FcFontSetDestroy.
1254 @end deftypefun
1255
1256
1257 @node Initialization, FcAtomic, Querying Fonts and Their Properties, Functions
1258 @subsection Initialization
1259
1260 An FcConfig object holds the internal representation of a configuration.
1261 There is a default configuration which applications may use by passing 0 to
1262 any function using the data within an FcConfig.
1263
1264 @deftypefun FcConfig *FcConfigCreate (void)
1265
1266 Creates an empty configuration.
1267 @end deftypefun
1268
1269 @deftypefun void FcConfigDestroy (FcConfig *config)
1270
1271 Destroys a configuration and any data associated with it.  Note that calling
1272 this function with the return value from FcConfigGetCurrent will place the
1273 library in an indeterminate state.
1274 @end deftypefun
1275
1276 @deftypefun FcBool FcConfigSetCurrent (FcConfig *config)
1277
1278 Sets the current default configuration to 'config'.  Implicitly calls
1279 FcConfigBuildFonts if necessary, returning FcFalse if that call fails.
1280 @end deftypefun
1281
1282 @deftypefun FcConfig *FcConfigGetCurrent (void)
1283
1284 Returns the current default configuration.
1285 @end deftypefun
1286
1287 @deftypefun FcBool FcConfigUptoDate (FcConfig *config)
1288
1289 Checks all of the files related to 'config' and returns whether the
1290 in-memory version is in sync with the disk version.
1291 @end deftypefun
1292
1293 @deftypefun FcBool FcConfigBuildFonts (FcConfig *config)
1294
1295 Builds the set of available fonts for the given configuration.  Note that
1296 any changes to the configuration after this call have indeterminate effects.
1297 Returns FcFalse if this operation runs out of memory.
1298 @end deftypefun
1299
1300 @deftypefun FcStrList *FcConfigGetConfigDirs (FcConfig *config)
1301
1302 Returns the list of font directories specified in the configuration files
1303 for 'config'.  Does not include any subdirectories.
1304 @end deftypefun
1305
1306 @deftypefun FcStrList *FcConfigGetFontDirs (FcConfig *config)
1307
1308 Returns the list of font directories in 'config'. This includes the
1309 configured font directories along with any directories below those in the
1310 filesystem.
1311 @end deftypefun
1312
1313 @deftypefun FcStrList *FcConfigGetConfigFiles (FcConfig *config)
1314
1315 Returns the list of known configuration files used to generate 'config'.
1316 Note that this will not include any configuration done with FcConfigParse.
1317 @end deftypefun
1318
1319 @deftypefun char *FcConfigGetCache (FcConfig *config)
1320
1321 Returns the name of the file used to store per-user font information.
1322 @end deftypefun
1323
1324 @deftypefun FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set)
1325
1326 Returns one of the two sets of fonts from the configuration as specified 
1327 by 'set'.
1328 @end deftypefun
1329
1330 @deftypefun FcBlanks *FcConfigGetBlanks (FcConfig *config)
1331
1332 Returns the FcBlanks object associated with the given configuration, if no
1333 blanks were present in the configuration, this function will return 0.
1334 @end deftypefun
1335
1336 @deftypefun int FcConfigGetRescanInverval (FcConfig *config)
1337
1338 Returns the interval between automatic checks of the configuration (in
1339 seconds) specified in 'config'.  The configuration is checked during
1340 a call to FcFontList when this interval has passed since the last check.
1341 @end deftypefun
1342
1343 @deftypefun FcBool FcConfigSetRescanInverval (FcConfig *config, int rescanInterval)
1344
1345 Sets the rescan interval; returns FcFalse if an error occurred.
1346 @end deftypefun
1347
1348 @deftypefun FcBool FcConfigAppFontAddFile (FcConfig *config, const char *file)
1349
1350 Adds an application-specific font to the configuration.
1351 @end deftypefun
1352
1353 @deftypefun FcBool FcConfigAppFontAddDir (FcConfig *config, const char *dir)
1354
1355 Scans the specified directory for fonts, adding each one found to the
1356 application-specific set of fonts.
1357 @end deftypefun
1358
1359 @deftypefun void FcConfigAppFontClear (FcConfig *config)
1360
1361 Clears the set of application-specific fonts.
1362 @end deftypefun
1363
1364 These functions provide some control over how the default configuration of
1365 the library is initialized.  (This configuration is normally implicitly
1366 initialized.)
1367
1368 @deftypefun char *FcConfigFilename (const char *name)
1369
1370 Given the specified external entity name, return the associated filename.
1371 This provides applications a way to convert various configuration file
1372 references into filename form. 
1373
1374 A null or empty 'name' indicates that the default configuration file should
1375 be used; which file this references can be overridden with the
1376 FC_CONFIG_FILE environment variable.  Next, if the name starts with '~', it
1377 refers to a file in the current users home directory.  Otherwise if the name
1378 doesn't start with '/', it refers to a file in the default configuration
1379 directory; the built-in default directory can be overridden with the
1380 FC_CONFIG_DIR environment variable.
1381 @end deftypefun
1382
1383 @deftypefun FcConfig *FcInitLoadConfig (void)
1384
1385 Loads the default configuration file and returns the resulting configuration.
1386 Does not load any font information.
1387 @end deftypefun
1388
1389 @deftypefun FcConfig *FcInitLoadConfigAndFonts (void)
1390
1391 Loads the default configuration file and builds information about the
1392 available fonts.  Returns the resulting configuration.
1393 @end deftypefun
1394
1395 @deftypefun FcBool FcInit (void)
1396
1397 Loads the default configuration file and the fonts referenced therein and
1398 sets the default configuration to that result.  Returns whether this
1399 process succeeded or not.  If the default configuration has already
1400 been loaded, this routine does nothing and returns FcTrue.
1401 @end deftypefun
1402
1403 @deftypefun int FcGetVersion (void)
1404
1405 Returns the version number of the library.
1406 @end deftypefun
1407
1408 @deftypefun FcBool FcInitReinitialize (void)
1409
1410 Forces the default configuration file to be reloaded and resets the default
1411 configuration.
1412 @end deftypefun
1413
1414 @deftypefun FcBool FcInitBringUptoDate (void)
1415
1416 Checks the rescan interval in the default configuration, checking the
1417 configuration if the interval has passed and reloading the configuration
1418 when any changes are detected.
1419 @end deftypefun
1420
1421
1422 @node FcAtomic, FreeType-Specific Functions, Initialization, Functions
1423 @subsection FcAtomic
1424
1425 These functions provide a safe way to update config files, allowing ongoing
1426 reading of the old config file while locked for writing and ensuring that a
1427 consistent and complete version of the config file is always available.
1428
1429 @deftypefun FcAtomic * FcAtomicCreate (const FcChar8   *file)
1430
1431 Creates a data structure containing data needed to control access to 'file'.
1432 Writing is done to a separate file.  Once that file is complete, the
1433 original configuration file is atomically replaced so that reading processes
1434 always see a consistent and complete file without the need to lock for
1435 reading.
1436 @end deftypefun
1437
1438 @deftypefun FcBool FcAtomicLock (FcAtomic *atomic)
1439
1440 Attempts to lock the file referenced by 'atomic'.  Returns FcFalse if the
1441 file is locked by another process, else returns FcTrue and leaves the file
1442 locked.
1443 @end deftypefun
1444
1445 @deftypefun FcChar8 *FcAtomicNewFile (FcAtomic *atomic)
1446
1447 Returns the filename for writing a new version of the file referenced
1448 by 'atomic'.
1449 @end deftypefun
1450
1451 @deftypefun FcChar8 *FcAtomicOrigFile (FcAtomic *atomic)
1452
1453 Returns the file refernced by 'atomic'.
1454 @end deftypefun
1455
1456 @deftypefun FcBool FcAtomicReplaceOrig (FcAtomic *atomic)
1457
1458 Replaces the original file referenced by 'atomic' with the new file.
1459 @end deftypefun
1460
1461 @deftypefun void FcAtomicDeleteNew (FcAtomic *atomic)
1462
1463 Deletes the new file.
1464 @end deftypefun
1465
1466 @deftypefun void FcAtomicUnlock (FcAtomic *atomic)
1467
1468 Unlocks the file.
1469 @end deftypefun
1470
1471 @deftypefun void FcAtomicDestroy (FcAtomic *atomic)
1472
1473 Destroys 'atomic'.
1474 @end deftypefun
1475
1476 @node FreeType-Specific Functions, XML-Specific Functions, FcAtomic, Functions
1477 @subsection FreeType-Specific Functions
1478
1479 @example
1480 #include <fontconfig/fcfreetype.h>
1481 @end example
1482
1483 While the fontconfig library doesn't insist that FreeType be used as the
1484 rasterization mechanism for fonts, it does provide some convenience
1485 functions.
1486
1487 @deftypefun FT_UInt FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
1488
1489 Maps a Unicode char to a glyph index.  This function uses information from
1490 several possible underlying encoding tables to work around broken fonts.
1491 As a result, this function isn't designed to be used in performance
1492 sensitive areas; results from this function are intended to be cached by
1493 higher level functions.
1494 @end deftypefun
1495
1496 @deftypefun {FcCharSet *} FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks) Scans a
1497
1498 FreeType face and returns the set of encoded Unicode chars.  This scans
1499 several encoding tables to build as complete a list as possible.  
1500 If 'blanks' is not 0, the glyphs in the font are examined and any blank glyphs
1501 not in 'blanks' are not placed in the returned FcCharSet.
1502 @end deftypefun
1503
1504 @deftypefun {FcPattern *} FcFreeTypeQuery (const char *file, int id, FcBlanks *blanks, int *count)
1505
1506 Constructs a pattern representing the 'id'th font in 'file'.  The number
1507 of fonts in 'file' is returned in 'count'.
1508 @end deftypefun
1509
1510 @node XML-Specific Functions, File and Directory Routines, FreeType-Specific Functions, Functions
1511 @subsection XML-Specific Functions
1512
1513 @deftypefun FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain)
1514
1515 Walks the configuration in 'file' and constructs the internal representation
1516 in 'config'.  Any include files referenced from within 'file' will be loaded
1517 with FcConfigLoad and also parsed.  If 'complain' is FcFalse, no warning
1518 will be displayed if 'file' does not exist.
1519 @end deftypefun
1520
1521 @node File and Directory Routines, FcStrSet and FcStrList, XML-Specific Functions, Functions
1522 @subsection File and Directory Routines
1523
1524 @deftypefun FcBool FcFileScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *file, FcBool force)
1525
1526 Scans a single file and adds all fonts found to 'set'.  If 'force' is FcTrue,
1527 then the file is scanned even if associated information is found in 'cache'.
1528 If 'file' is a directory, it is added to 'dirs'.
1529 @end deftypefun
1530
1531 @deftypefun FcBool FcDirScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *dir, FcBool force)
1532
1533 Scans an entire directory and adds all fonts found to 'set'.  If 'force' is
1534 FcTrue, then the directory and all files within it are scanned even if
1535 information is present in the per-directory cache file or 'cache'.  Any
1536 subdirectories found are added to 'dirs'.
1537 @end deftypefun
1538
1539 @deftypefun FcBool FcDirSave (FcFontSet *set, FcStrSet *dirs, const char *dir)
1540
1541 Creates the per-directory cache file for 'dir' and populates it with the
1542 fonts in 'set' and subdirectories in 'dirs'.
1543 @end deftypefun
1544
1545 @deftypefun FcBool FcDirCacheValid (const FcChar8 *cache_file)
1546
1547 Returns FcTrue if 'cache_file' is no older than the directory containing it,
1548 else FcFalse.
1549 @end deftypefun
1550
1551 @node FcStrSet and FcStrList, String Utilities, File and Directory Routines, Functions
1552 @subsection FcStrSet and FcStrList
1553
1554 A data structure for enumerating strings, used to list directories while
1555 scanning the configuration as directories are added while scanning.
1556
1557 @deftypefun FcStrSet *FcStrSetCreate (void)
1558
1559 Create an empty set.
1560 @end deftypefun
1561
1562 @deftypefun FcBool FcStrSetMember (FcStrSet *set, const FcChar8 *s)
1563
1564 Returns whether 's' is a member of 'set'.
1565 @end deftypefun
1566
1567 @deftypefun FcBool FcStrSetAdd (FcStrSet *set, const FcChar8 *s)
1568
1569 Adds a copy of 's' to 'set'.
1570 @end deftypefun
1571
1572 @deftypefun FcBool FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
1573
1574 Adds a copy of 's' to 'set', The copy is created with FcStrCopyFilename
1575 so that leading '~' values are replaced with the value of the HOME
1576 environment variable.
1577 @end deftypefun
1578
1579 @deftypefun FcBool FcStrSetDel (FcStrSet *set, const FcChar8 *s)
1580
1581 Removes 's' from 'set', returning FcTrue if 's' was a member else FcFalse.
1582 @end deftypefun
1583
1584 @deftypefun void FcStrSetDestroy (FcStrSet *set)
1585
1586 Destroys 'set'.
1587 @end deftypefun
1588
1589 @deftypefun FcStrList *FcStrListCreate (FcStrSet *set)
1590
1591 Creates an enumerator to list the strings in 'set'.
1592 @end deftypefun
1593
1594 @deftypefun FcChar8 *FcStrListNext (FcStrList *list)
1595
1596 Returns the next string in 'set'.
1597 @end deftypefun
1598
1599 @deftypefun void FcStrListDone (FcStrList *list)
1600
1601 Destroys the enumerator 'list'.
1602 @end deftypefun
1603
1604 @node String Utilities,  , FcStrSet and FcStrList, Functions
1605 @subsection String Utilities
1606
1607 @deftypefun int FcUtf8ToUcs4 (FcChar8 *src, FcChar32 *dst, int len)
1608
1609 Converts the next Unicode char from 'src' into 'dst' and returns the number
1610 of bytes containing the char.  'src' must be at least 'len' bytes long.
1611 @end deftypefun
1612
1613 @deftypefun int FcUcs4ToUtf8 (FcChar32 src, FcChar8 dst[FC_UTF8_MAX_LEN])
1614
1615 Converts the Unicode char from 'src' into 'dst' and returns the
1616 number of bytes needed to encode the char.
1617 @end deftypefun
1618
1619 @deftypefun FcBool FcUtf8Len (FcChar8 *src, int len, int *nchar, int *wchar)
1620
1621 Counts the number of Unicode chars in 'len' bytes of 'src'.  Places that
1622 count in 'nchar'.  'wchar' contains 1, 2 or 4 depending on the number of
1623 bytes needed to hold the largest unicode char counted.  The return value
1624 indicates whether 'src' is a well-formed UTF8 string.
1625 @end deftypefun
1626
1627 @deftypefun int FcUtf16ToUcs4 (FcChar8 *src, FcEndian endian, FcChar32 *dst, int len)
1628
1629 Converts the next Unicode char from 'src' into 'dst' and returns the
1630 number of bytes containing the char. 'src' must be at least 'len' bytes
1631 long.  Bytes of 'src' are combined into 16-bit units according to 'endian'.
1632 @end deftypefun
1633
1634 @deftypefun FcBool FcUtf16Len (FcChar8 *src, FcEndian endian, int len, int *nchar, int *wchar)
1635
1636 Counts the number of Unicode chars in 'len' bytes of 'src'.  Bytes of 'src'
1637 are combined into 16-bit units according to 'endian'.  Places that
1638 count in 'nchar'.  'wchar' contains 1, 2 or 4 depending on the number of
1639 bytes needed to hold the largest unicode char counted.  The return value
1640 indicates whether 'string' is a well-formed UTF16 string.
1641 @end deftypefun
1642
1643 @deftypefun FcChar8 *FcStrCopy (const FcChar8 *s)
1644
1645 Allocates memory, copies 's' and returns the resulting buffer.  Yes, this
1646 is 'strdup', but that function isn't available on every platform.
1647 @end deftypefun
1648
1649 @deftypefun FcChar8 *FcStrCopyFilename (const FcChar8 *s)
1650
1651 Just like FcStrCopy except that it converts any leading '~' characters 
1652 in 's' to the value of the HOME environment variable.
1653 @end deftypefun
1654
1655 @deftypefun int FcStrCmpIgnoreCase (const char *s1, const char *s2)
1656
1657 Returns the usual <0, 0, >0 result of comparing 's1' and 's2'.  This test
1658 is case-insensitive in the ASCII range and will operate properly with UTF8
1659 encoded strings, although it does not check for well formed strings.
1660 @end deftypefun
1661
1662 @deftypefun FcChar8 *FcStrDirname (const FcChar8 *file)
1663
1664 Returns the directory containing 'file'.
1665 @end deftypefun
1666
1667 @deftypefun FcChar8 *FcStrBasename (const FcChar8 *file)
1668
1669 Returns the filename of 'file' stripped of any leading directory names.
1670 @end deftypefun
1671
1672 @node Configuration File Format, Files, The fontconfig API, Top
1673 @chapter Configuration File Format
1674
1675 Configuration files for fontconfig are stored in XML format; this
1676 format makes external configuration tools easier to write and ensures that
1677 they will generate syntactically correct configuration files.  As XML
1678 files are plain text, they can also be manipulated by the expert user using
1679 a text editor.
1680
1681 The fontconfig document type definition resides in the external entity
1682 @samp{fonts.dtd}; this is normally stored in the default font configuration
1683 directory (@file{/etc/fonts}).  Each configuration file should contain the
1684 following structure:
1685
1686 @example
1687         <?xml version="1.0"?>
1688         <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1689         <fontconfig>
1690         ...
1691         </fontconfig>
1692 @end example
1693
1694 @table @samp
1695 @item <fontconfig>
1696 This is the top level element for a font configuration and can contain
1697 @samp{<dir>}, @samp{<cache>}, @samp{<include>}, @samp{<match>} and @samp{<alias>} elements in any order.
1698
1699 @item <dir>
1700 This element contains a directory name which will be scanned for font files
1701 to include in the set of available fonts.  The scan does not recurse into
1702 subdirectories.
1703
1704 @item <cache>
1705 This element contains a file name for the per-user cache of font
1706 information.  If it starts with '~', it refers to a file in the users
1707 home directory.  This file is used to hold information about fonts that
1708 isn't present in the per-directory cache files.  It is automatically
1709 maintained by the fontconfig library.  The default for this file 
1710 is ``~/.fonts.cache-<version>'', where <version> is the font configuration
1711 file version number (currently 1).
1712
1713 @item <include ignore_missing="no">
1714 This element contains the name of an additional configuration file.  When
1715 the XML datatype is traversed by FcConfigParse, the contents of the file
1716 will also be incorporated into the configuration by passing the filename to
1717 FcConfigLoadAndParse.  If 'ignore_missing' is set to "yes" instead of the
1718 default "no", a missing file will elicit no warning message from the library.
1719
1720 @item <config>
1721 This element provides a place to consolidate additional configuration
1722 information.  @samp{<config>} can contain @samp{<blank>} and @samp{<rescan>} elements in any
1723 order.
1724
1725 @item <blank>
1726 Fonts often include "broken" glyphs which appear in the encoding but are
1727 drawn as blanks on the screen.  Within the @samp{<blank>} element, place each
1728 Unicode characters which is supposed to be blank in an @samp{<int>} element.
1729 Characters outside of this set which are drawn as blank will be elided from
1730 the set of characters supported by the font.
1731
1732 @item <rescan>
1733 The @samp{<rescan>} element holds an @samp{<int>} element which indicates the default
1734 interval between automatic checks for font configuration changes.
1735 Fontconfig will validate all of the configuration files and directories and
1736 automatically rebuild the internal datastructures when this interval passes.
1737
1738 @item <match target="pattern">
1739 This element holds first a (possibly empty) list of @samp{<test>} elements and then
1740 a (possibly empty) list of @samp{<edit>} elements.  Patterns which match all of the
1741 tests are subjected to all the edits.  If 'target' is set to "font" instead
1742 of the default "pattern", then this element applies to the font name
1743 resulting from a match rather than a font pattern to be matched.
1744
1745 @item <test qual="any" name="property" compare="eq">
1746 This element contains a single value which is compared with the pattern
1747 property "property" (substitute any of the property names seen 
1748 above). 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", or
1749 "more_eq".  'qual' may either be the default, "any", in which case the match
1750 succeeds if any value associated with the property matches the test value, or
1751 "all", in which case all of the values associated with the property must
1752 match the test value.
1753
1754 @item <edit name="property" mode="assign" binding="weak">
1755 This element contains a list of expression elements (any of the value or
1756 operator elements).  The expression elements are evaluated at run-time and
1757 modify the property "property".  The modification depends on whether
1758 "property" was matched by one of the associated @samp{<test>} elements, if so, the
1759 modification may affect the first matched value.  Any values inserted into
1760 the property are given the indicated binding. 'mode' is one of:
1761
1762 @example
1763 Mode    Operation with match    Operation without match
1764
1765 "assign"        Replace matching value          Replace all values
1766 "assign_replace"        Replace all values      Replace all values
1767 "prepend"       Insert before matching value    Insert at head of list
1768 "prepend_first" Insert at head of list          Insert at head of list
1769 "append"        Append after matching value     Append at end of list
1770 "append_last"   Append at end of list           Append at end of list
1771 @end example
1772
1773 @item <int>
1774 @itemx <double>
1775 @itemx <string>
1776 @itemx <bool>
1777 These elements hold a single value of the indicated type.  @samp{<bool>} elements
1778 hold either true or false.
1779
1780 @item <matrix>
1781
1782 This element holds the four @samp{<double>} elements of an affine transformation.
1783
1784 @item <name>
1785 Holds a property name.  Evaluates to the first value from the property of
1786 the font, not the pattern.
1787
1788 @item <const>
1789 Holds the name of a constant; these are always integers and serve as
1790 symbolic names for common font values:
1791
1792 @example
1793 Constant        Property        CPP symbol
1794
1795 light           weight          FC_WEIGHT_LIGHT
1796 medium          weight          FC_WEIGHT_MEDIUM
1797 demibold        weight          FC_WEIGHT_DEMIBOLD
1798 bold            weight          FC_WEIGHT_BOLD
1799 black           weight          FC_WEIGHT_BLACK
1800 roman           slant           FC_SLANT_ROMAN
1801 italic          slant           FC_SLANT_ITALIC
1802 oblique         slant           FC_SLANT_OBLIQUE
1803 proportional    spacing         FC_PROPORTIONAL
1804 mono            spacing         FC_MONO
1805 charcell        spacing         FC_CHARCELL
1806 unknown         rgba            FC_RGBA_UNKNOWN
1807 rgb             rgba            FC_RGBA_RGB
1808 bgr             rgba            FC_RGBA_BGR
1809 vrgb            rgba            FC_RGBA_VRGB
1810 vbgr            rgba            FC_RGBA_VBGR
1811 none            rgba            FC_RGBA_NONE
1812 @end example
1813
1814 @item <or>
1815 @itemx <and>
1816 @itemx <plus>
1817 @itemx <minus>
1818 @itemx <times>
1819 @itemx <divide>
1820 These elements perform the specified operation on a list of expression
1821 elements.  @samp{<or>} and @samp{<and>} are boolean, not bitwise.
1822
1823 @item <eq>
1824 @itemx <not_eq>
1825 @itemx <less>
1826 @itemx <less_eq>
1827 @itemx <more>
1828 @itemx <more_eq>
1829 These elements compare two values, producing a boolean result.
1830
1831 @item <not>
1832 Inverts the boolean sense of its one expression element
1833
1834 @item <if>
1835 This element takes three expression elements; if the value of the first is
1836 true, it produces the value of the second, otherwise it produces the value
1837 of the third.
1838
1839 @item <alias>
1840 Alias elements provide a shorthand notation for the set of common match
1841 operations needed to substitute one font family for another.  They contain a
1842 @samp{<family>} element followed by optional @samp{<prefer>}, @samp{<accept>} and @samp{<default>}
1843 elements.  Fonts matching the @samp{<family>} element are edited to prepend the
1844 list of @samp{<prefer>}ed families before the matching @samp{<family>}, append the
1845 @samp{<accept>}able families after the matching @samp{<family>} and append the @samp{<default>}
1846 families to the end of the family list.
1847
1848 @item <family>
1849 Holds a single font family name
1850
1851 @item <prefer>
1852 @itemx <accept>
1853 @itemx <default>
1854 These each hold a list of @samp{<family>} elements to be used by the @samp{<alias>}
1855 element.
1856 @end table
1857
1858 @menu
1859 * Example System Configuration File::  
1860 * Example User Configuration File::  
1861 @end menu
1862
1863 @node Example System Configuration File, Example User Configuration File, Configuration File Format, Configuration File Format
1864 @section Example System Configuration File
1865
1866 This is an example of a system-wide configuration file:
1867
1868 @example
1869 <?xml version="1.0"?>
1870 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1871 <!-- /etc/fonts/fonts.conf file to configure system font access -->
1872 <fontconfig>
1873 <!-- 
1874         Find fonts in these directories
1875 -->
1876 <dir>/usr/X11R6/lib/X11/fonts/truetype</dir>
1877 <dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
1878
1879 <!--
1880         Accept deprecated 'mono' alias, replacing it with 'monospace'
1881 -->
1882 <match target="pattern">
1883         <test qual="any" name="family"><string>mono</string></test>
1884         <edit name="family" mode="assign"><string>monospace</string></edit>
1885 </match>
1886
1887 <!--
1888         Names not including any well known alias are given 'sans'
1889 -->
1890 <match target="pattern">
1891         <test qual="all" name="family" mode="not_eq">sans</test>
1892         <test qual="all" name="family" mode="not_eq">serif</test>
1893         <test qual="all" name="family" mode="not_eq">monospace</test>
1894         <edit name="family" mode="append_last"><string>sans</string></edit>
1895 </match>
1896
1897 <!--
1898         Load per-user customization file, but don't complain
1899         if it doesn't exist
1900 -->
1901 <include ignore_missing="yes">~/.fonts.conf</include>
1902
1903 <!--
1904         Alias well known font names to available TrueType fonts.
1905         These substitute TrueType faces for similar Type1
1906         faces to improve screen appearance.
1907 -->
1908 <alias>
1909         <family>Times</family>
1910         <prefer><family>Times New Roman</family></prefer>
1911         <default><family>serif</family></default>
1912 </alias>
1913 <alias>
1914         <family>Helvetica</family>
1915         <prefer><family>Verdana</family></prefer>
1916         <default><family>sans</family></default>
1917 </alias>
1918 <alias>
1919         <family>Courier</family>
1920         <prefer><family>Courier New</family></prefer>
1921         <default><family>monospace</family></default>
1922 </alias>
1923
1924 <!--
1925         Provide required aliases for standard names
1926         Do these after the users configuration file so that
1927         any aliases there are used preferentially
1928 -->
1929 <alias>
1930         <family>serif</family>
1931         <prefer><family>Times New Roman</family></prefer>
1932 </alias>
1933 <alias>
1934         <family>sans</family>
1935         <prefer><family>Verdana</family></prefer>
1936 </alias>
1937 <alias>
1938         <family>monospace</family>
1939         <prefer><family>Andale Mono</family></prefer>
1940 </alias>
1941 </fontconfig>
1942 @end example
1943
1944 @node Example User Configuration File,  , Example System Configuration File, Configuration File Format
1945 @section Example User Configuration File
1946
1947 This is an example of a per-user configuration file that lives in
1948 @file{~/.fonts.conf}:
1949
1950 @example
1951 <?xml version="1.0"?>
1952 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1953 <!-- ~/.fonts.conf for per-user font configuration -->
1954 <fontconfig>
1955
1956 <!--
1957         Private font directory
1958 -->
1959 <dir>~/misc/fonts</dir>
1960
1961 <!--
1962         use rgb sub-pixel ordering to improve glyph appearance on
1963         LCD screens.  Changes affecting rendering, but not matching,
1964         should always use target="font".
1965 -->
1966 <match target="font">
1967         <edit name="rgba" mode="assign"><const>rgb</const></edit>
1968 </match>
1969 </fontconfig>
1970 @end example
1971
1972 @node Files, Authors, Configuration File Format, Top
1973 @chapter Files
1974
1975 @table @file
1976 @item fonts.dtd 
1977 is a DTD that describes the format of the configuration files.
1978
1979 @item fonts.conf
1980 is the default system-wide font configuration file.  It
1981 contains configuration information for the fontconfig library
1982 consisting of directories to look at for font information as well as
1983 instructions on editing program specified font patterns before attempting to
1984 match the available fonts.  It is in xml format, with DTD @file{fonts.dtd}.
1985
1986 @item local.conf
1987 is the conventional default location for local font configuration.  It
1988 is sourced by the default system-wide fonts.conf file. 
1989 Note that the normal 'make install' procedure for XFree86 is to
1990 replace any existing fonts.conf file with the new version.  Place
1991 any local customizations in local.conf which this file references.
1992 It is in xml format, with DTD @file{fonts.dtd}.
1993
1994 @item ~/.fonts.conf
1995 is the conventional location for per-user font configuration, although the
1996 actual location is specified in the global fonts.conf file.
1997 It is in xml format, with DTD @file{fonts.dtd}.
1998
1999 @item fonts.cache-*
2000 is found in each font directory where fonts were found.  This file is
2001 automatically maintained by fontconfig.  It is a flat text table, and
2002 should be treated as opaque.
2003
2004 @item ~/.fonts.cache-*
2005 is the conventional repository of font information that isn't found in the
2006 per-directory caches.  This file is automatically maintained by fontconfig.
2007 It is a flat text table, and should be treated as opaque.
2008 @end table
2009
2010 @node Authors,  , Files, Top
2011 @chapter Authors
2012
2013 @table @strong
2014 @item Keith Packard
2015 member of the XFree86 Project, Inc.
2016
2017 @item Stephen J. Turnbull
2018 member of the XEmacs Project
2019 @end table
2020
2021 @bye
2022
2023 @c Local variables:
2024 @c mode: texinfo
2025 @c End:
2026
2027 @c  arch-tag: 108A3E8B-1CE1-11D9-9957-000A959E994E
2028
2029 @c end of fontconfig.texi