]> git.wh0rd.org Git - fontconfig.git/blob - fontconfig/fontconfig.h
Rewrite global cache handling code in fontconfig to eliminate per-file
[fontconfig.git] / fontconfig / fontconfig.h
1 /*
2  * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.21 2002/07/11 02:47:50 keithp Exp $
3  *
4  * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of Keith Packard not be used in
11  * advertising or publicity pertaining to distribution of the software without
12  * specific, written prior permission.  Keith Packard makes no
13  * representations about the suitability of this software for any purpose.  It
14  * is provided "as is" without express or implied warranty.
15  *
16  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  */
24
25 #ifndef _FONTCONFIG_H_
26 #define _FONTCONFIG_H_
27
28 #include <stdarg.h>
29
30 typedef unsigned char   FcChar8;
31 typedef unsigned short  FcChar16;
32 typedef unsigned int    FcChar32;
33 typedef int             FcBool;
34
35 /*
36  * Current Fontconfig version number
37  */
38 #define FC_MAJOR        1
39 #define FC_MINOR        0
40 #define FC_REVISION     1
41
42 #define FC_VERSION      ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
43
44 #define FcTrue          1
45 #define FcFalse         0
46
47 #define FC_FAMILY           "family"            /* String */
48 #define FC_STYLE            "style"             /* String */
49 #define FC_SLANT            "slant"             /* Int */
50 #define FC_WEIGHT           "weight"            /* Int */
51 #define FC_SIZE             "size"              /* Double */
52 #define FC_ASPECT           "aspect"            /* Double */
53 #define FC_PIXEL_SIZE       "pixelsize"         /* Double */
54 #define FC_SPACING          "spacing"           /* Int */
55 #define FC_FOUNDRY          "foundry"           /* String */
56 #define FC_ANTIALIAS        "antialias"         /* Bool (depends) */
57 #define FC_HINTING          "hinting"           /* Bool (true) */
58 #define FC_VERTICAL_LAYOUT  "verticallayout"    /* Bool (false) */
59 #define FC_AUTOHINT         "autohint"          /* Bool (false) */
60 #define FC_GLOBAL_ADVANCE   "globaladvance"     /* Bool (true) */
61 #define FC_FILE             "file"              /* String */
62 #define FC_INDEX            "index"             /* Int */
63 #define FC_FT_FACE          "ftface"            /* FT_Face */
64 #define FC_RASTERIZER       "rasterizer"        /* String */
65 #define FC_OUTLINE          "outline"           /* Bool */
66 #define FC_SCALABLE         "scalable"          /* Bool */
67 #define FC_SCALE            "scale"             /* double */
68 #define FC_DPI              "dpi"               /* double */
69 #define FC_RGBA             "rgba"              /* Int */
70 #define FC_MINSPACE         "minspace"          /* Bool use minimum line spacing */
71 #define FC_SOURCE           "source"            /* String (X11, freetype) */
72 #define FC_CHARSET          "charset"           /* CharSet */
73 #define FC_LANG             "lang"              /* String OS/2 CodePageRange */
74
75 #define FC_DIR_CACHE_FILE           "fonts.cache"
76 #define FC_USER_CACHE_FILE          ".fonts.cache"
77
78 /* Adjust outline rasterizer */
79 #define FC_CHAR_WIDTH       "charwidth" /* Int */
80 #define FC_CHAR_HEIGHT      "charheight"/* Int */
81 #define FC_MATRIX           "matrix"    /* FcMatrix */
82
83 #define FC_WEIGHT_LIGHT     0
84 #define FC_WEIGHT_MEDIUM    100
85 #define FC_WEIGHT_DEMIBOLD  180
86 #define FC_WEIGHT_BOLD      200
87 #define FC_WEIGHT_BLACK     210
88
89 #define FC_SLANT_ROMAN      0
90 #define FC_SLANT_ITALIC     100
91 #define FC_SLANT_OBLIQUE    110
92
93 #define FC_PROPORTIONAL     0
94 #define FC_MONO             100
95 #define FC_CHARCELL         110
96
97 /* sub-pixel order */
98 #define FC_RGBA_NONE        0
99 #define FC_RGBA_RGB         1
100 #define FC_RGBA_BGR         2
101 #define FC_RGBA_VRGB        3
102 #define FC_RGBA_VBGR        4
103
104 typedef enum _FcType {
105     FcTypeVoid, 
106     FcTypeInteger, 
107     FcTypeDouble, 
108     FcTypeString, 
109     FcTypeBool,
110     FcTypeMatrix,
111     FcTypeCharSet,
112     FcTypeFTFace
113 } FcType;
114
115 typedef struct _FcMatrix {
116     double xx, xy, yx, yy;
117 } FcMatrix;
118
119 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \
120                          (m)->xy = (m)->yx = 0)
121
122 /*
123  * A data structure to represent the available glyphs in a font.
124  * This is represented as a sparse boolean btree.
125  */
126
127 typedef struct _FcCharSet FcCharSet;
128
129 typedef struct _FcObjectType {
130     const char  *object;
131     FcType      type;
132 } FcObjectType;
133
134 typedef struct _FcConstant {
135     const FcChar8  *name;
136     const char  *object;
137     int         value;
138 } FcConstant;
139
140 typedef enum _FcResult {
141     FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId
142 } FcResult;
143
144 typedef struct _FcValue {
145     FcType      type;
146     union {
147         const FcChar8   *s;
148         int             i;
149         FcBool          b;
150         double          d;
151         const FcMatrix  *m;
152         const FcCharSet *c;
153         void            *f;
154     } u;
155 } FcValue;
156
157 typedef struct _FcPattern   FcPattern;
158
159 typedef struct _FcFontSet {
160     int         nfont;
161     int         sfont;
162     FcPattern   **fonts;
163 } FcFontSet;
164
165 typedef struct _FcObjectSet {
166     int         nobject;
167     int         sobject;
168     const char  **objects;
169 } FcObjectSet;
170     
171 typedef enum _FcMatchKind {
172     FcMatchPattern, FcMatchFont 
173 } FcMatchKind;
174
175 typedef enum _FcSetName {
176     FcSetSystem = 0,
177     FcSetApplication = 1
178 } FcSetName;
179
180 typedef struct _FcAtomic FcAtomic;
181
182 #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
183 #define _FCFUNCPROTOBEGIN extern "C" {  /* do not leave open across includes */
184 #define _FCFUNCPROTOEND }
185 #else
186 #define _FCFUNCPROTOBEGIN
187 #define _FCFUNCPROTOEND
188 #endif
189
190 typedef enum { FcEndianBig, FcEndianLittle } FcEndian;
191
192 typedef struct _FcConfig    FcConfig;
193
194 typedef struct _FcGlobalCache   FcFileCache;
195
196 typedef struct _FcBlanks    FcBlanks;
197
198 typedef struct _FcStrList   FcStrList;
199
200 typedef struct _FcStrSet    FcStrSet;
201
202 _FCFUNCPROTOBEGIN
203
204 /* fcblanks.c */
205 FcBlanks *
206 FcBlanksCreate (void);
207
208 void
209 FcBlanksDestroy (FcBlanks *b);
210
211 FcBool
212 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
213
214 FcBool
215 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
216
217 /* fccfg.c */
218 FcChar8 *
219 FcConfigFilename (const FcChar8 *url);
220     
221 FcConfig *
222 FcConfigCreate (void);
223
224 void
225 FcConfigDestroy (FcConfig *config);
226
227 FcBool
228 FcConfigSetCurrent (FcConfig *config);
229
230 FcConfig *
231 FcConfigGetCurrent (void);
232
233 FcBool
234 FcConfigUptoDate (FcConfig *config);
235     
236 FcBool
237 FcConfigBuildFonts (FcConfig *config);
238
239 FcStrList *
240 FcConfigGetFontDirs (FcConfig   *config);
241
242 FcStrList *
243 FcConfigGetConfigDirs (FcConfig   *config);
244
245 FcStrList *
246 FcConfigGetConfigFiles (FcConfig    *config);
247
248 FcChar8 *
249 FcConfigGetCache (FcConfig  *config);
250
251 FcBlanks *
252 FcConfigGetBlanks (FcConfig *config);
253
254 int
255 FcConfigGetRescanInverval (FcConfig *config);
256
257 FcBool
258 FcConfigSetRescanInverval (FcConfig *config, int rescanInterval);
259
260 FcFontSet *
261 FcConfigGetFonts (FcConfig      *config,
262                   FcSetName     set);
263
264 FcBool
265 FcConfigAppFontAddFile (FcConfig    *config,
266                         const FcChar8  *file);
267
268 FcBool
269 FcConfigAppFontAddDir (FcConfig     *config,
270                        const FcChar8   *dir);
271
272 void
273 FcConfigAppFontClear (FcConfig      *config);
274
275 FcBool
276 FcConfigSubstitute (FcConfig    *config,
277                     FcPattern   *p,
278                     FcMatchKind kind);
279
280 /* fccharset.c */
281 FcCharSet *
282 FcCharSetCreate (void);
283
284 void
285 FcCharSetDestroy (FcCharSet *fcs);
286
287 FcBool
288 FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
289
290 FcCharSet *
291 FcCharSetCopy (FcCharSet *src);
292
293 FcBool
294 FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
295
296 FcCharSet *
297 FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
298
299 FcCharSet *
300 FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
301
302 FcCharSet *
303 FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
304
305 FcBool
306 FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
307
308 FcChar32
309 FcCharSetCount (const FcCharSet *a);
310
311 FcChar32
312 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
313
314 FcChar32
315 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
316
317 FcBool
318 FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b);
319
320 #define FC_CHARSET_MAP_SIZE (256/32)
321 #define FC_CHARSET_DONE ((FcChar32) -1)
322
323 FcChar32
324 FcCharSetFirstPage (const FcCharSet *a, 
325                     FcChar32        map[FC_CHARSET_MAP_SIZE],
326                     FcChar32        *next);
327
328 FcChar32
329 FcCharSetNextPage (const FcCharSet  *a, 
330                    FcChar32         map[FC_CHARSET_MAP_SIZE],
331                    FcChar32         *next);
332
333
334 /* fcdbg.c */
335 void
336 FcValuePrint (FcValue v);
337
338 void
339 FcPatternPrint (FcPattern *p);
340
341 void
342 FcFontSetPrint (FcFontSet *s);
343
344 /* fcdefault.c */
345 void
346 FcDefaultSubstitute (FcPattern *pattern);
347
348 /* fcdir.c */
349 FcBool
350 FcFileScan (FcFontSet       *set,
351             FcStrSet        *dirs,
352             FcFileCache     *cache,
353             FcBlanks        *blanks,
354             const FcChar8   *file,
355             FcBool          force);
356
357 FcBool
358 FcDirScan (FcFontSet        *set,
359            FcStrSet         *dirs,
360            FcFileCache      *cache,
361            FcBlanks         *blanks,
362            const FcChar8    *dir,
363            FcBool           force);
364
365 FcBool
366 FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
367
368 /* fcfreetype.c */
369 FcPattern *
370 FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
371
372 /* fcfs.c */
373
374 FcFontSet *
375 FcFontSetCreate (void);
376
377 void
378 FcFontSetDestroy (FcFontSet *s);
379
380 FcBool
381 FcFontSetAdd (FcFontSet *s, FcPattern *font);
382
383 /* fcinit.c */
384 FcConfig *
385 FcInitLoadConfig (void);
386
387 FcConfig *
388 FcInitLoadConfigAndFonts (void);
389
390 FcBool
391 FcInit (void);
392
393 int
394 FcGetVersion (void);
395
396 FcBool
397 FcInitReinitialize (void);
398
399 FcBool
400 FcInitBringUptoDate (void);
401
402 /* fclist.c */
403 FcObjectSet *
404 FcObjectSetCreate (void);
405
406 FcBool
407 FcObjectSetAdd (FcObjectSet *os, const char *object);
408
409 void
410 FcObjectSetDestroy (FcObjectSet *os);
411
412 FcObjectSet *
413 FcObjectSetVaBuild (const char *first, va_list va);
414
415 FcObjectSet *
416 FcObjectSetBuild (const char *first, ...);
417
418 FcFontSet *
419 FcFontSetList (FcConfig     *config,
420                FcFontSet    **sets,
421                int          nsets,
422                FcPattern    *p,
423                FcObjectSet  *os);
424
425 FcFontSet *
426 FcFontList (FcConfig    *config,
427             FcPattern   *p,
428             FcObjectSet *os);
429
430 /* fcatomic.c */
431
432 FcAtomic *
433 FcAtomicCreate (const FcChar8   *file);
434
435 FcBool
436 FcAtomicLock (FcAtomic *atomic);
437
438 FcChar8 *
439 FcAtomicNewFile (FcAtomic *atomic);
440
441 FcChar8 *
442 FcAtomicOrigFile (FcAtomic *atomic);
443
444 FcBool
445 FcAtomicReplaceOrig (FcAtomic *atomic);
446
447 void
448 FcAtomicDeleteNew (FcAtomic *atomic);
449
450 void
451 FcAtomicUnlock (FcAtomic *atomic);
452
453 void
454 FcAtomicDestroy (FcAtomic *atomic);
455
456 /* fcmatch.c */
457 FcPattern *
458 FcFontSetMatch (FcConfig    *config,
459                 FcFontSet   **sets,
460                 int         nsets,
461                 FcPattern   *p,
462                 FcResult    *result);
463
464 FcPattern *
465 FcFontMatch (FcConfig   *config,
466              FcPattern  *p, 
467              FcResult   *result);
468
469 FcPattern *
470 FcFontRenderPrepare (FcConfig       *config,
471                      FcPattern      *pat,
472                      FcPattern      *font);
473
474 FcFontSet *
475 FcFontSetSort (FcConfig     *config,
476                FcFontSet    **sets,
477                int          nsets,
478                FcPattern    *p,
479                FcBool       trim,
480                FcCharSet    **csp,
481                FcResult     *result);
482
483 FcFontSet *
484 FcFontSort (FcConfig     *config,
485             FcPattern    *p,
486             FcBool       trim,
487             FcCharSet    **csp,
488             FcResult     *result);
489
490 void
491 FcFontSetSortDestroy (FcFontSet *fs);
492
493 /* fcmatrix.c */
494 FcMatrix *
495 FcMatrixCopy (const FcMatrix *mat);
496
497 FcBool
498 FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
499
500 void
501 FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
502
503 void
504 FcMatrixRotate (FcMatrix *m, double c, double s);
505
506 void
507 FcMatrixScale (FcMatrix *m, double sx, double sy);
508
509 void
510 FcMatrixShear (FcMatrix *m, double sh, double sv);
511
512 /* fcname.c */
513
514 FcBool
515 FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
516
517 FcBool
518 FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
519     
520 const FcObjectType *
521 FcNameGetObjectType (const char *object);
522
523 FcBool
524 FcNameRegisterConstants (const FcConstant *consts, int nconsts);
525
526 FcBool
527 FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
528     
529 const FcConstant *
530 FcNameGetConstant (FcChar8 *string);
531
532 FcBool
533 FcNameConstant (FcChar8 *string, int *result);
534
535 FcPattern *
536 FcNameParse (const FcChar8 *name);
537
538 FcChar8 *
539 FcNameUnparse (FcPattern *pat);
540
541 /* fcpat.c */
542 FcPattern *
543 FcPatternCreate (void);
544
545 FcPattern *
546 FcPatternDuplicate (FcPattern *p);
547
548 void
549 FcPatternReference (FcPattern *p);
550
551 void
552 FcValueDestroy (FcValue v);
553
554 FcBool
555 FcValueEqual (FcValue va, FcValue vb);
556
557 FcValue
558 FcValueSave (FcValue v);
559
560 void
561 FcPatternDestroy (FcPattern *p);
562
563 FcBool
564 FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
565
566 FcBool
567 FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
568
569 FcChar32
570 FcPatternHash (const FcPattern *p);
571
572 FcBool
573 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
574     
575 FcBool
576 FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
577     
578 FcResult
579 FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
580     
581 FcBool
582 FcPatternDel (FcPattern *p, const char *object);
583
584 FcBool
585 FcPatternAddInteger (FcPattern *p, const char *object, int i);
586
587 FcBool
588 FcPatternAddDouble (FcPattern *p, const char *object, double d);
589
590 FcBool
591 FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
592
593 FcBool
594 FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
595
596 FcBool
597 FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
598
599 FcBool
600 FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
601
602 FcResult
603 FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
604
605 FcResult
606 FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
607
608 FcResult
609 FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 ** s);
610
611 FcResult
612 FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
613
614 FcResult
615 FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
616
617 FcResult
618 FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
619
620 FcPattern *
621 FcPatternVaBuild (FcPattern *orig, va_list va);
622     
623 FcPattern *
624 FcPatternBuild (FcPattern *orig, ...);
625
626 /* fcstr.c */
627
628 FcChar8 *
629 FcStrCopy (const FcChar8 *s);
630
631 FcChar8 *
632 FcStrCopyFilename (const FcChar8 *s);
633     
634 #define FcToLower(c)    (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
635
636 int
637 FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
638
639 int
640 FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
641
642 int
643 FcUtf8ToUcs4 (FcChar8   *src_orig,
644               FcChar32  *dst,
645               int       len);
646
647 FcBool
648 FcUtf8Len (FcChar8      *string,
649            int          len,
650            int          *nchar,
651            int          *wchar);
652
653 #define FC_UTF8_MAX_LEN 6
654
655 int
656 FcUcs4ToUtf8 (FcChar32  ucs4,
657               FcChar8   dest[FC_UTF8_MAX_LEN]);
658
659 int
660 FcUtf16ToUcs4 (FcChar8  *src_orig,
661                FcEndian endian,
662                FcChar32 *dst,
663                int      len);       /* in bytes */
664
665 FcBool
666 FcUtf16Len (FcChar8     *string,
667             FcEndian    endian,
668             int         len,        /* in bytes */
669             int         *nchar,
670             int         *wchar);
671
672 FcChar8 *
673 FcStrDirname (const FcChar8 *file);
674
675 FcChar8 *
676 FcStrBasename (const FcChar8 *file);
677
678 FcStrSet *
679 FcStrSetCreate (void);
680
681 FcBool
682 FcStrSetMember (FcStrSet *set, const FcChar8 *s);
683
684 FcBool
685 FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
686
687 FcBool
688 FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
689
690 FcBool
691 FcStrSetDel (FcStrSet *set, const FcChar8 *s);
692
693 void
694 FcStrSetDestroy (FcStrSet *set);
695
696 FcStrList *
697 FcStrListCreate (FcStrSet *set);
698
699 FcChar8 *
700 FcStrListNext (FcStrList *list);
701
702 void
703 FcStrListDone (FcStrList *list);
704
705 /* fcxml.c */
706 FcBool
707 FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
708
709 _FCFUNCPROTOEND
710
711 #endif /* _FONTCONFIG_H_ */