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
72 #define FC_DBG_CONFIG 1024
74 #define FC_MEM_CHARSET 0
75 #define FC_MEM_CHARLEAF 1
76 #define FC_MEM_FONTSET 2
77 #define FC_MEM_FONTPTR 3
78 #define FC_MEM_OBJECTSET 4
79 #define FC_MEM_OBJECTPTR 5
80 #define FC_MEM_MATRIX 6
81 #define FC_MEM_PATTERN 7
82 #define FC_MEM_PATELT 8
83 #define FC_MEM_VALLIST 9
84 #define FC_MEM_SUBSTATE 10
85 #define FC_MEM_STRING 11
86 #define FC_MEM_LISTBUCK 12
87 #define FC_MEM_STRSET 13
88 #define FC_MEM_STRLIST 14
89 #define FC_MEM_CONFIG 15
90 #define FC_MEM_LANGSET 16
91 #define FC_MEM_ATOMIC 17
92 #define FC_MEM_BLANKS 18
93 #define FC_MEM_CACHE 19
94 #define FC_MEM_STRBUF 20
95 #define FC_MEM_SUBST 21
96 #define FC_MEM_OBJECTTYPE 22
97 #define FC_MEM_CONSTANT 23
98 #define FC_MEM_TEST 24
99 #define FC_MEM_EXPR 25
100 #define FC_MEM_VSTACK 26
101 #define FC_MEM_ATTR 27
102 #define FC_MEM_PSTACK 28
103 #define FC_MEM_STATICSTR 29
105 #define FC_MEM_NUM 30
107 typedef enum _FcValueBinding {
108 FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
111 typedef struct _FcValueList {
112 struct _FcValueList *next;
114 FcValueBinding binding;
117 typedef struct _FcPatternElt {
131 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
133 FcOpField, FcOpConst,
134 FcOpAssign, FcOpAssignReplace,
135 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
137 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
138 FcOpContains, FcOpListing, FcOpNotContains,
139 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
140 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
141 FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc,
145 typedef struct _FcExpr {
157 struct _FcExpr *left, *right;
162 typedef enum _FcQual {
163 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
166 #define FcMatchDefault ((FcMatchKind) -1)
168 typedef struct _FcTest {
169 struct _FcTest *next;
177 typedef struct _FcEdit {
178 struct _FcEdit *next;
182 FcValueBinding binding;
185 typedef struct _FcSubst {
186 struct _FcSubst *next;
191 typedef struct _FcCharLeaf {
192 FcChar32 map[256/32];
195 #define FC_REF_CONSTANT -1
198 int ref; /* reference count */
199 int num; /* size of leaves and numbers arrays */
205 int ref; /* reference count */
216 typedef struct _FcStrBuf {
225 * To map adobe glyph names to unicode values, a precomputed hash
229 typedef struct _FcGlyphName {
230 FcChar32 ucs; /* unicode value */
231 FcChar8 name[1]; /* name extends beyond struct */
234 #define FC_MAX_FILE_LEN 4096
237 * The per-user ~/.fonts.cache-<version> file is loaded into
238 * this data structure. Each directory gets a substructure
239 * which is validated by comparing the directory timestamp with
240 * that saved in the cache. When valid, the entire directory cache
241 * can be immediately loaded without reading the directory. Otherwise,
242 * the files are checked individually; updated files are loaded into the
243 * cache which is then rewritten to the users home directory
246 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
247 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
249 typedef struct _FcGlobalCacheInfo {
256 typedef struct _FcGlobalCacheFile {
257 struct _FcGlobalCacheFile *next;
258 FcGlobalCacheInfo info;
263 typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
265 typedef struct _FcGlobalCacheSubdir {
266 struct _FcGlobalCacheSubdir *next;
267 FcGlobalCacheDir *ent;
268 } FcGlobalCacheSubdir;
270 struct _FcGlobalCacheDir {
271 struct _FcGlobalCacheDir *next;
272 FcGlobalCacheInfo info;
274 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
275 FcGlobalCacheSubdir *subdirs;
278 typedef struct _FcGlobalCache {
279 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
287 FcChar8 *file; /* original file name */
288 FcChar8 *new; /* temp file name -- write data here */
289 FcChar8 *lck; /* lockfile name (used for locking) */
290 FcChar8 *tmp; /* tmpfile name (used for locking) */
301 * File names loaded from the configuration -- saved here as the
302 * cache file must be consulted before the directories are scanned,
303 * and those directives may occur in any order
305 FcStrSet *configDirs; /* directories to scan for fonts */
306 FcChar8 *cache; /* name of per-user cache file */
308 * Set of allowed blank chars -- used to
309 * trim fonts of bogus glyphs
313 * List of directories containing fonts,
314 * built by recursively scanning the set
315 * of configured directories
319 * Names of all of the configuration files used
320 * to create this configuration
322 FcStrSet *configFiles; /* config files loaded */
324 * Substitution instructions for patterns and fonts;
325 * maxObjects is used to allocate appropriate intermediate storage
326 * while performing a whole set of substitutions
328 FcSubst *substPattern; /* substitutions for patterns */
329 FcSubst *substFont; /* substitutions for fonts */
330 int maxObjects; /* maximum number of tests in all substs */
332 * List of patterns used to control font file selection
334 FcStrSet *acceptGlobs;
335 FcStrSet *rejectGlobs;
336 FcFontSet *acceptPatterns;
337 FcFontSet *rejectPatterns;
339 * The set of fonts loaded from the listed directories; the
340 * order within the set does not determine the font selection,
341 * except in the case of identical matches in which case earlier fonts
342 * match preferrentially
344 FcFontSet *fonts[FcSetApplication + 1];
346 * Fontconfig can periodically rescan the system configuration
347 * and font directories. This rescanning occurs when font
348 * listing requests are made, but no more often than rescanInterval
351 time_t rescanTime; /* last time information was scanned */
352 int rescanInterval; /* interval between scans */
355 extern FcConfig *_fcConfig;
357 typedef struct _FcCharMap FcCharMap;
364 FcGlobalCacheCreate (void);
367 FcGlobalCacheDestroy (FcGlobalCache *cache);
370 FcGlobalCacheCheckTime (const FcChar8*file, FcGlobalCacheInfo *info);
373 FcGlobalCacheReferenced (FcGlobalCache *cache,
374 FcGlobalCacheInfo *info);
377 FcGlobalCacheReferenceSubdir (FcGlobalCache *cache,
381 FcGlobalCacheDirGet (FcGlobalCache *cache,
384 FcBool create_missing);
387 FcGlobalCacheScanDir (FcFontSet *set,
389 FcGlobalCache *cache,
394 FcGlobalCacheFileGet (FcGlobalCache *cache,
401 FcGlobalCacheLoad (FcGlobalCache *cache,
402 const FcChar8 *cache_file);
405 FcGlobalCacheUpdate (FcGlobalCache *cache,
408 const FcChar8 *name);
411 FcGlobalCacheSave (FcGlobalCache *cache,
412 const FcChar8 *cache_file);
415 FcDirCacheReadDir (FcFontSet *set,
421 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
426 FcConfigAddConfigDir (FcConfig *config,
430 FcConfigAddFontDir (FcConfig *config,
434 FcConfigAddDir (FcConfig *config,
438 FcConfigAddConfigFile (FcConfig *config,
442 FcConfigSetCache (FcConfig *config,
446 FcConfigAddBlank (FcConfig *config,
450 FcConfigAddEdit (FcConfig *config,
456 FcConfigSetFonts (FcConfig *config,
461 FcConfigCompareValue (const FcValue m,
466 FcConfigGlobAdd (FcConfig *config,
471 FcConfigAcceptFilename (FcConfig *config,
472 const FcChar8 *filename);
475 FcConfigPatternsAdd (FcConfig *config,
480 FcConfigAcceptFont (FcConfig *config,
481 const FcPattern *font);
485 FcCharSetFreeze (FcCharSet *cs);
488 FcCharSetThawAll (void);
491 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
494 FcNameParseCharSet (FcChar8 *string);
497 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
501 FcValueListPrint (const FcValueList *l);
504 FcLangSetPrint (const FcLangSet *ls);
510 FcTestPrint (const FcTest *test);
513 FcExprPrint (const FcExpr *expr);
516 FcEditPrint (const FcEdit *edit);
519 FcSubstPrint (const FcSubst *subst);
527 FcFileIsDir (const FcChar8 *file);
530 FcFileScanConfig (FcFontSet *set,
539 FcDirScanConfig (FcFontSet *set,
553 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
556 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
559 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
562 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
565 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
570 FcConfigparse (void);
576 FcConfigerror (char *fmt, ...);
579 FcConfigSaveField (const char *field);
582 FcTestCreate (FcMatchKind kind,
584 const FcChar8 *field,
589 FcTestDestroy (FcTest *test);
592 FcExprCreateInteger (int i);
595 FcExprCreateDouble (double d);
598 FcExprCreateString (const FcChar8 *s);
601 FcExprCreateMatrix (const FcMatrix *m);
604 FcExprCreateBool (FcBool b);
607 FcExprCreateNil (void);
610 FcExprCreateField (const char *field);
613 FcExprCreateConst (const FcChar8 *constant);
616 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
619 FcExprDestroy (FcExpr *e);
622 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
625 FcEditDestroy (FcEdit *e);
633 FcMemAlloc (int kind, int size);
636 FcMemFree (int kind, int size);
640 FcFreeTypeLangSet (const FcCharSet *charset,
641 const FcChar8 *exclusiveLang);
644 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
647 FcCharSetForLang (const FcChar8 *lang);
650 FcLangSetPromote (const FcChar8 *lang);
653 FcNameParseLangSet (const FcChar8 *string);
656 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
661 FcListPatternMatchAny (const FcPattern *p,
662 const FcPattern *font);
669 FcNameBool (FcChar8 *v, FcBool *result);
673 FcValueListDestroy (FcValueList *l);
676 FcPatternFindElt (const FcPattern *p, const char *object);
679 FcPatternInsertElt (FcPattern *p, const char *object);
682 FcPatternAddWithBinding (FcPattern *p,
685 FcValueBinding binding,
689 FcPatternFreeze (FcPattern *p);
692 FcPatternThawAll (void);
695 FcPatternAppend (FcPattern *p, FcPattern *s);
698 FcObjectStaticName (const char *name);
704 extern const FcMatrix FcIdentityMatrix;
707 FcMatrixFree (FcMatrix *mat);
711 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
714 FcStrFree (FcChar8 *s);
717 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
720 FcStrBufDestroy (FcStrBuf *buf);
723 FcStrBufDone (FcStrBuf *buf);
726 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
729 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
732 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
735 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
738 FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
741 FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
744 FcStrUsesHome (const FcChar8 *s);
747 FcStrLastSlash (const FcChar8 *path);
749 #endif /* _FC_INT_H_ */