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