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