fcint.h revision 5e61939b
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"
57typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
58typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
59extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
60extern 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
107FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
108
109typedef 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
162typedef struct _FcValueList *FcValueListPtr;
163
164typedef struct _FcValueList {
165    struct _FcValueList	*next;
166    FcValue		value;
167    FcValueBinding	binding;
168} FcValueList;
169
170#define FcValueListNext(vl)	FcPointerMember(vl,next,FcValueList)
171
172typedef int FcObject;
173
174typedef 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 */
181typedef struct _FcPatternElt {
182    FcObject		object;
183    FcValueList		*values;
184} FcPatternElt;
185
186#define FcPatternEltValues(pe)	FcPointerMember(pe,values,FcValueList)
187
188struct _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
205typedef 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
221typedef 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
229typedef struct _FcExprMatrix {
230  struct _FcExpr *xx, *xy, *yx, *yy;
231} FcExprMatrix;
232
233typedef struct _FcExprName {
234  FcObject	object;
235  FcMatchKind	kind;
236} FcExprName;
237
238
239typedef 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
258typedef struct _FcExprPage FcExprPage;
259
260struct _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
267typedef enum _FcQual {
268    FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
269} FcQual;
270
271#define FcMatchDefault	((FcMatchKind) -1)
272
273typedef struct _FcTest {
274    struct _FcTest	*next;
275    FcMatchKind		kind;
276    FcQual		qual;
277    FcObject		object;
278    FcOp		op;
279    FcExpr		*expr;
280} FcTest;
281
282typedef struct _FcEdit {
283    struct _FcEdit *next;
284    FcObject	    object;
285    FcOp	    op;
286    FcExpr	    *expr;
287    FcValueBinding  binding;
288} FcEdit;
289
290typedef struct _FcSubst {
291    struct _FcSubst	*next;
292    FcTest		*test;
293    FcEdit		*edit;
294} FcSubst;
295
296typedef struct _FcCharLeaf {
297    FcChar32	map[256/32];
298} FcCharLeaf;
299
300struct _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
313struct _FcStrSet {
314    FcRef	    ref;	/* reference count */
315    int		    num;
316    int		    size;
317    FcChar8	    **strs;
318};
319
320struct _FcStrList {
321    FcStrSet	    *set;
322    int		    n;
323};
324
325typedef 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
334struct _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
360typedef union _FcAlign {
361    double	d;
362    int		i;
363    intptr_t	ip;
364    FcBool	b;
365    void	*p;
366} FcAlign;
367
368typedef struct _FcSerializeBucket {
369    struct _FcSerializeBucket *next;
370    const void	*object;
371    intptr_t	offset;
372} FcSerializeBucket;
373
374typedef struct _FcCharSetFreezer FcCharSetFreezer;
375
376typedef 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
388typedef 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
417typedef 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
430struct _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
437struct _FcBlanks {
438    int		nblank;
439    int		sblank;
440    FcChar32	*blanks;
441};
442
443struct _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
509typedef struct _FcFileTime {
510    time_t  time;
511    FcBool  set;
512} FcFileTime;
513
514typedef struct _FcCharMap FcCharMap;
515
516typedef struct _FcRange	    FcRange;
517
518struct _FcRange {
519    FcChar32 begin;
520    FcChar32 end;
521};
522
523typedef struct _FcStatFS    FcStatFS;
524
525struct _FcStatFS {
526    FcBool is_remote_fs;
527    FcBool is_mtime_broken;
528};
529
530typedef struct _FcValuePromotionBuffer FcValuePromotionBuffer;
531
532struct _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
545FcPrivate FcCache *
546FcDirCacheScan (const FcChar8 *dir, FcConfig *config);
547
548FcPrivate FcCache *
549FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs);
550
551FcPrivate FcBool
552FcDirCacheWrite (FcCache *cache, FcConfig *config);
553
554FcPrivate FcBool
555FcDirCacheCreateTagFile (const FcChar8 *cache_dir);
556
557FcPrivate void
558FcCacheObjectReference (void *object);
559
560FcPrivate void
561FcCacheObjectDereference (void *object);
562
563FcPrivate void
564FcCacheFini (void);
565
566FcPrivate void
567FcDirCacheReference (FcCache *cache, int nref);
568
569/* fccfg.c */
570
571FcPrivate FcBool
572FcConfigInit (void);
573
574FcPrivate void
575FcConfigFini (void);
576
577FcPrivate FcChar8 *
578FcConfigXdgCacheHome (void);
579
580FcPrivate FcChar8 *
581FcConfigXdgConfigHome (void);
582
583FcPrivate FcChar8 *
584FcConfigXdgDataHome (void);
585
586FcPrivate FcExpr *
587FcConfigAllocExpr (FcConfig *config);
588
589FcPrivate FcBool
590FcConfigAddConfigDir (FcConfig	    *config,
591		      const FcChar8 *d);
592
593FcPrivate FcBool
594FcConfigAddFontDir (FcConfig	    *config,
595		    const FcChar8   *d);
596
597FcPrivate FcBool
598FcConfigAddDir (FcConfig	*config,
599		const FcChar8	*d);
600
601FcPrivate FcBool
602FcConfigAddCacheDir (FcConfig	    *config,
603		     const FcChar8  *d);
604
605FcPrivate FcBool
606FcConfigAddConfigFile (FcConfig		*config,
607		       const FcChar8	*f);
608
609FcPrivate FcBool
610FcConfigAddBlank (FcConfig	*config,
611		  FcChar32    	blank);
612
613FcPrivate FcBool
614FcConfigAddEdit (FcConfig	*config,
615		 FcTest		*test,
616		 FcEdit		*edit,
617		 FcMatchKind	kind);
618
619FcPrivate void
620FcConfigSetFonts (FcConfig	*config,
621		  FcFontSet	*fonts,
622		  FcSetName	set);
623
624FcPrivate FcBool
625FcConfigCompareValue (const FcValue *m,
626		      FcOp	    op,
627		      const FcValue *v);
628
629FcPrivate FcBool
630FcConfigGlobAdd (FcConfig	*config,
631		 const FcChar8	*glob,
632		 FcBool		accept);
633
634FcPrivate FcBool
635FcConfigAcceptFilename (FcConfig	*config,
636			const FcChar8	*filename);
637
638FcPrivate FcBool
639FcConfigPatternsAdd (FcConfig	*config,
640		     FcPattern	*pattern,
641		     FcBool	accept);
642
643FcPrivate FcBool
644FcConfigAcceptFont (FcConfig	    *config,
645		    const FcPattern *font);
646
647FcPrivate FcFileTime
648FcConfigModifiedTime (FcConfig *config);
649
650FcPrivate FcBool
651FcConfigAddCache (FcConfig *config, FcCache *cache,
652		  FcSetName set, FcStrSet *dirSet);
653
654/* fcserialize.c */
655FcPrivate intptr_t
656FcAlignSize (intptr_t size);
657
658FcPrivate FcSerialize *
659FcSerializeCreate (void);
660
661FcPrivate void
662FcSerializeDestroy (FcSerialize *serialize);
663
664FcPrivate FcBool
665FcSerializeAlloc (FcSerialize *serialize, const void *object, int size);
666
667FcPrivate intptr_t
668FcSerializeReserve (FcSerialize *serialize, int size);
669
670FcPrivate intptr_t
671FcSerializeOffset (FcSerialize *serialize, const void *object);
672
673FcPrivate void *
674FcSerializePtr (FcSerialize *serialize, const void *object);
675
676FcPrivate FcBool
677FcLangSetSerializeAlloc (FcSerialize *serialize, const FcLangSet *l);
678
679FcPrivate FcLangSet *
680FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
681
682/* fccharset.c */
683FcPrivate void
684FcLangCharSetPopulate (void);
685
686FcPrivate FcCharSetFreezer *
687FcCharSetFreezerCreate (void);
688
689FcPrivate const FcCharSet *
690FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs);
691
692FcPrivate void
693FcCharSetFreezerDestroy (FcCharSetFreezer *freezer);
694
695FcPrivate FcBool
696FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
697
698FcPrivate FcCharSet *
699FcNameParseCharSet (FcChar8 *string);
700
701FcPrivate FcBool
702FcNameUnparseValue (FcStrBuf    *buf,
703                    FcValue     *v0,
704		    FcChar8     *escape);
705
706FcPrivate FcBool
707FcNameUnparseValueList (FcStrBuf	*buf,
708			FcValueListPtr	v,
709			FcChar8		*escape);
710
711FcPrivate FcCharLeaf *
712FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
713
714FcPrivate FcBool
715FcCharSetSerializeAlloc(FcSerialize *serialize, const FcCharSet *cs);
716
717FcPrivate FcCharSet *
718FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs);
719
720FcPrivate FcChar16 *
721FcCharSetGetNumbers(const FcCharSet *c);
722
723/* fccompat.c */
724FcPrivate int
725FcOpen(const char *pathname, int flags, ...);
726
727FcPrivate int
728FcMakeTempfile (char *template);
729
730FcPrivate int32_t
731FcRandom (void);
732
733/* fcdbg.c */
734
735FcPrivate void
736FcValuePrintFile (FILE *f, const FcValue v);
737
738FcPrivate void
739FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
740
741FcPrivate void
742FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos);
743
744FcPrivate void
745FcValueListPrint (FcValueListPtr l);
746
747FcPrivate void
748FcLangSetPrint (const FcLangSet *ls);
749
750FcPrivate void
751FcOpPrint (FcOp op);
752
753FcPrivate void
754FcTestPrint (const FcTest *test);
755
756FcPrivate void
757FcExprPrint (const FcExpr *expr);
758
759FcPrivate void
760FcEditPrint (const FcEdit *edit);
761
762FcPrivate void
763FcSubstPrint (const FcSubst *subst);
764
765FcPrivate void
766FcCharSetPrint (const FcCharSet *c);
767
768extern FcPrivate int FcDebugVal;
769
770#define FcDebug() (FcDebugVal)
771
772FcPrivate void
773FcInitDebug (void);
774
775/* fcdefault.c */
776FcPrivate FcChar8 *
777FcGetDefaultLang (void);
778
779FcPrivate FcChar8 *
780FcGetPrgname (void);
781
782FcPrivate void
783FcDefaultFini (void);
784
785/* fcdir.c */
786
787FcPrivate FcBool
788FcFileIsLink (const FcChar8 *file);
789
790FcPrivate FcBool
791FcFileScanConfig (FcFontSet	*set,
792		  FcStrSet	*dirs,
793		  FcBlanks	*blanks,
794		  const FcChar8 *file,
795		  FcConfig	*config);
796
797FcPrivate FcBool
798FcDirScanConfig (FcFontSet	*set,
799		 FcStrSet	*dirs,
800		 FcBlanks	*blanks,
801		 const FcChar8	*dir,
802		 FcBool		force,
803		 FcConfig	*config);
804
805/* fcfont.c */
806FcPrivate int
807FcFontDebug (void);
808
809/* fcfs.c */
810
811FcPrivate FcBool
812FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
813
814FcPrivate FcFontSet *
815FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
816
817/* fchash.c */
818FcPrivate FcChar8 *
819FcHashGetSHA256Digest (const FcChar8 *input_strings,
820		       size_t         len);
821
822FcPrivate FcChar8 *
823FcHashGetSHA256DigestFromFile (const FcChar8 *filename);
824
825FcPrivate FcChar8 *
826FcHashGetSHA256DigestFromMemory (const char *fontdata,
827				 size_t      length);
828
829/* fcinit.c */
830FcPrivate FcConfig *
831FcInitLoadOwnConfig (FcConfig *config);
832
833FcPrivate FcConfig *
834FcInitLoadOwnConfigAndFonts (FcConfig *config);
835
836/* fcxml.c */
837FcPrivate void
838FcTestDestroy (FcTest *test);
839
840FcPrivate void
841FcEditDestroy (FcEdit *e);
842
843/* fclang.c */
844FcPrivate FcLangSet *
845FcFreeTypeLangSet (const FcCharSet  *charset,
846		   const FcChar8    *exclusiveLang);
847
848FcPrivate FcLangResult
849FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
850
851FcPrivate FcLangSet *
852FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *buf);
853
854FcPrivate FcLangSet *
855FcNameParseLangSet (const FcChar8 *string);
856
857FcPrivate FcBool
858FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
859
860FcPrivate FcChar8 *
861FcNameUnparseEscaped (FcPattern *pat, FcBool escape);
862
863/* fclist.c */
864
865FcPrivate FcBool
866FcListPatternMatchAny (const FcPattern *p,
867		       const FcPattern *font);
868
869/* fcmatch.c */
870
871/* fcname.c */
872
873enum {
874  FC_INVALID_OBJECT = 0,
875#define FC_OBJECT(NAME, Type, Cmp) FC_##NAME##_OBJECT,
876#include "fcobjs.h"
877#undef FC_OBJECT
878  FC_ONE_AFTER_MAX_BASE_OBJECT
879#define FC_MAX_BASE_OBJECT (FC_ONE_AFTER_MAX_BASE_OBJECT - 1)
880};
881
882FcPrivate FcBool
883FcNameBool (const FcChar8 *v, FcBool *result);
884
885FcPrivate FcBool
886FcObjectValidType (FcObject object, FcType type);
887
888FcPrivate FcObject
889FcObjectFromName (const char * name);
890
891FcPrivate const char *
892FcObjectName (FcObject object);
893
894FcPrivate FcObjectSet *
895FcObjectGetSet (void);
896
897#define FcObjectCompare(a, b)	((int) a - (int) b)
898
899/* fcpat.c */
900
901FcPrivate FcValue
902FcValueCanonicalize (const FcValue *v);
903
904FcPrivate FcValueListPtr
905FcValueListCreate (void);
906
907FcPrivate void
908FcValueListDestroy (FcValueListPtr l);
909
910FcPrivate FcValueListPtr
911FcValueListPrepend (FcValueListPtr vallist,
912		    FcValue        value,
913		    FcValueBinding binding);
914
915FcPrivate FcValueListPtr
916FcValueListAppend (FcValueListPtr vallist,
917		   FcValue        value,
918		   FcValueBinding binding);
919
920FcPrivate FcValueListPtr
921FcValueListDuplicate(FcValueListPtr orig);
922
923FcPrivate FcPatternElt *
924FcPatternObjectFindElt (const FcPattern *p, FcObject object);
925
926FcPrivate FcPatternElt *
927FcPatternObjectInsertElt (FcPattern *p, FcObject object);
928
929FcPrivate FcBool
930FcPatternObjectListAdd (FcPattern	*p,
931			FcObject	object,
932			FcValueListPtr	list,
933			FcBool		append);
934
935FcPrivate FcBool
936FcPatternObjectAddWithBinding  (FcPattern	*p,
937				FcObject	object,
938				FcValue		value,
939				FcValueBinding  binding,
940				FcBool		append);
941
942FcPrivate FcBool
943FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append);
944
945FcPrivate FcBool
946FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append);
947
948FcPrivate FcResult
949FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v);
950
951FcPrivate FcBool
952FcPatternObjectDel (FcPattern *p, FcObject object);
953
954FcPrivate FcBool
955FcPatternObjectRemove (FcPattern *p, FcObject object, int id);
956
957FcPrivate FcBool
958FcPatternObjectAddInteger (FcPattern *p, FcObject object, int i);
959
960FcPrivate FcBool
961FcPatternObjectAddDouble (FcPattern *p, FcObject object, double d);
962
963FcPrivate FcBool
964FcPatternObjectAddString (FcPattern *p, FcObject object, const FcChar8 *s);
965
966FcPrivate FcBool
967FcPatternObjectAddMatrix (FcPattern *p, FcObject object, const FcMatrix *s);
968
969FcPrivate FcBool
970FcPatternObjectAddCharSet (FcPattern *p, FcObject object, const FcCharSet *c);
971
972FcPrivate FcBool
973FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b);
974
975FcPrivate FcBool
976FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
977
978FcPrivate FcResult
979FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
980
981FcPrivate FcResult
982FcPatternObjectGetDouble (const FcPattern *p, FcObject object, int n, double *d);
983
984FcPrivate FcResult
985FcPatternObjectGetString (const FcPattern *p, FcObject object, int n, FcChar8 ** s);
986
987FcPrivate FcResult
988FcPatternObjectGetMatrix (const FcPattern *p, FcObject object, int n, FcMatrix **s);
989
990FcPrivate FcResult
991FcPatternObjectGetCharSet (const FcPattern *p, FcObject object, int n, FcCharSet **c);
992
993FcPrivate FcResult
994FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
995
996FcPrivate FcResult
997FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
998
999FcPrivate FcBool
1000FcPatternAppend (FcPattern *p, FcPattern *s);
1001
1002FcPrivate FcChar32
1003FcStringHash (const FcChar8 *s);
1004
1005FcPrivate FcBool
1006FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat);
1007
1008FcPrivate FcPattern *
1009FcPatternSerialize (FcSerialize *serialize, const FcPattern *pat);
1010
1011FcPrivate FcBool
1012FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *pat);
1013
1014FcPrivate FcValueList *
1015FcValueListSerialize (FcSerialize *serialize, const FcValueList *pat);
1016
1017/* fcrender.c */
1018
1019/* fcmatrix.c */
1020
1021extern FcPrivate const FcMatrix    FcIdentityMatrix;
1022
1023FcPrivate void
1024FcMatrixFree (FcMatrix *mat);
1025
1026/* fcstat.c */
1027
1028FcPrivate int
1029FcStat (const FcChar8 *file, struct stat *statb);
1030
1031FcPrivate int
1032FcStatChecksum (const FcChar8 *file, struct stat *statb);
1033
1034FcPrivate FcBool
1035FcIsFsMmapSafe (int fd);
1036
1037FcPrivate FcBool
1038FcIsFsMtimeBroken (const FcChar8 *dir);
1039
1040/* fcstr.c */
1041FcPrivate FcBool
1042FcStrSetAddLangs (FcStrSet *strs, const char *languages);
1043
1044FcPrivate void
1045FcStrSetSort (FcStrSet * set);
1046
1047FcPrivate void
1048FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
1049
1050FcPrivate void
1051FcStrBufDestroy (FcStrBuf *buf);
1052
1053FcPrivate FcChar8 *
1054FcStrBufDone (FcStrBuf *buf);
1055
1056FcPrivate FcChar8 *
1057FcStrBufDoneStatic (FcStrBuf *buf);
1058
1059FcPrivate FcBool
1060FcStrBufChar (FcStrBuf *buf, FcChar8 c);
1061
1062FcPrivate FcBool
1063FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
1064
1065FcPrivate FcBool
1066FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
1067
1068FcPrivate int
1069FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1070
1071FcPrivate int
1072FcStrCmpIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims);
1073
1074FcPrivate FcBool
1075FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
1076
1077FcPrivate FcBool
1078FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
1079
1080FcPrivate const FcChar8 *
1081FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1082
1083FcPrivate const FcChar8 *
1084FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
1085
1086FcPrivate const FcChar8 *
1087FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2);
1088
1089FcPrivate int
1090FcStrMatchIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims);
1091
1092FcPrivate FcBool
1093FcStrGlobMatch (const FcChar8 *glob,
1094		const FcChar8 *string);
1095
1096FcPrivate FcBool
1097FcStrUsesHome (const FcChar8 *s);
1098
1099FcPrivate FcChar8 *
1100FcStrBuildFilename (const FcChar8 *path,
1101		    ...);
1102
1103FcPrivate FcChar8 *
1104FcStrLastSlash (const FcChar8  *path);
1105
1106FcPrivate FcChar32
1107FcStrHashIgnoreCase (const FcChar8 *s);
1108
1109FcPrivate FcChar8 *
1110FcStrCanonFilename (const FcChar8 *s);
1111
1112FcPrivate FcBool
1113FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
1114
1115FcPrivate FcChar8 *
1116FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
1117
1118/* fcobjs.c */
1119
1120FcPrivate FcObject
1121FcObjectLookupIdByName (const char *str);
1122
1123FcPrivate FcObject
1124FcObjectLookupBuiltinIdByName (const char *str);
1125
1126FcPrivate const char *
1127FcObjectLookupOtherNameById (FcObject id);
1128
1129FcPrivate const FcObjectType *
1130FcObjectLookupOtherTypeById (FcObject id);
1131
1132FcPrivate const FcObjectType *
1133FcObjectLookupOtherTypeByName (const char *str);
1134
1135#endif /* _FC_INT_H_ */
1136