2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.27 2002/08/31 22:17:32 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>
39 #include <fontconfig/fcfreetype.h>
44 typedef struct _FcSymbolic {
49 #ifndef FC_CONFIG_PATH
50 #define FC_CONFIG_PATH "fonts.conf"
53 #define FC_FONT_FILE_INVALID ((FcChar8 *) ".")
54 #define FC_FONT_FILE_DIR ((FcChar8 *) ".dir")
56 #define FC_DBG_MATCH 1
57 #define FC_DBG_MATCHV 2
59 #define FC_DBG_FONTSET 8
60 #define FC_DBG_CACHE 16
61 #define FC_DBG_CACHEV 32
62 #define FC_DBG_PARSE 64
63 #define FC_DBG_SCAN 128
64 #define FC_DBG_SCANV 256
65 #define FC_DBG_MEMORY 512
67 #define FC_MEM_CHARSET 0
68 #define FC_MEM_CHARLEAF 1
69 #define FC_MEM_FONTSET 2
70 #define FC_MEM_FONTPTR 3
71 #define FC_MEM_OBJECTSET 4
72 #define FC_MEM_OBJECTPTR 5
73 #define FC_MEM_MATRIX 6
74 #define FC_MEM_PATTERN 7
75 #define FC_MEM_PATELT 8
76 #define FC_MEM_VALLIST 9
77 #define FC_MEM_SUBSTATE 10
78 #define FC_MEM_STRING 11
79 #define FC_MEM_LISTBUCK 12
80 #define FC_MEM_STRSET 13
81 #define FC_MEM_STRLIST 14
82 #define FC_MEM_CONFIG 15
83 #define FC_MEM_LANGSET 16
84 #define FC_MEM_ATOMIC 17
85 #define FC_MEM_BLANKS 18
86 #define FC_MEM_CACHE 19
87 #define FC_MEM_STRBUF 20
88 #define FC_MEM_SUBST 21
89 #define FC_MEM_OBJECTTYPE 22
90 #define FC_MEM_CONSTANT 23
91 #define FC_MEM_TEST 24
92 #define FC_MEM_EXPR 25
93 #define FC_MEM_VSTACK 26
94 #define FC_MEM_ATTR 27
95 #define FC_MEM_PSTACK 28
99 typedef enum _FcValueBinding {
100 FcValueBindingWeak, FcValueBindingStrong
103 typedef struct _FcValueList {
104 struct _FcValueList *next;
106 FcValueBinding binding;
109 typedef struct _FcPatternElt {
123 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
125 FcOpField, FcOpConst,
126 FcOpAssign, FcOpAssignReplace,
127 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
129 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
130 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
131 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
132 FcOpNot, FcOpComma, FcOpInvalid
135 typedef struct _FcExpr {
147 struct _FcExpr *left, *right;
152 typedef enum _FcQual {
153 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
156 #define FcMatchDefault ((FcMatchKind) -1)
158 typedef struct _FcTest {
159 struct _FcTest *next;
167 typedef struct _FcEdit {
168 struct _FcEdit *next;
172 FcValueBinding binding;
175 typedef struct _FcSubst {
176 struct _FcSubst *next;
181 typedef struct _FcCharLeaf {
182 FcChar32 map[256/32];
185 #define FC_REF_CONSTANT -1
188 int ref; /* reference count */
189 int num; /* size of leaves and numbers arrays */
195 int ref; /* reference count */
206 typedef struct _FcStrBuf {
215 * The per-user ~/.fonts.cache-<version> file is loaded into
216 * this data structure. Each directory gets a substructure
217 * which is validated by comparing the directory timestamp with
218 * that saved in the cache. When valid, the entire directory cache
219 * can be immediately loaded without reading the directory. Otherwise,
220 * the files are checked individually; updated files are loaded into the
221 * cache which is then rewritten to the users home directory
224 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
225 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
227 typedef struct _FcGlobalCacheInfo {
234 typedef struct _FcGlobalCacheFile {
235 struct _FcGlobalCacheFile *next;
236 FcGlobalCacheInfo info;
241 typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
243 typedef struct _FcGlobalCacheSubdir {
244 struct _FcGlobalCacheSubdir *next;
245 FcGlobalCacheDir *ent;
246 } FcGlobalCacheSubdir;
248 struct _FcGlobalCacheDir {
249 struct _FcGlobalCacheDir *next;
250 FcGlobalCacheInfo info;
252 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
253 FcGlobalCacheSubdir *subdirs;
256 typedef struct _FcGlobalCache {
257 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
265 FcChar8 *file; /* original file name */
266 FcChar8 *new; /* temp file name -- write data here */
267 FcChar8 *lck; /* lockfile name (used for locking) */
268 FcChar8 *tmp; /* tmpfile name (used for locking) */
279 * File names loaded from the configuration -- saved here as the
280 * cache file must be consulted before the directories are scanned,
281 * and those directives may occur in any order
283 FcStrSet *configDirs; /* directories to scan for fonts */
284 FcChar8 *cache; /* name of per-user cache file */
286 * Set of allowed blank chars -- used to
287 * trim fonts of bogus glyphs
291 * List of directories containing fonts,
292 * built by recursively scanning the set
293 * of configured directories
297 * Names of all of the configuration files used
298 * to create this configuration
300 FcStrSet *configFiles; /* config files loaded */
302 * Substitution instructions for patterns and fonts;
303 * maxObjects is used to allocate appropriate intermediate storage
304 * while performing a whole set of substitutions
306 FcSubst *substPattern; /* substitutions for patterns */
307 FcSubst *substFont; /* substitutions for fonts */
308 int maxObjects; /* maximum number of tests in all substs */
310 * The set of fonts loaded from the listed directories; the
311 * order within the set does not determine the font selection,
312 * except in the case of identical matches in which case earlier fonts
313 * match preferrentially
315 FcFontSet *fonts[FcSetApplication + 1];
317 * Fontconfig can periodically rescan the system configuration
318 * and font directories. This rescanning occurs when font
319 * listing requests are made, but no more often than rescanInterval
322 time_t rescanTime; /* last time information was scanned */
323 int rescanInterval; /* interval between scans */
326 extern FcConfig *_fcConfig;
328 typedef struct _FcCharMap FcCharMap;
335 FcGlobalCacheCreate (void);
338 FcGlobalCacheDestroy (FcGlobalCache *cache);
341 FcGlobalCacheCheckTime (FcGlobalCacheInfo *info);
344 FcGlobalCacheReferenced (FcGlobalCache *cache,
345 FcGlobalCacheInfo *info);
348 FcGlobalCacheDirGet (FcGlobalCache *cache,
351 FcBool create_missing);
354 FcGlobalCacheScanDir (FcFontSet *set,
356 FcGlobalCache *cache,
360 FcGlobalCacheFileGet (FcGlobalCache *cache,
367 FcGlobalCacheLoad (FcGlobalCache *cache,
368 const FcChar8 *cache_file);
371 FcGlobalCacheUpdate (FcGlobalCache *cache,
374 const FcChar8 *name);
377 FcGlobalCacheSave (FcGlobalCache *cache,
378 const FcChar8 *cache_file);
381 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
384 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
389 FcConfigAddConfigDir (FcConfig *config,
393 FcConfigAddFontDir (FcConfig *config,
397 FcConfigAddDir (FcConfig *config,
401 FcConfigAddConfigFile (FcConfig *config,
405 FcConfigSetCache (FcConfig *config,
409 FcConfigAddBlank (FcConfig *config,
413 FcConfigAddEdit (FcConfig *config,
419 FcConfigSetFonts (FcConfig *config,
424 FcConfigCompareValue (const FcValue m,
430 FcCharSetFreeze (FcCharSet *cs);
433 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
436 FcNameParseCharSet (FcChar8 *string);
439 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
443 FcValueListPrint (const FcValueList *l);
449 FcTestPrint (const FcTest *test);
452 FcExprPrint (const FcExpr *expr);
455 FcEditPrint (const FcEdit *edit);
458 FcSubstPrint (const FcSubst *subst);
471 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
474 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
477 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
480 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
483 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
488 FcConfigparse (void);
494 FcConfigerror (char *fmt, ...);
497 FcConfigSaveField (const char *field);
500 FcTestCreate (FcMatchKind kind,
502 const FcChar8 *field,
507 FcTestDestroy (FcTest *test);
510 FcExprCreateInteger (int i);
513 FcExprCreateDouble (double d);
516 FcExprCreateString (const FcChar8 *s);
519 FcExprCreateMatrix (const FcMatrix *m);
522 FcExprCreateBool (FcBool b);
525 FcExprCreateNil (void);
528 FcExprCreateField (const char *field);
531 FcExprCreateConst (const FcChar8 *constant);
534 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
537 FcExprDestroy (FcExpr *e);
540 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
543 FcEditDestroy (FcEdit *e);
551 FcMemAlloc (int kind, int size);
554 FcMemFree (int kind, int size);
558 FcFreeTypeLangSet (const FcCharSet *charset,
559 const FcChar8 *exclusiveLang);
562 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
565 FcCharSetForLang (const FcChar8 *lang);
568 FcLangSetPromote (const FcChar8 *lang);
571 FcNameParseLangSet (const FcChar8 *string);
574 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
583 FcNameBool (FcChar8 *v, FcBool *result);
587 FcValueListDestroy (FcValueList *l);
590 FcPatternFindElt (const FcPattern *p, const char *object);
593 FcPatternInsertElt (FcPattern *p, const char *object);
596 FcPatternAddWithBinding (FcPattern *p,
599 FcValueBinding binding,
603 FcPatternFreeze (FcPattern *p);
609 extern const FcMatrix FcIdentityMatrix;
612 FcMatrixFree (FcMatrix *mat);
616 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
619 FcStrFree (FcChar8 *s);
622 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
625 FcStrBufDestroy (FcStrBuf *buf);
628 FcStrBufDone (FcStrBuf *buf);
631 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
634 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
637 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
640 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
642 #endif /* _FC_INT_H_ */