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