]> git.wh0rd.org - fontconfig.git/blame_incremental - doc/fontconfig-devel.sgml
Replace incorrect documentation uses of 'char' with 'FcChar8' (bug 13002).
[fontconfig.git] / doc / fontconfig-devel.sgml
... / ...
CommitLineData
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>
58Copyright © 2002 Keith Packard
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>
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>
127 <programlisting>
128 Property Definitions
129
130 Property CPP Symbol Type Description
131 ----------------------------------------------------
132 family FC_FAMILY String Font family names
133 familylang FC_FAMILYLANG String Language cooresponding to
134 each family name
135 style FC_STYLE String Font style. Overrides weight
136 and slant
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
141 family + style
142 fullnamelang FC_FULLNAMELANG String Language cooresponding to
143 each fullname
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
148 width FC_WIDTH Int Condensed, normal or expanded
149 aspect FC_ASPECT Double Stretches glyphs horizontally
150 before hinting
151 pixelsize FC_PIXEL_SIZE Double Pixel size
152 spacing FC_SPACING Int Proportional, dual-width,
153 monospace or charcell
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
159 hintstyle FC_HINT_STYLE Int Automatic hinting style
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 LangSet Set of RFC-3066-style
182 languages this font supports
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
188 </programlisting>
189 </sect2>
190</sect1>
191<sect1><title>Datatypes</title>
192 <para>
193Fontconfig uses abstract datatypes to hide internal implementation details
194for most data structures. A few structures are exposed where appropriate.
195 </para>
196 <sect2><title>FcChar8, FcChar16, FcChar32, FcBool</title>
197 <para>
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.
201 </para>
202 </sect2>
203 <sect2><title>FcMatrix</title>
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>
208 typedef struct _FcMatrix {
209 double xx, xy, yx, yy;
210 } FcMatrix;
211 </programlisting>
212 </para>
213 </sect2>
214 <sect2><title>FcCharSet</title>
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>
219 </sect2>
220 <sect2><title>FcLangSet</title>
221 <para>
222An FcLangSet is an abstract type that holds the set of languages supported
223by a font. Operations to build and compare these sets are provided. These
224are computed for a font based on orthographic information built into the
225fontconfig library. Fontconfig has orthographies for all of the ISO 639-1
226languages except for MS, NA, PA, PS, QU, RN, RW, SD, SG, SN, SU and ZA. If
227you have orthographic information for any of these languages, please submit
228them.
229 </para>
230 </sect2>
231 <sect2><title>FcLangResult</title>
232 <para>
233An FcLangResult is an enumeration used to return the results of comparing
234two language strings or FcLangSet objects. FcLangEqual means the
235objects match language and territory. FcLangDifferentTerritory means
236the objects match in language but differ in territory.
237FcLangDifferentLang means the objects differ in language.
238 </para>
239 </sect2>
240 <sect2><title>FcType</title>
241 <para>
242Tags the kind of data stored in an FcValue.
243 </para>
244 </sect2>
245 <sect2><title>FcValue</title>
246 <para>
247An FcValue object holds a single value with one of a number of different
248types. The 'type' tag indicates which member is valid.
249 <programlisting>
250 typedef struct _FcValue {
251 FcType type;
252 union {
253 const FcChar8 *s;
254 int i;
255 FcBool b;
256 double d;
257 const FcMatrix *m;
258 const FcCharSet *c;
259 void *f;
260 const FcLangSet *l;
261 } u;
262 } FcValue;
263 </programlisting>
264 <programlisting>
265 FcValue Members
266
267 Type Union member Datatype
268 --------------------------------
269 FcTypeVoid (none) (none)
270 FcTypeInteger i int
271 FcTypeDouble d double
272 FcTypeString s FcChar8 *
273 FcTypeBool b b
274 FcTypeMatrix m FcMatrix *
275 FcTypeCharSet c FcCharSet *
276 FcTypeFTFace f void * (FT_Face)
277 FcTypeLangSet l FcLangSet *
278 </programlisting>
279 </para>
280 </sect2>
281 <sect2><title>FcPattern</title>
282 <para>
283holds a set of names with associated value lists; each name refers to a
284property of a font. FcPatterns are used as inputs to the matching code as
285well as holding information about specific fonts. Each property can hold
286one or more values; conventionally all of the same type, although the
287interface doesn't demand that.
288 </para>
289 </sect2>
290 <sect2><title>FcFontSet</title>
291 <para>
292 <programlisting>
293 typedef struct _FcFontSet {
294 int nfont;
295 int sfont;
296 FcPattern **fonts;
297 } FcFontSet;
298 </programlisting>
299An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this
300data structure to hold sets of fonts. Externally, fontconfig returns the
301results of listing fonts in this format. 'nfont' holds the number of
302patterns in the 'fonts' array; 'sfont' is used to indicate the size of that
303array.
304 </para>
305 </sect2>
306 <sect2><title>FcStrSet, FcStrList</title>
307 <para>
308FcStrSet holds a list of strings that can be appended to and enumerated.
309Its unique characteristic is that the enumeration works even while strings
310are appended during enumeration. FcStrList is used during enumeration to
311safely and correctly walk the list of strings even while that list is edited
312in the middle of enumeration.
313 </para>
314 </sect2>
315 <sect2><title>FcObjectSet</title>
316 <para>
317 <programlisting>
318 typedef struct _FcObjectSet {
319 int nobject;
320 int sobject;
321 const char **objects;
322 } FcObjectSet;
323 </programlisting>
324holds a set of names and is used to specify which fields from fonts are
325placed in the the list of returned patterns when listing fonts.
326 </para>
327 </sect2>
328 <sect2><title>FcObjectType</title>
329 <para>
330 <programlisting>
331 typedef struct _FcObjectType {
332 const char *object;
333 FcType type;
334 } FcObjectType;
335 </programlisting>
336marks the type of a pattern element generated when parsing font names.
337Applications can add new object types so that font names may contain the new
338elements.
339 </para>
340 </sect2>
341 <sect2><title>FcConstant</title>
342 <para>
343 <programlisting>
344 typedef struct _FcConstant {
345 const FcChar8 *name;
346 const char *object;
347 int value;
348 } FcConstant;
349 </programlisting>
350Provides for symbolic constants for new pattern elements. When 'name' is
351seen in a font name, an 'object' element is created with value 'value'.
352 </para>
353 </sect2>
354 <sect2><title>FcBlanks</title>
355 <para>
356holds a list of Unicode chars which are expected to be blank; unexpectedly
357blank chars are assumed to be invalid and are elided from the charset
358associated with the font.
359 </para>
360 </sect2>
361 <sect2><title>FcFileCache</title>
362 <para>
363holds the per-user cache information for use while loading the font
364database. This is built automatically for the current configuration when
365that is loaded. Applications must always pass '0' when one is requested.
366 </para>
367 </sect2>
368 <sect2><title>FcConfig</title>
369 <para>
370holds a complete configuration of the library; there is one default
371configuration, other can be constructed from XML data structures. All
372public entry points that need global data can take an optional FcConfig*
373argument; passing 0 uses the default configuration. FcConfig objects hold two
374sets of fonts, the first contains those specified by the configuration, the
375second set holds those added by the application at run-time. Interfaces
376that need to reference a particulat set use one of the FcSetName enumerated
377values.
378 </para>
379 </sect2>
380 <sect2><title>FcSetName</title>
381 <para>
382Specifies one of the two sets of fonts available in a configuration;
383FcSetSystem for those fonts specified in the configuration and
384FcSetApplication which holds fonts provided by the application.
385 </para>
386 </sect2>
387 <sect2><title>FcResult</title>
388 <para>
389Used as a return type for functions manipulating FcPattern objects.
390 <programlisting>
391 FcResult Values
392 Result Code Meaning
393 -----------------------------------------------------------
394 FcResultMatch Object exists with the specified ID
395 FcResultNoMatch Object doesn't exist at all
396 FcResultTypeMismatch Object exists, but the type doesn't match
397 FcResultNoId Object exists, but has fewer values
398 than specified
399 FcResultOutOfMemory Malloc failed
400 </programlisting>
401 </para>
402 </sect2>
403 <sect2><title>FcAtomic</title>
404 <para>
405Used for locking access to config files. Provides a safe way to update
406configuration files.
407 </para>
408 </sect2>
409</sect1>
410<sect1><title>FUNCTIONS</title>
411 <para>
412These are grouped by functionality, often using the main datatype being
413manipulated.
414 </para>
415 <sect2><title>Initialization</title>
416 <para>
417These functions provide some control over how the library is initialized.
418 </para>
419 &fcinit;
420 </sect2>
421 <sect2><title>FcPattern</title>
422 <para>
423An FcPattern is an opaque type that holds both patterns to match against the
424available fonts, as well as the information about each font.
425 </para>
426 &fcpattern;
427 </sect2>
428 <sect2><title>FcFontSet</title>
429 <para>
430An FcFontSet simply holds a list of patterns; these are used to return the
431results of listing available fonts.
432 </para>
433 &fcfontset;
434 </sect2>
435 <sect2><title>FcObjectSet</title>
436 <para>
437An FcObjectSet holds a list of pattern property names; it is used to
438indiciate which properties are to be returned in the patterns from
439FcFontList.
440 </para>
441 &fcobjectset;
442 </sect2>
443 <sect2><title>FreeType specific functions</title>
444 <para>
445While the fontconfig library doesn't insist that FreeType be used as the
446rasterization mechanism for fonts, it does provide some convenience
447functions.
448 </para>
449 &fcfreetype;
450 </sect2>
451 <sect2><title>FcValue</title>
452 <para>
453FcValue is a structure containing a type tag and a union of all possible
454datatypes. The tag is an enum of type
455<emphasis>FcType</emphasis>
456and is intended to provide a measure of run-time
457typechecking, although that depends on careful programming.
458 </para>
459 &fcvalue;
460 </sect2>
461 <sect2><title>FcCharSet</title>
462 <para>
463An FcCharSet is a boolean array indicating a set of unicode chars. Those
464associated with a font are marked constant and cannot be edited.
465FcCharSets may be reference counted internally to reduce memory consumption;
466this may be visible to applications as the result of FcCharSetCopy may
467return it's argument, and that CharSet may remain unmodifiable.
468 </para>
469 &fccharset;
470 </sect2>
471 <sect2><title>FcMatrix</title>
472 <para>
473FcMatrix structures hold an affine transformation in matrix form.
474 </para>
475 &fcmatrix;
476 </sect2>
477 <sect2><title>FcConfig</title>
478 <para>
479An FcConfig object holds the internal representation of a configuration.
480There is a default configuration which applications may use by passing 0 to
481any function using the data within an FcConfig.
482 </para>
483 &fcconfig;
484 </sect2>
485 <sect2><title>FcObjectType</title>
486 <para>
487Provides for applcation-specified font name object types so that new
488pattern elements can be generated from font names.
489 </para>
490 &fcobjecttype;
491 </sect2>
492 <sect2><title>FcConstant</title>
493 <para>
494Provides for application-specified symbolic constants for font names.
495 </para>
496 &fcconstant;
497 </sect2>
498 <sect2><title>FcBlanks</title>
499 <para>
500An FcBlanks object holds a list of Unicode chars which are expected to
501be blank when drawn. When scanning new fonts, any glyphs which are
502empty and not in this list will be assumed to be broken and not placed in
503the FcCharSet associated with the font. This provides a significantly more
504accurate CharSet for applications.
505 </para>
506 &fcblanks;
507 </sect2>
508 <sect2><title>FcAtomic</title>
509 <para>
510These functions provide a safe way to update config files, allowing ongoing
511reading of the old config file while locked for writing and ensuring that a
512consistent and complete version of the config file is always available.
513 </para>
514 &fcatomic;
515 </sect2>
516 <sect2><title>File and Directory routines</title>
517 <para>
518These routines work with font files and directories, including font
519directory cache files.
520 </para>
521 &fcfile;
522 </sect2>
523 <sect2><title>FcStrSet and FcStrList</title>
524 <para>
525A data structure for enumerating strings, used to list directories while
526scanning the configuration as directories are added while scanning.
527 </para>
528 &fcstrset;
529 </sect2>
530 <sect2><title>String utilities</title>
531 <para>
532Fontconfig manipulates many UTF-8 strings represented with the FcChar8 type.
533These functions are exposed to help applications deal with these UTF-8
534strings in a locale-insensitive manner.
535 </para>
536 &fcstring;
537 </sect2>
538</sect1>
539</article>