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