]> git.wh0rd.org - fontconfig.git/blob - doc/fontconfig-devel.sgml
Add lots more function documentation
[fontconfig.git] / doc / fontconfig-devel.sgml
1 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
2 <!ENTITY fcmatrix SYSTEM "fcmatrix.sgml">
3 <!ENTITY fccharset SYSTEM "fccharset.sgml">
4 <!ENTITY fcvalue SYSTEM "fcvalue.sgml">
5 <!ENTITY fcpattern SYSTEM "fcpattern.sgml">
6 <!ENTITY fcfontset SYSTEM "fcfontset.sgml">
7 <!ENTITY fcobjectset SYSTEM "fcobjectset.sgml">
8 <!ENTITY fcobjecttype SYSTEM "fcobjecttype.sgml">
9 <!ENTITY fcconstant SYSTEM "fcconstant.sgml">
10 <!ENTITY fcblanks SYSTEM "fcblanks.sgml">
11 <!ENTITY fcconfig SYSTEM "fcconfig.sgml">
12 ]>
13 <!--
14 $Id$
15
16 Copyright © 2002 Keith Packard
17
18 Permission to use, copy, modify, distribute, and sell this software and its
19 documentation for any purpose is hereby granted without fee, provided that
20 the above copyright notice appear in all copies and that both that
21 copyright notice and this permission notice appear in supporting
22 documentation, and that the name of Keith Packard not be used in
23 advertising or publicity pertaining to distribution of the software without
24 specific, written prior permission. Keith Packard makes no
25 representations about the suitability of this software for any purpose. It
26 is provided "as is" without express or implied warranty.
27
28 KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
29 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
30 EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
31 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
32 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34 PERFORMANCE OF THIS SOFTWARE.
35 -->
36 <article>
37 <title>Fontconfig Developers Reference</title>
38 <artheader>
39 <author>
40 <firstname>Keith</firstname>
41 <surname>Packard</surname>
42 <affiliation><orgname>
43 HP Cambridge Research Lab
44 </orgname></affiliation>
45 </author>
46 <authorinitials>KRP</authorinitials>
47 <productname>Fontconfig</productname>
48 <productnumber>2.1.91</productnumber>
49 <LegalNotice>
50 <simpara>
51 Copyright © 2002 Keith Packard
52 </simpara><simpara>
53 Permission to use, copy, modify, distribute, and sell this software and its
54 documentation for any purpose is hereby granted without fee, provided that
55 the above copyright notice appear in all copies and that both that
56 copyright notice and this permission notice appear in supporting
57 documentation, and that the name of Keith Packard not be used in
58 advertising or publicity pertaining to distribution of the software without
59 specific, written prior permission. Keith Packard makes no
60 representations about the suitability of this software for any purpose. It
61 is provided "as is" without express or implied warranty.
62 </simpara><simpara>
63 KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
64 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
65 EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
66 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
67 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
68 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
69 PERFORMANCE OF THIS SOFTWARE.
70 </simpara>
71 </LegalNotice>
72 </artheader>
73 <!--
74 <refsynopsisdiv>
75 <synopsis>
76 #include &lt;fontconfig/fontconfig.h&gt;
77 #include &lt;fontconfig/fcfreetype.h&gt;
78 </synopsis>
79 </refsynopsisdiv>
80 -->
81 <sect1><title>DESCRIPTION</title>
82 <para>
83 Fontconfig is a library designed to provide system-wide font configuration,
84 customization and application access.
85 </para>
86 </sect1>
87 <sect1><title>FUNCTIONAL OVERVIEW</title>
88 <para>
89 Fontconfig contains two essential modules, the configuration module which
90 builds an internal configuration from XML files and the matching module
91 which accepts font patterns and returns the nearest matching font.
92 </para>
93 <sect2><title>FONT CONFIGURATION</title>
94 <para>
95 The configuration module consists of the FcConfig datatype, libexpat and
96 FcConfigParse which walks over an XML tree and ammends a configuration with
97 data found within. From an external perspective, configuration of the
98 library consists of generating a valid XML tree and feeding that to
99 FcConfigParse. The only other mechanism provided to applications for
100 changing the running configuration is to add fonts and directories to the
101 list of application-provided font files.
102 </para><para>
103 The intent is to make font configurations relatively static, and shared by
104 as many applications as possible. It is hoped that this will lead to more
105 stable font selection when passing names from one application to another.
106 XML was chosen as a configuration file format because it provides a format
107 which is easy for external agents to edit while retaining the correct
108 structure and syntax.
109 </para><para>
110 Font configuration is separate from font matching; applications needing to
111 do their own matching can access the available fonts from the library and
112 perform private matching. The intent is to permit applications to pick and
113 choose appropriate functionality from the library instead of forcing them to
114 choose between this library and a private configuration mechanism. The hope
115 is that this will ensure that configuration of fonts for all applications
116 can be centralized in one place. Centralizing font configuration will
117 simplify and regularize font installation and customization.
118 </para>
119 </sect2>
120 <sect2>
121 <title>FONT PROPERTIES</title>
122 <para>
123 While font patterns may contain essentially any properties, there are some
124 well known properties with associated types. Fontconfig uses some of these
125 properties for font matching and font completion. Others are provided as a
126 convenience for the applications rendering mechanism.
127 </para>
128 <programlisting>
129 Property Definitions
130
131 Property CPP Symbol Type Description
132 ----------------------------------------------------
133 family FC_FAMILY String Font family name
134 style FC_STYLE String Font style. Overrides weight
135 and slant
136 slant FC_SLANT Int Italic, oblique or roman
137 weight FC_WEIGHT Int Light, medium, demibold,
138 bold or black
139 size FC_SIZE Double Point size
140 aspect FC_ASPECT Double Stretches glyphs horizontally
141 before hinting
142 pixelsize FC_PIXEL_SIZE Double Pixel size
143 spacing FC_SPACING Int Proportional, monospace or
144 charcell
145 foundry FC_FOUNDRY String Font foundry name
146 antialias FC_ANTIALIAS Bool Whether glyphs can be
147 antialiased
148 hinting FC_HINTING Bool Whether the rasterizer should
149 use hinting
150 verticallayout FC_VERTICAL_LAYOUT Bool Use vertical layout
151 autohint FC_AUTOHINT Bool Use autohinter instead of
152 normal hinter
153 globaladvance FC_GLOBAL_ADVANCE Bool Use font global advance data
154 file FC_FILE String The filename holding the font
155 index FC_INDEX Int The index of the font within
156 the file
157 ftface FC_FT_FACE FT_Face Use the specified FreeType
158 face object
159 rasterizer FC_RASTERIZER String Which rasterizer is in use
160 outline FC_OUTLINE Bool Whether the glyphs are outlines
161 scalable FC_SCALABLE Bool Whether glyphs can be scaled
162 scale FC_SCALE Double Scale factor for point->pixel
163 conversions
164 dpi FC_DPI Double Target dots per inch
165 rgba FC_RGBA Int unknown, rgb, bgr, vrgb,
166 vbgr, none - subpixel geometry
167 minspace FC_MINSPACE Bool Eliminate leading from line
168 spacing
169 charset FC_CHARSET CharSet Unicode chars encoded by
170 the font
171 lang FC_LANG String List of RFC-3066-style
172 languages this font supports
173 </programlisting>
174 </sect2>
175 </sect1>
176 <sect1><title>DATATYPES</title>
177 <para>
178 Fontconfig uses abstract datatypes to hide internal implementation details
179 for most data structures. A few structures are exposed where appropriate.
180 </para>
181 <variablelist>
182 <varlistentry>
183 <term>FcChar8<term>
184 <term>FcChar16<term>
185 <term>FcChar32<term>
186 <term>FcBool</term>
187 <listitem>
188 <para>
189 These are primitive datatypes; the FcChar* types hold precisely the number
190 of bits stated (if supported by the C implementation). FcBool holds
191 one of two CPP symbols: FcFalse or FcTrue.
192 </para>
193 </listitem></varlistentry>
194 <varlistentry><term>FcMatrix</term><listitem>
195 <para>
196 An FcMatrix holds an affine transformation, usually used to reshape glyphs.
197 A small set of matrix operations are provided to manipulate these.
198 <programlisting>
199 typedef struct _FcMatrix {
200 double xx, xy, yx, yy;
201 } FcMatrix;
202 </programlisting>
203 </para>
204 </listitem></varlistentry>
205 <varlistentry><term>FcCharSet</term><listitem>
206 <para>
207 An FcCharSet is an abstract type that holds the set of encoded unicode chars
208 in a font. Operations to build and compare these sets are provided.
209 </para>
210 </listitem></varlistentry>
211 <varlistentry><term>FcType</term><listitem>
212 <para>
213 Tags the kind of data stored in an FcValue.
214 </para>
215 </listitem></varlistentry>
216 <varlistentry><term>FcValue</term><listitem>
217 <para>
218 An FcValue object holds a single value with one of a number of different
219 types. The 'type' tag indicates which member is valid.
220 <programlisting>
221 typedef struct _FcValue {
222 FcType type;
223 union {
224 const FcChar8 *s;
225 int i;
226 FcBool b;
227 double d;
228 const FcMatrix *m;
229 const FcCharSet *c;
230 } u;
231 } FcValue;
232 </programlisting>
233 <programlisting>
234 FcValue Members
235
236 Type Union member Datatype
237 --------------------------------
238 FcTypeVoid (none) (none)
239 FcTypeInteger i int
240 FcTypeDouble d double
241 FcTypeString s char *
242 FcTypeBool b b
243 FcTypeMatrix m FcMatrix *
244 FcTypeCharSet c FcCharSet *
245 </programlisting>
246 </para>
247 </listitem></varlistentry>
248 <varlistentry><term>FcPattern</term><listitem>
249 <para>
250 holds a set of names with associated value lists; each name refers to a
251 property of a font. FcPatterns are used as inputs to the matching code as
252 well as holding information about specific fonts. Each property can hold
253 one or more values; conventionally all of the same type, although the
254 interface doesn't demand that.
255 </para>
256 </listitem></varlistentry>
257 <varlistentry><term>FcFontSet</term><listitem>
258 <para>
259 <programlisting>
260 typedef struct _FcFontSet {
261 int nfont;
262 int sfont;
263 FcPattern **fonts;
264 } FcFontSet;
265 </programlisting>
266 An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this
267 data structure to hold sets of fonts. Externally, fontconfig returns the
268 results of listing fonts in this format. 'nfont' holds the number of
269 patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
270 array.
271 </para>
272 </listitem></varlistentry>
273 <varlistentry><term>FcStrSet</term><term>FcStrList</term><listitem>
274 <para>
275 FcStrSet holds a list of strings that can be appended to and enumerated.
276 Its unique characteristic is that the enumeration works even while strings
277 are appended during enumeration. FcStrList is used during enumeration to
278 safely and correctly walk the list of strings even while that list is edited
279 in the middle of enumeration.
280 </para>
281 </listitem></varlistentry>
282 <varlistentry><term>FcObjectSet</term><listitem>
283 <para>
284 <programlisting>
285 typedef struct _FcObjectSet {
286 int nobject;
287 int sobject;
288 const char **objects;
289 } FcObjectSet;
290 </programlisting>
291 holds a set of names and is used to specify which fields from fonts are
292 placed in the the list of returned patterns when listing fonts.
293 </para>
294 </listitem></varlistentry>
295 <varlistentry><term>FcObjectType</term><listitem>
296 <para>
297 <programlisting>
298 typedef struct _FcObjectType {
299 const char *object;
300 FcType type;
301 } FcObjectType;
302 </programlisting>
303 marks the type of a pattern element generated when parsing font names.
304 Applications can add new object types so that font names may contain the new
305 elements.
306 </para>
307 </listitem></varlistentry>
308 <varlistentry><term>FcConstant</term><listitem>
309 <para>
310 <programlisting>
311 typedef struct _FcConstant {
312 const FcChar8 *name;
313 const char *object;
314 int value;
315 } FcConstant;
316 </programlisting>
317 Provides for symbolic constants for new pattern elements. When 'name' is
318 seen in a font name, an 'object' element is created with value 'value'.
319 </para>
320 </listitem></varlistentry>
321 <varlistentry><term>FcBlanks</term><listitem>
322 <para>
323 holds a list of Unicode chars which are expected to be blank; unexpectedly
324 blank chars are assumed to be invalid and are elided from the charset
325 associated with the font.
326 </para>
327 </listitem></varlistentry>
328 <varlistentry><term>FcFileCache</term><listitem>
329 <para>
330 holds the per-user cache information for use while loading the font
331 database. This is built automatically for the current configuration when
332 that is loaded. Applications must always pass '0' when one is requested.
333 </para>
334 </listitem></varlistentry>
335 <varlistentry><term>FcConfig</term><listitem>
336 <para>
337 holds a complete configuration of the library; there is one default
338 configuration, other can be constructed from XML data structures. All
339 public entry points that need global data can take an optional FcConfig*
340 argument; passing 0 uses the default configuration. FcConfig objects hold two
341 sets of fonts, the first contains those specified by the configuration, the
342 second set holds those added by the application at run-time. Interfaces
343 that need to reference a particulat set use one of the FcSetName enumerated
344 values.
345 </para>
346 </listitem></varlistentry>
347 <varlistentry><term>FcSetName</term><listitem>
348 <para>
349 Specifies one of the two sets of fonts available in a configuration;
350 FcSetSystem for those fonts specified in the configuration and
351 FcSetApplication which holds fonts provided by the application.
352 </para>
353 </listitem></varlistentry>
354 <varlistentry><term>FcResult</term><listitem>
355 <para>
356 Used as a return type for functions manipulating FcPattern objects.
357 <programlisting>
358 FcResult Values
359 Result Code Meaning
360 -----------------------------------------------------------
361 FcResultMatch Object exists with the specified ID
362 FcResultNoMatch Object doesn't exist at all
363 FcResultTypeMismatch Object exists, but the type doesn't match
364 FcResultNoId Object exists, but has fewer values
365 than specified
366 </programlisting>
367 </para>
368 </listitem></varlistentry>
369 <varlistentry><term>FcAtomic</term><listitem>
370 <para>
371 Used for locking access to config files. Provides a safe way to update
372 configuration files.
373 </para>
374 </listitem></varlistentry>
375 </variablelist>
376 </sect1>
377 <sect1><title>FUNCTIONS</title>
378 <para>
379 Functions are grouped by the main datatype involved
380 </para>
381 <sect2><title>FcMatrix</title>
382 <para>
383 FcMatrix structures hold an affine transformation in matrix form.
384 </para>
385 &fcmatrix;
386 </sect2>
387 <sect2><title>FcCharSet</title>
388 <para>
389 An FcCharSet is a boolean array indicating a set of unicode chars. Those
390 associated with a font are marked constant and cannot be edited.
391 FcCharSets may be reference counted internally to reduce memory consumption;
392 this may be visible to applications as the result of FcCharSetCopy may
393 return it's argument, and that CharSet may remain unmodifiable.
394 </para>
395 &fccharset;
396 </sect2>
397 <sect2><title>FcValue</title>
398 <para>
399 FcValue is a structure containing a type tag and a union of all possible
400 datatypes. The tag is an enum of type
401 <emphasis>FcType</emphasis>
402 and is intended to provide a measure of run-time
403 typechecking, although that depends on careful programming.
404 </para>
405 &fcvalue;
406 </sect2>
407 <sect2><title>FcPattern</title>
408 <para>
409 An FcPattern is an opaque type that holds both patterns to match against the
410 available fonts, as well as the information about each font.
411 </para>
412 &fcpattern;
413 </sect2>
414 <sect2><title>FcFontSet</title>
415 <para>
416 An FcFontSet simply holds a list of patterns; these are used to return the
417 results of listing available fonts.
418 </para>
419 &fcfontset;
420 </sect2>
421 <sect2><title>FcObjectSet</title>
422 <para>
423 An FcObjectSet holds a list of pattern property names; it is used to
424 indiciate which properties are to be returned in the patterns from
425 FcFontList.
426 </para>
427 &fcobjectset;
428 </sect2>
429 <sect2><title>FcObjectType</title>
430 <para>
431 Provides for applcation-specified font name object types so that new
432 pattern elements can be generated from font names.
433 </para>
434 &fcobjecttype;
435 </sect2>
436 <sect2><title>FcConstant</title>
437 <para>
438 Provides for application-specified symbolic constants for font names.
439 </para>
440 &fcconstant;
441 </sect2>
442 <sect2><title>FcBlanks</title>
443 <para>
444 An FcBlanks object holds a list of Unicode chars which are expected to
445 be blank when drawn. When scanning new fonts, any glyphs which are
446 empty and not in this list will be assumed to be broken and not placed in
447 the FcCharSet associated with the font. This provides a significantly more
448 accurate CharSet for applications.
449 </para>
450 &fcblanks;
451 </sect2>
452 <sect2><title>FcConfig</title>
453 <para>
454 An FcConfig object holds the internal representation of a configuration.
455 There is a default configuration which applications may use by passing 0 to
456 any function using the data within an FcConfig.
457 </para>
458 &fcconfig;
459 </sect2>
460 <sect2><title>Initialization</title>
461 <para>
462 These functions provide some control over how the library is initialized.
463 </para>
464 <variablelist>
465 <varlistentry><term>
466 FcConfig *FcInitLoadConfig (void);
467 </term><listitem><para>
468 Loads the default configuration file and returns the resulting configuration.
469 Does not load any font information.
470 </para></listitem></varlistentry>
471 <varlistentry><term>
472 FcConfig *FcInitLoadConfigAndFonts (void);
473 </term><listitem><para>
474 Loads the default configuration file and builds information about the
475 available fonts. Returns the resulting configuration.
476 </para></listitem></varlistentry>
477 <varlistentry><term>
478 FcBool FcInit (void);
479 </term><listitem><para>
480 Loads the default configuration file and the fonts referenced therein and
481 sets the default configuration to that result. Returns whether this
482 process succeeded or not. If the default configuration has already
483 been loaded, this routine does nothing and returns FcTrue.
484 </para></listitem></varlistentry>
485 <varlistentry><term>
486 int FcGetVersion (void);
487 </term><listitem><para>
488 Returns the version number of the library.
489 </para></listitem></varlistentry>
490 <varlistentry><term>
491 FcBool FcInitReinitialize (void);
492 </term><listitem><para>
493 Forces the default configuration file to be reloaded and resets the default
494 configuration.
495 </para></listitem></varlistentry>
496 <varlistentry><term>
497 FcBool FcInitBringUptoDate (void);
498 </term><listitem><para>
499 Checks the rescan interval in the default configuration, checking the
500 configuration if the interval has passed and reloading the configuration if
501 when any changes are detected.
502 </para></listitem></varlistentry>
503 </variablelist></sect2>
504 <sect2><title>FcAtomic</title>
505 <para>
506 These functions provide a safe way to update config files, allowing ongoing
507 reading of the old config file while locked for writing and ensuring that a
508 consistent and complete version of the config file is always available.
509 </para>
510 <variablelist>
511 <varlistentry><term>
512 FcAtomic * FcAtomicCreate (const FcChar8 *file);
513 </term><listitem><para>
514 Creates a data structure containing data needed to control access to 'file'.
515 Writing is done to a separate file. Once that file is complete, the original
516 configuration file is atomically replaced so that reading process always see
517 a consistent and complete file without the need to lock for reading.
518 </para></listitem></varlistentry>
519 <varlistentry><term>
520 FcBool FcAtomicLock (FcAtomic *atomic);
521 </term><listitem><para>
522 Attempts to lock the file referenced by 'atomic'. Returns FcFalse if the
523 file is locked by another process, else returns FcTrue and leaves the file
524 locked.
525 </para></listitem></varlistentry>
526 <varlistentry><term>
527 FcChar8 *FcAtomicNewFile (FcAtomic *atomic);
528 </term><listitem><para>
529 Returns the filename for writing a new version of the file referenced
530 by 'atomic'.
531 </para></listitem></varlistentry>
532 <varlistentry><term>
533 FcChar8 *FcAtomicOrigFile (FcAtomic *atomic);
534 </term><listitem><para>
535 Returns the file refernced by 'atomic'.
536 </para></listitem></varlistentry>
537 <varlistentry><term>
538 FcBool FcAtomicReplaceOrig (FcAtomic *atomic);
539 </term><listitem><para>
540 Replaces the original file referenced by 'atomic' with the new file.
541 </para></listitem></varlistentry>
542 <varlistentry><term>
543 void FcAtomicDeleteNew (FcAtomic *atomic);
544 </term><listitem><para>
545 Deletes the new file.
546 </para></listitem></varlistentry>
547 <varlistentry><term>
548 void FcAtomicUnlock (FcAtomic *atomic);
549 </term><listitem><para>
550 Unlocks the file.
551 </para></listitem></varlistentry>
552 <varlistentry><term>
553 void FcAtomicDestroy (FcAtomic *atomic);
554 </term><listitem><para>
555 Destroys 'atomic'.
556 </para></listitem></varlistentry>
557 </variablelist></sect2>
558 <sect2><title>FreeType specific functions</title>
559 <para>
560 <programlisting>
561 #include &lt;fontconfig/fcfreetype.h&gt;
562 </programlisting>
563 While the fontconfig library doesn't insist that FreeType be used as the
564 rasterization mechanism for fonts, it does provide some convenience
565 functions.
566 </para>
567 <variablelist>
568 <varlistentry><term>
569 FT_UInt FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4);
570 </term><listitem><para>
571 Maps a Unicode char to a glyph index. This function uses information from
572 several possible underlying encoding tables to work around broken fonts.
573 As a result, this function isn't designed to be used in performance
574 sensitive areas; results from this function are intended to be cached by
575 higher level functions.
576 </para></listitem></varlistentry>
577 <varlistentry><term>
578 FcCharSet *FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks) Scans a
579 </term><listitem><para>
580 FreeType face and returns the set of encoded Unicode chars. This scans
581 several encoding tables to build as complete a list as possible.
582 If 'blanks' is not 0, the glyphs in the font are examined and any blank glyphs
583 not in 'blanks' are not placed in the returned FcCharSet.
584 </para></listitem></varlistentry>
585 <varlistentry><term>
586 FcPattern *FcFreeTypeQuery (const char *file, int id, FcBlanks *blanks, int *count);
587 </term><listitem><para>
588 Constructs a pattern representing the 'id'th font in 'file'. The number
589 of fonts in 'file' is returned in 'count'.
590 </para></listitem></varlistentry>
591 </variablelist></sect2>
592 <sect2><title>XML specific functions</title>
593 <variablelist>
594 <varlistentry><term>
595 FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
596 </term><listitem><para>
597 Walks the configuration in 'file' and constructs the internal representation
598 in 'config'. Any include files referenced from within 'file' will be loaded
599 with FcConfigLoad and also parsed. If 'complain' is FcFalse, no warning
600 will be displayed if 'file' does not exist.
601 </para></listitem></varlistentry>
602 </variablelist></sect2>
603 <sect2><title>File and Directory routines</title>
604 <variablelist>
605 <varlistentry><term>
606 FcBool FcFileScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *file, FcBool force);
607 </term><listitem><para>
608 Scans a single file and adds all fonts found to 'set'. If 'force' is FcTrue,
609 then the file is scanned even if associated information is found in 'cache'.
610 If 'file' is a directory, it is added to 'dirs'.
611 </para></listitem></varlistentry>
612 <varlistentry><term>
613 FcBool FcDirScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const char *dir, FcBool force);
614 </term><listitem><para>
615 Scans an entire directory and adds all fonts found to 'set'. If 'force' is
616 FcTrue, then the directory and all files within it are scanned even if
617 information is present in the per-directory cache file or 'cache'. Any
618 subdirectories found are added to 'dirs'.
619 </para></listitem></varlistentry>
620 <varlistentry><term>
621 FcBool FcDirSave (FcFontSet *set, FcStrSet *dirs, const char *dir);
622 </term><listitem><para>
623 Creates the per-directory cache file for 'dir' and populates it with the
624 fonts in 'set' and subdirectories in 'dirs'.
625 </para></listitem></varlistentry>
626 <varlistentry><term>
627 FcBool FcDirCacheValid (const FcChar8 *cache_file);
628 </term><listitem><para>
629 Returns FcTrue if 'cache_file' is no older than the directory containing it,
630 else FcFalse.
631 </para></listitem></varlistentry>
632 </variablelist></sect2>
633 <sect2><title>FcStrSet and FcStrList</title>
634 <para>
635 A data structure for enumerating strings, used to list directories while
636 scanning the configuration as directories are added while scanning.
637 </para>
638 <variablelist>
639 <varlistentry><term>
640 FcStrSet *FcStrSetCreate (void);
641 </term><listitem><para>
642 Create an empty set.
643 </para></listitem></varlistentry>
644 <varlistentry><term>
645 FcBool FcStrSetMember (FcStrSet *set, const FcChar8 *s);
646 </term><listitem><para>
647 Returns whether 's' is a member of 'set'.
648 </para></listitem></varlistentry>
649 <varlistentry><term>
650 FcBool FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
651 </term><listitem><para>
652 Adds a copy of 's' to 'set'.
653 </para></listitem></varlistentry>
654 <varlistentry><term>
655 FcBool FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
656 </term><listitem><para>
657 Adds a copy 's' to 'set', The copy is created with FcStrCopyFilename
658 so that leading '~' values are replaced with the value of the HOME
659 environment variable.
660 </para></listitem></varlistentry>
661 <varlistentry><term>
662 FcBool FcStrSetDel (FcStrSet *set, const FcChar8 *s);
663 </term><listitem><para>
664 Removes 's' from 'set', returning FcTrue if 's' was a member else FcFalse.
665 </para></listitem></varlistentry>
666 <varlistentry><term>
667 void FcStrSetDestroy (FcStrSet *set);
668 </term><listitem><para>
669 Destroys 'set'.
670 </para></listitem></varlistentry>
671 <varlistentry><term>
672 FcStrList *FcStrListCreate (FcStrSet *set);
673 </term><listitem><para>
674 Creates an enumerator to list the strings in 'set'.
675 </para></listitem></varlistentry>
676 <varlistentry><term>
677 FcChar8 *FcStrListNext (FcStrList *list);
678 </term><listitem><para>
679 Returns the next string in 'set'.
680 </para></listitem></varlistentry>
681 <varlistentry><term>
682 void FcStrListDone (FcStrList *list);
683 </term><listitem><para>
684 Destroys the enumerator 'list'.
685 </para></listitem></varlistentry>
686 </variablelist></sect2>
687 <sect2><title>String utilities</title>
688 <variablelist>
689 <varlistentry><term>
690 int FcUtf8ToUcs4 (FcChar8 *src, FcChar32 *dst, int len);
691 </term><listitem>
692 <para>
693 Converts the next Unicode char from 'src' into 'dst' and returns the number
694 of bytes containing the char. 'src' nust be at least 'len' bytes long.
695 </para></listitem></varlistentry>
696 <varlistentry><term>
697 int FcUcs4ToUtf8 (FcChar32 src, FcChar8 dst[FC_UTF8_MAX_LEN]);
698 </term><listitem><para>
699 Converts the Unicode char from 'src' into 'dst' and returns the
700 number of bytes needed to encode the char.
701 </para></listitem></varlistentry>
702 <varlistentry><term>
703 FcBool FcUtf8Len (FcChar8 *src, int len, int *nchar, int *wchar);
704 </term><listitem><para>
705 Counts the number of Unicode chars in 'len' bytes of 'src'. Places that
706 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
707 bytes needed to hold the largest unicode char counted. The return value
708 indicates whether 'src' is a well-formed UTF8 string.
709 </para></listitem></varlistentry>
710 <varlistentry><term>
711 int FcUtf16ToUcs4 (FcChar8 *src, FcEndian endian, FcChar32 *dst, int len);
712 </term><listitem><para>
713 Converts the next Unicode char from 'src' into 'dst' and returns the
714 number of bytes containing the char. 'src' must be at least 'len' bytes
715 long. Bytes of 'src' are combined into 16-bit units according to 'endian'.
716 </para></listitem></varlistentry>
717 <varlistentry><term>
718 FcBool FcUtf16Len (FcChar8 *src, FcEndian endian, int len, int *nchar, int *wchar);
719 </term><listitem><para>
720 Counts the number of Unicode chars in 'len' bytes of 'src'. Bytes of 'src'
721 are combined into 16-bit units according to 'endian'. Places that
722 count in 'nchar'. 'wchar' contains 1, 2 or 4 depending on the number of
723 bytes needed to hold the largest unicode char counted. The return value
724 indicates whether 'string' is a well-formed UTF16 string.
725 </para></listitem></varlistentry>
726 <varlistentry><term>
727 FcChar8 *FcStrCopy (const FcChar8 *s);
728 </term><listitem><para>
729 Allocates memory, copies 's' and returns the resulting buffer. Yes, this
730 is 'strdup', but that function isn't available on every platform.
731 </para></listitem></varlistentry>
732 <varlistentry><term>
733 FcChar8 *FcStrCopyFilename (const FcChar8 *s);
734 </term><listitem><para>
735 Just like FcStrCopy except that it converts any leading '~' characters
736 in 's' to the value of the HOME environment variable.
737 </para></listitem></varlistentry>
738 <varlistentry><term>
739 int FcStrCmpIgnoreCase (const char *s1, const char *s2);
740 </term><listitem><para>
741 Returns the usual &lt;0, 0, &gt;0 result of comparing 's1' and 's2'. This test
742 is case-insensitive in the ASCII range and will operate properly with UTF8
743 encoded strings, although it does not check for well formed strings.
744 </para></listitem></varlistentry>
745 <varlistentry><term>
746 FcChar8 *FcStrDirname (const FcChar8 *file);
747 </term><listitem><para>
748 Returns the directory containing 'file'.
749 </para></listitem></varlistentry>
750 <varlistentry><term>
751 FcChar8 *FcStrBasename (const FcChar8 *file);
752 </term><listitem><para>
753 Returns the filename of 'file' stripped of any leading directory names.
754 </para></listitem></varlistentry>
755 </variablelist></sect2>
756 </sect1>
757 </article>