2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.16 2002/07/06 23:47: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_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
;
156 typedef struct _FcSubst
{
157 struct _FcSubst
*next
;
162 typedef struct _FcCharLeaf
{
163 FcChar32 map
[256/32];
166 typedef enum _FcLangResult
{
167 FcLangEqual
, FcLangDifferentCountry
, FcLangDifferentLang
171 int ref
; /* reference count */
172 FcBool constant
; /* in hash table constant */
173 int num
; /* size of leaves and numbers arrays */
179 int ref
; /* reference count */
190 typedef struct _FcStrBuf
{
199 * The per-user ~/.fonts.cache file is loaded into
200 * this data structure. Each directory gets a substructure
201 * which is validated by comparing the directory timestamp with
202 * that saved in the cache. When valid, the entire directory cache
203 * can be immediately loaded without reading the directory. Otherwise,
204 * the files are checked individually; updated files are loaded into the
205 * cache which is then rewritten to the users home directory
208 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
209 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
211 typedef struct _FcGlobalCacheInfo
{
218 typedef struct _FcGlobalCacheFile
{
219 struct _FcGlobalCacheFile
*next
;
220 FcGlobalCacheInfo info
;
225 typedef struct _FcGlobalCacheSubdir
{
226 struct _FcGlobalCacheSubdir
*next
;
228 } FcGlobalCacheSubdir
;
230 typedef struct _FcGlobalCacheDir
{
231 struct _FcGlobalCacheDir
*next
;
232 FcGlobalCacheInfo info
;
234 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
235 FcGlobalCacheSubdir
*subdirs
;
238 typedef struct _FcGlobalCache
{
239 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
247 FcChar8
*file
; /* original file name */
248 FcChar8
*new; /* temp file name -- write data here */
249 FcChar8
*lck
; /* lockfile name (used for locking) */
250 FcChar8
*tmp
; /* tmpfile name (used for locking) */
261 * File names loaded from the configuration -- saved here as the
262 * cache file must be consulted before the directories are scanned,
263 * and those directives may occur in any order
265 FcStrSet
*configDirs
; /* directories to scan for fonts */
266 FcChar8
*cache
; /* name of per-user cache file */
268 * Set of allowed blank chars -- used to
269 * trim fonts of bogus glyphs
273 * List of directories containing fonts,
274 * built by recursively scanning the set
275 * of configured directories
279 * Names of all of the configuration files used
280 * to create this configuration
282 FcStrSet
*configFiles
; /* config files loaded */
284 * Substitution instructions for patterns and fonts;
285 * maxObjects is used to allocate appropriate intermediate storage
286 * while performing a whole set of substitutions
288 FcSubst
*substPattern
; /* substitutions for patterns */
289 FcSubst
*substFont
; /* substitutions for fonts */
290 int maxObjects
; /* maximum number of tests in all substs */
292 * The set of fonts loaded from the listed directories; the
293 * order within the set does not determine the font selection,
294 * except in the case of identical matches in which case earlier fonts
295 * match preferrentially
297 FcFontSet
*fonts
[FcSetApplication
+ 1];
299 * Fontconfig can periodically rescan the system configuration
300 * and font directories. This rescanning occurs when font
301 * listing requests are made, but no more often than rescanInterval
304 time_t rescanTime
; /* last time information was scanned */
305 int rescanInterval
; /* interval between scans */
308 extern FcConfig
*_fcConfig
;
310 typedef struct _FcCharMap FcCharMap
;
317 FcGlobalCacheCreate (void);
320 FcGlobalCacheDestroy (FcGlobalCache
*cache
);
323 FcGlobalCacheCheckTime (FcGlobalCacheInfo
*info
);
326 FcGlobalCacheReferenced (FcGlobalCache
*cache
,
327 FcGlobalCacheInfo
*info
);
330 FcGlobalCacheDirGet (FcGlobalCache
*cache
,
333 FcBool create_missing
);
336 FcGlobalCacheScanDir (FcFontSet
*set
,
338 FcGlobalCache
*cache
,
342 FcGlobalCacheFileGet (FcGlobalCache
*cache
,
349 FcGlobalCacheLoad (FcGlobalCache
*cache
,
350 const FcChar8
*cache_file
);
353 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
356 const FcChar8
*name
);
359 FcGlobalCacheSave (FcGlobalCache
*cache
,
360 const FcChar8
*cache_file
);
363 FcDirCacheValid (const FcChar8
*cache_file
);
366 FcDirCacheReadDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
369 FcDirCacheWriteDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
374 FcConfigAddConfigDir (FcConfig
*config
,
378 FcConfigAddFontDir (FcConfig
*config
,
382 FcConfigAddDir (FcConfig
*config
,
386 FcConfigAddConfigFile (FcConfig
*config
,
390 FcConfigSetCache (FcConfig
*config
,
394 FcConfigAddBlank (FcConfig
*config
,
398 FcConfigAddEdit (FcConfig
*config
,
404 FcConfigSetFonts (FcConfig
*config
,
409 FcConfigCompareValue (const FcValue m
,
415 FcCharSetFreeze (FcCharSet
*cs
);
418 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
421 FcNameParseCharSet (FcChar8
*string
);
424 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
427 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
430 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
434 FcValueListPrint (FcValueList
*l
);
440 FcTestPrint (FcTest
*test
);
443 FcExprPrint (FcExpr
*expr
);
446 FcEditPrint (FcEdit
*edit
);
449 FcSubstPrint (FcSubst
*subst
);
462 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
465 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
470 FcConfigparse (void);
476 FcConfigerror (char *fmt
, ...);
479 FcConfigSaveField (const char *field
);
482 FcTestCreate (FcQual qual
, const FcChar8
*field
, FcOp compare
, FcExpr
*expr
);
485 FcTestDestroy (FcTest
*test
);
488 FcExprCreateInteger (int i
);
491 FcExprCreateDouble (double d
);
494 FcExprCreateString (const FcChar8
*s
);
497 FcExprCreateMatrix (const FcMatrix
*m
);
500 FcExprCreateBool (FcBool b
);
503 FcExprCreateNil (void);
506 FcExprCreateField (const char *field
);
509 FcExprCreateConst (const FcChar8
*constant
);
512 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
515 FcExprDestroy (FcExpr
*e
);
518 FcEditCreate (const char *field
, FcOp op
, FcExpr
*expr
);
521 FcEditDestroy (FcEdit
*e
);
529 FcMemAlloc (int kind
, int size
);
532 FcMemFree (int kind
, int size
);
536 FcFreeTypeSetLang (FcPattern
*pattern
,
538 const FcChar8
*exclusiveLang
);
541 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
544 FcCharSetForLang (const FcChar8
*lang
);
553 FcNameBool (FcChar8
*v
, FcBool
*result
);
557 FcValueListDestroy (FcValueList
*l
);
560 FcPatternFindElt (const FcPattern
*p
, const char *object
);
563 FcPatternInsertElt (FcPattern
*p
, const char *object
);
566 FcPatternAddWithBinding (FcPattern
*p
,
569 FcValueBinding binding
,
576 extern const FcMatrix FcIdentityMatrix
;
579 FcMatrixFree (FcMatrix
*mat
);
583 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
586 FcStrFree (FcChar8
*s
);
589 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
592 FcStrBufDestroy (FcStrBuf
*buf
);
595 FcStrBufDone (FcStrBuf
*buf
);
598 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
601 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
604 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
607 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
609 #endif /* _FC_INT_H_ */