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