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
104 #define FC_MEM_NUM 29
106 typedef enum _FcValueBinding
{
107 FcValueBindingWeak
, FcValueBindingStrong
, FcValueBindingSame
110 typedef struct _FcValueList
{
111 struct _FcValueList
*next
;
113 FcValueBinding binding
;
116 typedef struct _FcPatternElt
{
130 FcOpInteger
, FcOpDouble
, FcOpString
, FcOpMatrix
, FcOpBool
, FcOpCharSet
,
132 FcOpField
, FcOpConst
,
133 FcOpAssign
, FcOpAssignReplace
,
134 FcOpPrependFirst
, FcOpPrepend
, FcOpAppend
, FcOpAppendLast
,
136 FcOpOr
, FcOpAnd
, FcOpEqual
, FcOpNotEqual
,
137 FcOpContains
, FcOpListing
, FcOpNotContains
,
138 FcOpLess
, FcOpLessEqual
, FcOpMore
, FcOpMoreEqual
,
139 FcOpPlus
, FcOpMinus
, FcOpTimes
, FcOpDivide
,
140 FcOpNot
, FcOpComma
, FcOpFloor
, FcOpCeil
, FcOpRound
, FcOpTrunc
,
144 typedef struct _FcExpr
{
156 struct _FcExpr
*left
, *right
;
161 typedef enum _FcQual
{
162 FcQualAny
, FcQualAll
, FcQualFirst
, FcQualNotFirst
165 #define FcMatchDefault ((FcMatchKind) -1)
167 typedef struct _FcTest
{
168 struct _FcTest
*next
;
176 typedef struct _FcEdit
{
177 struct _FcEdit
*next
;
181 FcValueBinding binding
;
184 typedef struct _FcSubst
{
185 struct _FcSubst
*next
;
190 typedef struct _FcCharLeaf
{
191 FcChar32 map
[256/32];
194 #define FC_REF_CONSTANT -1
197 int ref
; /* reference count */
198 int num
; /* size of leaves and numbers arrays */
204 int ref
; /* reference count */
215 typedef struct _FcStrBuf
{
224 * To map adobe glyph names to unicode values, a precomputed hash
228 typedef struct _FcGlyphName
{
229 FcChar32 ucs
; /* unicode value */
230 FcChar8 name
[1]; /* name extends beyond struct */
233 #define FC_MAX_FILE_LEN 4096
236 * The per-user ~/.fonts.cache-<version> file is loaded into
237 * this data structure. Each directory gets a substructure
238 * which is validated by comparing the directory timestamp with
239 * that saved in the cache. When valid, the entire directory cache
240 * can be immediately loaded without reading the directory. Otherwise,
241 * the files are checked individually; updated files are loaded into the
242 * cache which is then rewritten to the users home directory
245 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
246 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
248 typedef struct _FcGlobalCacheInfo
{
255 typedef struct _FcGlobalCacheFile
{
256 struct _FcGlobalCacheFile
*next
;
257 FcGlobalCacheInfo info
;
262 typedef struct _FcGlobalCacheDir FcGlobalCacheDir
;
264 typedef struct _FcGlobalCacheSubdir
{
265 struct _FcGlobalCacheSubdir
*next
;
266 FcGlobalCacheDir
*ent
;
267 } FcGlobalCacheSubdir
;
269 struct _FcGlobalCacheDir
{
270 struct _FcGlobalCacheDir
*next
;
271 FcGlobalCacheInfo info
;
273 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
274 FcGlobalCacheSubdir
*subdirs
;
277 typedef struct _FcGlobalCache
{
278 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
286 FcChar8
*file
; /* original file name */
287 FcChar8
*new; /* temp file name -- write data here */
288 FcChar8
*lck
; /* lockfile name (used for locking) */
289 FcChar8
*tmp
; /* tmpfile name (used for locking) */
300 * File names loaded from the configuration -- saved here as the
301 * cache file must be consulted before the directories are scanned,
302 * and those directives may occur in any order
304 FcStrSet
*configDirs
; /* directories to scan for fonts */
305 FcChar8
*cache
; /* name of per-user cache file */
307 * Set of allowed blank chars -- used to
308 * trim fonts of bogus glyphs
312 * List of directories containing fonts,
313 * built by recursively scanning the set
314 * of configured directories
318 * Names of all of the configuration files used
319 * to create this configuration
321 FcStrSet
*configFiles
; /* config files loaded */
323 * Substitution instructions for patterns and fonts;
324 * maxObjects is used to allocate appropriate intermediate storage
325 * while performing a whole set of substitutions
327 FcSubst
*substPattern
; /* substitutions for patterns */
328 FcSubst
*substFont
; /* substitutions for fonts */
329 int maxObjects
; /* maximum number of tests in all substs */
331 * List of patterns used to control font file selection
333 FcStrSet
*acceptGlobs
;
334 FcStrSet
*rejectGlobs
;
335 FcFontSet
*acceptPatterns
;
336 FcFontSet
*rejectPatterns
;
338 * The set of fonts loaded from the listed directories; the
339 * order within the set does not determine the font selection,
340 * except in the case of identical matches in which case earlier fonts
341 * match preferrentially
343 FcFontSet
*fonts
[FcSetApplication
+ 1];
345 * Fontconfig can periodically rescan the system configuration
346 * and font directories. This rescanning occurs when font
347 * listing requests are made, but no more often than rescanInterval
350 time_t rescanTime
; /* last time information was scanned */
351 int rescanInterval
; /* interval between scans */
354 extern FcConfig
*_fcConfig
;
356 typedef struct _FcCharMap FcCharMap
;
363 FcGlobalCacheCreate (void);
366 FcGlobalCacheDestroy (FcGlobalCache
*cache
);
369 FcGlobalCacheCheckTime (const FcChar8
*file
, FcGlobalCacheInfo
*info
);
372 FcGlobalCacheReferenced (FcGlobalCache
*cache
,
373 FcGlobalCacheInfo
*info
);
376 FcGlobalCacheReferenceSubdir (FcGlobalCache
*cache
,
380 FcGlobalCacheDirGet (FcGlobalCache
*cache
,
383 FcBool create_missing
);
386 FcGlobalCacheScanDir (FcFontSet
*set
,
388 FcGlobalCache
*cache
,
393 FcGlobalCacheFileGet (FcGlobalCache
*cache
,
400 FcGlobalCacheLoad (FcGlobalCache
*cache
,
401 const FcChar8
*cache_file
);
404 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
407 const FcChar8
*name
);
410 FcGlobalCacheSave (FcGlobalCache
*cache
,
411 const FcChar8
*cache_file
);
414 FcDirCacheReadDir (FcFontSet
*set
,
420 FcDirCacheWriteDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
425 FcConfigAddConfigDir (FcConfig
*config
,
429 FcConfigAddFontDir (FcConfig
*config
,
433 FcConfigAddDir (FcConfig
*config
,
437 FcConfigAddConfigFile (FcConfig
*config
,
441 FcConfigSetCache (FcConfig
*config
,
445 FcConfigAddBlank (FcConfig
*config
,
449 FcConfigAddEdit (FcConfig
*config
,
455 FcConfigSetFonts (FcConfig
*config
,
460 FcConfigCompareValue (const FcValue m
,
465 FcConfigGlobAdd (FcConfig
*config
,
470 FcConfigAcceptFilename (FcConfig
*config
,
471 const FcChar8
*filename
);
474 FcConfigPatternsAdd (FcConfig
*config
,
479 FcConfigAcceptFont (FcConfig
*config
,
480 const FcPattern
*font
);
484 FcCharSetFreeze (FcCharSet
*cs
);
487 FcCharSetThawAll (void);
490 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
493 FcNameParseCharSet (FcChar8
*string
);
496 FcCharSetFindLeafCreate (FcCharSet
*fcs
, FcChar32 ucs4
);
500 FcValueListPrint (const FcValueList
*l
);
503 FcLangSetPrint (const FcLangSet
*ls
);
509 FcTestPrint (const FcTest
*test
);
512 FcExprPrint (const FcExpr
*expr
);
515 FcEditPrint (const FcEdit
*edit
);
518 FcSubstPrint (const FcSubst
*subst
);
526 FcFileIsDir (const FcChar8
*file
);
529 FcFileScanConfig (FcFontSet
*set
,
538 FcDirScanConfig (FcFontSet
*set
,
552 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
555 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
558 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
561 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
564 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
569 FcConfigparse (void);
575 FcConfigerror (char *fmt
, ...);
578 FcConfigSaveField (const char *field
);
581 FcTestCreate (FcMatchKind kind
,
583 const FcChar8
*field
,
588 FcTestDestroy (FcTest
*test
);
591 FcExprCreateInteger (int i
);
594 FcExprCreateDouble (double d
);
597 FcExprCreateString (const FcChar8
*s
);
600 FcExprCreateMatrix (const FcMatrix
*m
);
603 FcExprCreateBool (FcBool b
);
606 FcExprCreateNil (void);
609 FcExprCreateField (const char *field
);
612 FcExprCreateConst (const FcChar8
*constant
);
615 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
618 FcExprDestroy (FcExpr
*e
);
621 FcEditCreate (const char *field
, FcOp op
, FcExpr
*expr
, FcValueBinding binding
);
624 FcEditDestroy (FcEdit
*e
);
632 FcMemAlloc (int kind
, int size
);
635 FcMemFree (int kind
, int size
);
639 FcFreeTypeLangSet (const FcCharSet
*charset
,
640 const FcChar8
*exclusiveLang
);
643 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
646 FcCharSetForLang (const FcChar8
*lang
);
649 FcLangSetPromote (const FcChar8
*lang
);
652 FcNameParseLangSet (const FcChar8
*string
);
655 FcNameUnparseLangSet (FcStrBuf
*buf
, const FcLangSet
*ls
);
660 FcListPatternMatchAny (const FcPattern
*p
,
661 const FcPattern
*font
);
668 FcNameBool (FcChar8
*v
, FcBool
*result
);
672 FcValueListDestroy (FcValueList
*l
);
675 FcPatternFindElt (const FcPattern
*p
, const char *object
);
678 FcPatternInsertElt (FcPattern
*p
, const char *object
);
681 FcPatternAddWithBinding (FcPattern
*p
,
684 FcValueBinding binding
,
688 FcPatternFreeze (FcPattern
*p
);
691 FcPatternThawAll (void);
694 FcPatternAppend (FcPattern
*p
, FcPattern
*s
);
697 FcObjectStaticName (const char *name
);
703 extern const FcMatrix FcIdentityMatrix
;
706 FcMatrixFree (FcMatrix
*mat
);
710 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
713 FcStrFree (FcChar8
*s
);
716 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
719 FcStrBufDestroy (FcStrBuf
*buf
);
722 FcStrBufDone (FcStrBuf
*buf
);
725 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
728 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
731 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
734 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
737 FcStrContainsIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
740 FcStrContainsIgnoreCase (const FcChar8
*s1
, const FcChar8
*s2
);
743 FcStrUsesHome (const FcChar8
*s
);
746 FcStrLastSlash (const FcChar8
*path
);
748 #endif /* _FC_INT_H_ */