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