2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.24 2002/08/22 07:36:44 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
87 typedef enum _FcValueBinding {
88 FcValueBindingWeak, FcValueBindingStrong
91 typedef struct _FcValueList {
92 struct _FcValueList *next;
94 FcValueBinding binding;
97 typedef struct _FcPatternElt {
111 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
113 FcOpField, FcOpConst,
114 FcOpAssign, FcOpAssignReplace,
115 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
117 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains, FcOpNotContains,
118 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
119 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
120 FcOpNot, FcOpComma, FcOpInvalid
123 typedef struct _FcExpr {
135 struct _FcExpr *left, *right;
140 typedef enum _FcQual {
141 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
144 #define FcMatchDefault ((FcMatchKind) -1)
146 typedef struct _FcTest {
147 struct _FcTest *next;
155 typedef struct _FcEdit {
156 struct _FcEdit *next;
160 FcValueBinding binding;
163 typedef struct _FcSubst {
164 struct _FcSubst *next;
169 typedef struct _FcCharLeaf {
170 FcChar32 map[256/32];
173 #define FC_REF_CONSTANT -1
176 int ref; /* reference count */
177 int num; /* size of leaves and numbers arrays */
183 int ref; /* reference count */
194 typedef struct _FcStrBuf {
203 * The per-user ~/.fonts.cache file is loaded into
204 * this data structure. Each directory gets a substructure
205 * which is validated by comparing the directory timestamp with
206 * that saved in the cache. When valid, the entire directory cache
207 * can be immediately loaded without reading the directory. Otherwise,
208 * the files are checked individually; updated files are loaded into the
209 * cache which is then rewritten to the users home directory
212 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
213 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
215 typedef struct _FcGlobalCacheInfo {
222 typedef struct _FcGlobalCacheFile {
223 struct _FcGlobalCacheFile *next;
224 FcGlobalCacheInfo info;
229 typedef struct _FcGlobalCacheSubdir {
230 struct _FcGlobalCacheSubdir *next;
232 } FcGlobalCacheSubdir;
234 typedef struct _FcGlobalCacheDir {
235 struct _FcGlobalCacheDir *next;
236 FcGlobalCacheInfo info;
238 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
239 FcGlobalCacheSubdir *subdirs;
242 typedef struct _FcGlobalCache {
243 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
251 FcChar8 *file; /* original file name */
252 FcChar8 *new; /* temp file name -- write data here */
253 FcChar8 *lck; /* lockfile name (used for locking) */
254 FcChar8 *tmp; /* tmpfile name (used for locking) */
265 * File names loaded from the configuration -- saved here as the
266 * cache file must be consulted before the directories are scanned,
267 * and those directives may occur in any order
269 FcStrSet *configDirs; /* directories to scan for fonts */
270 FcChar8 *cache; /* name of per-user cache file */
272 * Set of allowed blank chars -- used to
273 * trim fonts of bogus glyphs
277 * List of directories containing fonts,
278 * built by recursively scanning the set
279 * of configured directories
283 * Names of all of the configuration files used
284 * to create this configuration
286 FcStrSet *configFiles; /* config files loaded */
288 * Substitution instructions for patterns and fonts;
289 * maxObjects is used to allocate appropriate intermediate storage
290 * while performing a whole set of substitutions
292 FcSubst *substPattern; /* substitutions for patterns */
293 FcSubst *substFont; /* substitutions for fonts */
294 int maxObjects; /* maximum number of tests in all substs */
296 * The set of fonts loaded from the listed directories; the
297 * order within the set does not determine the font selection,
298 * except in the case of identical matches in which case earlier fonts
299 * match preferrentially
301 FcFontSet *fonts[FcSetApplication + 1];
303 * Fontconfig can periodically rescan the system configuration
304 * and font directories. This rescanning occurs when font
305 * listing requests are made, but no more often than rescanInterval
308 time_t rescanTime; /* last time information was scanned */
309 int rescanInterval; /* interval between scans */
312 extern FcConfig *_fcConfig;
314 typedef struct _FcCharMap FcCharMap;
321 FcGlobalCacheCreate (void);
324 FcGlobalCacheDestroy (FcGlobalCache *cache);
327 FcGlobalCacheCheckTime (FcGlobalCacheInfo *info);
330 FcGlobalCacheReferenced (FcGlobalCache *cache,
331 FcGlobalCacheInfo *info);
334 FcGlobalCacheDirGet (FcGlobalCache *cache,
337 FcBool create_missing);
340 FcGlobalCacheScanDir (FcFontSet *set,
342 FcGlobalCache *cache,
346 FcGlobalCacheFileGet (FcGlobalCache *cache,
353 FcGlobalCacheLoad (FcGlobalCache *cache,
354 const FcChar8 *cache_file);
357 FcGlobalCacheUpdate (FcGlobalCache *cache,
360 const FcChar8 *name);
363 FcGlobalCacheSave (FcGlobalCache *cache,
364 const FcChar8 *cache_file);
367 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
370 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
375 FcConfigAddConfigDir (FcConfig *config,
379 FcConfigAddFontDir (FcConfig *config,
383 FcConfigAddDir (FcConfig *config,
387 FcConfigAddConfigFile (FcConfig *config,
391 FcConfigSetCache (FcConfig *config,
395 FcConfigAddBlank (FcConfig *config,
399 FcConfigAddEdit (FcConfig *config,
405 FcConfigSetFonts (FcConfig *config,
410 FcConfigCompareValue (const FcValue m,
416 FcCharSetFreeze (FcCharSet *cs);
419 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
422 FcNameParseCharSet (FcChar8 *string);
425 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
428 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
431 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
435 FcValueListPrint (const FcValueList *l);
441 FcTestPrint (const FcTest *test);
444 FcExprPrint (const FcExpr *expr);
447 FcEditPrint (const FcEdit *edit);
450 FcSubstPrint (const FcSubst *subst);
463 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
466 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
471 FcConfigparse (void);
477 FcConfigerror (char *fmt, ...);
480 FcConfigSaveField (const char *field);
483 FcTestCreate (FcMatchKind kind,
485 const FcChar8 *field,
490 FcTestDestroy (FcTest *test);
493 FcExprCreateInteger (int i);
496 FcExprCreateDouble (double d);
499 FcExprCreateString (const FcChar8 *s);
502 FcExprCreateMatrix (const FcMatrix *m);
505 FcExprCreateBool (FcBool b);
508 FcExprCreateNil (void);
511 FcExprCreateField (const char *field);
514 FcExprCreateConst (const FcChar8 *constant);
517 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
520 FcExprDestroy (FcExpr *e);
523 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
526 FcEditDestroy (FcEdit *e);
534 FcMemAlloc (int kind, int size);
537 FcMemFree (int kind, int size);
541 FcFreeTypeLangSet (const FcCharSet *charset,
542 const FcChar8 *exclusiveLang);
545 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
548 FcCharSetForLang (const FcChar8 *lang);
551 FcLangSetPromote (const FcChar8 *lang);
554 FcNameParseLangSet (const FcChar8 *string);
557 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
566 FcNameBool (FcChar8 *v, FcBool *result);
570 FcValueListDestroy (FcValueList *l);
573 FcPatternFindElt (const FcPattern *p, const char *object);
576 FcPatternInsertElt (FcPattern *p, const char *object);
579 FcPatternAddWithBinding (FcPattern *p,
582 FcValueBinding binding,
586 FcPatternFreeze (FcPattern *p);
592 extern const FcMatrix FcIdentityMatrix;
595 FcMatrixFree (FcMatrix *mat);
599 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
602 FcStrFree (FcChar8 *s);
605 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
608 FcStrBufDestroy (FcStrBuf *buf);
611 FcStrBufDone (FcStrBuf *buf);
614 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
617 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
620 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
623 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
625 #endif /* _FC_INT_H_ */