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