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