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, FcValueBindingSame
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 FcGlobalCacheReferenceSubdir (FcGlobalCache *cache,
352 FcGlobalCacheDirGet (FcGlobalCache *cache,
355 FcBool create_missing);
358 FcGlobalCacheScanDir (FcFontSet *set,
360 FcGlobalCache *cache,
364 FcGlobalCacheFileGet (FcGlobalCache *cache,
371 FcGlobalCacheLoad (FcGlobalCache *cache,
372 const FcChar8 *cache_file);
375 FcGlobalCacheUpdate (FcGlobalCache *cache,
378 const FcChar8 *name);
381 FcGlobalCacheSave (FcGlobalCache *cache,
382 const FcChar8 *cache_file);
385 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
388 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
393 FcConfigAddConfigDir (FcConfig *config,
397 FcConfigAddFontDir (FcConfig *config,
401 FcConfigAddDir (FcConfig *config,
405 FcConfigAddConfigFile (FcConfig *config,
409 FcConfigSetCache (FcConfig *config,
413 FcConfigAddBlank (FcConfig *config,
417 FcConfigAddEdit (FcConfig *config,
423 FcConfigSetFonts (FcConfig *config,
428 FcConfigCompareValue (const FcValue m,
434 FcCharSetFreeze (FcCharSet *cs);
437 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
440 FcNameParseCharSet (FcChar8 *string);
443 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
447 FcValueListPrint (const FcValueList *l);
453 FcTestPrint (const FcTest *test);
456 FcExprPrint (const FcExpr *expr);
459 FcEditPrint (const FcEdit *edit);
462 FcSubstPrint (const FcSubst *subst);
475 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
478 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
481 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
484 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
487 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
492 FcConfigparse (void);
498 FcConfigerror (char *fmt, ...);
501 FcConfigSaveField (const char *field);
504 FcTestCreate (FcMatchKind kind,
506 const FcChar8 *field,
511 FcTestDestroy (FcTest *test);
514 FcExprCreateInteger (int i);
517 FcExprCreateDouble (double d);
520 FcExprCreateString (const FcChar8 *s);
523 FcExprCreateMatrix (const FcMatrix *m);
526 FcExprCreateBool (FcBool b);
529 FcExprCreateNil (void);
532 FcExprCreateField (const char *field);
535 FcExprCreateConst (const FcChar8 *constant);
538 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
541 FcExprDestroy (FcExpr *e);
544 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
547 FcEditDestroy (FcEdit *e);
555 FcMemAlloc (int kind, int size);
558 FcMemFree (int kind, int size);
562 FcFreeTypeLangSet (const FcCharSet *charset,
563 const FcChar8 *exclusiveLang);
566 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
569 FcCharSetForLang (const FcChar8 *lang);
572 FcLangSetPromote (const FcChar8 *lang);
575 FcNameParseLangSet (const FcChar8 *string);
578 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
587 FcNameBool (FcChar8 *v, FcBool *result);
591 FcValueListDestroy (FcValueList *l);
594 FcPatternFindElt (const FcPattern *p, const char *object);
597 FcPatternInsertElt (FcPattern *p, const char *object);
600 FcPatternAddWithBinding (FcPattern *p,
603 FcValueBinding binding,
607 FcPatternFreeze (FcPattern *p);
613 extern const FcMatrix FcIdentityMatrix;
616 FcMatrixFree (FcMatrix *mat);
620 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
623 FcStrFree (FcChar8 *s);
626 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
629 FcStrBufDestroy (FcStrBuf *buf);
632 FcStrBufDone (FcStrBuf *buf);
635 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
638 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
641 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
644 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
646 #endif /* _FC_INT_H_ */