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