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
84 #define FC_MEM_ATOMIC 17
85 #define FC_MEM_BLANKS 18
86 #define FC_MEM_CACHE 19
87 #define FC_MEM_STRBUF 20
88 #define FC_MEM_SUBST 21
89 #define FC_MEM_OBJECTTYPE 22
90 #define FC_MEM_CONSTANT 23
91 #define FC_MEM_TEST 24
92 #define FC_MEM_EXPR 25
93 #define FC_MEM_VSTACK 26
94 #define FC_MEM_ATTR 27
95 #define FC_MEM_PSTACK 28
99 typedef enum _FcValueBinding
{
100 FcValueBindingWeak
, FcValueBindingStrong
103 typedef struct _FcValueList
{
104 struct _FcValueList
*next
;
106 FcValueBinding binding
;
109 typedef struct _FcPatternElt
{
123 FcOpInteger
, FcOpDouble
, FcOpString
, FcOpMatrix
, FcOpBool
, FcOpCharSet
,
125 FcOpField
, FcOpConst
,
126 FcOpAssign
, FcOpAssignReplace
,
127 FcOpPrependFirst
, FcOpPrepend
, FcOpAppend
, FcOpAppendLast
,
129 FcOpOr
, FcOpAnd
, FcOpEqual
, FcOpNotEqual
, FcOpContains
, FcOpNotContains
,
130 FcOpLess
, FcOpLessEqual
, FcOpMore
, FcOpMoreEqual
,
131 FcOpPlus
, FcOpMinus
, FcOpTimes
, FcOpDivide
,
132 FcOpNot
, FcOpComma
, FcOpInvalid
135 typedef struct _FcExpr
{
147 struct _FcExpr
*left
, *right
;
152 typedef enum _FcQual
{
153 FcQualAny
, FcQualAll
, FcQualFirst
, FcQualNotFirst
156 #define FcMatchDefault ((FcMatchKind) -1)
158 typedef struct _FcTest
{
159 struct _FcTest
*next
;
167 typedef struct _FcEdit
{
168 struct _FcEdit
*next
;
172 FcValueBinding binding
;
175 typedef struct _FcSubst
{
176 struct _FcSubst
*next
;
181 typedef struct _FcCharLeaf
{
182 FcChar32 map
[256/32];
185 #define FC_REF_CONSTANT -1
188 int ref
; /* reference count */
189 int num
; /* size of leaves and numbers arrays */
195 int ref
; /* reference count */
206 typedef struct _FcStrBuf
{
215 * The per-user ~/.fonts.cache-<version> file is loaded into
216 * this data structure. Each directory gets a substructure
217 * which is validated by comparing the directory timestamp with
218 * that saved in the cache. When valid, the entire directory cache
219 * can be immediately loaded without reading the directory. Otherwise,
220 * the files are checked individually; updated files are loaded into the
221 * cache which is then rewritten to the users home directory
224 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
225 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
227 typedef struct _FcGlobalCacheInfo
{
234 typedef struct _FcGlobalCacheFile
{
235 struct _FcGlobalCacheFile
*next
;
236 FcGlobalCacheInfo info
;
241 typedef struct _FcGlobalCacheSubdir
{
242 struct _FcGlobalCacheSubdir
*next
;
244 } FcGlobalCacheSubdir
;
246 typedef struct _FcGlobalCacheDir
{
247 struct _FcGlobalCacheDir
*next
;
248 FcGlobalCacheInfo info
;
250 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
251 FcGlobalCacheSubdir
*subdirs
;
254 typedef struct _FcGlobalCache
{
255 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
263 FcChar8
*file
; /* original file name */
264 FcChar8
*new; /* temp file name -- write data here */
265 FcChar8
*lck
; /* lockfile name (used for locking) */
266 FcChar8
*tmp
; /* tmpfile name (used for locking) */
277 * File names loaded from the configuration -- saved here as the
278 * cache file must be consulted before the directories are scanned,
279 * and those directives may occur in any order
281 FcStrSet
*configDirs
; /* directories to scan for fonts */
282 FcChar8
*cache
; /* name of per-user cache file */
284 * Set of allowed blank chars -- used to
285 * trim fonts of bogus glyphs
289 * List of directories containing fonts,
290 * built by recursively scanning the set
291 * of configured directories
295 * Names of all of the configuration files used
296 * to create this configuration
298 FcStrSet
*configFiles
; /* config files loaded */
300 * Substitution instructions for patterns and fonts;
301 * maxObjects is used to allocate appropriate intermediate storage
302 * while performing a whole set of substitutions
304 FcSubst
*substPattern
; /* substitutions for patterns */
305 FcSubst
*substFont
; /* substitutions for fonts */
306 int maxObjects
; /* maximum number of tests in all substs */
308 * The set of fonts loaded from the listed directories; the
309 * order within the set does not determine the font selection,
310 * except in the case of identical matches in which case earlier fonts
311 * match preferrentially
313 FcFontSet
*fonts
[FcSetApplication
+ 1];
315 * Fontconfig can periodically rescan the system configuration
316 * and font directories. This rescanning occurs when font
317 * listing requests are made, but no more often than rescanInterval
320 time_t rescanTime
; /* last time information was scanned */
321 int rescanInterval
; /* interval between scans */
324 extern FcConfig
*_fcConfig
;
326 typedef struct _FcCharMap FcCharMap
;
333 FcGlobalCacheCreate (void);
336 FcGlobalCacheDestroy (FcGlobalCache
*cache
);
339 FcGlobalCacheCheckTime (FcGlobalCacheInfo
*info
);
342 FcGlobalCacheReferenced (FcGlobalCache
*cache
,
343 FcGlobalCacheInfo
*info
);
346 FcGlobalCacheDirGet (FcGlobalCache
*cache
,
349 FcBool create_missing
);
352 FcGlobalCacheScanDir (FcFontSet
*set
,
354 FcGlobalCache
*cache
,
358 FcGlobalCacheFileGet (FcGlobalCache
*cache
,
365 FcGlobalCacheLoad (FcGlobalCache
*cache
,
366 const FcChar8
*cache_file
);
369 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
372 const FcChar8
*name
);
375 FcGlobalCacheSave (FcGlobalCache
*cache
,
376 const FcChar8
*cache_file
);
379 FcDirCacheReadDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
382 FcDirCacheWriteDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
387 FcConfigAddConfigDir (FcConfig
*config
,
391 FcConfigAddFontDir (FcConfig
*config
,
395 FcConfigAddDir (FcConfig
*config
,
399 FcConfigAddConfigFile (FcConfig
*config
,
403 FcConfigSetCache (FcConfig
*config
,
407 FcConfigAddBlank (FcConfig
*config
,
411 FcConfigAddEdit (FcConfig
*config
,
417 FcConfigSetFonts (FcConfig
*config
,
422 FcConfigCompareValue (const FcValue m
,
428 FcCharSetFreeze (FcCharSet
*cs
);
431 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
434 FcNameParseCharSet (FcChar8
*string
);
437 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
440 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
443 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
447 FcValueListPrint (const FcValueList
*l
);
453 FcTestPrint (const FcTest
*test
);
456 FcExprPrint (const FcExpr
*expr
);
459 FcEditPrint (const FcEdit
*edit
);
462 FcSubstPrint (const FcSubst
*subst
);
475 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
478 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
483 FcConfigparse (void);
489 FcConfigerror (char *fmt
, ...);
492 FcConfigSaveField (const char *field
);
495 FcTestCreate (FcMatchKind kind
,
497 const FcChar8
*field
,
502 FcTestDestroy (FcTest
*test
);
505 FcExprCreateInteger (int i
);
508 FcExprCreateDouble (double d
);
511 FcExprCreateString (const FcChar8
*s
);
514 FcExprCreateMatrix (const FcMatrix
*m
);
517 FcExprCreateBool (FcBool b
);
520 FcExprCreateNil (void);
523 FcExprCreateField (const char *field
);
526 FcExprCreateConst (const FcChar8
*constant
);
529 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
532 FcExprDestroy (FcExpr
*e
);
535 FcEditCreate (const char *field
, FcOp op
, FcExpr
*expr
, FcValueBinding binding
);
538 FcEditDestroy (FcEdit
*e
);
546 FcMemAlloc (int kind
, int size
);
549 FcMemFree (int kind
, int size
);
553 FcFreeTypeLangSet (const FcCharSet
*charset
,
554 const FcChar8
*exclusiveLang
);
557 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
560 FcCharSetForLang (const FcChar8
*lang
);
563 FcLangSetPromote (const FcChar8
*lang
);
566 FcNameParseLangSet (const FcChar8
*string
);
569 FcNameUnparseLangSet (FcStrBuf
*buf
, const FcLangSet
*ls
);
578 FcNameBool (FcChar8
*v
, FcBool
*result
);
582 FcValueListDestroy (FcValueList
*l
);
585 FcPatternFindElt (const FcPattern
*p
, const char *object
);
588 FcPatternInsertElt (FcPattern
*p
, const char *object
);
591 FcPatternAddWithBinding (FcPattern
*p
,
594 FcValueBinding binding
,
598 FcPatternFreeze (FcPattern
*p
);
604 extern const FcMatrix FcIdentityMatrix
;
607 FcMatrixFree (FcMatrix
*mat
);
611 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
614 FcStrFree (FcChar8
*s
);
617 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
620 FcStrBufDestroy (FcStrBuf
*buf
);
623 FcStrBufDone (FcStrBuf
*buf
);
626 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
629 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
632 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
635 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
637 #endif /* _FC_INT_H_ */