]> git.wh0rd.org - fontconfig.git/blame - doc/fontconfig-devel.sgml
Link new function documentation into the fontconfig-devel.sgml
[fontconfig.git] / doc / fontconfig-devel.sgml
CommitLineData
22671e25 1<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [
39381776
KP
2<!ENTITY fcatomic SYSTEM "fcatomic.sgml">
3<!ENTITY fcblanks SYSTEM "fcblanks.sgml">
dc7b6f1d 4<!ENTITY fccache SYSTEM "fccache.sgml">
22671e25 5<!ENTITY fccharset SYSTEM "fccharset.sgml">
39381776
KP
6<!ENTITY fcconfig SYSTEM "fcconfig.sgml">
7<!ENTITY fcconstant SYSTEM "fcconstant.sgml">
dc7b6f1d 8<!ENTITY fcdircache SYSTEM "fcdircache.sgml">
39381776 9<!ENTITY fcfile SYSTEM "fcfile.sgml">
bfc2dc3a 10<!ENTITY fcfontset SYSTEM "fcfontset.sgml">
39381776
KP
11<!ENTITY fcfreetype SYSTEM "fcfreetype.sgml">
12<!ENTITY fcinit SYSTEM "fcinit.sgml">
dc7b6f1d 13<!ENTITY fclangset SYSTEM "fclangset.sgml">
39381776 14<!ENTITY fcmatrix SYSTEM "fcmatrix.sgml">
bfc2dc3a
KP
15<!ENTITY fcobjectset SYSTEM "fcobjectset.sgml">
16<!ENTITY fcobjecttype SYSTEM "fcobjecttype.sgml">
39381776
KP
17<!ENTITY fcpattern SYSTEM "fcpattern.sgml">
18<!ENTITY fcstring SYSTEM "fcstring.sgml">
19<!ENTITY fcstrset SYSTEM "fcstrset.sgml">
20<!ENTITY fcvalue SYSTEM "fcvalue.sgml">
fddb839b 21<!ENTITY version SYSTEM "version.sgml">
22671e25 22]>
584ac89a
KP
23<!--
24 $Id$
25
46b51147 26 Copyright © 2003 Keith Packard
584ac89a
KP
27
28 Permission to use, copy, modify, distribute, and sell this software and its
29 documentation for any purpose is hereby granted without fee, provided that
30 the above copyright notice appear in all copies and that both that
31 copyright notice and this permission notice appear in supporting
32 documentation, and that the name of Keith Packard not be used in
33 advertising or publicity pertaining to distribution of the software without
34 specific, written prior permission. Keith Packard makes no
35 representations about the suitability of this software for any purpose. It
36 is provided "as is" without express or implied warranty.
37
38 KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
39 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
40 EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
41 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
42 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
43 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44 PERFORMANCE OF THIS SOFTWARE.
45-->
46<article>
fddb839b 47 <title>Fontconfig Developers Reference, Version &version; </title>
22671e25
KP
48 <artheader>
49 <author>
50 <firstname>Keith</firstname>
51 <surname>Packard</surname>
52 <affiliation><orgname>
53 HP Cambridge Research Lab
54 </orgname></affiliation>
55 </author>
56 <authorinitials>KRP</authorinitials>
57 <productname>Fontconfig</productname>
fddb839b 58 <productnumber>&version;</productnumber>
22671e25
KP
59 <LegalNotice>
60 <simpara>
46b51147 61Copyright © 2002 Keith Packard
22671e25
KP
62 </simpara><simpara>
63Permission to use, copy, modify, distribute, and sell this software and its
64documentation for any purpose is hereby granted without fee, provided that
65the above copyright notice appear in all copies and that both that
66copyright notice and this permission notice appear in supporting
67documentation, and that the name of Keith Packard not be used in
68advertising or publicity pertaining to distribution of the software without
69specific, written prior permission. Keith Packard makes no
70representations about the suitability of this software for any purpose. It
71is provided "as is" without express or implied warranty.
72 </simpara><simpara>
73KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
74INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
75EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
76CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
77DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
78TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
79PERFORMANCE OF THIS SOFTWARE.
80 </simpara>
81 </LegalNotice>
82 </artheader>
584ac89a
KP
83<sect1><title>DESCRIPTION</title>
84 <para>
85Fontconfig is a library designed to provide system-wide font configuration,
86customization and application access.
87 </para>
88</sect1>
89<sect1><title>FUNCTIONAL OVERVIEW</title>
90 <para>
91Fontconfig contains two essential modules, the configuration module which
92builds an internal configuration from XML files and the matching module
93which accepts font patterns and returns the nearest matching font.
94 </para>
95 <sect2><title>FONT CONFIGURATION</title>
96 <para>
97The configuration module consists of the FcConfig datatype, libexpat and
98FcConfigParse which walks over an XML tree and ammends a configuration with
99data found within. From an external perspective, configuration of the
100library consists of generating a valid XML tree and feeding that to
101FcConfigParse. The only other mechanism provided to applications for
102changing the running configuration is to add fonts and directories to the
103list of application-provided font files.
104 </para><para>
105The intent is to make font configurations relatively static, and shared by
106as many applications as possible. It is hoped that this will lead to more
107stable font selection when passing names from one application to another.
108XML was chosen as a configuration file format because it provides a format
109which is easy for external agents to edit while retaining the correct
110structure and syntax.
111 </para><para>
112Font configuration is separate from font matching; applications needing to
113do their own matching can access the available fonts from the library and
114perform private matching. The intent is to permit applications to pick and
115choose appropriate functionality from the library instead of forcing them to
116choose between this library and a private configuration mechanism. The hope
117is that this will ensure that configuration of fonts for all applications
118can be centralized in one place. Centralizing font configuration will
119simplify and regularize font installation and customization.
120 </para>
121 </sect2>
122 <sect2>
123 <title>FONT PROPERTIES</title>
124 <para>
125While font patterns may contain essentially any properties, there are some
126well known properties with associated types. Fontconfig uses some of these
127properties for font matching and font completion. Others are provided as a
128convenience for the applications rendering mechanism.
129 </para>
22671e25
KP
130 <programlisting>
131 Property Definitions
132
4f27c1c0 133 Property CPP Symbol Type Description
22671e25 134 ----------------------------------------------------
4f27c1c0
KP
135 family FC_FAMILY String Font family names
136 familylang FC_FAMILYLANG String Language cooresponding to
137 each family name
22671e25
KP
138 style FC_STYLE String Font style. Overrides weight
139 and slant
4f27c1c0
KP
140 stylelang FC_STYLELANG String Language cooresponding to
141 each style name
142 fullname FC_FULLNAME String Font face full name where
143 different from family and
0c009d2b 144 family + style
4f27c1c0
KP
145 fullnamelang FC_FULLNAMELANG String Language cooresponding to
146 each fullname
22671e25
KP
147 slant FC_SLANT Int Italic, oblique or roman
148 weight FC_WEIGHT Int Light, medium, demibold,
149 bold or black
150 size FC_SIZE Double Point size
0c009d2b 151 width FC_WIDTH Int Condensed, normal or expanded
22671e25
KP
152 aspect FC_ASPECT Double Stretches glyphs horizontally
153 before hinting
154 pixelsize FC_PIXEL_SIZE Double Pixel size
a05d257f
NL
155 spacing FC_SPACING Int Proportional, dual-width,
156 monospace or charcell
22671e25
KP
157 foundry FC_FOUNDRY String Font foundry name
158 antialias FC_ANTIALIAS Bool Whether glyphs can be
159 antialiased
160 hinting FC_HINTING Bool Whether the rasterizer should
161 use hinting
0c009d2b 162 hintstyle FC_HINT_STYLE Int Automatic hinting style
22671e25
KP
163 verticallayout FC_VERTICAL_LAYOUT Bool Use vertical layout
164 autohint FC_AUTOHINT Bool Use autohinter instead of
165 normal hinter
166 globaladvance FC_GLOBAL_ADVANCE Bool Use font global advance data
167 file FC_FILE String The filename holding the font
168 index FC_INDEX Int The index of the font within
169 the file
170 ftface FC_FT_FACE FT_Face Use the specified FreeType
171 face object
172 rasterizer FC_RASTERIZER String Which rasterizer is in use
173 outline FC_OUTLINE Bool Whether the glyphs are outlines
174 scalable FC_SCALABLE Bool Whether glyphs can be scaled
175 scale FC_SCALE Double Scale factor for point->pixel
176 conversions
177 dpi FC_DPI Double Target dots per inch
178 rgba FC_RGBA Int unknown, rgb, bgr, vrgb,
179 vbgr, none - subpixel geometry
180 minspace FC_MINSPACE Bool Eliminate leading from line
181 spacing
182 charset FC_CHARSET CharSet Unicode chars encoded by
183 the font
a190678e 184 lang FC_LANG LangSet Set of RFC-3066-style
22671e25 185 languages this font supports
0c009d2b
KP
186 fontversion FC_FONTVERSION Int Version number of the font
187 capability FC_CAPABILITY String List of layout capabilities in
188 the font
189 embolden FC_EMBOLDEN Bool Rasterizer should
190 synthetically embolden the font
22671e25 191 </programlisting>
584ac89a 192 </sect2>
22dc6fc6 193</sect1>
39381776 194<sect1><title>Datatypes</title>
584ac89a
KP
195 <para>
196Fontconfig uses abstract datatypes to hide internal implementation details
197for most data structures. A few structures are exposed where appropriate.
198 </para>
39381776 199 <sect2><title>FcChar8, FcChar16, FcChar32, FcBool</title>
22671e25 200 <para>
584ac89a
KP
201These are primitive datatypes; the FcChar* types hold precisely the number
202of bits stated (if supported by the C implementation). FcBool holds
203one of two CPP symbols: FcFalse or FcTrue.
22671e25 204 </para>
39381776
KP
205 </sect2>
206 <sect2><title>FcMatrix</title>
584ac89a
KP
207 <para>
208An FcMatrix holds an affine transformation, usually used to reshape glyphs.
209A small set of matrix operations are provided to manipulate these.
210 <programlisting>
22671e25
KP
211 typedef struct _FcMatrix {
212 double xx, xy, yx, yy;
213 } FcMatrix;
584ac89a
KP
214 </programlisting>
215 </para>
39381776
KP
216 </sect2>
217 <sect2><title>FcCharSet</title>
584ac89a
KP
218 <para>
219An FcCharSet is an abstract type that holds the set of encoded unicode chars
220in a font. Operations to build and compare these sets are provided.
221 </para>
39381776 222 </sect2>
a190678e
KP
223 <sect2><title>FcLangSet</title>
224 <para>
225An FcLangSet is an abstract type that holds the set of languages supported
226by a font. Operations to build and compare these sets are provided. These
227are computed for a font based on orthographic information built into the
228fontconfig library. Fontconfig has orthographies for all of the ISO 639-1
229languages except for MS, NA, PA, PS, QU, RN, RW, SD, SG, SN, SU and ZA. If
230you have orthographic information for any of these languages, please submit
231them.
232 </para>
233 </sect2>
234 <sect2><title>FcLangResult</title>
235 <para>
236An FcLangResult is an enumeration used to return the results of comparing
237two language strings or FcLangSet objects. FcLangEqual means the
238objects match language and territory. FcLangDifferentTerritory means
239the objects match in language but differ in territory.
240FcLangDifferentLang means the objects differ in language.
241 </para>
242 </sect2>
39381776 243 <sect2><title>FcType</title>
584ac89a
KP
244 <para>
245Tags the kind of data stored in an FcValue.
22dc6fc6 246 </para>
39381776
KP
247 </sect2>
248 <sect2><title>FcValue</title>
584ac89a
KP
249 <para>
250An FcValue object holds a single value with one of a number of different
251types. The 'type' tag indicates which member is valid.
252 <programlisting>
22671e25
KP
253 typedef struct _FcValue {
254 FcType type;
255 union {
256 const FcChar8 *s;
257 int i;
258 FcBool b;
259 double d;
260 const FcMatrix *m;
261 const FcCharSet *c;
a190678e
KP
262 void *f;
263 const FcLangSet *l;
22671e25
KP
264 } u;
265 } FcValue;
266 </programlisting>
267 <programlisting>
268 FcValue Members
269
270 Type Union member Datatype
271 --------------------------------
272 FcTypeVoid (none) (none)
273 FcTypeInteger i int
274 FcTypeDouble d double
f2772d6b 275 FcTypeString s FcChar8 *
22671e25
KP
276 FcTypeBool b b
277 FcTypeMatrix m FcMatrix *
278 FcTypeCharSet c FcCharSet *
a190678e
KP
279 FcTypeFTFace f void * (FT_Face)
280 FcTypeLangSet l FcLangSet *
584ac89a 281 </programlisting>
22dc6fc6 282 </para>
39381776
KP
283 </sect2>
284 <sect2><title>FcPattern</title>
584ac89a
KP
285 <para>
286holds a set of names with associated value lists; each name refers to a
287property of a font. FcPatterns are used as inputs to the matching code as
288well as holding information about specific fonts. Each property can hold
289one or more values; conventionally all of the same type, although the
290interface doesn't demand that.
22dc6fc6 291 </para>
39381776
KP
292 </sect2>
293 <sect2><title>FcFontSet</title>
584ac89a
KP
294 <para>
295 <programlisting>
22671e25
KP
296 typedef struct _FcFontSet {
297 int nfont;
298 int sfont;
299 FcPattern **fonts;
300 } FcFontSet;
584ac89a
KP
301 </programlisting>
302An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this
303data structure to hold sets of fonts. Externally, fontconfig returns the
304results of listing fonts in this format. 'nfont' holds the number of
305patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
306array.
307 </para>
39381776
KP
308 </sect2>
309 <sect2><title>FcStrSet, FcStrList</title>
584ac89a
KP
310 <para>
311FcStrSet holds a list of strings that can be appended to and enumerated.
312Its unique characteristic is that the enumeration works even while strings
313are appended during enumeration. FcStrList is used during enumeration to
314safely and correctly walk the list of strings even while that list is edited
315in the middle of enumeration.
316 </para>
39381776
KP
317 </sect2>
318 <sect2><title>FcObjectSet</title>
584ac89a
KP
319 <para>
320 <programlisting>
22671e25
KP
321 typedef struct _FcObjectSet {
322 int nobject;
323 int sobject;
324 const char **objects;
325 } FcObjectSet;
584ac89a
KP
326 </programlisting>
327holds a set of names and is used to specify which fields from fonts are
328placed in the the list of returned patterns when listing fonts.
329 </para>
39381776
KP
330 </sect2>
331 <sect2><title>FcObjectType</title>
584ac89a
KP
332 <para>
333 <programlisting>
22671e25
KP
334 typedef struct _FcObjectType {
335 const char *object;
336 FcType type;
337 } FcObjectType;
584ac89a
KP
338 </programlisting>
339marks the type of a pattern element generated when parsing font names.
340Applications can add new object types so that font names may contain the new
341elements.
342 </para>
39381776
KP
343 </sect2>
344 <sect2><title>FcConstant</title>
584ac89a
KP
345 <para>
346 <programlisting>
22671e25
KP
347 typedef struct _FcConstant {
348 const FcChar8 *name;
349 const char *object;
350 int value;
351 } FcConstant;
584ac89a
KP
352 </programlisting>
353Provides for symbolic constants for new pattern elements. When 'name' is
354seen in a font name, an 'object' element is created with value 'value'.
355 </para>
39381776
KP
356 </sect2>
357 <sect2><title>FcBlanks</title>
584ac89a
KP
358 <para>
359holds a list of Unicode chars which are expected to be blank; unexpectedly
360blank chars are assumed to be invalid and are elided from the charset
361associated with the font.
362 </para>
39381776
KP
363 </sect2>
364 <sect2><title>FcFileCache</title>
584ac89a
KP
365 <para>
366holds the per-user cache information for use while loading the font
367database. This is built automatically for the current configuration when
368that is loaded. Applications must always pass '0' when one is requested.
369 </para>
39381776
KP
370 </sect2>
371 <sect2><title>FcConfig</title>
584ac89a
KP
372 <para>
373holds a complete configuration of the library; there is one default
374configuration, other can be constructed from XML data structures. All
375public entry points that need global data can take an optional FcConfig*
376argument; passing 0 uses the default configuration. FcConfig objects hold two
377sets of fonts, the first contains those specified by the configuration, the
378second set holds those added by the application at run-time. Interfaces
379that need to reference a particulat set use one of the FcSetName enumerated
380values.
381 </para>
39381776
KP
382 </sect2>
383 <sect2><title>FcSetName</title>
584ac89a
KP
384 <para>
385Specifies one of the two sets of fonts available in a configuration;
386FcSetSystem for those fonts specified in the configuration and
387FcSetApplication which holds fonts provided by the application.
388 </para>
39381776
KP
389 </sect2>
390 <sect2><title>FcResult</title>
584ac89a
KP
391 <para>
392Used as a return type for functions manipulating FcPattern objects.
22671e25
KP
393 <programlisting>
394 FcResult Values
395 Result Code Meaning
396 -----------------------------------------------------------
397 FcResultMatch Object exists with the specified ID
398 FcResultNoMatch Object doesn't exist at all
399 FcResultTypeMismatch Object exists, but the type doesn't match
400 FcResultNoId Object exists, but has fewer values
401 than specified
0c009d2b 402 FcResultOutOfMemory Malloc failed
22671e25 403 </programlisting>
584ac89a 404 </para>
39381776
KP
405 </sect2>
406 <sect2><title>FcAtomic</title>
584ac89a
KP
407 <para>
408Used for locking access to config files. Provides a safe way to update
409configuration files.
410 </para>
39381776 411 </sect2>
dc7b6f1d
KP
412 <sect2><title>FcCache</title>
413 <para>
414Holds information about the fonts contained in a single directory. Normal
415applications need not worry about this as caches for font access are
416automatically managed by the library. Applications dealing with cache
417management may want to use some of these objects in their work, however the
418included 'fc-cache' program generally suffices for all of that.
419 </para>
420 </sect2>
584ac89a
KP
421</sect1>
422<sect1><title>FUNCTIONS</title>
423 <para>
39381776
KP
424These are grouped by functionality, often using the main datatype being
425manipulated.
584ac89a 426 </para>
39381776 427 <sect2><title>Initialization</title>
584ac89a 428 <para>
39381776 429These functions provide some control over how the library is initialized.
584ac89a 430 </para>
39381776 431 &fcinit;
584ac89a
KP
432 </sect2>
433 <sect2><title>FcPattern</title>
434 <para>
435An FcPattern is an opaque type that holds both patterns to match against the
436available fonts, as well as the information about each font.
437 </para>
22671e25 438 &fcpattern;
584ac89a
KP
439 </sect2>
440 <sect2><title>FcFontSet</title>
441 <para>
442An FcFontSet simply holds a list of patterns; these are used to return the
443results of listing available fonts.
444 </para>
bfc2dc3a
KP
445 &fcfontset;
446 </sect2>
584ac89a
KP
447 <sect2><title>FcObjectSet</title>
448 <para>
449An FcObjectSet holds a list of pattern property names; it is used to
450indiciate which properties are to be returned in the patterns from
451FcFontList.
452 </para>
bfc2dc3a
KP
453 &fcobjectset;
454 </sect2>
39381776
KP
455 <sect2><title>FreeType specific functions</title>
456 <para>
457While the fontconfig library doesn't insist that FreeType be used as the
458rasterization mechanism for fonts, it does provide some convenience
459functions.
460 </para>
461 &fcfreetype;
462 </sect2>
463 <sect2><title>FcValue</title>
464 <para>
465FcValue is a structure containing a type tag and a union of all possible
466datatypes. The tag is an enum of type
467<emphasis>FcType</emphasis>
468and is intended to provide a measure of run-time
469typechecking, although that depends on careful programming.
470 </para>
471 &fcvalue;
472 </sect2>
473 <sect2><title>FcCharSet</title>
474 <para>
475An FcCharSet is a boolean array indicating a set of unicode chars. Those
476associated with a font are marked constant and cannot be edited.
477FcCharSets may be reference counted internally to reduce memory consumption;
478this may be visible to applications as the result of FcCharSetCopy may
479return it's argument, and that CharSet may remain unmodifiable.
480 </para>
481 &fccharset;
482 </sect2>
dc7b6f1d
KP
483 <sect2><title>FcLangSet</title>
484 <para>
485An FcLangSet is a set of language names (each of which include language and
486an optional territory). They are used when selecting fonts to indicate which
487languages the fonts need to support. Each font is marked, using language
488orthography information built into fontconfig, with the set of supported
489languages.
490 </para>
491 &fclangset;
492 </sect2>
39381776
KP
493 <sect2><title>FcMatrix</title>
494 <para>
495FcMatrix structures hold an affine transformation in matrix form.
496 </para>
497 &fcmatrix;
498 </sect2>
499 <sect2><title>FcConfig</title>
500 <para>
501An FcConfig object holds the internal representation of a configuration.
502There is a default configuration which applications may use by passing 0 to
503any function using the data within an FcConfig.
504 </para>
505 &fcconfig;
506 </sect2>
584ac89a
KP
507 <sect2><title>FcObjectType</title>
508 <para>
509Provides for applcation-specified font name object types so that new
510pattern elements can be generated from font names.
511 </para>
bfc2dc3a
KP
512 &fcobjecttype;
513 </sect2>
584ac89a
KP
514 <sect2><title>FcConstant</title>
515 <para>
516Provides for application-specified symbolic constants for font names.
517 </para>
bfc2dc3a
KP
518 &fcconstant;
519 </sect2>
584ac89a
KP
520 <sect2><title>FcBlanks</title>
521 <para>
522An FcBlanks object holds a list of Unicode chars which are expected to
523be blank when drawn. When scanning new fonts, any glyphs which are
524empty and not in this list will be assumed to be broken and not placed in
525the FcCharSet associated with the font. This provides a significantly more
526accurate CharSet for applications.
527 </para>
bfc2dc3a
KP
528 &fcblanks;
529 </sect2>
584ac89a
KP
530 <sect2><title>FcAtomic</title>
531 <para>
532These functions provide a safe way to update config files, allowing ongoing
533reading of the old config file while locked for writing and ensuring that a
534consistent and complete version of the config file is always available.
535 </para>
39381776
KP
536 &fcatomic;
537 </sect2>
584ac89a 538 <sect2><title>File and Directory routines</title>
39381776
KP
539 <para>
540These routines work with font files and directories, including font
541directory cache files.
8c87b429 542 </para>
39381776 543 &fcfile;
dc7b6f1d
KP
544 &fcdircache;
545 </sect2>
546 <sect2><title>FcCache routines</title>
547 <para>
548These routines work with font directory caches, accessing their contents in
549limited ways. It is not expected that normal applications will need to use
550these functions.
551 </para>
552 &fccache;
39381776 553 </sect2>
584ac89a
KP
554 <sect2><title>FcStrSet and FcStrList</title>
555 <para>
556A data structure for enumerating strings, used to list directories while
557scanning the configuration as directories are added while scanning.
558 </para>
39381776
KP
559 &fcstrset;
560 </sect2>
584ac89a 561 <sect2><title>String utilities</title>
39381776
KP
562 <para>
563Fontconfig manipulates many UTF-8 strings represented with the FcChar8 type.
564These functions are exposed to help applications deal with these UTF-8
565strings in a locale-insensitive manner.
566 </para>
567 &fcstring;
568 </sect2>
584ac89a
KP
569</sect1>
570</article>