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