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