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