fontconfig-devel.sgml revision ae02b298
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 width FC_WIDTH Int Condensed, normal or expanded 154 size FC_SIZE Double Point size 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 hintstyle FC_HINT_STYLE Int Automatic hinting style 164 hinting FC_HINTING Bool Whether the rasterizer should 165 use hinting 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 relative to the config's sysroot 172 index FC_INDEX Int The index of the font within 173 the file 174 ftface FC_FT_FACE FT_Face Use the specified FreeType 175 face object 176 rasterizer FC_RASTERIZER String Which rasterizer is in use (deprecated) 177 outline FC_OUTLINE Bool Whether the glyphs are outlines 178 scalable FC_SCALABLE Bool Whether glyphs can be scaled 179 dpi FC_DPI Double Target dots per inch 180 rgba FC_RGBA Int unknown, rgb, bgr, vrgb, 181 vbgr, none - subpixel geometry 182 scale FC_SCALE Double Scale factor for point->pixel 183 conversions (deprecated) 184 minspace FC_MINSPACE Bool Eliminate leading from line 185 spacing 186 charset FC_CHARSET CharSet Unicode chars encoded by 187 the font 188 lang FC_LANG LangSet Set of RFC-3066-style 189 languages this font supports 190 fontversion FC_FONTVERSION Int Version number of the font 191 capability FC_CAPABILITY String List of layout capabilities in 192 the font 193 fontformat FC_FONTFORMAT String String name of the font format 194 embolden FC_EMBOLDEN Bool Rasterizer should 195 synthetically embolden the font 196 embeddedbitmap FC_EMBEDDED_BITMAP Bool Use the embedded bitmap instead 197 of the outline 198 decorative FC_DECORATIVE Bool Whether the style is a decorative 199 variant 200 lcdfilter FC_LCD_FILTER Int Type of LCD filter 201 namelang FC_NAMELANG String Language name to be used for the 202 default value of familylang, 203 stylelang and fullnamelang 204 fontfeatures FC_FONT_FEATURES String List of extra feature tags in 205 OpenType to be enabled 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 symbol FC_SYMBOL Bool Whether font uses MS symbol-font encoding 211 color FC_COLOR Bool Whether any glyphs have color 212 fontvariations FC_FONT_VARIATIONS String comma-separated string of axes in variable font 213 variable FC_VARIABLE Bool Whether font is Variable Font 214 fonthashint FC_FONT_HAS_HINT Bool Whether font has hinting 215 order FC_ORDER Int Order number of the font 216 </programlisting> 217 </sect2> 218</sect1> 219<sect1><title>Datatypes</title> 220 <para> 221Fontconfig uses abstract data types to hide internal implementation details 222for most data structures. A few structures are exposed where appropriate. 223 </para> 224 <sect2><title>FcChar8, FcChar16, FcChar32, FcBool</title> 225 <para> 226These are primitive data types; the FcChar* types hold precisely the number 227of bits stated (if supported by the C implementation). FcBool holds 228one of two C preprocessor symbols: FcFalse or FcTrue. 229 </para> 230 </sect2> 231 <sect2><title>FcMatrix</title> 232 <para> 233An FcMatrix holds an affine transformation, usually used to reshape glyphs. 234A small set of matrix operations are provided to manipulate these. 235 <programlisting> 236 typedef struct _FcMatrix { 237 double xx, xy, yx, yy; 238 } FcMatrix; 239 </programlisting> 240 </para> 241 </sect2> 242 <sect2><title>FcCharSet</title> 243 <para> 244An FcCharSet is an abstract type that holds the set of encoded Unicode chars 245in a font. Operations to build and compare these sets are provided. 246 </para> 247 </sect2> 248 <sect2><title>FcLangSet</title> 249 <para> 250An FcLangSet is an abstract type that holds the set of languages supported 251by a font. Operations to build and compare these sets are provided. These 252are computed for a font based on orthographic information built into the 253fontconfig library. Fontconfig has orthographies for all of the ISO 639-1 254languages except for MS, NA, PA, PS, QU, RN, RW, SD, SG, SN, SU and ZA. If 255you have orthographic information for any of these languages, please submit 256them. 257 </para> 258 </sect2> 259 <sect2><title>FcLangResult</title> 260 <para> 261An FcLangResult is an enumeration used to return the results of comparing 262two language strings or FcLangSet objects. FcLangEqual means the 263objects match language and territory. FcLangDifferentTerritory means 264the objects match in language but differ in territory. 265FcLangDifferentLang means the objects differ in language. 266 </para> 267 </sect2> 268 <sect2><title>FcType</title> 269 <para> 270Tags the kind of data stored in an FcValue. 271 </para> 272 </sect2> 273 <sect2><title>FcValue</title> 274 <para> 275An FcValue object holds a single value with one of a number of different 276types. The 'type' tag indicates which member is valid. 277 <programlisting> 278 typedef struct _FcValue { 279 FcType type; 280 union { 281 const FcChar8 *s; 282 int i; 283 FcBool b; 284 double d; 285 const FcMatrix *m; 286 const FcCharSet *c; 287 void *f; 288 const FcLangSet *l; 289 const FcRange *r; 290 } u; 291 } FcValue; 292 </programlisting> 293 <programlisting> 294 FcValue Members 295 296 Type Union member Datatype 297 -------------------------------- 298 FcTypeVoid (none) (none) 299 FcTypeInteger i int 300 FcTypeDouble d double 301 FcTypeString s FcChar8 * 302 FcTypeBool b b 303 FcTypeMatrix m FcMatrix * 304 FcTypeCharSet c FcCharSet * 305 FcTypeFTFace f void * (FT_Face) 306 FcTypeLangSet l FcLangSet * 307 FcTypeRange r FcRange * 308 </programlisting> 309 </para> 310 </sect2> 311 <sect2><title>FcPattern, FcPatternIter</title> 312 <para> 313An FcPattern holds a set of names with associated value lists; each name refers to a 314property of a font. FcPatterns are used as inputs to the matching code as 315well as holding information about specific fonts. Each property can hold 316one or more values; conventionally all of the same type, although the 317interface doesn't demand that. An FcPatternIter is used during iteration to 318access properties in FcPattern. 319 </para> 320 </sect2> 321 <sect2><title>FcFontSet</title> 322 <para> 323 <programlisting> 324 typedef struct _FcFontSet { 325 int nfont; 326 int sfont; 327 FcPattern **fonts; 328 } FcFontSet; 329 </programlisting> 330An FcFontSet contains a list of FcPatterns. Internally fontconfig uses this 331data structure to hold sets of fonts. Externally, fontconfig returns the 332results of listing fonts in this format. 'nfont' holds the number of 333patterns in the 'fonts' array; 'sfont' is used to indicate the size of that 334array. 335 </para> 336 </sect2> 337 <sect2><title>FcStrSet, FcStrList</title> 338 <para> 339FcStrSet holds a list of strings that can be appended to and enumerated. 340Its unique characteristic is that the enumeration works even while strings 341are appended during enumeration. FcStrList is used during enumeration to 342safely and correctly walk the list of strings even while that list is edited 343in the middle of enumeration. 344 </para> 345 </sect2> 346 <sect2><title>FcObjectSet</title> 347 <para> 348 <programlisting> 349 typedef struct _FcObjectSet { 350 int nobject; 351 int sobject; 352 const char **objects; 353 } FcObjectSet; 354 </programlisting> 355holds a set of names and is used to specify which fields from fonts are 356placed in the the list of returned patterns when listing fonts. 357 </para> 358 </sect2> 359 <sect2><title>FcObjectType</title> 360 <para> 361 <programlisting> 362 typedef struct _FcObjectType { 363 const char *object; 364 FcType type; 365 } FcObjectType; 366 </programlisting> 367marks the type of a pattern element generated when parsing font names. 368Applications can add new object types so that font names may contain the new 369elements. 370 </para> 371 </sect2> 372 <sect2><title>FcConstant</title> 373 <para> 374 <programlisting> 375 typedef struct _FcConstant { 376 const FcChar8 *name; 377 const char *object; 378 int value; 379 } FcConstant; 380 </programlisting> 381Provides for symbolic constants for new pattern elements. When 'name' is 382seen in a font name, an 'object' element is created with value 'value'. 383 </para> 384 </sect2> 385 <sect2><title>FcBlanks</title> 386 <para> 387holds a list of Unicode chars which are expected to be blank; unexpectedly 388blank chars are assumed to be invalid and are elided from the charset 389associated with the font. 390 </para> 391 <para> 392 FcBlanks is deprecated and should not be used in newly written code. 393 It is still accepted by some functions for compatibility with 394 older code but will be removed in the future. 395 </para> 396 </sect2> 397 <sect2><title>FcFileCache</title> 398 <para> 399holds the per-user cache information for use while loading the font 400database. This is built automatically for the current configuration when 401that is loaded. Applications must always pass '0' when one is requested. 402 </para> 403 </sect2> 404 <sect2><title>FcConfig</title> 405 <para> 406holds a complete configuration of the library; there is one default 407configuration, other can be constructed from XML data structures. All 408public entry points that need global data can take an optional FcConfig* 409argument; passing 0 uses the default configuration. FcConfig objects hold two 410sets of fonts, the first contains those specified by the configuration, the 411second set holds those added by the application at run-time. Interfaces 412that need to reference a particular set use one of the FcSetName enumerated 413values. 414 </para> 415 </sect2> 416 <sect2><title>FcSetName</title> 417 <para> 418Specifies one of the two sets of fonts available in a configuration; 419FcSetSystem for those fonts specified in the configuration and 420FcSetApplication which holds fonts provided by the application. 421 </para> 422 </sect2> 423 <sect2><title>FcResult</title> 424 <para> 425Used as a return type for functions manipulating FcPattern objects. 426 <programlisting> 427 FcResult Values 428 Result Code Meaning 429 ----------------------------------------------------------- 430 FcResultMatch Object exists with the specified ID 431 FcResultNoMatch Object doesn't exist at all 432 FcResultTypeMismatch Object exists, but the type doesn't match 433 FcResultNoId Object exists, but has fewer values 434 than specified 435 FcResultOutOfMemory malloc failed 436 </programlisting> 437 </para> 438 </sect2> 439 <sect2><title>FcAtomic</title> 440 <para> 441Used for locking access to configuration files. Provides a safe way to update 442configuration files. 443 </para> 444 </sect2> 445 <sect2><title>FcCache</title> 446 <para> 447Holds information about the fonts contained in a single directory. Normal 448applications need not worry about this as caches for font access are 449automatically managed by the library. Applications dealing with cache 450management may want to use some of these objects in their work, however the 451included 'fc-cache' program generally suffices for all of that. 452 </para> 453 </sect2> 454</sect1> 455<sect1><title>FUNCTIONS</title> 456 <para> 457These are grouped by functionality, often using the main data type being 458manipulated. 459 </para> 460 <sect2><title>Initialization</title> 461 <para> 462These functions provide some control over how the library is initialized. 463 </para> 464 &fcinit; 465 </sect2> 466 <sect2><title>FcPattern</title> 467 <para> 468An FcPattern is an opaque type that holds both patterns to match against the 469available fonts, as well as the information about each font. 470 </para> 471 &fcpattern; 472 &fcformat; 473 </sect2> 474 <sect2><title>FcFontSet</title> 475 <para> 476An FcFontSet simply holds a list of patterns; these are used to return the 477results of listing available fonts. 478 </para> 479 &fcfontset; 480 </sect2> 481 <sect2><title>FcObjectSet</title> 482 <para> 483An FcObjectSet holds a list of pattern property names; it is used to 484indicate which properties are to be returned in the patterns from 485FcFontList. 486 </para> 487 &fcobjectset; 488 </sect2> 489 <sect2><title>FreeType specific functions</title> 490 <para> 491While the fontconfig library doesn't insist that FreeType be used as the 492rasterization mechanism for fonts, it does provide some convenience 493functions. 494 </para> 495 &fcfreetype; 496 </sect2> 497 <sect2><title>FcValue</title> 498 <para> 499FcValue is a structure containing a type tag and a union of all possible 500datatypes. The tag is an enum of type 501<emphasis>FcType</emphasis> 502and is intended to provide a measure of run-time 503typechecking, although that depends on careful programming. 504 </para> 505 &fcvalue; 506 </sect2> 507 <sect2><title>FcCharSet</title> 508 <para> 509An FcCharSet is a boolean array indicating a set of Unicode chars. Those 510associated with a font are marked constant and cannot be edited. 511FcCharSets may be reference counted internally to reduce memory consumption; 512this may be visible to applications as the result of FcCharSetCopy may 513return it's argument, and that CharSet may remain unmodifiable. 514 </para> 515 &fccharset; 516 </sect2> 517 <sect2><title>FcLangSet</title> 518 <para> 519An FcLangSet is a set of language names (each of which include language and 520an optional territory). They are used when selecting fonts to indicate which 521languages the fonts need to support. Each font is marked, using language 522orthography information built into fontconfig, with the set of supported 523languages. 524 </para> 525 &fclangset; 526 </sect2> 527 <sect2><title>FcMatrix</title> 528 <para> 529FcMatrix structures hold an affine transformation in matrix form. 530 </para> 531 &fcmatrix; 532 </sect2> 533 <sect2><title>FcRange</title> 534 <para> 535An FcRange holds two variables to indicate a range in between. 536 </para> 537 &fcrange; 538 </sect2> 539 <sect2><title>FcConfig</title> 540 <para> 541An FcConfig object holds the internal representation of a configuration. 542There is a default configuration which applications may use by passing 0 to 543any function using the data within an FcConfig. 544 </para> 545 &fcconfig; 546 </sect2> 547 <sect2><title>FcObjectType</title> 548 <para> 549Provides for application-specified font name object types so that new 550pattern elements can be generated from font names. 551 </para> 552 &fcobjecttype; 553 </sect2> 554 <sect2><title>FcConstant</title> 555 <para> 556Provides for application-specified symbolic constants for font names. 557 </para> 558 &fcconstant; 559 </sect2> 560 <sect2><title>FcWeight</title> 561 <para> 562Maps weights to and from OpenType weights. 563 </para> 564 &fcweight; 565 </sect2> 566 <sect2><title>FcBlanks</title> 567 <para> 568An FcBlanks object holds a list of Unicode chars which are expected to 569be blank when drawn. When scanning new fonts, any glyphs which are 570empty and not in this list will be assumed to be broken and not placed in 571the FcCharSet associated with the font. This provides a significantly more 572accurate CharSet for applications. 573 </para> 574 <para> 575 FcBlanks is deprecated and should not be used in newly written code. 576 It is still accepted by some functions for compatibility with 577 older code but will be removed in the future. 578 </para> 579 &fcblanks; 580 </sect2> 581 <sect2><title>FcAtomic</title> 582 <para> 583These functions provide a safe way to update configuration files, allowing ongoing 584reading of the old configuration file while locked for writing and ensuring that a 585consistent and complete version of the configuration file is always available. 586 </para> 587 &fcatomic; 588 </sect2> 589 <sect2><title>File and Directory routines</title> 590 <para> 591These routines work with font files and directories, including font 592directory cache files. 593 </para> 594 &fcfile; 595 &fcdircache; 596 </sect2> 597 <sect2><title>FcCache routines</title> 598 <para> 599These routines work with font directory caches, accessing their contents in 600limited ways. It is not expected that normal applications will need to use 601these functions. 602 </para> 603 &fccache; 604 </sect2> 605 <sect2><title>FcStrSet and FcStrList</title> 606 <para> 607A data structure for enumerating strings, used to list directories while 608scanning the configuration as directories are added while scanning. 609 </para> 610 &fcstrset; 611 </sect2> 612 <sect2><title>String utilities</title> 613 <para> 614Fontconfig manipulates many UTF-8 strings represented with the FcChar8 type. 615These functions are exposed to help applications deal with these UTF-8 616strings in a locale-insensitive manner. 617 </para> 618 &fcstring; 619 </sect2> 620</sect1> 621</article> 622