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>
45 typedef struct _FcSymbolic
{
50 #ifndef FC_CONFIG_PATH
51 #define FC_CONFIG_PATH "fonts.conf"
54 #define FC_FONT_FILE_INVALID ((FcChar8 *) ".")
55 #define FC_FONT_FILE_DIR ((FcChar8 *) ".dir")
58 #define FC_SEARCH_PATH_SEPARATOR ';'
60 #define FC_SEARCH_PATH_SEPARATOR ':'
63 #define FC_DBG_MATCH 1
64 #define FC_DBG_MATCHV 2
66 #define FC_DBG_FONTSET 8
67 #define FC_DBG_CACHE 16
68 #define FC_DBG_CACHEV 32
69 #define FC_DBG_PARSE 64
70 #define FC_DBG_SCAN 128
71 #define FC_DBG_SCANV 256
72 #define FC_DBG_MEMORY 512
73 #define FC_DBG_CONFIG 1024
75 #define FC_MEM_CHARSET 0
76 #define FC_MEM_CHARLEAF 1
77 #define FC_MEM_FONTSET 2
78 #define FC_MEM_FONTPTR 3
79 #define FC_MEM_OBJECTSET 4
80 #define FC_MEM_OBJECTPTR 5
81 #define FC_MEM_MATRIX 6
82 #define FC_MEM_PATTERN 7
83 #define FC_MEM_PATELT 8
84 #define FC_MEM_VALLIST 9
85 #define FC_MEM_SUBSTATE 10
86 #define FC_MEM_STRING 11
87 #define FC_MEM_LISTBUCK 12
88 #define FC_MEM_STRSET 13
89 #define FC_MEM_STRLIST 14
90 #define FC_MEM_CONFIG 15
91 #define FC_MEM_LANGSET 16
92 #define FC_MEM_ATOMIC 17
93 #define FC_MEM_BLANKS 18
94 #define FC_MEM_CACHE 19
95 #define FC_MEM_STRBUF 20
96 #define FC_MEM_SUBST 21
97 #define FC_MEM_OBJECTTYPE 22
98 #define FC_MEM_CONSTANT 23
99 #define FC_MEM_TEST 24
100 #define FC_MEM_EXPR 25
101 #define FC_MEM_VSTACK 26
102 #define FC_MEM_ATTR 27
103 #define FC_MEM_PSTACK 28
104 #define FC_MEM_STATICSTR 29
106 #define FC_MEM_NUM 30
108 typedef enum _FcValueBinding
{
109 FcValueBindingWeak
, FcValueBindingStrong
, FcValueBindingSame
112 typedef struct _FcStrSetPtr
{
116 struct _FcStrSet
*dyn
;
120 typedef struct _FcValueListPtr
{
124 struct _FcValueList
*dyn
;
128 typedef struct _FcValueList
{
132 FcValueBinding binding
;
135 typedef struct _FcPatternEltPtr
{
139 struct _FcPatternElt
*dyn
;
143 typedef struct _FcPatternElt
{
145 FcValueListPtr values
;
151 FcPatternEltPtr elts
;
156 FcOpInteger
, FcOpDouble
, FcOpString
, FcOpMatrix
, FcOpBool
, FcOpCharSet
,
158 FcOpField
, FcOpConst
,
159 FcOpAssign
, FcOpAssignReplace
,
160 FcOpPrependFirst
, FcOpPrepend
, FcOpAppend
, FcOpAppendLast
,
162 FcOpOr
, FcOpAnd
, FcOpEqual
, FcOpNotEqual
,
163 FcOpContains
, FcOpListing
, FcOpNotContains
,
164 FcOpLess
, FcOpLessEqual
, FcOpMore
, FcOpMoreEqual
,
165 FcOpPlus
, FcOpMinus
, FcOpTimes
, FcOpDivide
,
166 FcOpNot
, FcOpComma
, FcOpFloor
, FcOpCeil
, FcOpRound
, FcOpTrunc
,
170 typedef struct _FcExpr
{
182 struct _FcExpr
*left
, *right
;
187 typedef enum _FcQual
{
188 FcQualAny
, FcQualAll
, FcQualFirst
, FcQualNotFirst
191 #define FcMatchDefault ((FcMatchKind) -1)
193 typedef struct _FcTest
{
194 struct _FcTest
*next
;
202 typedef struct _FcEdit
{
203 struct _FcEdit
*next
;
207 FcValueBinding binding
;
210 typedef struct _FcSubst
{
211 struct _FcSubst
*next
;
216 typedef struct _FcCharLeaf
{
217 FcChar32 map
[256/32];
220 #define FC_REF_CONSTANT -1
223 int ref
; /* reference count */
224 int num
; /* size of leaves and numbers arrays */
239 int ref
; /* reference count */
254 typedef struct _FcStrBuf
{
263 * To map adobe glyph names to unicode values, a precomputed hash
267 typedef struct _FcGlyphName
{
268 FcChar32 ucs
; /* unicode value */
269 FcChar8 name
[1]; /* name extends beyond struct */
273 * To perform case-insensitive string comparisons, a table
274 * is used which holds three different kinds of folding data.
276 * The first is a range of upper case values mapping to a range
277 * of their lower case equivalents. Within each range, the offset
278 * between upper and lower case is constant.
280 * The second is a range of upper case values which are interleaved
281 * with their lower case equivalents.
283 * The third is a set of raw unicode values mapping to a list
284 * of unicode values for comparison purposes. This allows conversion
285 * of ß to "ss" so that SS, ss and ß all match. A separate array
286 * holds the list of unicode values for each entry.
288 * These are packed into a single table. Using a binary search,
289 * the appropriate entry can be located.
292 #define FC_CASE_FOLD_RANGE 0
293 #define FC_CASE_FOLD_EVEN_ODD 1
294 #define FC_CASE_FOLD_FULL 2
296 typedef struct _FcCaseFold
{
300 short offset
; /* lower - upper for RANGE, table id for FULL */
303 #define FC_MAX_FILE_LEN 4096
306 * The per-user ~/.fonts.cache-<version> file is loaded into
307 * this data structure. Each directory gets a substructure
308 * which is validated by comparing the directory timestamp with
309 * that saved in the cache. When valid, the entire directory cache
310 * can be immediately loaded without reading the directory. Otherwise,
311 * the files are checked individually; updated files are loaded into the
312 * cache which is then rewritten to the users home directory
315 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
316 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
318 typedef struct _FcGlobalCacheInfo
{
325 typedef struct _FcGlobalCacheFile
{
326 struct _FcGlobalCacheFile
*next
;
327 FcGlobalCacheInfo info
;
332 typedef struct _FcGlobalCacheDir FcGlobalCacheDir
;
334 typedef struct _FcGlobalCacheSubdir
{
335 struct _FcGlobalCacheSubdir
*next
;
336 FcGlobalCacheDir
*ent
;
337 } FcGlobalCacheSubdir
;
339 struct _FcGlobalCacheDir
{
340 struct _FcGlobalCacheDir
*next
;
341 FcGlobalCacheInfo info
;
343 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
344 FcGlobalCacheSubdir
*subdirs
;
347 typedef struct _FcGlobalCache
{
348 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
356 FcChar8
*file
; /* original file name */
357 FcChar8
*new; /* temp file name -- write data here */
358 FcChar8
*lck
; /* lockfile name (used for locking) */
359 FcChar8
*tmp
; /* tmpfile name (used for locking) */
370 * File names loaded from the configuration -- saved here as the
371 * cache file must be consulted before the directories are scanned,
372 * and those directives may occur in any order
374 FcStrSet
*configDirs
; /* directories to scan for fonts */
375 FcChar8
*cache
; /* name of per-user cache file */
377 * Set of allowed blank chars -- used to
378 * trim fonts of bogus glyphs
382 * List of directories containing fonts,
383 * built by recursively scanning the set
384 * of configured directories
388 * Names of all of the configuration files used
389 * to create this configuration
391 FcStrSet
*configFiles
; /* config files loaded */
393 * Substitution instructions for patterns and fonts;
394 * maxObjects is used to allocate appropriate intermediate storage
395 * while performing a whole set of substitutions
397 FcSubst
*substPattern
; /* substitutions for patterns */
398 FcSubst
*substFont
; /* substitutions for fonts */
399 int maxObjects
; /* maximum number of tests in all substs */
401 * List of patterns used to control font file selection
403 FcStrSet
*acceptGlobs
;
404 FcStrSet
*rejectGlobs
;
405 FcFontSet
*acceptPatterns
;
406 FcFontSet
*rejectPatterns
;
408 * The set of fonts loaded from the listed directories; the
409 * order within the set does not determine the font selection,
410 * except in the case of identical matches in which case earlier fonts
411 * match preferrentially
413 FcFontSet
*fonts
[FcSetApplication
+ 1];
415 * Fontconfig can periodically rescan the system configuration
416 * and font directories. This rescanning occurs when font
417 * listing requests are made, but no more often than rescanInterval
420 time_t rescanTime
; /* last time information was scanned */
421 int rescanInterval
; /* interval between scans */
424 extern FcConfig
*_fcConfig
;
426 typedef struct _FcCharMap FcCharMap
;
433 FcGlobalCacheCreate (void);
436 FcGlobalCacheDestroy (FcGlobalCache
*cache
);
439 FcGlobalCacheCheckTime (const FcChar8
*file
, FcGlobalCacheInfo
*info
);
442 FcGlobalCacheReferenced (FcGlobalCache
*cache
,
443 FcGlobalCacheInfo
*info
);
446 FcGlobalCacheReferenceSubdir (FcGlobalCache
*cache
,
450 FcGlobalCacheDirGet (FcGlobalCache
*cache
,
453 FcBool create_missing
);
456 FcGlobalCacheScanDir (FcFontSet
*set
,
458 FcGlobalCache
*cache
,
463 FcGlobalCacheFileGet (FcGlobalCache
*cache
,
470 FcGlobalCacheLoad (FcGlobalCache
*cache
,
471 const FcChar8
*cache_file
);
474 FcGlobalCacheUpdate (FcGlobalCache
*cache
,
477 const FcChar8
*name
);
480 FcGlobalCacheSave (FcGlobalCache
*cache
,
481 const FcChar8
*cache_file
);
484 FcDirCacheReadDir (FcFontSet
*set
,
490 FcDirCacheWriteDir (FcFontSet
*set
, FcStrSet
*dirs
, const FcChar8
*dir
);
495 FcConfigAddConfigDir (FcConfig
*config
,
499 FcConfigAddFontDir (FcConfig
*config
,
503 FcConfigAddDir (FcConfig
*config
,
507 FcConfigAddConfigFile (FcConfig
*config
,
511 FcConfigSetCache (FcConfig
*config
,
515 FcConfigAddBlank (FcConfig
*config
,
519 FcConfigAddEdit (FcConfig
*config
,
525 FcConfigSetFonts (FcConfig
*config
,
530 FcConfigCompareValue (const FcValue m
,
535 FcConfigGlobAdd (FcConfig
*config
,
540 FcConfigAcceptFilename (FcConfig
*config
,
541 const FcChar8
*filename
);
544 FcConfigPatternsAdd (FcConfig
*config
,
549 FcConfigAcceptFont (FcConfig
*config
,
550 const FcPattern
*font
);
554 FcCharSetFreeze (FcCharSet
*cs
);
557 FcCharSetThawAll (void);
560 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
563 FcNameParseCharSet (FcChar8
*string
);
566 FcCharSetFindLeafCreate (FcCharSet
*fcs
, FcChar32 ucs4
);
569 FcCharSetPtrDestroy (FcCharSetPtr fcs
);
572 FcCharSetClearStatic(void);
575 FcCharSetPrepareSerialize(FcCharSet
*c
);
578 FcCharSetSerialize(FcCharSet
*c
);
581 FcCharSetPtrCreateDynamic(FcCharSet
*c
);
584 FcCharSetGetLeaf(const FcCharSet
*c
, int i
);
587 FcCharSetGetNumbers(const FcCharSet
*c
);
591 FcValueListPrint (const FcValueListPtr l
);
594 FcLangSetPrint (const FcLangSet
*ls
);
600 FcTestPrint (const FcTest
*test
);
603 FcExprPrint (const FcExpr
*expr
);
606 FcEditPrint (const FcEdit
*edit
);
609 FcSubstPrint (const FcSubst
*subst
);
615 FcCharSetPtrU (FcCharSetPtr mi
);
620 FcFileIsDir (const FcChar8
*file
);
623 FcFileScanConfig (FcFontSet
*set
,
632 FcDirScanConfig (FcFontSet
*set
,
646 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
649 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
652 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
655 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
658 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
663 FcFontSetClearStatic (void);
666 FcFontSetPrepareSerialize (FcFontSet
* s
);
669 FcFontSetSerialize (FcFontSet
* s
);
673 FcConfigparse (void);
679 FcConfigerror (char *fmt
, ...);
682 FcConfigSaveField (const char *field
);
685 FcTestDestroy (FcTest
*test
);
688 FcExprCreateInteger (int i
);
691 FcExprCreateDouble (double d
);
694 FcExprCreateString (const FcChar8
*s
);
697 FcExprCreateMatrix (const FcMatrix
*m
);
700 FcExprCreateBool (FcBool b
);
703 FcExprCreateNil (void);
706 FcExprCreateField (const char *field
);
709 FcExprCreateConst (const FcChar8
*constant
);
712 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
715 FcExprDestroy (FcExpr
*e
);
718 FcEditDestroy (FcEdit
*e
);
726 FcMemAlloc (int kind
, int size
);
729 FcMemFree (int kind
, int size
);
733 FcFreeTypeLangSet (const FcCharSet
*charset
,
734 const FcChar8
*exclusiveLang
);
737 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
740 FcCharSetForLang (const FcChar8
*lang
);
743 FcLangSetPromote (const FcChar8
*lang
);
746 FcNameParseLangSet (const FcChar8
*string
);
749 FcNameUnparseLangSet (FcStrBuf
*buf
, const FcLangSet
*ls
);
752 FcLangSetClearStatic (void);
755 FcLangSetPrepareSerialize (FcLangSet
*l
);
758 FcLangSetSerialize (FcLangSet
*l
);
761 FcLangSetPtrU (FcLangSetPtr li
);
764 FcLangSetPtrCreateDynamic (FcLangSet
*l
);
767 FcLangSetPtrDestroy (FcLangSetPtr li
);
772 FcListPatternMatchAny (const FcPattern
*p
,
773 const FcPattern
*font
);
780 FcCacheClearStatic(void);
783 FcCachePrepareSerialize(FcConfig
* config
);
786 FcCacheSerialize (FcConfig
* config
);
792 FcNameBool (const FcChar8
*v
, FcBool
*result
);
796 FcValueListDestroy (FcValueListPtr l
);
799 FcPatternFindElt (const FcPattern
*p
, const char *object
);
802 FcPatternInsertElt (FcPattern
*p
, const char *object
);
805 FcPatternAddWithBinding (FcPattern
*p
,
808 FcValueBinding binding
,
812 FcPatternFreeze (FcPattern
*p
);
815 FcPatternThawAll (void);
818 FcPatternAppend (FcPattern
*p
, FcPattern
*s
);
821 FcObjectClearStatic(void);
824 FcObjectStaticName (const char *name
);
827 FcObjectPrepareSerialize (FcObjectPtr si
);
830 FcObjectPtrU (FcObjectPtr p
);
833 FcObjectPtrCompare (FcObjectPtr a
, FcObjectPtr b
);
836 FcObjectPtrCreateDynamic (const char * s
);
839 FcObjectPtrDestroy (FcObjectPtr p
);
842 FcPatternPrepareSerialize (FcPattern
*p
);
845 FcValueListClearStatic (void);
848 FcPatternClearStatic (void);
851 FcValueListPtrU(FcValueListPtr p
);
854 FcPatternEltU (FcPatternEltPtr pei
);
857 FcValueListPtrCreateDynamic(FcValueList
* p
);
860 FcValueListPrepareSerialize (FcValueList
*p
);
863 FcValueListSerialize(FcValueList
*pi
);
866 FcPatternSerialize (FcPattern
* p
);
872 extern const FcMatrixPtr FcIdentityMatrix
;
875 FcMatrixFree (FcMatrix
*mat
);
878 FcMatrixPtrDestroy (FcMatrixPtr mi
);
881 FcMatrixPrepareSerialize(FcMatrix
*m
);
884 FcMatrixSerialize(FcMatrix
*m
);
887 FcMatrixPtrU (FcMatrixPtr mi
);
890 FcMatrixPtrCreateDynamic (FcMatrix
*m
);
893 FcMatrixClearStatic (void);
897 FcStrSetPtrU (const FcStrSetPtr set
);
900 FcStrSetPtrCreateDynamic (const FcStrSet
* set
);
903 FcStrSetClearStatic (void);
906 FcStrSetPrepareSerialize (const FcStrSet
*set
);
909 FcStrSetSort (FcStrSet
* set
);
912 FcStrSetGet (const FcStrSet
*set
, int i
);
915 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
918 FcStrFree (FcChar8
*s
);
921 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
924 FcStrBufDestroy (FcStrBuf
*buf
);
927 FcStrBufDone (FcStrBuf
*buf
);
930 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
933 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
936 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
939 FcStrSetSerialize (FcStrSet
*set
);
942 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
945 FcStrContainsIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
948 FcStrContainsIgnoreCase (const FcChar8
*s1
, const FcChar8
*s2
);
951 FcStrUsesHome (const FcChar8
*s
);
954 FcStrLastSlash (const FcChar8
*path
);
957 FcStrHashIgnoreCase (const FcChar8
*s
);
959 #endif /* _FC_INT_H_ */