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