2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.21 2002/07/31 01:36:37 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_CHARNODE 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
81 #define FC_MEM_STRSET 14
82 #define FC_MEM_STRLIST 15
83 #define FC_MEM_CONFIG 16
85 typedef enum _FcValueBinding {
86 FcValueBindingWeak, FcValueBindingStrong
89 typedef struct _FcValueList {
90 struct _FcValueList *next;
92 FcValueBinding binding;
95 typedef struct _FcPatternElt {
108 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
110 FcOpField, FcOpConst,
111 FcOpAssign, FcOpAssignReplace,
112 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
114 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
115 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
116 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
117 FcOpNot, FcOpComma, FcOpInvalid
120 typedef struct _FcExpr {
132 struct _FcExpr *left, *right;
137 typedef enum _FcQual {
138 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
141 typedef struct _FcTest {
142 struct _FcTest *next;
149 typedef struct _FcEdit {
150 struct _FcEdit *next;
154 FcValueBinding binding;
157 typedef struct _FcSubst {
158 struct _FcSubst *next;
163 typedef struct _FcCharLeaf {
164 FcChar32 map[256/32];
167 typedef enum _FcLangResult {
168 FcLangEqual, FcLangDifferentCountry, FcLangDifferentLang
172 int ref; /* reference count */
173 FcBool constant; /* in hash table constant */
174 int num; /* size of leaves and numbers arrays */
180 int ref; /* reference count */
191 typedef struct _FcStrBuf {
200 * The per-user ~/.fonts.cache file is loaded into
201 * this data structure. Each directory gets a substructure
202 * which is validated by comparing the directory timestamp with
203 * that saved in the cache. When valid, the entire directory cache
204 * can be immediately loaded without reading the directory. Otherwise,
205 * the files are checked individually; updated files are loaded into the
206 * cache which is then rewritten to the users home directory
209 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
210 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
212 typedef struct _FcGlobalCacheInfo {
219 typedef struct _FcGlobalCacheFile {
220 struct _FcGlobalCacheFile *next;
221 FcGlobalCacheInfo info;
226 typedef struct _FcGlobalCacheSubdir {
227 struct _FcGlobalCacheSubdir *next;
229 } FcGlobalCacheSubdir;
231 typedef struct _FcGlobalCacheDir {
232 struct _FcGlobalCacheDir *next;
233 FcGlobalCacheInfo info;
235 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
236 FcGlobalCacheSubdir *subdirs;
239 typedef struct _FcGlobalCache {
240 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
248 FcChar8 *file; /* original file name */
249 FcChar8 *new; /* temp file name -- write data here */
250 FcChar8 *lck; /* lockfile name (used for locking) */
251 FcChar8 *tmp; /* tmpfile name (used for locking) */
262 * File names loaded from the configuration -- saved here as the
263 * cache file must be consulted before the directories are scanned,
264 * and those directives may occur in any order
266 FcStrSet *configDirs; /* directories to scan for fonts */
267 FcChar8 *cache; /* name of per-user cache file */
269 * Set of allowed blank chars -- used to
270 * trim fonts of bogus glyphs
274 * List of directories containing fonts,
275 * built by recursively scanning the set
276 * of configured directories
280 * Names of all of the configuration files used
281 * to create this configuration
283 FcStrSet *configFiles; /* config files loaded */
285 * Substitution instructions for patterns and fonts;
286 * maxObjects is used to allocate appropriate intermediate storage
287 * while performing a whole set of substitutions
289 FcSubst *substPattern; /* substitutions for patterns */
290 FcSubst *substFont; /* substitutions for fonts */
291 int maxObjects; /* maximum number of tests in all substs */
293 * The set of fonts loaded from the listed directories; the
294 * order within the set does not determine the font selection,
295 * except in the case of identical matches in which case earlier fonts
296 * match preferrentially
298 FcFontSet *fonts[FcSetApplication + 1];
300 * Fontconfig can periodically rescan the system configuration
301 * and font directories. This rescanning occurs when font
302 * listing requests are made, but no more often than rescanInterval
305 time_t rescanTime; /* last time information was scanned */
306 int rescanInterval; /* interval between scans */
309 extern FcConfig *_fcConfig;
311 typedef struct _FcCharMap FcCharMap;
318 FcGlobalCacheCreate (void);
321 FcGlobalCacheDestroy (FcGlobalCache *cache);
324 FcGlobalCacheCheckTime (FcGlobalCacheInfo *info);
327 FcGlobalCacheReferenced (FcGlobalCache *cache,
328 FcGlobalCacheInfo *info);
331 FcGlobalCacheDirGet (FcGlobalCache *cache,
334 FcBool create_missing);
337 FcGlobalCacheScanDir (FcFontSet *set,
339 FcGlobalCache *cache,
343 FcGlobalCacheFileGet (FcGlobalCache *cache,
350 FcGlobalCacheLoad (FcGlobalCache *cache,
351 const FcChar8 *cache_file);
354 FcGlobalCacheUpdate (FcGlobalCache *cache,
357 const FcChar8 *name);
360 FcGlobalCacheSave (FcGlobalCache *cache,
361 const FcChar8 *cache_file);
364 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
367 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
372 FcConfigAddConfigDir (FcConfig *config,
376 FcConfigAddFontDir (FcConfig *config,
380 FcConfigAddDir (FcConfig *config,
384 FcConfigAddConfigFile (FcConfig *config,
388 FcConfigSetCache (FcConfig *config,
392 FcConfigAddBlank (FcConfig *config,
396 FcConfigAddEdit (FcConfig *config,
402 FcConfigSetFonts (FcConfig *config,
407 FcConfigCompareValue (const FcValue m,
413 FcCharSetFreeze (FcCharSet *cs);
416 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
419 FcNameParseCharSet (FcChar8 *string);
422 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
425 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
428 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
432 FcValueListPrint (FcValueList *l);
438 FcTestPrint (FcTest *test);
441 FcExprPrint (FcExpr *expr);
444 FcEditPrint (FcEdit *edit);
447 FcSubstPrint (FcSubst *subst);
460 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
463 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
468 FcConfigparse (void);
474 FcConfigerror (char *fmt, ...);
477 FcConfigSaveField (const char *field);
480 FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
483 FcTestDestroy (FcTest *test);
486 FcExprCreateInteger (int i);
489 FcExprCreateDouble (double d);
492 FcExprCreateString (const FcChar8 *s);
495 FcExprCreateMatrix (const FcMatrix *m);
498 FcExprCreateBool (FcBool b);
501 FcExprCreateNil (void);
504 FcExprCreateField (const char *field);
507 FcExprCreateConst (const FcChar8 *constant);
510 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
513 FcExprDestroy (FcExpr *e);
516 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
519 FcEditDestroy (FcEdit *e);
527 FcMemAlloc (int kind, int size);
530 FcMemFree (int kind, int size);
534 FcFreeTypeSetLang (FcPattern *pattern,
536 const FcChar8 *exclusiveLang);
539 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
542 FcCharSetForLang (const FcChar8 *lang);
551 FcNameBool (FcChar8 *v, FcBool *result);
555 FcValueListDestroy (FcValueList *l);
558 FcPatternFindElt (const FcPattern *p, const char *object);
561 FcPatternInsertElt (FcPattern *p, const char *object);
564 FcPatternAddWithBinding (FcPattern *p,
567 FcValueBinding binding,
574 extern const FcMatrix FcIdentityMatrix;
577 FcMatrixFree (FcMatrix *mat);
581 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
584 FcStrFree (FcChar8 *s);
587 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
590 FcStrBufDestroy (FcStrBuf *buf);
593 FcStrBufDone (FcStrBuf *buf);
596 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
599 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
602 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
605 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
607 #endif /* _FC_INT_H_ */