Imported Upstream version 2.10.0
[platform/upstream/fontconfig.git] / src / fcint.h
1 /*
2  * fontconfig/src/fcint.h
3  *
4  * Copyright © 2000 Keith Packard
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 the author(s) not be used in
11  * advertising or publicity pertaining to distribution of the software without
12  * specific, written prior permission.  The authors make 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  * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL THE AUTHOR(S) 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 _FCINT_H_
26 #define _FCINT_H_
27
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32 #include <stdlib.h>
33 #include <stdio.h>
34 #ifdef HAVE_INTTYPES_H
35 #include <inttypes.h>
36 #elif defined(HAVE_STDINT_H)
37 #include <stdint.h>
38 #else
39 #error missing C99 integer data types
40 #endif
41 #include <string.h>
42 #include <ctype.h>
43 #include <errno.h>
44 #include <unistd.h>
45 #include <stddef.h>
46 #include <sys/types.h>
47 #include <sys/stat.h>
48 #include <time.h>
49 #include <fontconfig/fontconfig.h>
50 #include <fontconfig/fcprivate.h>
51 #include "fcdeprecate.h"
52
53 #ifndef FC_CONFIG_PATH
54 #define FC_CONFIG_PATH "fonts.conf"
55 #endif
56
57 #ifdef _WIN32
58 #  ifndef _WIN32_WINNT
59 #    define _WIN32_WINNT 0x0500
60 #  endif
61 #  define WIN32_LEAN_AND_MEAN
62 #  define STRICT
63 #  include <windows.h>
64 typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
65 typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
66 extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
67 extern pfnSHGetFolderPathA pSHGetFolderPathA;
68 #  define FC_SEARCH_PATH_SEPARATOR ';'
69 #  define FC_DIR_SEPARATOR         '\\'
70 #  define FC_DIR_SEPARATOR_S       "\\"
71 #else
72 #  define FC_SEARCH_PATH_SEPARATOR ':'
73 #  define FC_DIR_SEPARATOR         '/'
74 #  define FC_DIR_SEPARATOR_S       "/"
75 #endif
76
77 #define FC_DBG_MATCH    1
78 #define FC_DBG_MATCHV   2
79 #define FC_DBG_EDIT     4
80 #define FC_DBG_FONTSET  8
81 #define FC_DBG_CACHE    16
82 #define FC_DBG_CACHEV   32
83 #define FC_DBG_PARSE    64
84 #define FC_DBG_SCAN     128
85 #define FC_DBG_SCANV    256
86 #define FC_DBG_MEMORY   512
87 #define FC_DBG_CONFIG   1024
88 #define FC_DBG_LANGSET  2048
89 #define FC_DBG_OBJTYPES 4096
90
91 #define FC_MEM_CHARSET      0
92 #define FC_MEM_CHARLEAF     1
93 #define FC_MEM_FONTSET      2
94 #define FC_MEM_FONTPTR      3
95 #define FC_MEM_OBJECTSET    4
96 #define FC_MEM_OBJECTPTR    5
97 #define FC_MEM_MATRIX       6
98 #define FC_MEM_PATTERN      7
99 #define FC_MEM_PATELT       8
100 #define FC_MEM_VALLIST      9
101 #define FC_MEM_SUBSTATE     10
102 #define FC_MEM_STRING       11
103 #define FC_MEM_LISTBUCK     12
104 #define FC_MEM_STRSET       13
105 #define FC_MEM_STRLIST      14
106 #define FC_MEM_CONFIG       15
107 #define FC_MEM_LANGSET      16
108 #define FC_MEM_ATOMIC       17
109 #define FC_MEM_BLANKS       18
110 #define FC_MEM_CACHE        19
111 #define FC_MEM_STRBUF       20
112 #define FC_MEM_SUBST        21
113 #define FC_MEM_OBJECTTYPE   22
114 #define FC_MEM_CONSTANT     23
115 #define FC_MEM_TEST         24
116 #define FC_MEM_EXPR         25
117 #define FC_MEM_VSTACK       26
118 #define FC_MEM_ATTR         27
119 #define FC_MEM_PSTACK       28
120 #define FC_MEM_SHAREDSTR    29
121
122 #define FC_MEM_NUM          30
123
124 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
125 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
126 #define FC_ASSERT_STATIC(_cond) _FC_ASSERT_STATIC0 (__LINE__, (_cond))
127
128 #define FC_MIN(a,b) ((a) < (b) ? (a) : (b))
129 #define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
130 #define FC_ABS(a)   ((a) < 0 ? -(a) : (a))
131
132 /* slim_internal.h */
133 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
134 #define FcPrivate               __attribute__((__visibility__("hidden")))
135 #define HAVE_GNUC_ATTRIBUTE 1
136 #include "fcalias.h"
137 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
138 #define FcPrivate               __hidden
139 #else /* not gcc >= 3.3 and not Sun Studio >= 8 */
140 #define FcPrivate
141 #endif
142
143 typedef enum _FcValueBinding {
144     FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
145 } FcValueBinding;
146
147 /*
148  * Serialized data structures use only offsets instead of pointers
149  * A low bit of 1 indicates an offset.
150  */
151
152 /* Is the provided pointer actually an offset? */
153 #define FcIsEncodedOffset(p)    ((((intptr_t) (p)) & 1) != 0)
154
155 /* Encode offset in a pointer of type t */
156 #define FcOffsetEncode(o,t)     ((t *) ((o) | 1))
157
158 /* Decode a pointer into an offset */
159 #define FcOffsetDecode(p)       (((intptr_t) (p)) & ~1)
160
161 /* Compute pointer offset */
162 #define FcPtrToOffset(b,p)      ((intptr_t) (p) - (intptr_t) (b))
163
164 /* Given base address, offset and type, return a pointer */
165 #define FcOffsetToPtr(b,o,t)    ((t *) ((intptr_t) (b) + (o)))
166
167 /* Given base address, encoded offset and type, return a pointer */
168 #define FcEncodedOffsetToPtr(b,p,t) FcOffsetToPtr(b,FcOffsetDecode(p),t)
169
170 /* Given base address, pointer and type, return an encoded offset */
171 #define FcPtrToEncodedOffset(b,p,t) FcOffsetEncode(FcPtrToOffset(b,p),t)
172
173 /* Given a structure, offset member and type, return pointer */
174 #define FcOffsetMember(s,m,t)       FcOffsetToPtr(s,(s)->m,t)
175
176 /* Given a structure, encoded offset member and type, return pointer to member */
177 #define FcEncodedOffsetMember(s,m,t) FcOffsetToPtr(s,FcOffsetDecode((s)->m), t)
178
179 /* Given a structure, member and type, convert the member to a pointer */
180 #define FcPointerMember(s,m,t)  (FcIsEncodedOffset((s)->m) ? \
181                                  FcEncodedOffsetMember (s,m,t) : \
182                                  (s)->m)
183
184 /*
185  * Serialized values may hold strings, charsets and langsets as pointers,
186  * unfortunately FcValue is an exposed type so we can't just always use
187  * offsets
188  */
189 #define FcValueString(v)        FcPointerMember(v,u.s,FcChar8)
190 #define FcValueCharSet(v)       FcPointerMember(v,u.c,const FcCharSet)
191 #define FcValueLangSet(v)       FcPointerMember(v,u.l,const FcLangSet)
192
193 typedef struct _FcValueList *FcValueListPtr;
194
195 typedef struct _FcValueList {
196     struct _FcValueList *next;
197     FcValue             value;
198     FcValueBinding      binding;
199 } FcValueList;
200
201 #define FcValueListNext(vl)     FcPointerMember(vl,next,FcValueList)
202                         
203 typedef int FcObject;
204
205 typedef struct _FcPatternElt *FcPatternEltPtr;
206
207 /*
208  * Pattern elts are stuck in a structure connected to the pattern,
209  * so they get moved around when the pattern is resized. Hence, the
210  * values field must be a pointer/offset instead of just an offset
211  */
212 typedef struct _FcPatternElt {
213     FcObject            object;
214     FcValueList         *values;
215 } FcPatternElt;
216
217 #define FcPatternEltValues(pe)  FcPointerMember(pe,values,FcValueList)
218
219 struct _FcPattern {
220     int             num;
221     int             size;
222     intptr_t        elts_offset;
223     int             ref;
224 };
225
226 #define FcPatternElts(p)        FcOffsetMember(p,elts_offset,FcPatternElt)
227
228 #define FcFontSetFonts(fs)      FcPointerMember(fs,fonts,FcPattern *)
229
230 #define FcFontSetFont(fs,i)     (FcIsEncodedOffset((fs)->fonts) ? \
231                                  FcEncodedOffsetToPtr(fs, \
232                                                       FcFontSetFonts(fs)[i], \
233                                                       FcPattern) : \
234                                  fs->fonts[i])
235                                                 
236 typedef enum _FcOp {
237     FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpRange, FcOpBool, FcOpCharSet, FcOpLangSet,
238     FcOpNil,
239     FcOpField, FcOpConst,
240     FcOpAssign, FcOpAssignReplace,
241     FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
242     FcOpQuest,
243     FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
244     FcOpContains, FcOpListing, FcOpNotContains,
245     FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
246     FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
247     FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc,
248     FcOpInvalid
249 } FcOp;
250
251 typedef enum _FcOpFlags {
252         FcOpFlagIgnoreBlanks = 1 << 0
253 } FcOpFlags;
254
255 #define FC_OP_GET_OP(_x_)       ((_x_) & 0xffff)
256 #define FC_OP_GET_FLAGS(_x_)    (((_x_) & 0xffff0000) >> 16)
257 #define FC_OP(_x_,_f_)          (FC_OP_GET_OP (_x_) | ((_f_) << 16))
258
259 typedef struct _FcExpr {
260     FcOp   op;
261     union {
262         int         ival;
263         double      dval;
264         const FcChar8       *sval;
265         FcMatrix    *mval;
266         FcBool      bval;
267         FcCharSet   *cval;
268         FcLangSet   *lval;
269         FcObject    object;
270         const FcChar8       *constant;
271         struct {
272             struct _FcExpr *left, *right;
273         } tree;
274     } u;
275 } FcExpr;
276
277 typedef struct _FcExprPage FcExprPage;
278
279 struct _FcExprPage {
280   FcExprPage *next_page;
281   FcExpr *next;
282   FcExpr exprs[(1024 - 2/* two pointers */ - 2/* malloc overhead */) * sizeof (void *) / sizeof (FcExpr)];
283   FcExpr end[FLEXIBLE_ARRAY_MEMBER];
284 };
285
286 typedef enum _FcQual {
287     FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
288 } FcQual;
289
290 #define FcMatchDefault  ((FcMatchKind) -1)
291
292 typedef struct _FcTest {
293     struct _FcTest      *next;
294     FcMatchKind         kind;
295     FcQual              qual;
296     FcObject            object;
297     FcOp                op;
298     FcExpr              *expr;
299 } FcTest;
300
301 typedef struct _FcEdit {
302     struct _FcEdit *next;
303     FcObject        object;
304     FcOp            op;
305     FcExpr          *expr;
306     FcValueBinding  binding;
307 } FcEdit;
308
309 typedef struct _FcSubst {
310     struct _FcSubst     *next;
311     FcTest              *test;
312     FcEdit              *edit;
313 } FcSubst;
314
315 typedef struct _FcCharLeaf {
316     FcChar32    map[256/32];
317 } FcCharLeaf;
318
319 #define FC_REF_CONSTANT     -1
320
321 struct _FcCharSet {
322     int             ref;        /* reference count */
323     int             num;        /* size of leaves and numbers arrays */
324     intptr_t        leaves_offset;
325     intptr_t        numbers_offset;
326 };
327
328 #define FcCharSetLeaves(c)      FcOffsetMember(c,leaves_offset,intptr_t)
329 #define FcCharSetLeaf(c,i)      (FcOffsetToPtr(FcCharSetLeaves(c), \
330                                                FcCharSetLeaves(c)[i], \
331                                                FcCharLeaf))
332 #define FcCharSetNumbers(c)     FcOffsetMember(c,numbers_offset,FcChar16)
333
334 struct _FcStrSet {
335     int             ref;        /* reference count */
336     int             num;
337     int             size;
338     FcChar8         **strs;
339 };
340
341 struct _FcStrList {
342     FcStrSet        *set;
343     int             n;
344 };
345
346 typedef struct _FcStrBuf {
347     FcChar8 *buf;
348     FcBool  allocated;
349     FcBool  failed;
350     int     len;
351     int     size;
352     FcChar8 buf_static[16 * sizeof (void *)];
353 } FcStrBuf;
354
355 struct _FcCache {
356     int         magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
357     int         version;            /* FC_CACHE_CONTENT_VERSION */
358     intptr_t    size;               /* size of file */
359     intptr_t    dir;                /* offset to dir name */
360     intptr_t    dirs;               /* offset to subdirs */
361     int         dirs_count;         /* number of subdir strings */
362     intptr_t    set;                /* offset to font set */
363     int         checksum;           /* checksum of directory state */
364 };
365
366 #undef FcCacheDir
367 #undef FcCacheSubdir
368 #define FcCacheDir(c)   FcOffsetMember(c,dir,FcChar8)
369 #define FcCacheDirs(c)  FcOffsetMember(c,dirs,intptr_t)
370 #define FcCacheSet(c)   FcOffsetMember(c,set,FcFontSet)
371 #define FcCacheSubdir(c,i)  FcOffsetToPtr (FcCacheDirs(c),\
372                                            FcCacheDirs(c)[i], \
373                                            FcChar8)
374
375 /*
376  * Used while constructing a directory cache object
377  */
378
379 #define FC_SERIALIZE_HASH_SIZE  8191
380
381 typedef union _FcAlign {
382     double      d;
383     int         i;
384     intptr_t    ip;
385     FcBool      b;
386     void        *p;
387 } FcAlign;
388
389 typedef struct _FcSerializeBucket {
390     struct _FcSerializeBucket *next;
391     const void  *object;
392     intptr_t    offset;
393 } FcSerializeBucket;
394
395 typedef struct _FcCharSetFreezer FcCharSetFreezer;
396
397 typedef struct _FcSerialize {
398     intptr_t            size;
399     FcCharSetFreezer    *cs_freezer;
400     void                *linear;
401     FcSerializeBucket   *buckets[FC_SERIALIZE_HASH_SIZE];
402 } FcSerialize;
403
404 /*
405  * To map adobe glyph names to unicode values, a precomputed hash
406  * table is used
407  */
408
409 typedef struct _FcGlyphName {
410     FcChar32    ucs;            /* unicode value */
411     FcChar8     name[1];        /* name extends beyond struct */
412 } FcGlyphName;
413
414 /*
415  * To perform case-insensitive string comparisons, a table
416  * is used which holds three different kinds of folding data.
417  *
418  * The first is a range of upper case values mapping to a range
419  * of their lower case equivalents.  Within each range, the offset
420  * between upper and lower case is constant.
421  *
422  * The second is a range of upper case values which are interleaved
423  * with their lower case equivalents.
424  *
425  * The third is a set of raw unicode values mapping to a list
426  * of unicode values for comparison purposes.  This allows conversion
427  * of ß to "ss" so that SS, ss and ß all match.  A separate array
428  * holds the list of unicode values for each entry.
429  *
430  * These are packed into a single table.  Using a binary search,
431  * the appropriate entry can be located.
432  */
433
434 #define FC_CASE_FOLD_RANGE          0
435 #define FC_CASE_FOLD_EVEN_ODD       1
436 #define FC_CASE_FOLD_FULL           2
437
438 typedef struct _FcCaseFold {
439     FcChar32    upper;
440     FcChar16    method : 2;
441     FcChar16    count : 14;
442     short       offset;     /* lower - upper for RANGE, table id for FULL */
443 } FcCaseFold;
444
445 #define FC_MAX_FILE_LEN     4096
446
447 #define FC_CACHE_MAGIC_MMAP         0xFC02FC04
448 #define FC_CACHE_MAGIC_ALLOC        0xFC02FC05
449 #define FC_CACHE_CONTENT_VERSION    3 /* also check FC_CACHE_VERSION */
450
451 struct _FcAtomic {
452     FcChar8     *file;          /* original file name */
453     FcChar8     *new;           /* temp file name -- write data here */
454     FcChar8     *lck;           /* lockfile name (used for locking) */
455     FcChar8     *tmp;           /* tmpfile name (used for locking) */
456 };
457
458 struct _FcBlanks {
459     int         nblank;
460     int         sblank;
461     FcChar32    *blanks;
462 };
463
464 struct _FcConfig {
465     /*
466      * File names loaded from the configuration -- saved here as the
467      * cache file must be consulted before the directories are scanned,
468      * and those directives may occur in any order
469      */
470     FcStrSet    *configDirs;        /* directories to scan for fonts */
471     /*
472      * Set of allowed blank chars -- used to
473      * trim fonts of bogus glyphs
474      */
475     FcBlanks    *blanks;
476     /*
477      * List of directories containing fonts,
478      * built by recursively scanning the set
479      * of configured directories
480      */
481     FcStrSet    *fontDirs;
482     /*
483      * List of directories containing cache files.
484      */
485     FcStrSet    *cacheDirs;
486     /*
487      * Names of all of the configuration files used
488      * to create this configuration
489      */
490     FcStrSet    *configFiles;       /* config files loaded */
491     /*
492      * Substitution instructions for patterns and fonts;
493      * maxObjects is used to allocate appropriate intermediate storage
494      * while performing a whole set of substitutions
495      */
496     FcSubst     *substPattern;      /* substitutions for patterns */
497     FcSubst     *substFont;         /* substitutions for fonts */
498     FcSubst     *substScan;         /* substitutions for scanned fonts */
499     int         maxObjects;         /* maximum number of tests in all substs */
500     /*
501      * List of patterns used to control font file selection
502      */
503     FcStrSet    *acceptGlobs;
504     FcStrSet    *rejectGlobs;
505     FcFontSet   *acceptPatterns;
506     FcFontSet   *rejectPatterns;
507     /*
508      * The set of fonts loaded from the listed directories; the
509      * order within the set does not determine the font selection,
510      * except in the case of identical matches in which case earlier fonts
511      * match preferrentially
512      */
513     FcFontSet   *fonts[FcSetApplication + 1];
514     /*
515      * Fontconfig can periodically rescan the system configuration
516      * and font directories.  This rescanning occurs when font
517      * listing requests are made, but no more often than rescanInterval
518      * seconds apart.
519      */
520     time_t      rescanTime;         /* last time information was scanned */
521     int         rescanInterval;     /* interval between scans */
522
523     int         ref;                /* reference count */
524
525     FcExprPage *expr_pool;          /* pool of FcExpr's */
526 };
527
528 extern FcPrivate FcConfig       *_fcConfig;
529
530 typedef struct _FcFileTime {
531     time_t  time;
532     FcBool  set;
533 } FcFileTime;
534
535 typedef struct _FcCharMap FcCharMap;
536
537 typedef struct _FcRange     FcRange;
538
539 struct _FcRange {
540     FcChar32 begin;
541     FcChar32 end;
542 };
543
544 typedef struct _FcStatFS    FcStatFS;
545
546 struct _FcStatFS {
547     FcBool is_remote_fs;
548     FcBool is_mtime_broken;
549 };
550
551 /* fcblanks.c */
552
553 /* fccache.c */
554
555 FcPrivate FcCache *
556 FcDirCacheScan (const FcChar8 *dir, FcConfig *config);
557
558 FcPrivate FcCache *
559 FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs);
560
561 FcPrivate FcBool
562 FcDirCacheWrite (FcCache *cache, FcConfig *config);
563
564 FcPrivate FcBool
565 FcDirCacheCreateTagFile (const FcChar8 *cache_dir);
566
567 FcPrivate void
568 FcCacheObjectReference (void *object);
569
570 FcPrivate void
571 FcCacheObjectDereference (void *object);
572
573 FcPrivate void
574 FcCacheFini (void);
575
576 FcPrivate void
577 FcDirCacheReference (FcCache *cache, int nref);
578
579 /* fccfg.c */
580
581 FcPrivate FcChar8 *
582 FcConfigXdgCacheHome (void);
583
584 FcPrivate FcChar8 *
585 FcConfigXdgConfigHome (void);
586
587 FcPrivate FcChar8 *
588 FcConfigXdgDataHome (void);
589
590 FcPrivate FcExpr *
591 FcConfigAllocExpr (FcConfig *config);
592
593 FcPrivate FcBool
594 FcConfigAddConfigDir (FcConfig      *config,
595                       const FcChar8 *d);
596
597 FcPrivate FcBool
598 FcConfigAddFontDir (FcConfig        *config,
599                     const FcChar8   *d);
600
601 FcPrivate FcBool
602 FcConfigAddDir (FcConfig        *config,
603                 const FcChar8   *d);
604
605 FcPrivate FcBool
606 FcConfigAddCacheDir (FcConfig       *config,
607                      const FcChar8  *d);
608
609 FcPrivate FcBool
610 FcConfigAddConfigFile (FcConfig         *config,
611                        const FcChar8    *f);
612
613 FcPrivate FcBool
614 FcConfigAddBlank (FcConfig      *config,
615                   FcChar32      blank);
616
617 FcPrivate FcBool
618 FcConfigAddEdit (FcConfig       *config,
619                  FcTest         *test,
620                  FcEdit         *edit,
621                  FcMatchKind    kind);
622
623 FcPrivate void
624 FcConfigSetFonts (FcConfig      *config,
625                   FcFontSet     *fonts,
626                   FcSetName     set);
627
628 FcPrivate FcBool
629 FcConfigCompareValue (const FcValue *m,
630                       FcOp          op,
631                       const FcValue *v);
632
633 FcPrivate FcBool
634 FcConfigGlobAdd (FcConfig       *config,
635                  const FcChar8  *glob,
636                  FcBool         accept);
637
638 FcPrivate FcBool
639 FcConfigAcceptFilename (FcConfig        *config,
640                         const FcChar8   *filename);
641
642 FcPrivate FcBool
643 FcConfigPatternsAdd (FcConfig   *config,
644                      FcPattern  *pattern,
645                      FcBool     accept);
646
647 FcPrivate FcBool
648 FcConfigAcceptFont (FcConfig        *config,
649                     const FcPattern *font);
650
651 FcPrivate FcFileTime
652 FcConfigModifiedTime (FcConfig *config);
653
654 FcPrivate FcBool
655 FcConfigAddCache (FcConfig *config, FcCache *cache,
656                   FcSetName set, FcStrSet *dirSet);
657
658 /* fcserialize.c */
659 FcPrivate intptr_t
660 FcAlignSize (intptr_t size);
661
662 FcPrivate FcSerialize *
663 FcSerializeCreate (void);
664
665 FcPrivate void
666 FcSerializeDestroy (FcSerialize *serialize);
667
668 FcPrivate FcBool
669 FcSerializeAlloc (FcSerialize *serialize, const void *object, int size);
670
671 FcPrivate intptr_t
672 FcSerializeReserve (FcSerialize *serialize, int size);
673
674 FcPrivate intptr_t
675 FcSerializeOffset (FcSerialize *serialize, const void *object);
676
677 FcPrivate void *
678 FcSerializePtr (FcSerialize *serialize, const void *object);
679
680 FcPrivate FcBool
681 FcLangSetSerializeAlloc (FcSerialize *serialize, const FcLangSet *l);
682
683 FcPrivate FcLangSet *
684 FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
685
686 /* fccharset.c */
687 FcPrivate void
688 FcLangCharSetPopulate (void);
689
690 FcPrivate FcCharSetFreezer *
691 FcCharSetFreezerCreate (void);
692
693 FcPrivate const FcCharSet *
694 FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs);
695
696 FcPrivate void
697 FcCharSetFreezerDestroy (FcCharSetFreezer *freezer);
698
699 FcPrivate FcBool
700 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
701
702 FcPrivate FcCharSet *
703 FcNameParseCharSet (FcChar8 *string);
704
705 FcPrivate FcBool
706 FcNameUnparseValue (FcStrBuf    *buf,
707                     FcValue     *v0,
708                     FcChar8     *escape);
709
710 FcPrivate FcBool
711 FcNameUnparseValueList (FcStrBuf        *buf,
712                         FcValueListPtr  v,
713                         FcChar8         *escape);
714
715 FcPrivate FcCharLeaf *
716 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
717
718 FcPrivate FcBool
719 FcCharSetSerializeAlloc(FcSerialize *serialize, const FcCharSet *cs);
720
721 FcPrivate FcCharSet *
722 FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs);
723
724 FcPrivate FcChar16 *
725 FcCharSetGetNumbers(const FcCharSet *c);
726
727 /* fcdbg.c */
728 FcPrivate void
729 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
730
731 FcPrivate void
732 FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos);
733
734 FcPrivate void
735 FcValueListPrint (FcValueListPtr l);
736
737 FcPrivate void
738 FcLangSetPrint (const FcLangSet *ls);
739
740 FcPrivate void
741 FcOpPrint (FcOp op);
742
743 FcPrivate void
744 FcTestPrint (const FcTest *test);
745
746 FcPrivate void
747 FcExprPrint (const FcExpr *expr);
748
749 FcPrivate void
750 FcEditPrint (const FcEdit *edit);
751
752 FcPrivate void
753 FcSubstPrint (const FcSubst *subst);
754
755 FcPrivate void
756 FcCharSetPrint (const FcCharSet *c);
757
758 extern FcPrivate int FcDebugVal;
759
760 #define FcDebug() (FcDebugVal)
761
762 FcPrivate void
763 FcInitDebug (void);
764
765 /* fcdefault.c */
766 FcPrivate FcChar8 *
767 FcGetDefaultLang (void);
768
769 /* fcdir.c */
770
771 FcPrivate FcBool
772 FcFileScanConfig (FcFontSet     *set,
773                   FcStrSet      *dirs,
774                   FcBlanks      *blanks,
775                   const FcChar8 *file,
776                   FcConfig      *config);
777
778 FcPrivate FcBool
779 FcDirScanConfig (FcFontSet      *set,
780                  FcStrSet       *dirs,
781                  FcBlanks       *blanks,
782                  const FcChar8  *dir,
783                  FcBool         force,
784                  FcConfig       *config);
785
786 /* fcfont.c */
787 FcPrivate int
788 FcFontDebug (void);
789
790 /* fcfs.c */
791
792 FcPrivate FcBool
793 FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
794
795 FcPrivate FcFontSet *
796 FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
797
798 /* fcxml.c */
799 FcPrivate void
800 FcTestDestroy (FcTest *test);
801
802 FcPrivate void
803 FcEditDestroy (FcEdit *e);
804
805 /* fcinit.c */
806
807 FcPrivate void
808 FcMemReport (void);
809
810 FcPrivate void
811 FcMemAlloc (int kind, int size);
812
813 FcPrivate void
814 FcMemFree (int kind, int size);
815
816 /* fclang.c */
817 FcPrivate FcLangSet *
818 FcFreeTypeLangSet (const FcCharSet  *charset,
819                    const FcChar8    *exclusiveLang);
820
821 FcPrivate FcChar8 *
822 FcLangNormalize (const FcChar8 *lang);
823
824 FcPrivate FcLangResult
825 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
826
827 FcPrivate FcLangSet *
828 FcLangSetPromote (const FcChar8 *lang);
829
830 FcPrivate FcLangSet *
831 FcNameParseLangSet (const FcChar8 *string);
832
833 FcPrivate FcBool
834 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
835
836 FcPrivate FcChar8 *
837 FcNameUnparseEscaped (FcPattern *pat, FcBool escape);
838
839 /* fclist.c */
840
841 FcPrivate FcBool
842 FcListPatternMatchAny (const FcPattern *p,
843                        const FcPattern *font);
844
845 /* fcmatch.c */
846
847 /* fcname.c */
848
849 /*
850  * NOTE -- this ordering is part of the cache file format.
851  * It must also match the ordering in fcname.c
852  */
853
854 #define FC_FAMILY_OBJECT        1
855 #define FC_FAMILYLANG_OBJECT    2
856 #define FC_STYLE_OBJECT         3
857 #define FC_STYLELANG_OBJECT     4
858 #define FC_FULLNAME_OBJECT      5
859 #define FC_FULLNAMELANG_OBJECT  6
860 #define FC_SLANT_OBJECT         7
861 #define FC_WEIGHT_OBJECT        8
862 #define FC_WIDTH_OBJECT         9
863 #define FC_SIZE_OBJECT          10
864 #define FC_ASPECT_OBJECT        11
865 #define FC_PIXEL_SIZE_OBJECT    12
866 #define FC_SPACING_OBJECT       13
867 #define FC_FOUNDRY_OBJECT       14
868 #define FC_ANTIALIAS_OBJECT     15
869 #define FC_HINT_STYLE_OBJECT    16
870 #define FC_HINTING_OBJECT       17
871 #define FC_VERTICAL_LAYOUT_OBJECT       18
872 #define FC_AUTOHINT_OBJECT      19
873 #define FC_GLOBAL_ADVANCE_OBJECT        20      /* deprecated */
874 #define FC_FILE_OBJECT          21
875 #define FC_INDEX_OBJECT         22
876 #define FC_RASTERIZER_OBJECT    23
877 #define FC_OUTLINE_OBJECT       24
878 #define FC_SCALABLE_OBJECT      25
879 #define FC_DPI_OBJECT           26
880 #define FC_RGBA_OBJECT          27
881 #define FC_SCALE_OBJECT         28
882 #define FC_MINSPACE_OBJECT      29
883 #define FC_CHAR_WIDTH_OBJECT    30
884 #define FC_CHAR_HEIGHT_OBJECT   31
885 #define FC_MATRIX_OBJECT        32
886 #define FC_CHARSET_OBJECT       33
887 #define FC_LANG_OBJECT          34
888 #define FC_FONTVERSION_OBJECT   35
889 #define FC_CAPABILITY_OBJECT    36
890 #define FC_FONTFORMAT_OBJECT    37
891 #define FC_EMBOLDEN_OBJECT      38
892 #define FC_EMBEDDED_BITMAP_OBJECT       39
893 #define FC_DECORATIVE_OBJECT    40
894 #define FC_LCD_FILTER_OBJECT    41
895 #define FC_NAMELANG_OBJECT      42
896 #define FC_MAX_BASE_OBJECT      FC_NAMELANG_OBJECT
897
898 FcPrivate FcBool
899 FcNameBool (const FcChar8 *v, FcBool *result);
900
901 FcPrivate FcBool
902 FcObjectValidType (FcObject object, FcType type);
903
904 FcPrivate FcObject
905 FcObjectFromName (const char * name);
906
907 FcPrivate const char *
908 FcObjectName (FcObject object);
909
910 FcPrivate FcObjectSet *
911 FcObjectGetSet (void);
912
913 FcPrivate FcBool
914 FcObjectInit (void);
915
916 FcPrivate void
917 FcObjectFini (void);
918
919 #define FcObjectCompare(a, b)   ((int) a - (int) b)
920
921 /* fcpat.c */
922
923 FcPrivate FcValue
924 FcValueCanonicalize (const FcValue *v);
925
926 FcPrivate void
927 FcValueListDestroy (FcValueListPtr l);
928
929 FcPrivate FcPatternElt *
930 FcPatternObjectFindElt (const FcPattern *p, FcObject object);
931
932 FcPrivate FcPatternElt *
933 FcPatternObjectInsertElt (FcPattern *p, FcObject object);
934
935 FcPrivate FcBool
936 FcPatternObjectAddWithBinding  (FcPattern       *p,
937                                 FcObject        object,
938                                 FcValue         value,
939                                 FcValueBinding  binding,
940                                 FcBool          append);
941
942 FcPrivate FcBool
943 FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append);
944
945 FcPrivate FcBool
946 FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append);
947
948 FcPrivate FcResult
949 FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v);
950
951 FcPrivate FcBool
952 FcPatternObjectDel (FcPattern *p, FcObject object);
953
954 FcPrivate FcBool
955 FcPatternObjectRemove (FcPattern *p, FcObject object, int id);
956
957 FcPrivate FcBool
958 FcPatternObjectAddInteger (FcPattern *p, FcObject object, int i);
959
960 FcPrivate FcBool
961 FcPatternObjectAddDouble (FcPattern *p, FcObject object, double d);
962
963 FcPrivate FcBool
964 FcPatternObjectAddString (FcPattern *p, FcObject object, const FcChar8 *s);
965
966 FcPrivate FcBool
967 FcPatternObjectAddMatrix (FcPattern *p, FcObject object, const FcMatrix *s);
968
969 FcPrivate FcBool
970 FcPatternObjectAddCharSet (FcPattern *p, FcObject object, const FcCharSet *c);
971
972 FcPrivate FcBool
973 FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b);
974
975 FcPrivate FcBool
976 FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
977
978 FcPrivate FcResult
979 FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
980
981 FcPrivate FcResult
982 FcPatternObjectGetDouble (const FcPattern *p, FcObject object, int n, double *d);
983
984 FcPrivate FcResult
985 FcPatternObjectGetString (const FcPattern *p, FcObject object, int n, FcChar8 ** s);
986
987 FcPrivate FcResult
988 FcPatternObjectGetMatrix (const FcPattern *p, FcObject object, int n, FcMatrix **s);
989
990 FcPrivate FcResult
991 FcPatternObjectGetCharSet (const FcPattern *p, FcObject object, int n, FcCharSet **c);
992
993 FcPrivate FcResult
994 FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
995
996 FcPrivate FcResult
997 FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
998
999 FcPrivate FcBool
1000 FcPatternAppend (FcPattern *p, FcPattern *s);
1001
1002 FcPrivate const FcChar8 *
1003 FcSharedStr (const FcChar8 *name);
1004
1005 FcPrivate FcBool
1006 FcSharedStrFree (const FcChar8 *name);
1007
1008 FcPrivate FcChar32
1009 FcStringHash (const FcChar8 *s);
1010
1011 FcPrivate FcBool
1012 FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat);
1013
1014 FcPrivate FcPattern *
1015 FcPatternSerialize (FcSerialize *serialize, const FcPattern *pat);
1016
1017 FcPrivate FcBool
1018 FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *pat);
1019
1020 FcPrivate FcValueList *
1021 FcValueListSerialize (FcSerialize *serialize, const FcValueList *pat);
1022
1023 /* fcrender.c */
1024
1025 /* fcmatrix.c */
1026
1027 extern FcPrivate const FcMatrix    FcIdentityMatrix;
1028
1029 FcPrivate void
1030 FcMatrixFree (FcMatrix *mat);
1031
1032 /* fcstat.c */
1033
1034 FcPrivate int
1035 FcStat (const FcChar8 *file, struct stat *statb);
1036
1037 FcPrivate int
1038 FcStatChecksum (const FcChar8 *file, struct stat *statb);
1039
1040 FcPrivate FcBool
1041 FcIsFsMmapSafe (int fd);
1042
1043 FcPrivate FcBool
1044 FcIsFsMtimeBroken (const FcChar8 *dir);
1045
1046 /* fcstr.c */
1047 FcPrivate FcBool
1048 FcStrSetAddLangs (FcStrSet *strs, const char *languages);
1049
1050 FcPrivate void
1051 FcStrSetSort (FcStrSet * set);
1052
1053 FcPrivate void
1054 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
1055
1056 FcPrivate void
1057 FcStrBufDestroy (FcStrBuf *buf);
1058
1059 FcPrivate FcChar8 *
1060 FcStrBufDone (FcStrBuf *buf);
1061
1062 FcPrivate FcChar8 *
1063 FcStrBufDoneStatic (FcStrBuf *buf);
1064
1065 FcPrivate FcBool
1066 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
1067
1068 FcPrivate FcBool
1069 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
1070
1071 FcPrivate FcBool
1072 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
1073
1074 FcPrivate int
1075 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1076
1077 FcPrivate FcBool
1078 FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
1079
1080 FcPrivate FcBool
1081 FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
1082
1083 FcPrivate const FcChar8 *
1084 FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1085
1086 FcPrivate const FcChar8 *
1087 FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
1088
1089 FcPrivate const FcChar8 *
1090 FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2);
1091
1092 FcPrivate FcBool
1093 FcStrUsesHome (const FcChar8 *s);
1094
1095 FcPrivate FcChar8 *
1096 FcStrLastSlash (const FcChar8  *path);
1097
1098 FcPrivate FcChar32
1099 FcStrHashIgnoreCase (const FcChar8 *s);
1100
1101 FcPrivate FcChar8 *
1102 FcStrCanonFilename (const FcChar8 *s);
1103
1104 FcPrivate FcBool
1105 FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
1106
1107 FcPrivate FcChar8 *
1108 FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
1109
1110 #endif /* _FC_INT_H_ */