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