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
73 #define FC_MEM_CHARSET 0
74 #define FC_MEM_CHARLEAF 1
75 #define FC_MEM_FONTSET 2
76 #define FC_MEM_FONTPTR 3
77 #define FC_MEM_OBJECTSET 4
78 #define FC_MEM_OBJECTPTR 5
79 #define FC_MEM_MATRIX 6
80 #define FC_MEM_PATTERN 7
81 #define FC_MEM_PATELT 8
82 #define FC_MEM_VALLIST 9
83 #define FC_MEM_SUBSTATE 10
84 #define FC_MEM_STRING 11
85 #define FC_MEM_LISTBUCK 12
86 #define FC_MEM_STRSET 13
87 #define FC_MEM_STRLIST 14
88 #define FC_MEM_CONFIG 15
89 #define FC_MEM_LANGSET 16
90 #define FC_MEM_ATOMIC 17
91 #define FC_MEM_BLANKS 18
92 #define FC_MEM_CACHE 19
93 #define FC_MEM_STRBUF 20
94 #define FC_MEM_SUBST 21
95 #define FC_MEM_OBJECTTYPE 22
96 #define FC_MEM_CONSTANT 23
97 #define FC_MEM_TEST 24
98 #define FC_MEM_EXPR 25
99 #define FC_MEM_VSTACK 26
100 #define FC_MEM_ATTR 27
101 #define FC_MEM_PSTACK 28
103 #define FC_MEM_NUM 29
105 typedef enum _FcValueBinding
{
106 FcValueBindingWeak
, FcValueBindingStrong
, FcValueBindingSame
109 typedef struct _FcValueList
{
110 struct _FcValueList
*next
;
112 FcValueBinding binding
;
115 typedef struct _FcPatternElt
{
129 FcOpInteger
, FcOpDouble
, FcOpString
, FcOpMatrix
, FcOpBool
, FcOpCharSet
,
131 FcOpField
, FcOpConst
,
132 FcOpAssign
, FcOpAssignReplace
,
133 FcOpPrependFirst
, FcOpPrepend
, FcOpAppend
, FcOpAppendLast
,
135 FcOpOr
, FcOpAnd
, FcOpEqual
, FcOpNotEqual
,
136 FcOpContains
, FcOpListing
, FcOpNotContains
,
137 FcOpLess
, FcOpLessEqual
, FcOpMore
, FcOpMoreEqual
,
138 FcOpPlus
, FcOpMinus
, FcOpTimes
, FcOpDivide
,
139 FcOpNot
, FcOpComma
, FcOpFloor
, FcOpCeil
, FcOpRound
, FcOpTrunc
,
143 typedef struct _FcExpr
{
155 struct _FcExpr
*left
, *right
;
160 typedef enum _FcQual
{
161 FcQualAny
, FcQualAll
, FcQualFirst
, FcQualNotFirst
164 #define FcMatchDefault ((FcMatchKind) -1)
166 typedef struct _FcTest
{
167 struct _FcTest
*next
;
175 typedef struct _FcEdit
{
176 struct _FcEdit
*next
;
180 FcValueBinding binding
;
183 typedef struct _FcSubst
{
184 struct _FcSubst
*next
;
189 typedef struct _FcCharLeaf
{
190 FcChar32 map
[256/32];
193 #define FC_REF_CONSTANT -1
196 int ref
; /* reference count */
197 int num
; /* size of leaves and numbers arrays */
203 int ref
; /* reference count */
214 typedef struct _FcStrBuf
{
223 * To map adobe glyph names to unicode values, a precomputed hash
227 typedef struct _FcGlyphName
{
228 FcChar32 ucs
; /* unicode value */
229 FcChar8 name
[1]; /* name extends beyond struct */
233 * The per-user ~/.fonts.cache-<version> file is loaded into
234 * this data structure. Each directory gets a substructure
235 * which is validated by comparing the directory timestamp with
236 * that saved in the cache. When valid, the entire directory cache
237 * can be immediately loaded without reading the directory. Otherwise,
238 * the files are checked individually; updated files are loaded into the
239 * cache which is then rewritten to the users home directory
242 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
243 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
245 typedef struct _FcGlobalCacheInfo
{
252 typedef struct _FcGlobalCacheFile
{
253 struct _FcGlobalCacheFile
*next
;
254 FcGlobalCacheInfo info
;
259 typedef struct _FcGlobalCacheDir FcGlobalCacheDir
;
261 typedef struct _FcGlobalCacheSubdir
{
262 struct _FcGlobalCacheSubdir
*next
;
263 FcGlobalCacheDir
*ent
;
264 } FcGlobalCacheSubdir
;
266 struct _FcGlobalCacheDir
{
267 struct _FcGlobalCacheDir
*next
;
268 FcGlobalCacheInfo info
;
270 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
271 FcGlobalCacheSubdir
*subdirs
;
274 typedef struct _FcGlobalCache
{
275 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
283 FcChar8
*file
; /* original file name */
284 FcChar8
*new; /* temp file name -- write data here */
285 FcChar8
*lck
; /* lockfile name (used for locking) */
286 FcChar8
*tmp
; /* tmpfile name (used for locking) */
297 * File names loaded from the configuration -- saved here as the
298 * cache file must be consulted before the directories are scanned,
299 * and those directives may occur in any order
301 FcStrSet
*configDirs
; /* directories to scan for fonts */
302 FcChar8
*cache
; /* name of per-user cache file */
304 * Set of allowed blank chars -- used to
305 * trim fonts of bogus glyphs
309 * List of directories containing fonts,
310 * built by recursively scanning the set
311 * of configured directories
315 * Names of all of the configuration files used
316 * to create this configuration
318 FcStrSet
*configFiles
; /* config files loaded */
320 * Substitution instructions for patterns and fonts;
321 * maxObjects is used to allocate appropriate intermediate storage
322 * while performing a whole set of substitutions
324 FcSubst
*substPattern
; /* substitutions for patterns */
325 FcSubst
*substFont
; /* substitutions for fonts */
326 int maxObjects
; /* maximum number of tests in all substs */
328 * List of patterns used to control font file selection
330 FcStrSet
*acceptGlobs
;
331 FcStrSet
*rejectGlobs
;
332 FcFontSet
*acceptPatterns
;
333 FcFontSet
*rejectPatterns
;
335 * The set of fonts loaded from the listed directories; the
336 * order within the set does not determine the font selection,
337 * except in the case of identical matches in which case earlier fonts
338 * match preferrentially
340 FcFontSet
*fonts
[FcSetApplication
+ 1];
342 * Fontconfig can periodically rescan the system configuration
343 * and font directories. This rescanning occurs when font
344 * listing requests are made, but no more often than rescanInterval
347 time_t rescanTime
; /* last time information was scanned */
348 int rescanInterval
; /* interval between scans */
351 extern FcConfig
*_fcConfig
;
353 typedef struct _FcCharMap FcCharMap
;
360 FcGlobalCacheCreate (void);
363 FcGlobalCacheDestroy (FcGlobalCache
*cache
);
366 FcGlobalCacheCheckTime (const FcChar8
*file
, FcGlobalCacheInfo
*info
);
369 FcGlobalCacheReferenced (FcGlobalCache
*cache
,
370 FcGlobalCacheInfo
*info
);
373 FcGlobalCacheReferenceSubdir (FcGlobalCache
*cache
,
377 FcGlobalCacheDirGet (FcGlobalCache
*cache
,
380 FcBool create_missing
);
383 FcGlobalCacheScanDir (FcFontSet
*set
,
385 FcGlobalCache
*cache
,
390 FcGlobalCacheFileGet (FcGlobalCache
*cache
,
397 FcGlobalCacheLoad (FcGlobalCache
*cache
,
398 const FcChar8
*cache_file
);
401 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
404 const FcChar8
*name
);
407 FcGlobalCacheSave (FcGlobalCache
*cache
,
408 const FcChar8
*cache_file
);
411 FcDirCacheReadDir (FcFontSet
*set
,
417 FcDirCacheWriteDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
422 FcConfigAddConfigDir (FcConfig
*config
,
426 FcConfigAddFontDir (FcConfig
*config
,
430 FcConfigAddDir (FcConfig
*config
,
434 FcConfigAddConfigFile (FcConfig
*config
,
438 FcConfigSetCache (FcConfig
*config
,
442 FcConfigAddBlank (FcConfig
*config
,
446 FcConfigAddEdit (FcConfig
*config
,
452 FcConfigSetFonts (FcConfig
*config
,
457 FcConfigCompareValue (const FcValue m
,
462 FcConfigGlobAdd (FcConfig
*config
,
467 FcConfigAcceptFilename (FcConfig
*config
,
468 const FcChar8
*filename
);
471 FcConfigPatternsAdd (FcConfig
*config
,
476 FcConfigAcceptFont (FcConfig
*config
,
477 const FcPattern
*font
);
481 FcCharSetFreeze (FcCharSet
*cs
);
484 FcCharSetThawAll (void);
487 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
490 FcNameParseCharSet (FcChar8
*string
);
493 FcCharSetFindLeafCreate (FcCharSet
*fcs
, FcChar32 ucs4
);
497 FcValueListPrint (const FcValueList
*l
);
500 FcLangSetPrint (const FcLangSet
*ls
);
506 FcTestPrint (const FcTest
*test
);
509 FcExprPrint (const FcExpr
*expr
);
512 FcEditPrint (const FcEdit
*edit
);
515 FcSubstPrint (const FcSubst
*subst
);
523 FcFileScanConfig (FcFontSet
*set
,
532 FcDirScanConfig (FcFontSet
*set
,
546 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
549 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
552 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
555 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
558 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
563 FcConfigparse (void);
569 FcConfigerror (char *fmt
, ...);
572 FcConfigSaveField (const char *field
);
575 FcTestCreate (FcMatchKind kind
,
577 const FcChar8
*field
,
582 FcTestDestroy (FcTest
*test
);
585 FcExprCreateInteger (int i
);
588 FcExprCreateDouble (double d
);
591 FcExprCreateString (const FcChar8
*s
);
594 FcExprCreateMatrix (const FcMatrix
*m
);
597 FcExprCreateBool (FcBool b
);
600 FcExprCreateNil (void);
603 FcExprCreateField (const char *field
);
606 FcExprCreateConst (const FcChar8
*constant
);
609 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
612 FcExprDestroy (FcExpr
*e
);
615 FcEditCreate (const char *field
, FcOp op
, FcExpr
*expr
, FcValueBinding binding
);
618 FcEditDestroy (FcEdit
*e
);
626 FcMemAlloc (int kind
, int size
);
629 FcMemFree (int kind
, int size
);
633 FcFreeTypeLangSet (const FcCharSet
*charset
,
634 const FcChar8
*exclusiveLang
);
637 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
640 FcCharSetForLang (const FcChar8
*lang
);
643 FcLangSetPromote (const FcChar8
*lang
);
646 FcNameParseLangSet (const FcChar8
*string
);
649 FcNameUnparseLangSet (FcStrBuf
*buf
, const FcLangSet
*ls
);
654 FcListPatternMatchAny (const FcPattern
*p
,
655 const FcPattern
*font
);
662 FcNameBool (FcChar8
*v
, FcBool
*result
);
666 FcValueListDestroy (FcValueList
*l
);
669 FcPatternFindElt (const FcPattern
*p
, const char *object
);
672 FcPatternInsertElt (FcPattern
*p
, const char *object
);
675 FcPatternAddWithBinding (FcPattern
*p
,
678 FcValueBinding binding
,
682 FcPatternFreeze (FcPattern
*p
);
685 FcPatternThawAll (void);
688 FcPatternAppend (FcPattern
*p
, FcPattern
*s
);
691 FcObjectStaticName (const char *name
);
697 extern const FcMatrix FcIdentityMatrix
;
700 FcMatrixFree (FcMatrix
*mat
);
704 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
707 FcStrFree (FcChar8
*s
);
710 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
713 FcStrBufDestroy (FcStrBuf
*buf
);
716 FcStrBufDone (FcStrBuf
*buf
);
719 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
722 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
725 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
728 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
731 FcStrContainsIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
734 FcStrContainsIgnoreCase (const FcChar8
*s1
, const FcChar8
*s2
);
737 FcStrUsesHome (const FcChar8
*s
);
740 FcStrLastSlash (const FcChar8
*path
);
742 #endif /* _FC_INT_H_ */