2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.8 2002/05/21 17:06:22 keithp Exp $
4 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
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 Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD 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.
34 #include <sys/types.h>
37 #include <fontconfig/fontconfig.h>
38 #include <fontconfig/fcprivate.h>
43 typedef struct _FcMatcher {
45 double (*compare) (char *object, FcValue value1, FcValue value2);
48 typedef struct _FcSymbolic {
53 #ifndef FC_CONFIG_PATH
54 #define FC_CONFIG_PATH "fonts.conf"
57 #define FC_FONT_FILE_INVALID ((FcChar8 *) ".")
58 #define FC_FONT_FILE_DIR ((FcChar8 *) ".dir")
60 #define FC_DBG_MATCH 1
61 #define FC_DBG_MATCHV 2
63 #define FC_DBG_FONTSET 8
64 #define FC_DBG_CACHE 16
65 #define FC_DBG_CACHEV 32
66 #define FC_DBG_PARSE 64
67 #define FC_DBG_SCAN 128
68 #define FC_DBG_MEMORY 512
70 #define FC_MEM_CHARSET 0
71 #define FC_MEM_CHARNODE 1
72 #define FC_MEM_FONTSET 2
73 #define FC_MEM_FONTPTR 3
74 #define FC_MEM_OBJECTSET 4
75 #define FC_MEM_OBJECTPTR 5
76 #define FC_MEM_MATRIX 6
77 #define FC_MEM_PATTERN 7
78 #define FC_MEM_PATELT 8
79 #define FC_MEM_VALLIST 9
80 #define FC_MEM_SUBSTATE 10
81 #define FC_MEM_STRING 11
82 #define FC_MEM_LISTBUCK 12
84 #define FC_MEM_STRSET 14
85 #define FC_MEM_STRLIST 15
86 #define FC_MEM_CONFIG 16
88 typedef struct _FcValueList {
89 struct _FcValueList *next;
93 typedef struct _FcPatternElt {
105 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
107 FcOpField, FcOpConst,
108 FcOpAssign, FcOpAssignReplace,
109 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
111 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
112 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
113 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
114 FcOpNot, FcOpComma, FcOpInvalid
117 typedef struct _FcExpr {
129 struct _FcExpr *left, *right;
134 typedef enum _FcQual {
138 typedef struct _FcTest {
139 struct _FcTest *next;
146 typedef struct _FcEdit {
147 struct _FcEdit *next;
153 typedef struct _FcSubst {
154 struct _FcSubst *next;
159 typedef struct _FcCharLeaf FcCharLeaf;
160 typedef struct _FcCharBranch FcCharBranch;
161 typedef union _FcCharNode FcCharNode;
164 FcChar32 map[256/32];
168 FcCharBranch *branch;
172 struct _FcCharBranch {
173 FcCharNode nodes[256];
179 int ref; /* reference count */
180 FcBool constant; /* shared constant */
185 int ref; /* reference count */
196 typedef struct _FcStrBuf {
204 typedef struct _FcFileCacheEnt {
205 struct _FcFileCacheEnt *next;
214 #define FC_FILE_CACHE_HASH_SIZE 509
216 struct _FcFileCache {
217 FcFileCacheEnt *ents[FC_FILE_CACHE_HASH_SIZE];
224 FcChar8 *file; /* original file name */
225 FcChar8 *new; /* temp file name -- write data here */
226 FcChar8 *lck; /* lockfile name (used for locking) */
227 FcChar8 *tmp; /* tmpfile name (used for locking) */
238 * File names loaded from the configuration -- saved here as the
239 * cache file must be consulted before the directories are scanned,
240 * and those directives may occur in any order
242 FcStrSet *configDirs; /* directories to scan for fonts */
243 FcChar8 *cache; /* name of per-user cache file */
245 * Set of allowed blank chars -- used to
246 * trim fonts of bogus glyphs
250 * List of directories containing fonts,
251 * built by recursively scanning the set
252 * of configured directories
256 * Names of all of the configuration files used
257 * to create this configuration
259 FcStrSet *configFiles; /* config files loaded */
261 * Substitution instructions for patterns and fonts;
262 * maxObjects is used to allocate appropriate intermediate storage
263 * while performing a whole set of substitutions
265 FcSubst *substPattern; /* substitutions for patterns */
266 FcSubst *substFont; /* substitutions for fonts */
267 int maxObjects; /* maximum number of tests in all substs */
269 * The set of fonts loaded from the listed directories; the
270 * order within the set does not determine the font selection,
271 * except in the case of identical matches in which case earlier fonts
272 * match preferrentially
274 FcFontSet *fonts[FcSetApplication + 1];
276 * Fontconfig can periodically rescan the system configuration
277 * and font directories. This rescanning occurs when font
278 * listing requests are made, but no more often than rescanInterval
281 time_t rescanTime; /* last time information was scanned */
282 int rescanInterval; /* interval between scans */
285 extern FcConfig *_fcConfig;
292 FcFileCacheCreate (void);
295 FcFileCacheFind (FcFileCache *cache,
301 FcFileCacheDestroy (FcFileCache *cache);
304 FcFileCacheValid (const FcChar8 *cache_file);
307 FcFileCacheLoad (FcFileCache *cache,
308 const FcChar8 *cache_file);
311 FcFileCacheUpdate (FcFileCache *cache,
314 const FcChar8 *name);
317 FcFileCacheSave (FcFileCache *cache,
318 const FcChar8 *cache_file);
321 FcFileCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *cache_file);
324 FcFileCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *cache_file);
329 FcConfigAddConfigDir (FcConfig *config,
333 FcConfigAddFontDir (FcConfig *config,
337 FcConfigAddDir (FcConfig *config,
341 FcConfigAddConfigFile (FcConfig *config,
345 FcConfigSetCache (FcConfig *config,
349 FcConfigAddBlank (FcConfig *config,
353 FcConfigAddEdit (FcConfig *config,
359 FcConfigSetFonts (FcConfig *config,
364 FcConfigCompareValue (const FcValue m,
370 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
373 FcNameParseCharSet (FcChar8 *string);
377 FcValueListPrint (FcValueList *l);
383 FcTestPrint (FcTest *test);
386 FcExprPrint (FcExpr *expr);
389 FcEditPrint (FcEdit *edit);
392 FcSubstPrint (FcSubst *subst);
406 FcConfigparse (void);
412 FcConfigerror (char *fmt, ...);
415 FcConfigSaveField (const char *field);
418 FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
421 FcTestDestroy (FcTest *test);
424 FcExprCreateInteger (int i);
427 FcExprCreateDouble (double d);
430 FcExprCreateString (const FcChar8 *s);
433 FcExprCreateMatrix (const FcMatrix *m);
436 FcExprCreateBool (FcBool b);
439 FcExprCreateNil (void);
442 FcExprCreateField (const char *field);
445 FcExprCreateConst (const FcChar8 *constant);
448 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
451 FcExprDestroy (FcExpr *e);
454 FcEditCreate (const char *field, FcOp op, FcExpr *expr);
457 FcEditDestroy (FcEdit *e);
465 FcMemAlloc (int kind, int size);
468 FcMemFree (int kind, int size);
477 FcNameBool (FcChar8 *v, FcBool *result);
481 FcValueListDestroy (FcValueList *l);
484 FcPatternFind (FcPattern *p, const char *object, FcBool insert);
490 FcMatrixFree (FcMatrix *mat);
494 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
497 FcStrFree (FcChar8 *s);
500 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
503 FcStrBufDestroy (FcStrBuf *buf);
506 FcStrBufDone (FcStrBuf *buf);
509 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
512 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
515 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
517 #endif /* _FC_INT_H_ */