]> git.wh0rd.org - fontconfig.git/blob - doc/fontconfig-devel.sgml
f5d958f475d3cfee386c3a91478602c9701bf3fa
[fontconfig.git] / doc / fontconfig-devel.sgml
1 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
2 <!--
3 $Id$
4
5 Copyright © 2002 Keith Packard
6
7 Permission to use, copy, modify, distribute, and sell this software and its
8 documentation for any purpose is hereby granted without fee, provided that
9 the above copyright notice appear in all copies and that both that
10 copyright notice and this permission notice appear in supporting
11 documentation, and that the name of Keith Packard not be used in
12 advertising or publicity pertaining to distribution of the software without
13 specific, written prior permission. Keith Packard makes no
14 representations about the suitability of this software for any purpose. It
15 is provided "as is" without express or implied warranty.
16
17 KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23 PERFORMANCE OF THIS SOFTWARE.
24 -->
25 <article>
26 <artheader>
27 <title>Fontconfig Developers Guide</title>
28 <titleabbrev>Fontconfig</titleabbrev>
29 <author><firstname>Keith</><surname>Packard</></author>
30 <authorinitials>krp</authorinitials>
31 </artheader>
32 <sect1><title>NAME</title>
33 <para>
34 fontconfig - Font configuration and customization library
35 </para>
36 </sect1>
37 <sect1><title>SYNOPSIS</title>
38 <programlisting>
39 #include &lt;fontconfig/fontconfig.h&gt;
40 #include &lt;fontconfig/fcfreetype.h&gt;
41 </programlisting>
42 </sect1>
43 <sect1><title>DESCRIPTION</title>
44 <para>
45 Fontconfig is a library designed to provide system-wide font configuration,
46 customization and application access.
47 </para>
48 </sect1>
49 <sect1><title>FUNCTIONAL OVERVIEW</title>
50 <para>
51 Fontconfig contains two essential modules, the configuration module which
52 builds an internal configuration from XML files and the matching module
53 which accepts font patterns and returns the nearest matching font.
54 </para>
55 <sect2><title>FONT CONFIGURATION</title>
56 <para>
57 The configuration module consists of the FcConfig datatype, libexpat and
58 FcConfigParse which walks over an XML tree and ammends a configuration with
59 data found within. From an external perspective, configuration of the
60 library consists of generating a valid XML tree and feeding that to
61 FcConfigParse. The only other mechanism provided to applications for
62 changing the running configuration is to add fonts and directories to the
63 list of application-provided font files.
64 </para><para>
65 The intent is to make font configurations relatively static, and shared by
66 as many applications as possible. It is hoped that this will lead to more
67 stable font selection when passing names from one application to another.
68 XML was chosen as a configuration file format because it provides a format
69 which is easy for external agents to edit while retaining the correct
70 structure and syntax.
71 </para><para>
72 Font configuration is separate from font matching; applications needing to
73 do their own matching can access the available fonts from the library and
74 perform private matching. The intent is to permit applications to pick and
75 choose appropriate functionality from the library instead of forcing them to
76 choose between this library and a private configuration mechanism. The hope
77 is that this will ensure that configuration of fonts for all applications
78 can be centralized in one place. Centralizing font configuration will
79 simplify and regularize font installation and customization.
80 </para>
81 </sect2>
82 <sect2>
83 <title>FONT PROPERTIES</title>
84 <para>
85 While font patterns may contain essentially any properties, there are some
86 well known properties with associated types. Fontconfig uses some of these
87 properties for font matching and font completion. Others are provided as a
88 convenience for the applications rendering mechanism.
89 </para>
90 <table>
91 <title>Property Definitions</title>
92 <tgroup cols=4 align=left colsep=1 rowsep=1>
93 <colspec colname=Property>
94 <colspec colname=CPP>
95 <colspec colname=Type>
96 <colspec colname=Description>
97 <thead>
98 <row>
99 <entry>Property</entry>
100 <entry>CPP Symbol</entry>
101 <entry>Type</entry>
102 <entry>Description</entry>
103 </row>
104 </thead>
105 <tbody>
106 <row><entry>family</entry><entry>FC_FAMILY</entry><entry>String</entry><entry>Font family name</entry></row>
107 <row><entry>style</entry><entry>FC_STYLE</entry><entry>String</entry><entry>Font style. Overrides weight and slant</entry></row>
108 <row><entry>slant</entry><entry>FC_SLANT</entry><entry>Int</entry><entry>Italic, oblique or roman</entry></row>
109 <row><entry>weight</entry><entry>FC_WEIGHT</entry><entry>Int</entry><entry>Light, medium, demibold, bold or black</entry></row>
110 <row><entry>size</entry><entry>FC_SIZE</entry><entry>Double</entry><entry>Point size</entry></row>
111 <row><entry>aspect</entry><entry>FC_ASPECT</entry><entry>Double</entry><entry>Stretches glyphs horizontally before hinting</entry></row>
112 <row><entry>pixelsize</entry><entry>FC_PIXEL_SIZE</entry><entry>Double</entry><entry>Pixel size</entry></row>
113 <row><entry>spacing</entry><entry>FC_SPACING</entry><entry>Int</entry><entry>Proportional, monospace or charcell</entry></row>
114 <row><entry>foundry</entry><entry>FC_FOUNDRY</entry><entry>String</entry><entry>Font foundry name</entry></row>
115 <row><entry>antialias</entry><entry>FC_ANTIALIAS</entry><entry>Bool</entry><entry>Whether glyphs can be antialiased</entry></row>
116 <row><entry>hinting</entry><entry>FC_HINTING</entry><entry>Bool</entry><entry>Whether the rasterizer should use hinting</entry></row>
117 <row><entry>verticallayout</entry><entry>FC_VERTICAL_LAYOUT</entry><entry>Bool</entry><entry>Use vertical layout</entry></row>
118 <row><entry>autohint</entry><entry>FC_AUTOHINT</entry><entry>Bool</entry><entry>Use autohinter instead of normal hinter</entry></row>
119 <row><entry>globaladvance</entry><entry>FC_GLOBAL_ADVANCE</entry><entry>Bool</entry><entry>Use font global advance data</entry></row>
120 <row><entry>file</entry><entry>FC_FILE</entry><entry>String</entry><entry>The filename holding the font</entry></row>
121 <row><entry>index</entry><entry>FC_INDEX</entry><entry>Int</entry><entry>The index of the font within the file</entry></row>
122 <row><entry>ftface</entry><entry>FC_FT_FACE</entry><entry>FT_Face</entry><entry>Use the specified FreeType face object</entry></row>
123 <row><entry>rasterizer</entry><entry>FC_RASTERIZER</entry><entry>String</entry><entry>Which rasterizer is in use</entry></row>
124 <row><entry>outline</entry><entry>FC_OUTLINE</entry><entry>Bool</entry><entry>Whether the glyphs are outlines</entry></row>
125 <row><entry>scalable</entry><entry>FC_SCALABLE</entry><entry>Bool</entry><entry>Whether glyphs can be scaled</entry></row>
126 <row><entry>scale</entry><entry>FC_SCALE</entry><entry>Double</entry><entry>Scale factor for point->pixel conversions</entry></row>
127 <row><entry>dpi</entry><entry>FC_DPI</entry><entry>Double</entry><entry>Target dots per inch</entry></row>
128 <row><entry>rgba</entry><entry>FC_RGBA</entry><entry>Int</entry><entry>unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry</entry></row>
129 <row><entry>minspace</entry><entry>FC_MINSPACE</entry><entry>Bool</entry><entry>Eliminate leading from line spacing</entry></row>
130 <row><entry>charset</entry><entry>FC_CHARSET</entry><entry>CharSet</entry><entry>Unicode chars encoded by the font</entry></row>
131 <row><entry>lang</entry><entry>FC_LANG</entry><entry>String</entry><entry>List of RFC-3066-style languages this font supports</entry></row>
132 </tbody>
133 </tgroup>
134 </table>
135 </sect2>
136 <sect1><title>DATATYPES</title>
137 <para>
138 Fontconfig uses abstract datatypes to hide internal implementation details
139 for most data structures. A few structures are exposed where appropriate.
140 </para>
141 <sect2><title>FcChar8, FcChar16, FcChar32, FcBool</title>
142 <para>
143 These are primitive datatypes; the FcChar* types hold precisely the number
144 of bits stated (if supported by the C implementation). FcBool holds
145 one of two CPP symbols: FcFalse or FcTrue.
146 </para>
147 </sect2>
148 <sect2><title>FcMatrix</title>
149 <para>
150 An FcMatrix holds an affine transformation, usually used to reshape glyphs.
151 A small set of matrix operations are provided to manipulate these.
152 <programlisting>
153 typedef struct _FcMatrix {
154 double xx, xy, yx, yy;
155 } FcMatrix;
156 </programlisting>
157 </para>
158 </sect2>
159 <sect2>
160 <title>FcCharSet</title>
161 <para>
162 An FcCharSet is an abstract type that holds the set of encoded unicode chars
163 in a font. Operations to build and compare these sets are provided.
164 </para>
165 </sect2>
166 <sect2>
167 <title>FcType</title>
168 <para>
169 Tags the kind of data stored in an FcValue.
170 </sect2>
171 <sect2>
172 <title>FcValue</title>
173 <para>
174 An FcValue object holds a single value with one of a number of different
175 types. The 'type' tag indicates which member is valid.
176 <programlisting>
177 typedef struct _FcValue {
178 FcType type;
179 union {
180 const FcChar8 *s;
181 int i;
182 FcBool b;
183 double d;
184 const FcMatrix *m;
185 const FcCharSet *c;
186 } u;
187 } FcValue;
188 </programlisting>
189 <table colsep=0 rowsep=0>
190 <title>FcValue Members</title>
191 <tgroup cols=3 align=left colsep=0 rowsep=0>
192 <thead><row>
193 <entry>Type</entry>
194 <entry>Union member</entry>
195 <entry>Datatype</entry>
196 </row></thead>
197 <tbody>
198 <row><entry>FcTypeVoid</entry><entry>(none)</entry><entry>(none)</entry></row>
199 <row><entry>FcTypeInteger</entry><entry>i</entry><entry>int</entry></row>
200 <row><entry>FcTypeDouble</entry><entry>d</entry><entry>double</entry></row>
201 <row><entry>FcTypeString</entry><entry>s</entry><entry>char *</entry></row>
202 <row><entry>FcTypeBool</entry><entry>b</entry><entry>b</entry></row>
203 <row><entry>FcTypeMatrix</entry><entry>m</entry><entry>FcMatrix *</entry></row>
204 <row><entry>FcTypeCharSet</entry><entry>c</entry><entry>FcCharSet *</entry></row>
205 </tbody>
206 </tgroup>
207 </table>
208 <sect2>
209 <title>FcPattern</title>
210 <para>
211 holds a set of names with associated value lists; each name refers to a
212 property of a font. FcPatterns are used as inputs to the matching code as
213 well as holding information about specific fonts. Each property can hold
214 one or more values; conventionally all of the same type, although the
215 interface doesn't demand that.
216 </sect2>
217 <sect2>
218 <title>FcFontSet</title>
219 <para>
220 <programlisting>
221 typedef struct _FcFontSet {
222 int nfont;
223 int sfont;
224 FcPattern **fonts;
225 } FcFontSet;
226 </programlisting>
227 An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this
228 data structure to hold sets of fonts. Externally, fontconfig returns the
229 results of listing fonts in this format. 'nfont' holds the number of
230 patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
231 array.
232 </para>
233 </sect2>
234 <sect2>
235 <title>FcStrSet, FcStrList</title>
236 <para>
237 FcStrSet holds a list of strings that can be appended to and enumerated.
238 Its unique characteristic is that the enumeration works even while strings
239 are appended during enumeration. FcStrList is used during enumeration to
240 safely and correctly walk the list of strings even while that list is edited
241 in the middle of enumeration.
242 </para>
243 </sect2>
244 <sect2>
245 <title>FcObjectSet</title>
246 <para>
247 <programlisting>
248 typedef struct _FcObjectSet {
249 int nobject;
250 int sobject;
251 const char **objects;
252 } FcObjectSet;
253 </programlisting>
254 holds a set of names and is used to specify which fields from fonts are
255 placed in the the list of returned patterns when listing fonts.
256 </para>
257 </sect2>
258 <sect2>
259 <title>FcObjectType</title>
260 <para>
261 <programlisting>
262 typedef struct _FcObjectType {
263 const char *object;
264 FcType type;
265 } FcObjectType;
266 </programlisting>
267 marks the type of a pattern element generated when parsing font names.
268 Applications can add new object types so that font names may contain the new
269 elements.
270 </para>
271 </sect2>
272 <sect2>
273 <title>FcConstant</title>
274 <para>
275 <programlisting>
276 typedef struct _FcConstant {
277 const FcChar8 *name;
278 const char *object;
279 int value;
280 } FcConstant;
281 </programlisting>
282 Provides for symbolic constants for new pattern elements. When 'name' is
283 seen in a font name, an 'object' element is created with value 'value'.
284 </para>
285 </sect2>
286 <sect2>
287 <title>FcBlanks</title>
288 <para>
289 holds a list of Unicode chars which are expected to be blank; unexpectedly
290 blank chars are assumed to be invalid and are elided from the charset
291 associated with the font.
292 </para>
293 </sect2>
294 <sect2>
295 <title>FcFileCache</title>
296 <para>
297 holds the per-user cache information for use while loading the font
298 database. This is built automatically for the current configuration when
299 that is loaded. Applications must always pass '0' when one is requested.
300 </para>
301 </sect2>
302 <sect2>
303 <title>FcConfig</title>
304 <para>
305 holds a complete configuration of the library; there is one default
306 configuration, other can be constructed from XML data structures. All
307 public entry points that need global data can take an optional FcConfig*
308 argument; passing 0 uses the default configuration. FcConfig objects hold two
309 sets of fonts, the first contains those specified by the configuration, the
310 second set holds those added by the application at run-time. Interfaces
311 that need to reference a particulat set use one of the FcSetName enumerated
312 values.
313 </para>
314 </sect2>
315 <sect2>
316 <title>FcSetName</title>
317 <para>
318 Specifies one of the two sets of fonts available in a configuration;
319 FcSetSystem for those fonts specified in the configuration and
320 FcSetApplication which holds fonts provided by the application.
321 </para>
322 </sect2>
323 <sect2>
324 <title>FcResult</title>
325 <para>
326 Used as a return type for functions manipulating FcPattern objects.
327 <table colsep=0 rowsep=0>
328 <title>FcResult Values</title>
329 <tgroup cols=2 align=left colsep=0 rowsep=0>
330 <thead><row>
331 <entry>Result Code</entry>
332 <entry>Meaning</entry>
333 </row></thead>
334 <tbody>
335 <row><entry>FcResultMatch</entry><entry>Object exists with the specified ID</entry></row>
336 <row><entry>FcResultNoMatch</entry><entry>Object doesn't exist at all</entry></row>
337 <row><entry>FcResultTypeMismatch</entry><entry>Object exists, but the type doesn't match</entry></row>
338 <row><entry>FcResultNoId</entry><entry>Object exists, but has fewer values than specified</entry></row>
339 </tbody>
340 </tgroup>
341 </table>
342 </para>
343 </sect2>
344 <sect2>
345 <title>FcAtomic</title>
346 <para>
347 Used for locking access to config files. Provides a safe way to update
348 configuration files.
349 </para>
350 </sect2>
351 </sect1>
352 <sect1><title>FUNCTIONS</title>
353 <para>
354 Functions are grouped by the main datatype involved
355 </para>
356 <sect2><title>FcMatrix</title>
357 <para>
358 FcMatrix structures hold an affine transformation in matrix form.
359 </para>
360 <sect3><title>FcMatrixInit</title><programlisting>
361 #define FcMatrixInit(m) ((m)-&gt;xx = (m)-&gt;yy = 1, (m)-&gt;xy = (m)-&gt;yx = 0)
362 </programlisting><para>
363 Initializes a matrix to the identify transformation.
364 </para>
365 <sect3><title>FcMatrixCopy</title><programlisting>
366 FcMatrix *FcMatrixCopy (const FcMatrix *mat)
367 </programlisting><para>
368 Allocates a new FcMatrix and copies 'mat' into it.
369 </para>
370 <sect3><title>FcMatrixEqual</title><programlisting>
371 FcBool FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2)
372 </programlisting><para>
373 Returns FcTrue if 'mat1' and 'mat2' are equal, else FcFalse.
374 </para>
375 <sect3><title>FcMatrixMultiply</title><programlisting>
376 void FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b)
377 </programlisting><para>
378 Multiplies 'a' and 'b' together, placing the result in 'result'. 'result'
379 may refer to the sam matrix as either 'a' or 'b'.
380 </para>
381 <sect3><title>FcMatrixRotate</title><programlisting>
382 void FcMatrixRotate (FcMatrix *m, double c, double s)
383 </programlisting><para>
384 If 'c' is cos(angle) and 's' is sin(angle), FcMatrixRotate rotates the
385 matrix by 'angle'.
386 </para>
387 <sect3><title>FcMatrixScale</title><programlisting>
388 void FcMatrixScale (FcMatrix *m, double sx, double sy)
389 </programlisting><para>
390 Scales 'm' by 'sx' in the horizontal dimension and 'sy' in the
391 vertical dimension.
392 </para>
393 <sect3><title>FcMatrixShear</title><programlisting>
394 void FcMatrixShear (FcMatrix *m, double sh, double sv)
395 </programlisting><para>
396 Shears 'm' by 'sh' in the horizontal direction and 'sv' in the
397 vertical direction.
398 </para>
399 </sect2>
400 <sect2><title>FcCharSet</title>
401 <para>
402 An FcCharSet is a boolean array indicating a set of unicode chars. Those
403 associated with a font are marked constant and cannot be edited.
404 FcCharSets may be reference counted internally to reduce memory consumption;
405 this may be visible to applications as the result of FcCharSetCopy may
406 return it's argument, and that CharSet may remain unmodifiable.
407 </para>
408 <sect3><title>FcCharSetCreate</title><programlisting>
409 FcCharSet *FcCharSetCreate (void)
410 </programlisting><para>
411 Creates an empty FcCharSet object.
412 </para>
413 <sect3><title>FcCharSetDestroy</title><programlisting>
414 void FcCharSetDestroy (FcCharSet *fcs)
415 </programlisting><para>
416 Frees an FcCharSet object.
417 </para>
418 <sect3><title>FcCharSetAddChar</title><programlisting>
419 FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4)
420 </programlisting><para>
421 Adds a single unicode char to the set, returning FcFalse on
422 failure, either as a result of a constant set or from running out of memory.
423 </para>
424 <sect3><title>FcCharSetCopy</title><programlisting>
425 FcCharSet *FcCharSetCopy (FcCharSet *src)
426 </programlisting><para>
427 Makes a copy of 'src'; note that this may not actually do anything more than
428 increment the reference count on 'src'.
429 </para>
430 <sect3><title>FcCharSetEqual</title><programlisting>
431 FcBool FcCharSetEqual (const FcCharSet *a, const FcCharSet *b)
432 </programlisting><para>
433 Returns whether 'a' and 'b' contain the same set of unicode chars.
434 </para>
435 <sect3><title>FcCharSetIntersect</title><programlisting>
436 FcCharSet *FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b)
437 </programlisting><para>
438 Returns a set including only those chars found in both 'a' and 'b'.
439 </para>
440 <sect3><title>FcCharSetUnion</title><programlisting>
441 FcCharSet *FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
442 </programlisting><para>
443 Returns a set including only those chars found in either 'a' or 'b'.
444 </para>
445 <sect3><title>FcCharSetSubtract</title><programlisting>
446 FcCharSet *FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b)
447 </programlisting><para>
448 Returns a set including only those chars found in 'a' but not 'b'.
449 </para>
450 <sect3><title>FcCharSetHasChar</title><programlisting>
451 FcBool FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4)
452 </programlisting><para>
453 Returns whether 'fcs' contains the char 'ucs4'.
454 </para>
455 <sect3><title>FcCharSetCount</title><programlisting>
456 FcChar32 FcCharSetCount (const FcCharSet *a)
457 </programlisting><para>
458 Returns the total number of unicode chars in 'a'.
459 </para>
460 <sect3><title>FcCharSetIntersectCount</title><programlisting>
461 FcChar32 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b)
462 </programlisting><para>
463 Returns the number of chars that are in both 'a' and 'b'.
464 </para>
465 <sect3><title>FcCharSetSubtractCount</title><programlisting>
466 FcChar32 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b)
467 </programlisting><para>
468 Returns the number of chars that are in 'a' but not in 'b'.
469 </para>
470 <sect3><title>FcCharSetIsSubset</title><programlisting>
471 FcBool FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b)
472 </programlisting><para>
473 Returns whether 'a' is a subset of 'b'.
474 </para>
475 <sect3><title>FcCharSetFirstPage</title><programlisting>
476 FcChar32 FcCharSetFirstPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
477 </programlisting><para>
478 Builds an array of bits marking the first page of Unicode coverage of 'a'.
479 Returns the base of the array. 'next' contains the next page in the font.
480 </para>
481 <sect3><title>FcCharSetNextPage</title><programlisting>
482 FcChar32 FcCharSetNextPage (const FcCharSet *a, FcChar32 [FC_CHARSET_MAP_SIZE], FcChar32 *next)
483 </programlisting><para>
484 Builds an array of bits marking the Unicode coverage of 'a' for page '*next'.
485 Returns the base of the array. 'next' contains the next page in the font.
486 </para>
487 </sect2>
488 <sect2><title>FcValue</title>
489 <para>
490 FcValue is a structure containing a type tag and a union of all possible
491 datatypes. The tag is an enum of type
492 <emphasis>FcType</emphasis>
493 and is intended to provide a measure of run-time
494 typechecking, although that depends on careful programming.
495 </para>
496 <sect3><title>FcValueDestroy</title><programlisting>
497 void FcValueDestroy (FcValue v)
498 </programlisting><para>
499 Frees any memory referenced by `v'. Values of type FcTypeString,
500 FcTypeMatrix and FcTypeCharSet reference memory, the other types do not.
501 </para>
502 <sect3><title>FcValueSave</title><programlisting>
503 FcValue FcValueSave (FcValue v)
504 </programlisting><para>
505 Returns a copy of `v' duplicating any object referenced by it so that `v'
506 may be safely destroyed without harming the new value.
507 </para>
508 </sect2>
509 <sect2><title>FcPattern</title>
510 <para>
511 An FcPattern is an opaque type that holds both patterns to match against the
512 available fonts, as well as the information about each font.
513 </para>
514 <sect3><title>FcPatternCreate</title><programlisting>
515 FcPattern *FcPatternCreate (void)
516 </programlisting><para>
517 Creates a pattern with no properties; used to build patterns from scratch.
518 </para>
519 <sect3><title>FcPatternDestroy</title><programlisting>
520 void FcPatternDestroy (FcPattern *p)
521 </programlisting><para>
522 Destroys a pattern, in the process destroying all related values.
523 </para>
524 <sect3><title>FcPatternEqual</title><programlisting>
525 FcBool FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
526 </programlisting><para>
527 Returns whether 'pa' and 'pb' are exactly alike.
528 </para>
529 <sect3><title>FcPatternEqualSubset</title><programlisting>
530 FcBool FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os)
531 </programlisting><para>
532 Returns whether 'pa' and 'pb' have exactly the same values for all of the
533 objects in 'os'.
534 </para>
535 <sect3><title>FcPatternHash</title><programlisting>
536 FcChar32 FcPatternHash (const FcPattern *p)
537 </programlisting><para>
538 Returns a 32-bit number which is the same for any two patterns which are
539 exactly alike.
540 </para>
541 <sect3><title>FcPatternAdd</title><programlisting>
542 FcBool FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append)
543 </programlisting><para>
544 Adds a single value to the list of values associated with the property named
545 `object'. If `append' is FcTrue, the value is added at the end of any
546 existing list, otherwise it is inserted at the begining. `value' is saved
547 (with FcValueSave) when inserted into the pattern so that the library
548 retains no reference to any application-supplied data structure.
549 </para>
550 <sect3><title>FcPatternAddWeak</title><programlisting>
551 FcBool FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append)
552 </programlisting><para>
553 FcPatternAddWeak is essentially the same as FcPatternAdd except that any
554 values added to the list have binding 'weak' instead of 'strong'.
555 </para>
556 <sect3><title>FcPatternAdd <emphasis>Type</emphasis></title><programlisting>
557 FcBool FcPatternAddInteger (FcPattern *p, const char *object, int i)
558 FcBool FcPatternAddDouble (FcPattern *p, const char *object, double d)
559 FcBool FcPatternAddString (FcPattern *p, const char *object, const char *s)
560 FcBool FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s)
561 FcBool FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c)
562 FcBool FcPatternAddBool (FcPattern *p, const char *object, FcBool b)
563 </programlisting><para>
564 These are all convenience functions that insert objects of the specified
565 type into the pattern. Use these in preference to FcPatternAdd as they
566 will provide compile-time typechecking. These all append values to
567 any existing list of values.
568 </para>
569 <sect3><title>FcPatternGet</title><programlisting>
570 FcResult FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
571 </programlisting><para>
572 Returns in `v' the `id'th value associated with the property `object'.
573 The value returned is not a copy, but rather refers to the data stored
574 within the pattern directly. Applications must not free this value.
575 </para>
576 <sect3><title>FcPatternGet <emphasis>Type</emphasis></title><programlisting>
577 FcResult FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
578 FcResult FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
579 FcResult FcPatternGetString (FcPattern *p, const char *object, int n, char **const s);
580 FcResult FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
581 FcResult FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
582 FcResult FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
583 </programlisting><para>
584 These are convenience functions that call FcPatternGet and verify that the
585 returned data is of the expected type. They return FcResultTypeMismatch if
586 this is not the case. Note that these (like FcPatternGet) do not make a
587 copy of any data structure referenced by the return value. Use these
588 in preference to FcPatternGet to provide compile-time typechecking.
589 </para>
590 <sect3><title>FcPatternBuild, FcPatternVaBuild</title><programlisting>
591 FcPattern *FcPatternBuild (FcPattern *orig, ...);
592 FcPattern *FcPatternVaBuild (FcPattern *orig, va_list va)
593 </programlisting><para>
594 Builds a pattern using a list of objects, types and values. Each
595 value to be entered in the pattern is specified with three arguments:
596 </para>
597 <orderedlist>
598 <listitem><para>
599 Object name, a string describing the property to be added.
600 </para></listitem><listitem><para>
601 Object type, one of the FcType enumerated values
602 </para></listitem><listitem><para>
603 Value, not an FcValue, but the raw type as passed to any of the
604 FcPatternAdd&lt;type&gt; functions. Must match the type of the second
605 argument.
606 </orderedlist>
607 <para>
608 The argument list is terminated by a null object name, no object type nor
609 value need be passed for this. The values are added to `pattern', if
610 `pattern' is null, a new pattern is created. In either case, the pattern is
611 returned. Example
612 </para>
613 <programlisting>
614 pattern = FcPatternBuild (0, FC_FAMILY, FtTypeString, "Times", (char *) 0);
615 </programlisting>
616 <para>
617 FcPatternVaBuild is used when the arguments are already in the form of a
618 varargs value.
619 </para>
620 <sect3><title>FcPatternDel</title><programlisting>
621 FcBool FcPatternDel (FcPattern *p, const char *object)
622 </programlisting><para>
623 Deletes all values associated with the property `object', returning
624 whether the property existed or not.
625 </para>
626 <sect3><title>FcPatternPrint</title><programlisting>
627 void FcPatternPrint (const FcPattern *p)
628 </programlisting><para>
629 Prints an easily readable version of the pattern to stdout. There is
630 no provision for reparsing data in this format, it's just for diagnostics
631 and debugging.
632 </para>
633 <sect3><title>FcDefaultSubstitute</title><programlisting>
634 void FcDefaultSubstitute (FcPattern *pattern)
635 </programlisting><para>
636 Supplies default values for underspecified font patterns:
637 <itemizedlist>
638 <listitem><para>
639 Patterns without a specified style or weight are set to Medium
640 </para></listitem>
641 <listitem><para>
642 Patterns without a specified style or slant are set to Roman
643 </para></listitem>
644 <listitem><para>
645 Patterns without a specified pixel size are given one computed from any
646 specified point size (default 12), dpi (default 75) and scale (default 1).
647 </para></listitem>
648 </itemizedlist>
649 </para>
650 <sect3><title>FcNameParse</title><programlisting>
651 FcPattern *FcNameParse (const char *name)
652 </programlisting><para>
653 Converts 'name' from the standard text format described above into a pattern.
654 </para>
655 <sect3><title>FcNameUnparse</title><programlisting>
656 FcChar8 *FcNameUnparse (FcPattern *pat)
657 </programlisting><para>
658 Converts the given pattern into the standard text format described above.
659 The return value is not static, but instead refers to newly allocated memory
660 which should be freed by the caller.
661 </para>
662 </sect2>
663 <sect2><title>FcFontSet</title>
664 <para>
665 An FcFontSet simply holds a list of patterns; these are used to return the
666 results of listing available fonts.
667 </para>
668 <sect3><title>FcFontSetCreate</title><programlisting>
669 FcFontSet *FcFontSetCreate (void)
670 </programlisting><para>
671 Creates an empty font set.
672 </para>
673 <sect3><title>FcFontSetDestroy</title><programlisting>
674 void FcFontSetDestroy (FcFontSet *s);
675 </programlisting><para>
676 Destroys a font set. Note that this destroys any referenced patterns as
677 well.
678 </para>
679 <sect3><title>FcFontSetAdd</title><programlisting>
680 FcBool FcFontSetAdd (FcFontSet *s, FcPattern *font)
681 </programlisting><para>
682 Adds a pattern to a font set. Note that the pattern is not copied before
683 being inserted into the set.
684 </para>
685 </sect2>
686 <sect2><title>FcObjectSet</title>
687 <para>
688 An FcObjectSet holds a list of pattern property names; it is used to
689 indiciate which properties are to be returned in the patterns from
690 FcFontList.
691 </para>
692 <sect3><title>FcObjectSetCreate</title><programlisting>
693 FcObjectSet *FcObjectSetCreate (void)
694 </programlisting><para>
695 Creates an empty set.
696 </para>
697 <sect3><title>FcObjectSetAdd</title><programlisting>
698 FcBool FcObjectSetAdd (FcObjectSet *os, const char *object)
699 </programlisting><para>
700 Adds a proprety name to the set.
701 </para>
702 <sect3><title>FcObjectSetDestroy</title><programlisting>
703 void FcObjectSetDestroy (FcObjectSet *os)
704 </programlisting><para>
705 Destroys an object set.
706 </para>
707 <sect3><title>FcObjectSetBuild, FcObjectSetVaBuild</title><programlisting>
708 FcObjectSet *FcObjectSetBuild (const char *first, ...)
709 FcObjectSet *FcObjectSetVaBuild (const char *first, va_list va)
710 </programlisting><para>
711 These build an object set from a null-terminated list of property names.
712 </para>
713 </sect2>
714 <sect2><title>FcObjectType</title>
715 <para>
716 Provides for applcation-specified font name object types so that new
717 pattern elements can be generated from font names.
718 </para>
719 <sect3><title>FcNameRegisterObjectTypes</title><programlisting>
720 FcBool FcNameRegisterObjectTypes (const FcObjectType *types, int ntype)
721 </programlisting><para>
722 Register 'ntype' new object types.
723 </para>
724 <sect3><title>FcNameUnregisterObjectTypes</title><programlisting>
725 FcBool FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype)
726 </programlisting><para>
727 Unregister 'ntype' object types.
728
729 <sect3><title>FcNameGetObjectType</title><programlisting>
730 const FcObjectType *FcNameGetObjectType (const char *object)
731 </programlisting><para>
732 Return the object type for the pattern element named 'object'.
733 </para>
734 </sect2>
735 <sect2><title>FcConstant</title>
736 <para>
737 Provides for application-specified symbolic constants for font names.
738 </para>
739 <sect3><title>FcNameRegisterConstants</title><programlisting>
740 FcBool FcNameRegisterConstants (const FcConstant *consts, int nconsts)
741 </programlisting><para>
742 Register 'nconsts' new symbolic constants.
743 </para>
744 <sect3><title>FcNameUnregisterConstants</title><programlisting>
745 FcBool FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
746 </programlisting><para>
747 Unregister 'nconsts' symbolic constants.
748
749 <sect3><title>FcNameGetConstant</title><programlisting>
750 const FcConstant *FcNameGetConstant (FcChar8 *string)
751 </programlisting><para>
752 Return the FcConstant structure related to symbolic constant 'string'.
753 </para>
754 <sect3><title>FcNameConstant</title><programlisting>
755 FcBool FcNameConstant (FcChar8 *string, int *result);
756 </programlisting><para>
757 Returns whether a symbolic constant with name 'string' is registered,
758 placing the value of the constant in 'result' if present.
759 </para>
760 </sect2>
761 <sect2><title>FcBlanks</title>
762 <para>
763 An FcBlanks object holds a list of Unicode chars which are expected to
764 be blank when drawn. When scanning new fonts, any glyphs which are
765 empty and not in this list will be assumed to be broken and not placed in
766 the FcCharSet associated with the font. This provides a significantly more
767 accurate CharSet for applications.
768 </para>
769 <sect3><title>FcBlanksCreate</title><programlisting>
770 FcBlanks *FcBlanksCreate (void)
771 </programlisting><para>
772 Creates an empty FcBlanks object.
773 </para>
774 <sect3><title>FcBlanksDestroy</title><programlisting>
775 void FcBlanksDestroy (FcBlanks *b)
776 </programlisting><para>
777 Destroys an FcBlanks object, freeing any associated memory.
778 </para>
779 <sect3><title>FcBlanksAdd</title><programlisting>
780 FcBool FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
781 </programlisting><para>
782 Adds a single character to an FcBlanks object, returning FcFalse
783 if this process ran out of memory.
784 </para>
785 <sect3><title>FcBlanksIsMember</title><programlisting>
786 FcBool FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
787 </programlisting><para>
788 Returns whether the specified FcBlanks object contains the indicated Unicode
789 value.
790 </para>
791 </sect2>
792 <sect2><title>FcConfig</title>
793 <para>
794 An FcConfig object holds the internal representation of a configuration.
795 There is a default configuration which applications may use by passing 0 to
796 any function using the data within an FcConfig.
797 </para>
798 <sect3><title>FcConfigCreate</title><programlisting>
799 FcConfig *FcConfigCreate (void)
800 </programlisting><para>
801 Creates an empty configuration.
802 </para>
803 <sect3><title>FcConfigDestroy</title><programlisting>
804 void FcConfigDestroy (FcConfig *config)
805 </programlisting><para>
806 Destroys a configuration and any data associated with it. Note that calling
807 this function with the return from FcConfigGetCurrent will place the library
808 in an indeterminate state.
809 </para>
810 <sect3><title>FcConfigSetCurrent</title><programlisting>
811 FcBool FcConfigSetCurrent (FcConfig *config)
812 </programlisting><para>
813 Sets the current default configuration to 'config'. Implicitly calls
814 FcConfigBuildFonts if necessary, returning FcFalse if that call fails.
815 </para>
816 <sect3><title>FcConfigGetCurrent</title><programlisting>
817 FcConfig *FcConfigGetCurrent (void)
818 </programlisting><para>
819 Returns the current default configuration.
820 </para>
821 <sect3><title>FcConfigUptoDate</title><programlisting>
822 FcBool FcConfigUptoDate (FcConfig *config)
823 </programlisting><para>
824 Checks all of the files related to 'config' and returns whether the
825 in-memory version is in sync with the disk version.
826 </para>
827 <sect3><title>FcConfigBuildFonts</title><programlisting>
828 FcBool FcConfigBuildFonts (FcConfig *config)
829 </programlisting><para>
830 Builds the set of available fonts for the given configuration. Note that
831 any changes to the configuration after this call have indeterminate effects.
832 Returns FcFalse if this operation runs out of memory.
833 </para>
834 <sect3><title>FcConfigGetConfigDirs</title><programlisting>
835 FcStrList *FcConfigGetConfigDirs (FcConfig *config)
836 </programlisting><para>
837 Returns the list of font directories specified in the configuration files
838 for 'config'. Does not include any subdirectories.
839 </para>
840 <sect3><title>FcConfigGetFontDirs</title><programlisting>
841 FcStrList *FcConfigGetFontDirs (FcConfig *config)
842 </programlisting><para>
843 Returns the list of font directories in 'config'. This includes the
844 configured font directories along with any directories below those in the
845 filesystem.
846 </para>
847 <sect3><title>FcConfigGetConfigFiles</title><programlisting>
848 FcStrList *FcConfigGetConfigFiles (FcConfig *config)
849 </programlisting><para>
850 Returns the list of known configuration files used to generate 'config'.
851 Note that this will not include any configuration done with FcConfigParse.
852 </para>
853 <sect3><title>FcConfigGetCache</title><programlisting>
854 char *FcConfigGetCache (FcConfig *config)
855 </programlisting><para>
856 Returns the name of the file used to store per-user font information.
857 </para>
858 <sect3><title>FcConfigGetFonts</title><programlisting>
859 FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set)
860 </programlisting><para>
861 Returns one of the two sets of fonts from the configuration as specified
862 by 'set'.
863 </para>
864 <sect3><title>FcConfigGetBlanks</title><programlisting>
865 FcBlanks *FcConfigGetBlanks (FcConfig *config)
866 </programlisting><para>
867 Returns the FcBlanks object associated with the given configuration, if no
868 blanks were present in the configuration, this function will return 0.
869 </para>
870 <sect3><title>FcConfigGetRescanInverval</title><programlisting>
871 int FcConfigGetRescanInverval (FcConfig *config)
872 </programlisting><para>
873 Returns the interval between automatic checks of the configuration (in
874 seconds) specified in 'config'. The configuration is checked during
875 a call to FcFontList when this interval has passed since the last check.
876 </para>
877 <sect3><title>FcConfigSetRescanInverval</title><programlisting>
878 FcBool FcConfigSetRescanInverval (FcConfig *config, int rescanInterval)
879 </programlisting><para>
880 Sets the rescan interval; returns FcFalse if an error occurred.
881 </para>
882 <sect3><title>FcConfigAppFontAddFile</title><programlisting>
883 FcBool FcConfigAppFontAddFile (FcConfig *config, const char *file)
884 </programlisting><para>
885 Adds an application-specific font to the configuration.
886 </para>
887 <sect3><title>FcConfigAppFontAddDir</title><programlisting>
888 FcBool FcConfigAppFontAddDir (FcConfig *config, const char *dir)
889 </programlisting><para>
890 Scans the specified directory for fonts, adding each one found to the
891 application-specific set of fonts.
892 </para>
893 <sect3><title>FcConfigAppFontClear</title><programlisting>
894 void FcConfigAppFontClear (FcConfig *config)
895 </programlisting><para>
896 Clears the set of application-specific fonts.
897 </para>
898 <sect3><title>FcConfigSubstituteWithPat</title><programlisting>
899 FcBool FcConfigSubstituteWithPat (FcConfig *config, FcPattern *p, FcPattern *p_pat FcMatchKind kind)
900 </programlisting><para>
901 Performs the sequence of pattern modification operations, if 'kind' is
902 FcMatchPattern, then those tagged as pattern operations are applied, else
903 if 'kind' is FcMatchFont, those tagged as font operations are applied and
904 p_pat is used for &lt;test&gt; elements with target=pattern.
905 </para>
906 <sect3><title>FcConfigSubstitute</title><programlisting>
907 FcBool FcConfigSubstitute (FcConfig *config, FcPattern *p, FcMatchKind kind)
908 </programlisting><para>
909 Calls FcConfigSubstituteWithPat setting p_pat to NULL.
910 </para>
911 <sect3><title>FcFontMatch</title><programlisting>
912 FcPattern *FcFontMatch (FcConfig *config, FcPattern *p, FcResult *result)
913 </programlisting><para>
914 Returns the font in 'config' most close matching 'p'. This function
915 should be called only after FcConfigSubstitute and FcDefaultSubstitute have
916 been called for 'p'; otherwise the results will not be correct.
917 </para>
918 <sect3><title>FcFontSort</title><programlisting>
919 FcFontSet *FcFontSort (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result)
920 </programlisting><para>
921 Returns the list of fonts sorted by closeness to 'p'. If 'trim' is FcTrue,
922 elements in the list which don't include Unicode coverage not provided by
923 earlier elements in the list are elided. The union of Unicode coverage of
924 all of the fonts is returned in 'csp', if 'csp' is not NULL. This function
925 should be called only after FcConfigSubstitute and FcDefaultSubstitute have
926 been called for 'p'; otherwise the results will not be correct.
927 </para><para>
928 The returned FcFontSet references FcPattern structures which may be shared
929 by the return value from multiple FcFontSort calls, applications must not
930 modify these patterns. Instead, they should be passed, along with 'p' to
931 FcFontRenderPrepare which combines them into a complete pattern.
932 </para><para>
933 The FcFontSet returned by FcFontSort is destroyed by caling FcFontSetDestroy.
934 </para>
935 <sect3><title>FcFontRenderPrepare</title><programlisting>
936 FcPattern *FcFontRenderPrepare (FcConfig *config, FcPattern *pat, FcPattern *font)
937 </programlisting><para>
938 Creates a new pattern consisting of elements of 'font' not appearing
939 in 'pat', elements of 'pat' not appearing in 'font' and the best matching
940 value from 'pat' for elements appearing in both. The result is passed to
941 FcConfigSubstitute with 'kind' FcMatchFont and then returned.
942 </para>
943 <sect3><title>FcFontList</title><programlisting>
944 FcFontSet *FcFontList (FcConfig *config, FcPattern *p, FcObjectSet *os)
945 </programlisting><para>
946 Selects fonts matching 'p', creates patterns from those fonts containing
947 only the objects in 'os' and returns the set of unique such patterns.
948 </para>
949 <sect3><title>FcConfigFilename</title><programlisting>
950 char *FcConfigFilename (const char *name)
951 </programlisting><para>
952 Given the specified external entity name, return the associated filename.
953 This provides applications a way to convert various configuration file
954 references into filename form.
955 </para><para>
956 A null or empty 'name' indicates that the default configuration file should
957 be used; which file this references can be overridden with the
958 FC_CONFIG_FILE environment variable. Next, if the name starts with '~', it
959 refers to a file in the current users home directory. Otherwise if the name
960 doesn't start with '/', it refers to a file in the default configuration
961 directory; the built-in default directory can be overridden with the
962 FC_CONFIG_DIR environment variable.
963 </para>
964 </sect2>
965 <sect2><title>Initialization</title>
966 <para>
967 These functions provide some control over how the library is initialized.
968 </para>
969 <sect3><title>FcInitLoadConfig</title><programlisting>
970 FcConfig *FcInitLoadConfig (void)
971 </programlisting><para>
972 Loads the default configuration file and returns the resulting configuration.
973 Does not load any font information.
974 </para>
975 <sect3><title>FcInitLoadConfigAndFonts</title><programlisting>
976 FcConfig *FcInitLoadConfigAndFonts (void)
977 </programlisting><para>
978 Loads the default configuration file and builds information about the
979 available fonts. Returns the resulting configuration.
980 </para>
981 <sect3><title>FcInit</title><programlisting>
982 FcBool FcInit (void)
983 </programlisting><para>
984 Loads the default configuration file and the fonts referenced therein and
985 sets the default configuration to that result. Returns whether this
986 process succeeded or not. If the default configuration has already
987 been loaded, this routine does nothing and returns FcTrue.
988 </para>
989 <sect3><title>FcGetVersion</title><programlisting>
990 int FcGetVersion (void)
991 </programlisting><para>
992 Returns the version number of the library.
993 </para>
994 <sect3><title>FcInitReinitialize</title><programlisting>
995 FcBool FcInitReinitialize (void)
996 </programlisting><para>
997 Forces the default configuration file to be reloaded and resets the default
998 configuration.
999 </para>
1000 <sect3><title>FcInitBringUptoDate</title><programlisting>
1001 FcBool FcInitBringUptoDate (void)
1002 </programlisting><para>
1003 Checks the rescan interval in the default configuration, checking the
1004 configuration if the interval has passed and reloading the configuration if
1005 when any changes are detected.
1006 </para>
1007 </sect2>
1008 <sect2><title>FcAtomic</title>
1009 <para>
1010 These functions provide a safe way to update config files, allowing ongoing
1011 reading of the old config file while locked for writing and ensuring that a
1012 consistent and complete version of the config file is always available.
1013 </para>
1014 <sect3><title>FcAtomicCreate</title><programlisting>
1015 FcAtomic * FcAtomicCreate (const FcChar8 *file)
1016 </programlisting><para>
1017 Creates a data structure containing data needed to control access to 'file'.
1018 Writing is done to a separate file. Once that file is complete, the original
1019 configuration file is atomically replaced so that reading process always see
1020 a consistent and complete file without the need to lock for reading.
1021 </para>
1022 <sect3><title>FcAtomicLock</title><programlisting>
1023 FcBool FcAtomicLock (FcAtomic *atomic)
1024 </programlisting><para>
1025 Attempts to lock the file referenced by 'atomic'. Returns FcFalse if the
1026 file is locked by another process, else returns FcTrue and leaves the file
1027 locked.
1028 </para>
1029 <sect3><title>FcAtomicNewFile</title><programlisting>
1030 FcChar8 *FcAtomicNewFile (FcAtomic *atomic)
1031 </programlisting><para>
1032 Returns the filename for writing a new version of the file referenced
1033 by 'atomic'.
1034 </para>
1035 <sect3><title>FcAtomicOrigFile</title><programlisting>
1036 FcChar8 *FcAtomicOrigFile (FcAtomic *atomic)
1037 </programlisting><para>
1038 Returns the file refernced by 'atomic'.
1039 </para>
1040 <sect3><title>FcAtomicReplaceOrig</title><programlisting>
1041 FcBool FcAtomicReplaceOrig (FcAtomic *atomic)
1042 </programlisting><para>
1043 Replaces the original file referenced by 'atomic' with the new file.
1044 </para>
1045 <sect3><title>FcAtomicDeleteNew</title><programlisting>
1046 void FcAtomicDeleteNew (FcAtomic *atomic)
1047 </programlisting><para>
1048 Deletes the new file.
1049 </para>
1050 <sect3><title>FcAtomicUnlock</title><programlisting>
1051 void FcAtomicUnlock (FcAtomic *atomic)
1052 </programlisting><para>
1053 Unlocks the file.
1054 </para>
1055 <sect3><title>FcAtomicDestroy</title><programlisting>
1056 void FcAtomicDestroy (FcAtomic *atomic)
1057 </programlisting><para>
1058 Destroys 'atomic'.
1059 </para>
1060 </sect2>
1061 <sect2><title>FreeType specific functions</title>
1062 <para>
1063 <programlisting>
1064 #include &lt;fontconfig/fcfreetype.h&gt;
1065 </programlisting>
1066 While the fontconfig library doesn't insist that FreeType be used as the
1067 rasterization mechanism for fonts, it does provide some convenience
1068 functions.
1069 </para>
1070 <sect3><title>FcFreeTypeCharIndex</title><programlisting>
1071 FT_UInt FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4)
1072 </programlisting><para>
1073 Maps a Unicode char to a glyph index. This function uses information from
1074 several possible underlying encoding tables to work around broken fonts.
1075 As a result, this function isn't designed to be used in performance
1076 sensitive areas; results from this function are intended to be cached by
1077 higher level functions.
1078 </para>
1079 <sect3><title>FcFreeTypeCharSet</title><programlisting>
1080 FcCharSet *FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks) Scans a
1081 </programlisting><para>
1082 FreeType face and returns the set of encoded Unicode chars. This scans
1083 several encoding tables to build as complete a list as possible.
1084 If 'blanks' is not 0, the glyphs in the font are examined and any blank glyphs
1085 not in 'blanks' are not placed in the returned FcCharSet.
1086 </para>
1087 <sect3><title>FcFreeTypeQuery</title><programlisting>
1088 FcPattern *FcFreeTypeQuery (const char *file, int id, FcBlanks *blanks, int *count)
1089 </programlisting><para>
1090 Constructs a pattern representing the 'id'th font in 'file'. The number
1091 of fonts in 'file' is returned in 'count'.
1092 </para>
1093 </sect2>
1094 <sect2><title>XML specific functions</title>
1095 <sect3><title>FcConfigParseAndLoad</title><programlisting>
1096 FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain)
1097 </programlisting><para>
1098 Walks the configuration in 'file' and constructs the internal representation
1099 in 'config'. Any include files referenced from within 'file' will be loaded
1100 with FcConfigLoad and also parsed. If 'complain' is FcFalse, no warning
1101 will be displayed if 'file' does not exist.
1102 </para>
1103 </sect2>
1104 <sect2><title>File and Directory routines</title>
1105 <sect3><title>FcFileScan</title><programlisting>
1106 FcBool FcFileScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *file, FcBool force)
1107 </programlisting><para>
1108 Scans a single file and adds all fonts found to 'set'. If 'force' is FcTrue,
1109 then the file is scanned even if associated information is found in 'cache'.
1110 If 'file' is a directory, it is added to 'dirs'.
1111 </para>
1112 <sect3><title>FcDirScan</title><programlisting>
1113 FcBool FcDirScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *dir, FcBool force)
1114 </programlisting><para>
1115 Scans an entire directory and adds all fonts found to 'set'. If 'force' is
1116 FcTrue, then the directory and all files within it are scanned even if
1117 information is present in the per-directory cache file or 'cache'. Any
1118 subdirectories found are added to 'dirs'.
1119 </para>
1120 <sect3><title>FcDirSave</title><programlisting>
1121 FcBool FcDirSave (FcFontSet *set, FcStrSet *dirs, const char *dir)
1122 </programlisting><para>
1123 Creates the per-directory cache file for 'dir' and populates it with the
1124 fonts in 'set' and subdirectories in 'dirs'.
1125 </para>
1126 <sect3><title>FcDirCacheValid</title><programlisting>
1127 FcBool FcDirCacheValid (const FcChar8 *cache_file)
1128 </programlisting><para>
1129 Returns FcTrue if 'cache_file' is no older than the directory containing it,
1130 else FcFalse.
1131 </para>
1132 </sect2>
1133 <sect2><title>FcStrSet and FcStrList</title>
1134 <para>
1135 A data structure for enumerating strings, used to list directories while
1136 scanning the configuration as directories are added while scanning.
1137 </para>
1138 <sect3><title>FcStrSetCreate</title><programlisting>
1139 FcStrSet *FcStrSetCreate (void)
1140 </programlisting><para>
1141 Create an empty set.
1142 </para>
1143 <sect3><title>FcStrSetMember</title><programlisting>
1144 FcBool FcStrSetMember (FcStrSet *set, const FcChar8 *s)
1145 </programlisting><para>
1146 Returns whether 's' is a member of 'set'.
1147 </para>
1148 <sect3><title>FcStrSetAdd</title><programlisting>
1149 FcBool FcStrSetAdd (FcStrSet *set, const FcChar8 *s)
1150 </programlisting><para>
1151 Adds a copy of 's' to 'set'.
1152 </para>
1153 <sect3><title>FcStrSetAddFilename</title><programlisting>
1154 FcBool FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
1155 </programlisting><para>
1156 Adds a copy 's' to 'set', The copy is created with FcStrCopyFilename
1157 so that leading '~' values are replaced with the value of the HOME
1158 environment variable.
1159 </para>
1160 <sect3><title>FcStrSetDel</title><programlisting>
1161 FcBool FcStrSetDel (FcStrSet *set, const FcChar8 *s)
1162 </programlisting><para>
1163 Removes 's' from 'set', returning FcTrue if 's' was a member else FcFalse.
1164 </para>
1165 <sect3><title>FcStrSetDestroy</title><programlisting>
1166 void FcStrSetDestroy (FcStrSet *set)
1167 </programlisting><para>
1168 Destroys 'set'.
1169 </para>
1170 <sect3><title>FcStrListCreate</title><programlisting>
1171 FcStrList *FcStrListCreate (FcStrSet *set)
1172 </programlisting><para>
1173 Creates an enumerator to list the strings in 'set'.
1174 </para>
1175 <sect3><title>FcStrListNext</title><programlisting>
1176 FcChar8 *FcStrListNext (FcStrList *list)
1177 </programlisting><para>
1178 Returns the next string in 'set'.
1179 </para>
1180 <sect3><title>FcStrListDone</title><programlisting>
1181 void FcStrListDone (FcStrList *list)
1182 </programlisting><para>
1183 Destroys the enumerator 'list'.
1184 </para>
1185 </sect2>
1186 <sect2><title>String utilities</title>
1187 <sect3><title>FcUtf8ToUcs4</title>
1188 <programlisting>
1189 int FcUtf8ToUcs4 (FcChar8 *src, FcChar32 *dst, int len)
1190 </programlisting>
1191 <para>
1192 Converts the next Unicode char from 'src' into 'dst' and returns the number
1193 of bytes containing the char. 'src' nust be at least 'len' bytes long.
1194 </para>
1195 </sect3>
1196 <sect3><title>FcUcs4ToUtf8</title><programlisting>
1197 int FcUcs4ToUtf8 (FcChar32 src, FcChar8 dst[FC_UTF8_MAX_LEN])
1198 </programlisting><para>
1199 Converts the Unicode char from 'src' into 'dst' and returns the
1200 number of bytes needed to encode the char.
1201 </para></sect3>
1202 <sect3><title>FcUtf8Len</title><programlisting>
1203 FcBool FcUtf8Len (FcChar8 *src, int len, int *nchar, int *wchar)
1204 </programlisting><para>
1205 Counts the number of Unicode chars in 'len' bytes of 'src'. Places that
1206 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
1207 bytes needed to hold the largest unicode char counted. The return value
1208 indicates whether 'src' is a well-formed UTF8 string.
1209 </para></sect3>
1210 <sect3><title>FcUtf16ToUcs4</title><programlisting>
1211 int FcUtf16ToUcs4 (FcChar8 *src, FcEndian endian, FcChar32 *dst, int len)
1212 </programlisting><para>
1213 Converts the next Unicode char from 'src' into 'dst' and returns the
1214 number of bytes containing the char. 'src' must be at least 'len' bytes
1215 long. Bytes of 'src' are combined into 16-bit units according to 'endian'.
1216 </para></sect3>
1217 <sect3><title>FcUtf16Len</title><programlisting>
1218 FcBool FcUtf16Len (FcChar8 *src, FcEndian endian, int len, int *nchar, int *wchar)
1219 </programlisting><para>
1220 Counts the number of Unicode chars in 'len' bytes of 'src'. Bytes of 'src'
1221 are combined into 16-bit units according to 'endian'. Places that
1222 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
1223 bytes needed to hold the largest unicode char counted. The return value
1224 indicates whether 'string' is a well-formed UTF16 string.
1225 </para></sect3>
1226 <sect3><title>FcStrCopy</title><programlisting>
1227 FcChar8 *FcStrCopy (const FcChar8 *s)
1228 </programlisting><para>
1229 Allocates memory, copies 's' and returns the resulting buffer. Yes, this
1230 is 'strdup', but that function isn't available on every platform.
1231 </para></sect3>
1232 <sect3><title>FcStrCopyFilename</title><programlisting>
1233 FcChar8 *FcStrCopyFilename (const FcChar8 *s)
1234 </programlisting><para>
1235 Just like FcStrCopy except that it converts any leading '~' characters
1236 in 's' to the value of the HOME environment variable.
1237
1238 <sect3><title>FcStrCmpIgnoreCase</title><programlisting>
1239 int FcStrCmpIgnoreCase (const char *s1, const char *s2)
1240 </programlisting><para>
1241 Returns the usual &lt;0, 0, &gt;0 result of comparing 's1' and 's2'. This test
1242 is case-insensitive in the ASCII range and will operate properly with UTF8
1243 encoded strings, although it does not check for well formed strings.
1244 </para></sect3>
1245 <sect3><title>FcStrDirname</title><programlisting>
1246 FcChar8 *FcStrDirname (const FcChar8 *file)
1247 </programlisting><para>
1248 Returns the directory containing 'file'.
1249 </para></sect3>
1250 <sect3><title>FcStrBasename</title><programlisting>
1251 FcChar8 *FcStrBasename (const FcChar8 *file)
1252 </programlisting><para>
1253 Returns the filename of 'file' stripped of any leading directory names.
1254 </para></sect3>
1255 </sect2>
1256 </sect1>
1257 </article>