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