]> git.wh0rd.org - fontconfig.git/blob - src/fontconfig.man
Fix weird first/not-first lameness in font matches, replacing with target
[fontconfig.git] / src / fontconfig.man
1 .\"
2 .\" $XFree86: xc/lib/fontconfig/src/fontconfig.man,v 1.2 2002/08/06 19:54:10 keithp Exp $
3 .\"
4 .\" Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
5 .\"
6 .\" Permission to use, copy, modify, distribute, and sell this software and its
7 .\" documentation for any purpose is hereby granted without fee, provided that
8 .\" the above copyright notice appear in all copies and that both that
9 .\" copyright notice and this permission notice appear in supporting
10 .\" documentation, and that the name of Keith Packard not be used in
11 .\" advertising or publicity pertaining to distribution of the software without
12 .\" specific, written prior permission. Keith Packard makes no
13 .\" representations about the suitability of this software for any purpose. It
14 .\" is provided "as is" without express or implied warranty.
15 .\"
16 .\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 .\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 .\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 .\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 .\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 .\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 .\" PERFORMANCE OF THIS SOFTWARE.
23 .\"
24 .de TQ
25 .br
26 .ns
27 .TP \\$1
28 ..
29 .TH FONTCONFIG 3 "Version 1.0" "XFree86"
30
31 .SH NAME
32 fontconfig \- Font configuration and customization library
33
34 .SH SYNOPSIS
35 .nf
36 .B #include <fontconfig/fontconfig.h>
37 .B #include <fontconfig/fcfreetype.h>
38 .fi
39 .SH DESCRIPTION
40 .B Fontconfig
41 is a library designed to provide system-wide font configuration,
42 customization and application access.
43
44 .SH FUNCTIONAL OVERVIEW
45 Fontconfig contains two essential modules, the configuration module which
46 builds an internal configuration from XML files and the matching module
47 which accepts font patterns and returns the nearest matching font.
48
49 .SS FONT CONFIGURATION
50 The configuration module consists of the FcConfig datatype, libexpat and
51 FcConfigParse which walks over an XML tree and ammends a configuration with
52 data found within. From an external perspective, configuration of the
53 library consists of generating a valid XML tree and feeding that to
54 FcConfigParse. The only other mechanism provided to applications for
55 changing the running configuration is to add fonts and directories to the
56 list of application-provided font files.
57 .P
58 The intent is to make font configurations relatively static, and shared by
59 as many applications as possible. It is hoped that this will lead to more
60 stable font selection when passing names from one application to another.
61 XML was chosen as a configuration file format because it provides a format
62 which is easy for external agents to edit while retaining the correct
63 structure and syntax.
64 .P
65 Font configuration is separate from font matching; applications needing to
66 do their own matching can access the available fonts from the library and
67 perform private matching. The intent is to permit applications to pick and
68 choose appropriate functionality from the library instead of forcing them to
69 choose between this library and a private configuration mechanism. The hope
70 is that this will ensure that configuration of fonts for all applications
71 can be centralized in one place. Centralizing font configuration will make
72 simplify and regularize font installation and customization.
73
74 .SS FONT PROPERTIES
75 While font patterns may contain essentially any properties, there are some
76 well known properties with associated types. Fontconfig uses some of these
77 properties for font matching and font completion. Others are provided as a
78 convenience for the applications rendering mechanism.
79 .sp
80 .nf
81 .ta 1i 2.75i 3.5i 5.5i
82 .lc \(em
83 Property CPP symbol Type Description
84 \ 1\ 1\ 1\ 1
85 family FC_FAMILY String Font family name
86 style FC_STYLE String Font style. Overrides weight and slant
87 slant FC_SLANT Int Italic, oblique or roman
88 weight FC_WEIGHT Int Light, medium, demibold, bold or black
89 size FC_SIZE Double Point size
90 aspect FC_ASPECT Double Stretches glyphs horizontally before hinting
91 pixelsize FC_PIXEL_SIZE Double Pixel size
92 spacing FC_SPACING Int Proportional, monospace or charcell
93 foundry FC_FOUNDRY String Font foundry name
94 antialias FC_ANTIALIAS Bool Whether glyphs can be antialiased
95 hinting FC_HINTING Bool Whether the rasterizer should use hinting
96 verticallayout FC_VERTICAL_LAYOUT Bool Use vertical layout
97 autohint FC_AUTOHINT Bool Use autohinter instead of normal hinter
98 globaladvance FC_GLOBAL_ADVANCE Bool Use font global advance data
99 file FC_FILE String The filename holding the font
100 index FC_INDEX Int The index of the font within the file
101 ftface FC_FT_FACE FT_Face Use the specified FreeType face object
102 rasterizer FC_RASTERIZER String Which rasterizer is in use
103 outline FC_OUTLINE Bool Whether the glyphs are outlines
104 scalable FC_SCALABLE Bool Whether glyphs can be scaled
105 scale FC_SCALE Double Scale factor for point->pixel conversions
106 dpi FC_DPI Double Target dots per inch
107 rgba FC_RGBA Int rgb, bgr, vrgb, vbgr - subpixel geometry
108 minspace FC_MINSPACE Bool Eliminate leading from line spacing
109 charset FC_CHARSET CharSet Unicode chars encoded by the font
110 lang FC_LANG String List of RFC-3066-style languages this font supports
111 .DT
112 .fi
113
114 .SS FONT MATCHING
115 Fontconfig performs matching by measuring the distance from a provided
116 pattern to all of the available fonts in the system. The closest matching
117 font is selected. This ensures that a font will always be returned, but
118 doesn't ensure that it is anything like the requested pattern.
119 .P
120 Font matching starts with an application constructed pattern. The desired
121 attributes of the resulting font are collected together in an FcPattern
122 object. Each property of the pattern can contain one or more values; these
123 are listed in priority order; matches earlier in the list are considered
124 "closer" than matches later in the list.
125 .P
126 The initial pattern is modified by applying the list of editing instructions
127 specific to patterns found in the configuration; each consists of a match
128 predicate and a set of editing operations. They are executed in the order
129 they appeared in the configuration. Each match causes the associated
130 sequence of editing operations to be applied.
131 .P
132 After the pattern has been edited, a sequence of default substitutions are
133 performed to canonicalize the set of available properties; this avoids the
134 need for the lower layers to constantly provide default values for various
135 font properties during rendering.
136 .P
137 The canonical font pattern is finally matched against all available fonts.
138 The distance from the pattern to the font is measured for each of several
139 properties: foundry, charset, family, lang, spacing, pixelsize, style,
140 slant, weight, antialias, rasterizer and outline. This list is in priority
141 order -- results of comparing earlier elements of this list weigh more
142 heavily than later elements.
143 .P
144 There is one special case to this rule; family names are split into two
145 bindings; strong and weak. Strong family names are given greater precedence
146 in the match than lang elements while weak family names are given lower
147 precedence than lang elements. This permits the document language to drive
148 font selection when any document specified font is unavailable.
149 .P
150 The pattern representing that font is augmented to include any properties
151 found in the pattern but not found in the font itself; this permits the
152 application to pass rendering instructions or any other data through the
153 matching system. Finally, the list of editing instructions specific to
154 fonts found in the configuration are applied to the pattern. This modified
155 pattern is returned to the application.
156 .P
157 The return value contains sufficient information to locate and rasterize the
158 font, including the file name, pixel size and other rendering data. As
159 none of the information involved pertains to the FreeType library,
160 applications are free to use any rasterization engine or even to take
161 the identified font file and access it directly.
162 .P
163 The match/edit sequences in the configuration are performed in two passes
164 because there are essentially two different operations necessary -- the
165 first is to modify how fonts are selected; aliasing families and adding
166 suitable defaults. The second is to modify how the selected fonts are
167 rasterized. Those must apply to the selected font, not the original pattern
168 as false matches will often occur.
169 .SS FONT LIST MATCHING
170 .P
171 While many applications want to locate a single font best matching their
172 search criteria, other applications need to build a set of fonts which can
173 be used to present any Unicode data. Fontconfig provides an API to generate
174 a list sorted by the nearness of each font to the pattern. Every font in
175 the system is considered, the best matching fonts are placed first. The
176 application then can select whether the remaining fonts are unconditionally
177 included in the list, or whether they are included only if they cover
178 portions of Unicode not covered by any of the preceeding fonts.
179 .P
180 The list resulting from this match is represented by references to the
181 original font patterns and so consumes very little memory. Using a list
182 entry involves creating a pattern which combines the information from the
183 font with the information from the original pattern and executing the font
184 substitutions.
185 .SS FONT NAMES
186 Fontconfig provides a textual representation for patterns that the library
187 can both accept and generate. The representation is in three parts, first a
188 list of family names, second a list of point sizes and finally a list of
189 additional properties:
190 .nf
191 <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>...
192 .fi
193 Values in a list are separated with commas. The name needn't include either
194 families or point sizes; they can be elided. In addition, there are
195 symbolic constants that simultaneously indicate both a name and a value.
196 Here are some examples:
197 .sp
198 .nf
199 .ta 1i 3i
200 Times-12 12 point Times Roman
201 Times-12:bold 12 point Times Bold
202 Courier:italic Courier Italic in the default size
203 Monospace:matrix=1 .1 0 1 The users preferred monospace font
204 with artificial obliquing
205 .fi
206 .DT
207
208 .SH LANG TAGS
209 .P
210 Each font in the database contains a list of languages it supports. This is
211 computed by comparing the Unicode coverage of the font with the orthography
212 of each language. Languages are tagged using an RFC-3066 compatible naming
213 and occur in two parts -- the ISO639 language tag followed a hyphen and then
214 by the ISO 3166 country code. The hyphen and country code may be elided.
215
216 .P
217 Fontconfig has orthographies for several languages built into the library.
218 No provision has been made for adding new ones aside from rebuilding the
219 library. It currently supports 122 of the 139 languages named in ISO 639-1,
220 141 of the languages with two-letter codes from ISO 639-2 and another 30
221 languages with only three-letter codes.
222
223 .SH DATATYPES
224
225 .TP
226 .B FcChar8
227 .TQ
228 .B FcChar16
229 .TQ
230 .B FcChar32
231 .TQ
232 .B FcBool
233 These are primitive datatypes; the FcChar* types hold precisely the number
234 of bits stated (if supported by the C implementation). FcBool holds
235 one of two CPP symbols: FcFalse or FcTrue.
236
237 .TP
238 .B FcMatrix
239 An FcMatrix holds an affine transformation, usually used to reshape glyphs.
240 A small set of matrix operations are provided to manipulate these.
241 .sp
242 .nf
243 typedef struct _FcMatrix {
244 double xx, xy, yx, yy;
245 } FcMatrix;
246 .fi
247
248 .TP
249 .B FcCharSet
250 An FcCharSet is an abstract type that holds the set of encoded unicode chars
251 in a font. Operations to build and compare these sets are provided.
252
253 .TP
254 .B FcType
255 Tags the kind of data stored in an FcValue.
256
257 .TP
258 .B FcValue
259 An FcValue object holds a single value with one of a number of different
260 types. The 'type' tag indicates which member is valid.
261 .sp
262 .nf
263 typedef struct _FcValue {
264 FcType type;
265 union {
266 const FcChar8 *s;
267 int i;
268 FcBool b;
269 double d;
270 const FcMatrix *m;
271 const FcCharSet *c;
272 } u;
273 } FcValue;
274 .fi
275 .P
276 .ta 1i 2i 3i 4i
277 .nf
278 .lc \(em
279 type Union member Datatype
280 \ 1\ 1\ 1
281 FcTypeVoid (none) (none)
282 FcTypeInteger i int
283 FcTypeDouble d double
284 FcTypeString s char *
285 FcTypeBool b b
286 FcTypeMatrix m FcMatrix *
287 FcTypeCharSet c FcCharSet *
288 .fi
289 .DT
290 .TP
291 .B FcPattern
292 holds a set of names with associated value lists; each name refers to a
293 property of a font. FcPatterns are used as inputs to the matching code as
294 well as holding information about specific fonts. Each property can hold
295 one or more values; conventionally all of the same type, although the
296 interface doesn't demand that.
297
298 .TP
299 .B FcFontSet
300 .sp
301 .nf
302 typedef struct _FcFontSet {
303 int nfont;
304 int sfont;
305 FcPattern **fonts;
306 } FcFontSet;
307 .fi
308 An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this
309 data structure to hold sets of fonts. Externally, fontconfig returns the
310 results of listing fonts in this format. 'nfont' holds the number of
311 patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
312 array.
313
314 .TP
315 .B FcStrSet
316 .B FcStrList
317 FcStrSet holds a list of strings that can be appended to and enumerated.
318 Its unique characteristic is that the enumeration works even while strings
319 are appended during enumeration. FcStrList is used during enumeration to
320 safely and correctly walk the list of strings even while that list is edited
321 in the middle of enumeration.
322
323 .TP
324 .B FcObjectSet
325 .sp
326 .nf
327 typedef struct _FcObjectSet {
328 int nobject;
329 int sobject;
330 const char **objects;
331 } FcObjectSet;
332 .fi
333 .sp
334 holds a set of names and is used to specify which fields from fonts are
335 placed in the the list of returned patterns when listing fonts.
336
337 .TP
338 .B FcObjectType
339 .sp
340 typedef struct _FcObjectType {
341 const char *object;
342 FcType type;
343 } FcObjectType;
344 .fi
345 marks the type of a pattern element generated when parsing font names.
346 Applications can add new object types so that font names may contain the new
347 elements.
348
349 .TP
350 .B FcConstant
351 .sp
352 typedef struct _FcConstant {
353 const FcChar8 *name;
354 const char *object;
355 int value;
356 } FcConstant;
357 .fi
358 Provides for symbolic constants for new pattern elements. When 'name' is
359 seen in a font name, an 'object' element is created with value 'value'.
360
361 .TP
362 .B FcBlanks
363 holds a list of Unicode chars which are expected to be blank; unexpectedly
364 blank chars are assumed to be invalid and are elided from the charset
365 associated with the font.
366
367 .TP
368 .B FcFileCache
369 holds the per-user cache information for use while loading the font
370 database. This is built automatically for the current configuration when
371 that is loaded. Applications must always pass '0' when one is requested.
372
373 .TP
374 .B FcConfig
375 holds a complete configuration of the library; there is one default
376 configuration, other can be constructed from XML data structures. All
377 public entry points that need global data can take an optional FcConfig*
378 argument; passing 0 uses the default configuration. FcConfig objects hold two
379 sets of fonts, the first contains those specified by the configuration, the
380 second set holds those added by the application at run-time. Interfaces
381 that need to reference a particulat set use one of the FcSetName enumerated
382 values.
383
384 .TP
385 .B FcSetName
386 Specifies one of the two sets of fonts available in a configuration;
387 FcSetSystem for those fonts specified in the configuration and
388 FcSetApplication which holds fonts provided by the application.
389
390 .TP
391 .B FcResult
392 Used as a return type for functions manipulating FcPattern objects.
393 .P
394 .ta 1i 3i 4i
395 .lc \(em
396 Result code Meaning
397 .br
398 \ 1\ 1
399 .br
400 FcResultMatch Object exists with the specified ID
401 .br
402 FcResultNoMatch Object doesn't exist at all
403 .br
404 FcResultTypeMismatch Object exists, but the type doesn't match
405 .br
406 FcResultNoId Object exists, but has fewer values than specified
407 .br
408 .DT
409
410 .TP
411 .B FcAtomic
412 Used for locking access to config files. Provides a safe way to update
413 configuration files.
414
415 .SH FUNCTIONS
416
417 .SS FcMatrix
418 FcMatrix structures hold an affine transformation in matrix form.
419 .TP
420 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, (m)->xy = (m)->yx = 0)
421 Initializes a matrix to the identify transformation.
422
423 .TP
424 FcMatrix *FcMatrixCopy (const FcMatrix *mat)
425 Allocates a new FcMatrix and copies 'mat' into it.
426
427 .TP
428 FcBool FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2)
429 Returns FcTrue if 'mat1' and 'mat2' are equal, else FcFalse.
430
431 .TP
432 void FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b)
433 Multiplies 'a' and 'b' together, placing the result in
434 'result'. 'result' may refer to the sam matrix as either 'a' or 'b'.
435
436 .TP
437 void FcMatrixRotate (FcMatrix *m, double c, double s)
438 If 'c' is cos(angle) and 's' is sin(angle), FcMatrixRotate rotates the
439 matrix by 'angle'.
440
441 .TP
442 void FcMatrixScale (FcMatrix *m, double sx, double sy)
443 Scales 'm' by 'sx' in the horizontal dimension and 'sy' in the
444 vertical dimension.
445
446 .TP
447 void FcMatrixShear (FcMatrix *m, double sh, double sv)
448 Shears 'm' by 'sh' in the horizontal direction and 'sv' in the
449 vertical direction.
450
451 .SS FcCharSet
452 An FcCharSet is a boolean array indicating a set of unicode chars. Those
453 associated with a font are marked constant and cannot be edited.
454 FcCharSets may be reference counted internally to reduce memory consumption;
455 this may be visible to applications as the result of FcCharSetCopy may
456 return it's argument, and that CharSet may remain unmodifiable.
457
458 .TP
459 FcCharSet *FcCharSetCreate (void)
460 Creates an empty FcCharSet object.
461
462 .TP
463 void FcCharSetDestroy (FcCharSet *fcs)
464 Frees an FcCharSet object.
465
466 .TP
467 FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4)
468 Adds a single unicode char to the set, returning FcFalse on
469 failure, either as a result of a constant set or from running out of memory.
470
471 .TP
472 FcCharSet *FcCharSetCopy (FcCharSet *src)
473 Makes a copy of 'src'; note that this may not actually do anything more than
474 increment the reference count on 'src'.
475
476 .TP
477 FcBool FcCharSetEqual (const FcCharSet *a, const FcCharSet *b)
478 Returns whether 'a' and 'b' contain the same set of unicode chars.
479
480 .TP
481 FcCharSet *FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b)
482 Returns a set including only those chars found in both 'a' and 'b'.
483
484 .TP
485 FcCharSet *FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
486 Returns a set including only those chars found in either 'a' or 'b'.
487
488 .TP
489 FcCharSet *FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b)
490 Returns a set including only those chars found in 'a' but not 'b'.
491
492 .TP
493 FcBool FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4)
494 Returns whether 'fcs' contains the char 'ucs4'.
495
496 .TP
497 FcChar32 FcCharSetCount (const FcCharSet *a)
498 Returns the total number of unicode chars in 'a'.
499
500 .TP
501 FcChar32 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b)
502 Returns the number of chars that are in both 'a' and 'b'.
503
504 .TP
505 FcChar32 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b)
506 Returns the number of chars that are in 'a' but not in 'b'.
507
508 .TP
509 FcBool FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
510 Returns whether 'a' is a subset of 'b'.
511
512 .TP FcChar32 FcCharSetFirstPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
513 Builds an array of bits marking the first page of Unicode coverage of 'a'.
514 Returns the base of the array. 'next' contains the next page in the font.
515
516 .TP FcChar32 FcCharSetNextPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
517 Builds an array of bits marking the Unicode coverage of 'a' for page '*next'.
518 Returns the base of the array. 'next' contains the next page in the font.
519
520 .SS FcValue
521 FcValue is a structure containing a type tag and a union of all possible
522 datatypes. The tag is an enum of type
523 .B FcType
524 and is intended to provide a measure of run-time
525 typechecking, although that depends on careful programming.
526
527 .TP
528 void FcValueDestroy (FcValue v)
529 Frees any memory referenced by `v'. Values of type FcTypeString,
530 FcTypeMatrix and FcTypeCharSet reference memory, the other types do not.
531
532 .TP
533 FcValue FcValueSave (FcValue v)
534 Returns a copy of `v' duplicating any object referenced by it so that `v'
535 may be safely destroyed without harming the new value.
536
537 .SS FcPattern
538 An FcPattern is an opaque type that holds both patterns to match against the
539 available fonts, as well as the information about each font.
540
541 .TP
542 FcPattern *FcPatternCreate (void)
543 Creates a pattern with no properties; used to build patterns from scratch.
544
545 .TP
546 void FcPatternDestroy (FcPattern *p)
547 Destroys a pattern, in the process destroying all related values.
548
549 .TP
550 FcBool FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
551 Returns whether 'pa' and 'pb' are exactly alike.
552
553 .TP
554 FcBool FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os)
555 Returns whether 'pa' and 'pb' have exactly the same values for all of the
556 objects in 'os'.
557
558 .TP
559 FcChar32 FcPatternHash (const FcPattern *p)
560 Returns a 32-bit number which is the same for any two patterns which are
561 exactly alike.
562
563 .TP
564 FcBool FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
565 Adds a single value to the list of values associated with the property named
566 `object'. If `append' is FcTrue, the value is added at the end of any
567 existing list, otherwise it is inserted at the begining. `value' is saved
568 (with FcValueSave) when inserted into the pattern so that the library
569 retains no reference to any application-supplied data structure.
570
571 .TP
572 FcBool FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append)
573 FcPatternAddWeak is essentially the same as FcPatternAdd except that any
574 values added to the list have binding 'weak' instead of 'strong'.
575
576 .TP
577 FcBool FcPatternAddInteger (FcPattern *p, const char *object, int i)
578 .TQ
579 FcBool FcPatternAddDouble (FcPattern *p, const char *object, double d)
580 .TQ
581 FcBool FcPatternAddString (FcPattern *p, const char *object, const char *s)
582 .TQ
583 FcBool FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s)
584 .TQ
585 FcBool FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c)
586 .TQ
587 FcBool FcPatternAddBool (FcPattern *p, const char *object, FcBool b)
588 These are all convenience functions that insert objects of the specified
589 type into the pattern. Use these in preference to FcPatternAdd as they
590 will provide compile-time typechecking. These all append values to
591 any existing list of values.
592
593 .TP
594 FcResult FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
595 Returns in `v' the `id'th value associated with the property `object'.
596 The value returned is not a copy, but rather refers to the data stored
597 within the pattern directly. Applications must not free this value.
598
599 .TP
600 FcResult FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
601 .TQ
602 FcResult FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
603 .TQ
604 FcResult FcPatternGetString (FcPattern *p, const char *object, int n, char **const s);
605 .TQ
606 FcResult FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
607 .TQ
608 FcResult FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
609 .TQ
610 FcResult FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
611 These are convenience functions that call FcPatternGet and verify that the
612 returned data is of the expected type. They return FcResultTypeMismatch if
613 this is not the case. Note that these (like FcPatternGet) do not make a
614 copy of any data structure referenced by the return value. Use these
615 in preference to FcPatternGet to provide compile-time typechecking.
616
617 .TP
618 FcPattern *FcPatternBuild (FcPattern *orig, ...);
619 .TQ
620 FcPattern *FcPatternVaBuild (FcPattern *orig, va_list va)
621 Builds a pattern using a list of objects, types and values. Each
622 value to be entered in the pattern is specified with three arguments:
623 .IP
624 1. Object name, a string describing the property to be added.
625 .IP
626 2. Object type, one of the FcType enumerated values
627 .IP
628 3. Value, not an FcValue, but the raw type as passed to any of the
629 FcPatternAdd<type> functions. Must match the type of the second argument.
630 .IP
631 The argument list is terminated by a null object name, no object type nor
632 value need be passed for this. The values are added to `pattern', if
633 `pattern' is null, a new pattern is created. In either case, the pattern is
634 returned. Example:
635 .RS
636 .IP
637 pattern = FcPatternBuild (0, FC_FAMILY, FtTypeString, "Times", (char *) 0);
638 .RE
639 .IP
640 FcPatternVaBuild is used when the arguments are already in the form of a
641 varargs value.
642
643 .TP
644 FcBool FcPatternDel (FcPattern *p, const char *object)
645 Deletes all values associated with the property `object', returning
646 whether the property existed or not.
647
648 .TP
649 void FcPatternPrint (const FcPattern *p)
650 Prints an easily readable version of the pattern to stdout. There is
651 no provision for reparsing data in this format, it's just for diagnostics
652 and debugging.
653
654 .TP
655 void FcDefaultSubstitute (FcPattern *pattern)
656 Supplies default values for underspecified font patterns:
657 .RS
658 .IP \(bu
659 Patterns without a specified style or weight are set to Medium
660 .IP \(bu
661 Patterns without a specified style or slant are set to Roman
662 .IP \(bu
663 Patterns without a specified pixel size are given one computed from
664 any specified point size (default 12), dpi (default 75) and scale (default
665 1).
666 .RE
667
668 .TP
669 FcPattern *FcNameParse (const char *name)
670 Converts 'name' from the standard text format described above into a pattern.
671
672 .TP
673 FcChar8 *FcNameUnparse (FcPattern *pat)
674 Converts the given pattern into the standard text format described above.
675 The return value is not static, but instead refers to newly allocated memory
676 which should be freed by the caller.
677
678 .SS FcFontSet
679 An FcFontSet simply holds a list of patterns; these are used to return the
680 results of listing available fonts.
681 .TP
682 FcFontSet *FcFontSetCreate (void)
683 Creates an empty font set.
684
685 .TP
686 void FcFontSetDestroy (FcFontSet *s);
687 Destroys a font set. Note that this destroys any referenced patterns as
688 well.
689
690 .TP
691 FcBool FcFontSetAdd (FcFontSet *s, FcPattern *font)
692 Adds a pattern to a font set. Note that the pattern is not copied before
693 being inserted into the set.
694
695 .SS FcObjectSet
696 An FcObjectSet holds a list of pattern property names; it is used to
697 indiciate which properties are to be returned in the patterns from
698 FcFontList.
699
700 .TP
701 FcObjectSet *FcObjectSetCreate (void)
702 Creates an empty set.
703
704 .TP
705 FcBool FcObjectSetAdd (FcObjectSet *os, const char *object)
706 Adds a proprety name to the set.
707
708 .TP
709 void FcObjectSetDestroy (FcObjectSet *os)
710 Destroys an object set.
711
712
713 .TP
714 FcObjectSet *FcObjectSetBuild (const char *first, ...)
715 .TQ
716 FcObjectSet *FcObjectSetVaBuild (const char *first, va_list va)
717 These build an object set from a null-terminated list of property names.
718
719 .SS FcObjectType
720 Provides for applcation-specified font name object types so that new
721 pattern elements can be generated from font names.
722
723 .TP FcBool FcNameRegisterObjectTypes (const FcObjectType *types, int ntype)
724 Register 'ntype' new object types.
725
726 .TP
727 FcBool FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype)
728 Unregister 'ntype' object types.
729
730 .TP
731 const FcObjectType *FcNameGetObjectType (const char *object)
732 Return the object type for the pattern element named 'object'.
733
734 .SS FcConstant
735 Provides for application-specified symbolic constants for font names.
736
737 .TP
738 FcBool FcNameRegisterConstants (const FcConstant *consts, int nconsts)
739 Register 'nconsts' new symbolic constants.
740
741 .TP
742 FcBool FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
743 Unregister 'nconsts' symbolic constants.
744
745 .TP
746 const FcConstant *FcNameGetConstant (FcChar8 *string)
747 Return the FcConstant structure related to symbolic constant 'string'.
748
749 .TP
750 FcBool FcNameConstant (FcChar8 *string, int *result);
751 Returns whether a symbolic constant with name 'string' is registered,
752 placing the value of the constant in 'result' if present.
753
754 .SS FcBlanks
755 An FcBlanks object holds a list of Unicode chars which are expected to
756 be blank when drawn. When scanning new fonts, any glyphs which are
757 empty and not in this list will be assumed to be broken and not placed in
758 the FcCharSet associated with the font. This provides a significantly more
759 accurate CharSet for applications.
760
761 .TP
762 FcBlanks *FcBlanksCreate (void)
763 Creates an empty FcBlanks object.
764
765 .TP
766 void FcBlanksDestroy (FcBlanks *b)
767 Destroys an FcBlanks object, freeing any associated memory.
768
769 .TP
770 FcBool FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
771 Adds a single character to an FcBlanks object, returning FcFalse
772 if this process ran out of memory.
773
774 .TP
775 FcBool FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
776 Returns whether the specified FcBlanks object contains the indicated Unicode
777 value.
778
779 .SS FcConfig
780 An FcConfig object holds the internal representation of a configuration.
781 There is a default configuration which applications may use by passing 0 to
782 any function using the data within an FcConfig.
783
784 .TP
785 FcConfig *FcConfigCreate (void)
786 Creates an empty configuration.
787
788 .TP
789 void FcConfigDestroy (FcConfig *config)
790 Destroys a configuration and any data associated with it. Note that calling
791 this function with the return from FcConfigGetCurrent will place the library
792 in an indeterminate state.
793
794 .TP
795 FcBool FcConfigSetCurrent (FcConfig *config)
796 Sets the current default configuration to 'config'. Implicitly calls
797 FcConfigBuildFonts if necessary, returning FcFalse if that call fails.
798
799 .TP
800 FcConfig *FcConfigGetCurrent (void)
801 Returns the current default configuration.
802
803 .TP
804 FcBool FcConfigUptoDate (FcConfig *config)
805 Checks all of the files related to 'config' and returns whether the
806 in-memory version is in sync with the disk version.
807
808 .TP
809 FcBool FcConfigBuildFonts (FcConfig *config)
810 Builds the set of available fonts for the given configuration. Note that
811 any changes to the configuration after this call have indeterminate effects.
812 Returns FcFalse if this operation runs out of memory.
813
814 .TP
815 FcStrList *FcConfigGetConfigDirs (FcConfig *config)
816 Returns the list of font directories specified in the configuration files
817 for 'config'. Does not include any subdirectories.
818
819 .TP
820 FcStrList *FcConfigGetFontDirs (FcConfig *config)
821 Returns the list of font directories in 'config'. This includes the
822 configured font directories along with any directories below those in the
823 filesystem.
824
825 .TP
826 FcStrList *FcConfigGetConfigFiles (FcConfig *config)
827 Returns the list of known configuration files used to generate 'config'.
828 Note that this will not include any configuration done with FcConfigParse.
829
830 .TP
831 char *FcConfigGetCache (FcConfig *config)
832 Returns the name of the file used to store per-user font information.
833
834 .TP
835 FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set)
836 Returns one of the two sets of fonts from the configuration as specified
837 by 'set'.
838
839 .TP
840 FcBlanks *FcConfigGetBlanks (FcConfig *config)
841 Returns the FcBlanks object associated with the given configuration, if no
842 blanks were present in the configuration, this function will return 0.
843
844 .TP
845 int FcConfigGetRescanInverval (FcConfig *config)
846 Returns the interval between automatic checks of the configuration (in
847 seconds) specified in 'config'. The configuration is checked during
848 a call to FcFontList when this interval has passed since the last check.
849
850 .TP
851 FcBool FcConfigSetRescanInverval (FcConfig *config, int rescanInterval)
852 Sets the rescan interval; returns FcFalse if an error occurred.
853
854 .TP
855 FcBool FcConfigAppFontAddFile (FcConfig *config, const char *file)
856 Adds an application-specific font to the configuration.
857
858 .TP
859 FcBool FcConfigAppFontAddDir (FcConfig *config, const char *dir)
860 Scans the specified directory for fonts, adding each one found to the
861 application-specific set of fonts.
862
863 .TP
864 void FcConfigAppFontClear (FcConfig *config)
865 Clears the set of application-specific fonts.
866
867 .TP
868 FcBool FcConfigSubstitute (FcConfig *config, FcPattern *p, FcMatchKind kind)
869 Performs the sequence of pattern modification operations, if 'kind' is
870 FcMatchPattern, then those tagged as pattern operations are applied, else
871 if 'kind' is FcMatchFont, those tagged as font operations are applied.
872
873 .TP
874 FcPattern *FcFontMatch (FcConfig *config, FcPattern *p, FcResult *result)
875 Returns the font in 'config' most close matching 'p'. This function
876 should be called only after FcConfigSubstitute and FcDefaultSubstitute have
877 been called for 'p'; otherwise the results will not be correct.
878
879 .TP
880 FcFontSet *FcFontSort (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result) Returns the list of fonts sorted by
881 closeness to 'p'. If 'trim' is FcTrue, elements in the list which don't
882 include Unicode coverage not provided by earlier elements in the list are
883 elided. The union of Unicode coverage of all of the fonts is returned in
884 'csp', if 'csp' is not NULL. This function should be called only after
885 FcConfigSubstitute and FcDefaultSubstitute have been called for 'p';
886 otherwise the results will not be correct.
887 .P
888 The returned FcFontSet references FcPattern structures which may be shared
889 by the return value from multiple FcFontSort calls, applications must not
890 modify these patterns. Instead, they should be passed, along with 'p' to
891 FcFontRenderPrepare which combines them into a complete pattern.
892 .P
893 The FcFontSet returned by FcFontSort is destroyed by caling FcFontSetDestroy.
894
895 .TP
896 FcPattern *FcFontRenderPrepare (FcConfig *config, FcPattern *pat, FcPattern *font)
897 Creates a new pattern consisting of elements of 'font' not appearing in
898 'pat', elements of 'pat' not appearing in 'font' and the best matching value
899 from 'pat' for elements appearing in both. The result is passed to
900 FcConfigSubstitute with 'kind' FcMatchFont and then returned.
901
902 .TP
903 FcFontSet *FcFontList (FcConfig *config, FcPattern *p, FcObjectSet *os)
904 Selects fonts matching 'p', creates patterns from those fonts containing
905 only the objects in 'os' and returns the set of unique such patterns.
906
907 .TP
908 char *FcConfigFilename (const char *name)
909 Given the specified external entity name, return the associated filename.
910 This provides applications a way to convert various configuration file
911 references into filename form.
912 .P
913 A null or empty 'name' indicates that the default configuration file should
914 be used; which file this references can be overridden with the
915 FC_CONFIG_FILE environment variable. Next, if the name starts with '~', it
916 refers to a file in the current users home directory. Otherwise if the name
917 doesn't start with '/', it refers to a file in the default configuration
918 directory; the built-in default directory can be overridden with the
919 FC_CONFIG_DIR environment variable.
920
921 .SS Initialization
922 These functions provide some control over how the library is initialized.
923
924 .TP
925 FcConfig *FcInitLoadConfig (void)
926 Loads the default configuration file and returns the resulting configuration.
927 Does not load any font information.
928
929 .TP
930 FcConfig *FcInitLoadConfigAndFonts (void)
931 Loads the default configuration file and builds information about the
932 available fonts. Returns the resulting configuration.
933
934 .TP
935 FcBool FcInit (void)
936 Loads the default configuration file and the fonts referenced therein and
937 sets the default configuration to that result. Returns whether this
938 process succeeded or not. If the default configuration has already
939 been loaded, this routine does nothing and returns FcTrue.
940
941 .TP
942 int FcGetVersion (void)
943 Returns the version number of the library.
944
945 .TP
946 FcBool FcInitReinitialize (void)
947 Forces the default configuration file to be reloaded and resets the default
948 configuration.
949
950 .TP
951 FcBool FcInitBringUptoDate (void)
952 Checks the rescan interval in the default configuration, checking the
953 configuration if the interval has passed and reloading the configuration if
954 when any changes are detected.
955
956 .SS FcAtomic
957 These functions provide a safe way to update config files, allowing ongoing
958 reading of the old config file while locked for writing and ensuring that a
959 consistent and complete version of the config file is always available.
960
961 .TP
962 FcAtomic * FcAtomicCreate (const FcChar8 *file)
963 Creates a data structure containing data needed to control access to 'file'.
964 Writing is done to a separate file. Once that file is complete, the original
965 configuration file is atomically replaced so that reading process always see
966 a consistent and complete file without the need to lock for reading.
967
968 .TP
969 FcBool FcAtomicLock (FcAtomic *atomic)
970 Attempts to lock the file referenced by 'atomic'. Returns FcFalse if the
971 file is locked by another process, else returns FcTrue and leaves the file
972 locked.
973
974 .TP
975 FcChar8 *FcAtomicNewFile (FcAtomic *atomic)
976 Returns the filename for writing a new version of the file refernced by
977 'atomic'.
978
979 .TP
980 FcChar8 *FcAtomicOrigFile (FcAtomic *atomic)
981 Returns the file refernced by 'atomic'.
982
983 .TP
984 FcBool FcAtomicReplaceOrig (FcAtomic *atomic)
985 Replaces the original file referenced by 'atomic' with the new file.
986
987 .TP
988 void FcAtomicDeleteNew (FcAtomic *atomic)
989 Deletes the new file.
990
991 .TP
992 void FcAtomicUnlock (FcAtomic *atomic)
993 Unlocks the file.
994
995 .TP
996 void FcAtomicDestroy (FcAtomic *atomic)
997 Destroys 'atomic'.
998
999 .SS FreeType specific functions
1000 .nf
1001 .B #include <fontconfig/fcfreetype.h>
1002 .fi
1003 While the fontconfig library doesn't insist that FreeType be used as the
1004 rasterization mechanism for fonts, it does provide some convenience
1005 functions.
1006
1007 .TP
1008 FT_UInt FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
1009 Maps a Unicode char to a glyph index. This function uses information from
1010 several possible underlying encoding tables to work around broken fonts.
1011 As a result, this function isn't designed to be used in performance
1012 sensitive areas; results from this function are intended to be cached by
1013 higher level functions.
1014
1015 .TP
1016 FcCharSet *FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks) Scans a
1017 FreeType face and returns the set of encoded Unicode chars. This scans
1018 several encoding tables to build as complete a list as possible. If
1019 'blanks' is not 0, the glyphs in the font are examined and any blank glyphs
1020 not in 'blanks' are not placed in the returned FcCharSet.
1021
1022 .TP
1023 FcPattern *FcFreeTypeQuery (const char *file, int id, FcBlanks *blanks, int *count)
1024 Constructs a pattern representing the 'id'th font in 'file'. The number
1025 of fonts in 'file' is returned in 'count'.
1026
1027 .SS XML specific functions
1028 .nf
1029 .B #include <fontconfig/fcxml.h>
1030 .fi
1031 These functions expose the libxml2 datatypes used for font configuration.
1032
1033 .TP
1034 xmlDocPtr FcConfigLoad (const char *file)
1035 Loads a configuration file mapping 'file' into a filename with
1036 FcConfigFilename. This doesn't load a complete configuration as any
1037 include files referenced from 'file' will not be loaded.
1038
1039 .TP
1040 FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain)
1041 Walks the configuration in 'file' and constructs the internal representation in
1042 'config'. Any include files referenced from within 'file' will be loaded
1043 with FcConfigLoad and also parsed. If 'complain' is FcFalse, no warning
1044 will be displayed if 'file' does not exist.
1045
1046 .SS File and Directory routines
1047
1048 .TP
1049 FcBool FcFileScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *file, FcBool force)
1050 Scans a single file and adds all fonts found to 'set'. If 'force' is FcTrue,
1051 then the file is scanned even if associated information is found in 'cache'.
1052 If 'file' is a directory, it is added to 'dirs'.
1053
1054 .TP
1055 FcBool FcDirScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *dir, FcBool force)
1056 Scans an entire directory and adds all fonts found to 'set'. If 'force' is
1057 FcTrue, then the directory and all files within it are scanned even if
1058 information is present in the per-directory cache file or 'cache'. Any
1059 subdirectories found are added to 'dirs'.
1060
1061 .TP
1062 FcBool FcDirSave (FcFontSet *set, FcStrSet *dirs, const char *dir)
1063 Creates the per-directory cache file for 'dir' and populates it with the
1064 fonts in 'set' and subdirectories in 'dirs'.
1065
1066 .TP
1067 FcBool FcDirCacheValid (const FcChar8 *cache_file)
1068 Returns FcTrue if 'cache_file' is no older than the directory containing it,
1069 else FcFalse.
1070
1071 .SS FcStrSet and FcStrList
1072 A data structure for enumerating strings, used to list directories while
1073 scanning the configuration as directories are added while scanning.
1074
1075 .TP
1076 FcStrSet *FcStrSetCreate (void)
1077 Create an empty set.
1078
1079 .TP
1080 FcBool FcStrSetMember (FcStrSet *set, const FcChar8 *s)
1081 Returns whether 's' is a member of 'set'.
1082
1083 .TP
1084 FcBool FcStrSetAdd (FcStrSet *set, const FcChar8 *s)
1085 Adds a copy of 's' to 'set'.
1086
1087 .TP
1088 FcBool FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
1089 Adds a copy 's' to 'set', The copy is created with FcStrCopyFilename
1090 so that leading '~' values are replaced with the value of the HOME
1091 environment variable.
1092
1093 .TP
1094 FcBool FcStrSetDel (FcStrSet *set, const FcChar8 *s)
1095 Removes 's' from 'set', returning FcTrue if 's' was a member else FcFalse.
1096
1097 .TP
1098 void FcStrSetDestroy (FcStrSet *set)
1099 Destroys 'set'.
1100
1101 .TP
1102 FcStrList *FcStrListCreate (FcStrSet *set)
1103 Creates an enumerator to list the strings in 'set'.
1104
1105 .TP
1106 FcChar8 *FcStrListNext (FcStrList *list)
1107 Returns the next string in 'set'.
1108
1109 .TP
1110 void FcStrListDone (FcStrList *list)
1111 Destroys the enumerator 'list'.
1112
1113 .SS String utilities
1114
1115 .TP
1116 int FcUtf8ToUcs4 (FcChar8 *src, FcChar32 *dst, int len)
1117 Converts the next Unicode char from 'src' into 'dst' and returns the number
1118 of bytes containing the char. 'src' nust be at least 'len' bytes long.
1119
1120 .TP
1121 int FcUcs4ToUtf8 (FcChar32 src, FcChar8 dst[FC_UTF8_MAX_LEN])
1122 Converts the Unicode char from 'src' into 'dst' and returns the
1123 number of bytes needed to encode the char.
1124
1125 .TP
1126 FcBool FcUtf8Len (FcChar8 *src, int len, int *nchar, int *wchar)
1127 Counts the number of Unicode chars in 'len' bytes of 'src'. Places that
1128 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
1129 bytes needed to hold the largest unicode char counted. The return value
1130 indicates whether 'src' is a well-formed UTF8 string.
1131
1132 .TP
1133 int FcUtf16ToUcs4 (FcChar8 *src, FcEndian endian, FcChar32 *dst, int len)
1134 Converts the next Unicode char from 'src' into 'dst' and returns the
1135 number of bytes containing the char. 'src' must be at least 'len' bytes
1136 long. Bytes of 'src' are combined into 16-bit units according to 'endian'.
1137
1138 .TP
1139 FcBool FcUtf16Len (FcChar8 *src, FcEndian endian, int len, int *nchar, int *wchar)
1140 Counts the number of Unicode chars in 'len' bytes of 'src'. Bytes of
1141 'src' are combined into 16-bit units according to 'endian'. Places that
1142 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
1143 bytes needed to hold the largest unicode char counted. The return value
1144 indicates whether 'string' is a well-formed UTF16 string.
1145
1146 .TP
1147 FcChar8 *FcStrCopy (const FcChar8 *s)
1148 Allocates memory, copies 's' and returns the resulting buffer. Yes, this is
1149 'strdup', but that function isn't available on every platform.
1150
1151 .TP
1152 FcChar8 *FcStrCopyFilename (const FcChar8 *s)
1153 Just like FcStrCopy except that it converts any leading '~' characters in
1154 's' to the value of the HOME environment variable.
1155
1156 .TP
1157 int FcStrCmpIgnoreCase (const char *s1, const char *s2)
1158 Returns the usual <0, 0, >0 result of comparing 's1' and 's2'. This test
1159 is case-insensitive in the ASCII range and will operate properly with UTF8
1160 encoded strings, although it does not check for well formed strings.
1161
1162 .TP
1163 FcChar8 *FcStrDirname (const FcChar8 *file)
1164 Returns the directory containing 'file'.
1165
1166 .TP
1167 FcChar8 *FcStrBasename (const FcChar8 *file)
1168 Returns the filename of 'file' stripped of any leading directory names.
1169
1170 .SH CONFIGURATION FILE FORMAT
1171 Configuration files for fontconfig are stored in XML format; this
1172 format makes external configuration tools easier to write and ensures that
1173 they will generate syntactically correct configuration files. As XML
1174 files are plain text, they can also be manipulated by the expert user using
1175 a text editor.
1176 .P
1177 The fontconfig document type definition resides in the external entity
1178 "fonts.dtd"; this is normally stored in the default font configuration
1179 directory (/etc/fonts). Each configuration file should contain the
1180 following structure:
1181 .sp
1182 .nf
1183 <?xml version="1.0"?>
1184 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1185 <fontconfig>
1186 ...
1187 </fontconfig>
1188 .fi
1189 .P
1190 .SS <fontconfig>
1191 This is the top level element for a font configuration and can contain
1192 <dir>, <cache>, <include>, <match> and <alias> elements in any order.
1193
1194 .SS <dir>
1195 This element contains a directory name which will be scanned for font files
1196 to include in the set of available fonts.
1197
1198 .SS <cache>
1199 This element contains a file name for the per-user cache of font
1200 information. If it starts with '~', it refers to a file in the users
1201 home directory. This file is used to hold information about fonts that
1202 isn't present in the per-directory cache files. It is automatically
1203 maintained by the fontconfig library. The default for this file
1204 is ``~/.fonts.cache''.
1205
1206 .SS <include ignore_missing="no">
1207 This element contains the name of an additional configuration file. When
1208 the XML datatype is traversed by FcConfigParse, the contents of the file
1209 will also be incorporated into the configuration by passing the filename to
1210 FcConfigLoadAndParse. If 'ignore_missing' is set to "yes" instead of the
1211 default "no", a missing file will elicit no warning message from the library.
1212
1213 .SS <config>
1214 This element provides a place to consolodate additional configuration
1215 information. <config> can contain <blank> and <rescan> elements in any
1216 order.
1217
1218 .SS <blank>
1219 Fonts often include "broken" glyphs which appear in the encoding but are
1220 drawn as blanks on the screen. Within the <blank> element, place each
1221 Unicode characters which is supposed to be blank in an <int> element.
1222 Characters outside of this set which are drawn as blank will be elided from
1223 the set of characters supported by the font. <b
1224
1225 .SS <rescan>
1226 The <rescan> element holds an <int> element which indicates the default
1227 interval between automatic checks for font configuration changes.
1228 Fontconfig will validate all of the configuration files and directories and
1229 automatically rebuild the internal datastructures when this interval passes.
1230
1231 .SS <match target="pattern">
1232 This element holds first a (possibly empty) list of <test> elements and then
1233 a (possibly empty) list of <edit> elements. Patterns which match all of the
1234 tests are subjected to all the edits. If 'target' is set to "font" instead
1235 of the default "pattern", then this element applies to the font name
1236 resulting from a match rather than a font pattern to be matched.
1237
1238 .SS <test qual="any" name="property" compare="eq">
1239 This element contains a single value which is compared with the pattern
1240 property "property" (substitute any of the property names seen above).
1241 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", or
1242 "more_eq". 'qual' may either be the default, "any", in which case the match
1243 succeeds if any value associated with the property matches the test value, or
1244 "all", in which case all of the values associated with the property must
1245 match the test value.
1246
1247 .SS <edit name="property" mode="assign" binding="weak">
1248 This element contains a list of expression elements (any of the value or
1249 operator elements). The expression elements are evaluated at run-time and
1250 modify the property "property". The modification depends on whether
1251 "property" was matched by one of the associated <test> elements, if so, the
1252 modification may affect the first matched value. Any values inserted into
1253 the property are given the indicated binding. 'mode' is one of:
1254 .nf
1255 .RS
1256 .ta 1i 3i 5i
1257 Mode Operation with match Operation without match
1258 \ 1\ 1\ 1
1259 "assign" Replace matching value Replace all values
1260 "assign_replace" Replace all values Replace all values
1261 "prepend" Insert before matching value Insert at head of list
1262 "prepend_first" Insert at head of list Insert at head of list
1263 "append" Append after matching value Append at end of list
1264 "append_last" Append at end of list Append at end of list
1265 .RE
1266 .DT
1267 .fi
1268 .SS <int>
1269 .SS <double>
1270 .SS <string>
1271 .SS <bool>
1272 These elements hold a single value of the indicated type. <bool> elements
1273 hold either true or false.
1274 .SS <matrix>
1275 This element holds the four <double> elements of an affine transformation.
1276 .SS <name>
1277 Holds a property name. Evaluates to the first value from the property of
1278 the font, not the pattern.
1279 .SS <const>
1280 Holds the name of a constant; these are always integers and serve as
1281 symbolic names for common font values:
1282 .RS
1283 .sp
1284 .nf
1285 .ta 1i 2i 3i
1286 .lc \(em
1287 Constant Property CPP symbol
1288 \ 1\ 1\ 1
1289 light weight FC_WEIGHT_LIGHT
1290 medium weight FC_WEIGHT_MEDIUM
1291 demibold weight FC_WEIGHT_DEMIBOLD
1292 bold weight FC_WEIGHT_BOLD
1293 black weight FC_WEIGHT_BLACK
1294 roman slant FC_SLANT_ROMAN
1295 italic slant FC_SLANT_ITALIC
1296 oblique slant FC_SLANT_OBLIQUE
1297 proportional spacing FC_PROPORTIONAL
1298 mono spacing FC_MONO
1299 charcell spacing FC_CHARCELL
1300 rgb rgba FC_RGBA_RGB
1301 bgr rgba FC_RGBA_BGR
1302 vrgb rgba FC_RGBA_VRGB
1303 vbgr rgba FC_RGBA_VBGR
1304 .DT
1305 .fi
1306 .RE
1307 .SS <or>
1308 .SS <and>
1309 .SS <plus>
1310 .SS <minus>
1311 .SS <times>
1312 .SS <divide>
1313 These elements perform the specified operation on a list of expression
1314 elements. <or> and <and> are boolean, not bitwise.
1315 .SS <eq>
1316 .SS <not_eq>
1317 .SS <less>
1318 .SS <less_eq>
1319 .SS <more>
1320 .SS <more_eq>
1321 These elements compare two values, producing a boolean result.
1322 .SS <not>
1323 Inverts the boolean sense of its one expression element
1324 .SS <if>
1325 This element takes three expression elements; if the value of the first is
1326 true, it produces the value of the second, otherwise it produces the value
1327 of the third.
1328 .SS <alias>
1329 Alias elements provide a shorthand notation for the set of common match
1330 operations needed to substitute one font family for another. They contain a
1331 <family> element followed by optional <prefer>, <accept> and <default>
1332 elements. Fonts matching the <family> element are edited to prepend the
1333 list of <prefer>ed families before the matching <family>, append the
1334 <accept>able familys after the matching <family> and append the <default>
1335 families to the end of the family list.
1336 .SS <family>
1337 Holds a single font family name
1338 .SS <prefer>
1339 .SS <accept>
1340 .SS <default>
1341 These hold a list of <family> elements to be used by the <alias> element.
1342 .SH EXAMPLE CONFIGURATION FILE
1343 .SS System configuration file
1344 This is an example of a system-wide configuration file
1345 .sp
1346 .nf
1347 <?xml version="1.0"?>
1348 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1349 <!-- /etc/fonts/fonts.conf file to configure system font access -->
1350 <fontconfig>
1351 <!--
1352 Find fonts in these directories
1353 -->
1354 <dir>/usr/X11R6/lib/X11/fonts/truetype</dir>
1355 <dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
1356
1357 <!--
1358 Accept deprecated 'mono' alias, replacing it with 'monospace'
1359 -->
1360 <match target="pattern">
1361 <test qual="any" name="family"><string>mono</string></test>
1362 <edit name="family" mode="assign"><string>monospace</string></edit>
1363 </match>
1364
1365 <!--
1366 Names not including any well known alias are given 'sans'
1367 -->
1368 <match target="pattern">
1369 <test qual="all" name="family" mode="not_eq">sans</test>
1370 <test qual="all" name="family" mode="not_eq">serif</test>
1371 <test qual="all" name="family" mode="not_eq">monospace</test>
1372 <edit name="family" mode="append_last"><string>sans</string></edit>
1373 </match>
1374
1375 <!--
1376 Load per-user customization file, but don't complain
1377 if it doesn't exist
1378 -->
1379 <include ignore_missing="yes">~/.fonts.conf</include>
1380
1381 <!--
1382 Alias well known font names to available TrueType fonts.
1383 These substitute TrueType faces for similar Type1
1384 faces to improve screen appearance.
1385 -->
1386 <alias>
1387 <family>Times</family>
1388 <prefer><family>Times New Roman</family></prefer>
1389 <default><family>serif</family></default>
1390 </alias>
1391 <alias>
1392 <family>Helvetica</family>
1393 <prefer><family>Verdana</family></prefer>
1394 <default><family>sans</family></default>
1395 </alias>
1396 <alias>
1397 <family>Courier</family>
1398 <prefer><family>Courier New</family></prefer>
1399 <default><family>monospace</family></default>
1400 </alias>
1401
1402 <!--
1403 Provide required aliases for standard names
1404 Do these after the users configuration file so that
1405 any aliases there are used preferentially
1406 -->
1407 <alias>
1408 <family>serif</family>
1409 <prefer><family>Times New Roman</family></prefer>
1410 </alias>
1411 <alias>
1412 <family>sans</family>
1413 <prefer><family>Verdana</family></prefer>
1414 </alias>
1415 <alias>
1416 <family>monospace</family>
1417 <prefer><family>Andale Mono</family></prefer>
1418 </alias>
1419 </fontconfig>
1420 .fi
1421 .SS User configuration file
1422 This is an example of a per-user configuration file that lives in
1423 ~/.fonts.conf
1424 .sp
1425 .nf
1426 <?xml version="1.0"?>
1427 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
1428 <!-- ~/.fonts.conf for per-user font configuration -->
1429 <fontconfig>
1430
1431 <!--
1432 Private font directory
1433 -->
1434 <dir>~/misc/fonts</dir>
1435
1436 <!--
1437 use rgb sub-pixel ordering to improve glyph appearance on
1438 LCD screens. Changes affecting rendering, but not matching
1439 should always use target="font".
1440 -->
1441 <match target="font">
1442 <edit name="rgba" mode="assign"><const>rgb</const></edit>
1443 </match>
1444 </fontconfig>
1445 .fi
1446 .SH FILES
1447 .B fonts.conf
1448 contains configuration information for the fontconfig library
1449 consisting of directories to look at for font information as well as
1450 instructions on editing program specified font patterns before attempting to
1451 match the available fonts. It is in xml format.
1452
1453 .B fonts.dtd
1454 is a DTD that describes the format of the configuration files.
1455
1456 .B ~/.fonts.conf
1457 is the conventional location for per-user font configuration, although the
1458 actual location is specified in the global fonts.conf file.
1459
1460 .B ~/.fonts.cache
1461 is the conventional repository of font information that isn't found in the
1462 per-directory caches. This file is automatically maintained by fontconfig.
1463
1464 .SH AUTHOR
1465 Keith Packard, member of the XFree86 Project, Inc.