2 * $RCSId: xc/lib/fontconfig/src/fcint.h,v 1.27 2002/08/31 22:17:32 keithp Exp $
4 * Copyright © 2000 Keith Packard
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")
57 #define FC_SEARCH_PATH_SEPARATOR ';'
59 #define FC_SEARCH_PATH_SEPARATOR ':'
62 #define FC_DBG_MATCH 1
63 #define FC_DBG_MATCHV 2
65 #define FC_DBG_FONTSET 8
66 #define FC_DBG_CACHE 16
67 #define FC_DBG_CACHEV 32
68 #define FC_DBG_PARSE 64
69 #define FC_DBG_SCAN 128
70 #define FC_DBG_SCANV 256
71 #define FC_DBG_MEMORY 512
73 #define FC_MEM_CHARSET 0
74 #define FC_MEM_CHARLEAF 1
75 #define FC_MEM_FONTSET 2
76 #define FC_MEM_FONTPTR 3
77 #define FC_MEM_OBJECTSET 4
78 #define FC_MEM_OBJECTPTR 5
79 #define FC_MEM_MATRIX 6
80 #define FC_MEM_PATTERN 7
81 #define FC_MEM_PATELT 8
82 #define FC_MEM_VALLIST 9
83 #define FC_MEM_SUBSTATE 10
84 #define FC_MEM_STRING 11
85 #define FC_MEM_LISTBUCK 12
86 #define FC_MEM_STRSET 13
87 #define FC_MEM_STRLIST 14
88 #define FC_MEM_CONFIG 15
89 #define FC_MEM_LANGSET 16
90 #define FC_MEM_ATOMIC 17
91 #define FC_MEM_BLANKS 18
92 #define FC_MEM_CACHE 19
93 #define FC_MEM_STRBUF 20
94 #define FC_MEM_SUBST 21
95 #define FC_MEM_OBJECTTYPE 22
96 #define FC_MEM_CONSTANT 23
97 #define FC_MEM_TEST 24
98 #define FC_MEM_EXPR 25
99 #define FC_MEM_VSTACK 26
100 #define FC_MEM_ATTR 27
101 #define FC_MEM_PSTACK 28
103 #define FC_MEM_NUM 29
105 typedef enum _FcValueBinding {
106 FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
109 typedef struct _FcValueList {
110 struct _FcValueList *next;
112 FcValueBinding binding;
115 typedef struct _FcPatternElt {
129 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
131 FcOpField, FcOpConst,
132 FcOpAssign, FcOpAssignReplace,
133 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
135 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
136 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
137 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
138 FcOpNot, FcOpComma, FcOpInvalid
141 typedef struct _FcExpr {
153 struct _FcExpr *left, *right;
158 typedef enum _FcQual {
159 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
162 #define FcMatchDefault ((FcMatchKind) -1)
164 typedef struct _FcTest {
165 struct _FcTest *next;
173 typedef struct _FcEdit {
174 struct _FcEdit *next;
178 FcValueBinding binding;
181 typedef struct _FcSubst {
182 struct _FcSubst *next;
187 typedef struct _FcCharLeaf {
188 FcChar32 map[256/32];
191 #define FC_REF_CONSTANT -1
194 int ref; /* reference count */
195 int num; /* size of leaves and numbers arrays */
201 int ref; /* reference count */
212 typedef struct _FcStrBuf {
221 * The per-user ~/.fonts.cache-<version> file is loaded into
222 * this data structure. Each directory gets a substructure
223 * which is validated by comparing the directory timestamp with
224 * that saved in the cache. When valid, the entire directory cache
225 * can be immediately loaded without reading the directory. Otherwise,
226 * the files are checked individually; updated files are loaded into the
227 * cache which is then rewritten to the users home directory
230 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
231 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
233 typedef struct _FcGlobalCacheInfo {
240 typedef struct _FcGlobalCacheFile {
241 struct _FcGlobalCacheFile *next;
242 FcGlobalCacheInfo info;
247 typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
249 typedef struct _FcGlobalCacheSubdir {
250 struct _FcGlobalCacheSubdir *next;
251 FcGlobalCacheDir *ent;
252 } FcGlobalCacheSubdir;
254 struct _FcGlobalCacheDir {
255 struct _FcGlobalCacheDir *next;
256 FcGlobalCacheInfo info;
258 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
259 FcGlobalCacheSubdir *subdirs;
262 typedef struct _FcGlobalCache {
263 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
271 FcChar8 *file; /* original file name */
272 FcChar8 *new; /* temp file name -- write data here */
273 FcChar8 *lck; /* lockfile name (used for locking) */
274 FcChar8 *tmp; /* tmpfile name (used for locking) */
285 * File names loaded from the configuration -- saved here as the
286 * cache file must be consulted before the directories are scanned,
287 * and those directives may occur in any order
289 FcStrSet *configDirs; /* directories to scan for fonts */
290 FcChar8 *cache; /* name of per-user cache file */
292 * Set of allowed blank chars -- used to
293 * trim fonts of bogus glyphs
297 * List of directories containing fonts,
298 * built by recursively scanning the set
299 * of configured directories
303 * Names of all of the configuration files used
304 * to create this configuration
306 FcStrSet *configFiles; /* config files loaded */
308 * Substitution instructions for patterns and fonts;
309 * maxObjects is used to allocate appropriate intermediate storage
310 * while performing a whole set of substitutions
312 FcSubst *substPattern; /* substitutions for patterns */
313 FcSubst *substFont; /* substitutions for fonts */
314 int maxObjects; /* maximum number of tests in all substs */
316 * The set of fonts loaded from the listed directories; the
317 * order within the set does not determine the font selection,
318 * except in the case of identical matches in which case earlier fonts
319 * match preferrentially
321 FcFontSet *fonts[FcSetApplication + 1];
323 * Fontconfig can periodically rescan the system configuration
324 * and font directories. This rescanning occurs when font
325 * listing requests are made, but no more often than rescanInterval
328 time_t rescanTime; /* last time information was scanned */
329 int rescanInterval; /* interval between scans */
332 extern FcConfig *_fcConfig;
334 typedef struct _FcCharMap FcCharMap;
341 FcGlobalCacheCreate (void);
344 FcGlobalCacheDestroy (FcGlobalCache *cache);
347 FcGlobalCacheCheckTime (const FcChar8*file, FcGlobalCacheInfo *info);
350 FcGlobalCacheReferenced (FcGlobalCache *cache,
351 FcGlobalCacheInfo *info);
354 FcGlobalCacheReferenceSubdir (FcGlobalCache *cache,
358 FcGlobalCacheDirGet (FcGlobalCache *cache,
361 FcBool create_missing);
364 FcGlobalCacheScanDir (FcFontSet *set,
366 FcGlobalCache *cache,
370 FcGlobalCacheFileGet (FcGlobalCache *cache,
377 FcGlobalCacheLoad (FcGlobalCache *cache,
378 const FcChar8 *cache_file);
381 FcGlobalCacheUpdate (FcGlobalCache *cache,
384 const FcChar8 *name);
387 FcGlobalCacheSave (FcGlobalCache *cache,
388 const FcChar8 *cache_file);
391 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
394 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
399 FcConfigAddConfigDir (FcConfig *config,
403 FcConfigAddFontDir (FcConfig *config,
407 FcConfigAddDir (FcConfig *config,
411 FcConfigAddConfigFile (FcConfig *config,
415 FcConfigSetCache (FcConfig *config,
419 FcConfigAddBlank (FcConfig *config,
423 FcConfigAddEdit (FcConfig *config,
429 FcConfigSetFonts (FcConfig *config,
434 FcConfigCompareValue (const FcValue m,
440 FcCharSetFreeze (FcCharSet *cs);
443 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
446 FcNameParseCharSet (FcChar8 *string);
449 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
453 FcValueListPrint (const FcValueList *l);
456 FcLangSetPrint (const FcLangSet *ls);
462 FcTestPrint (const FcTest *test);
465 FcExprPrint (const FcExpr *expr);
468 FcEditPrint (const FcEdit *edit);
471 FcSubstPrint (const FcSubst *subst);
484 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
487 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
490 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
493 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
496 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
501 FcConfigparse (void);
507 FcConfigerror (char *fmt, ...);
510 FcConfigSaveField (const char *field);
513 FcTestCreate (FcMatchKind kind,
515 const FcChar8 *field,
520 FcTestDestroy (FcTest *test);
523 FcExprCreateInteger (int i);
526 FcExprCreateDouble (double d);
529 FcExprCreateString (const FcChar8 *s);
532 FcExprCreateMatrix (const FcMatrix *m);
535 FcExprCreateBool (FcBool b);
538 FcExprCreateNil (void);
541 FcExprCreateField (const char *field);
544 FcExprCreateConst (const FcChar8 *constant);
547 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
550 FcExprDestroy (FcExpr *e);
553 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
556 FcEditDestroy (FcEdit *e);
564 FcMemAlloc (int kind, int size);
567 FcMemFree (int kind, int size);
571 FcFreeTypeLangSet (const FcCharSet *charset,
572 const FcChar8 *exclusiveLang);
575 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
578 FcCharSetForLang (const FcChar8 *lang);
581 FcLangSetPromote (const FcChar8 *lang);
584 FcNameParseLangSet (const FcChar8 *string);
587 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
596 FcNameBool (FcChar8 *v, FcBool *result);
600 FcValueListDestroy (FcValueList *l);
603 FcPatternFindElt (const FcPattern *p, const char *object);
606 FcPatternInsertElt (FcPattern *p, const char *object);
609 FcPatternAddWithBinding (FcPattern *p,
612 FcValueBinding binding,
616 FcPatternFreeze (FcPattern *p);
622 extern const FcMatrix FcIdentityMatrix;
625 FcMatrixFree (FcMatrix *mat);
629 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
632 FcStrFree (FcChar8 *s);
635 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
638 FcStrBufDestroy (FcStrBuf *buf);
641 FcStrBufDone (FcStrBuf *buf);
644 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
647 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
650 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
653 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
656 FcStrUsesHome (const FcChar8 *s);
659 FcStrLastSlash (const FcChar8 *path);
661 #endif /* _FC_INT_H_ */