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