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