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
{
262 typedef struct _FcCache
{
264 off_t fontsets_offset
;
265 off_t pattern_offset
; int pattern_length
;
266 off_t patternelt_offset
; int patternelt_length
;
267 off_t valuelist_offset
; int valuelist_length
;
268 off_t object_offset
; int object_length
;
269 off_t objectcontent_offset
; int objectcontent_length
;
270 off_t langsets_offset
; int langsets_length
;
271 off_t charsets_offset
; int charsets_length
;
272 off_t charset_leaf_offset
; int charset_num_sum
;
273 off_t charset_leafidx_offset
;
274 off_t charset_numbers_offset
;
275 off_t matrices_offset
; int matrices_length
;
276 off_t strsets_offset
; int strsets_length
;
277 off_t strsets_idx_offset
; int strsets_idx_length
;
278 off_t strset_buf_offset
; int strset_buf_length
;
282 * To map adobe glyph names to unicode values, a precomputed hash
286 typedef struct _FcGlyphName
{
287 FcChar32 ucs
; /* unicode value */
288 FcChar8 name
[1]; /* name extends beyond struct */
292 * To perform case-insensitive string comparisons, a table
293 * is used which holds three different kinds of folding data.
295 * The first is a range of upper case values mapping to a range
296 * of their lower case equivalents. Within each range, the offset
297 * between upper and lower case is constant.
299 * The second is a range of upper case values which are interleaved
300 * with their lower case equivalents.
302 * The third is a set of raw unicode values mapping to a list
303 * of unicode values for comparison purposes. This allows conversion
304 * of ß to "ss" so that SS, ss and ß all match. A separate array
305 * holds the list of unicode values for each entry.
307 * These are packed into a single table. Using a binary search,
308 * the appropriate entry can be located.
311 #define FC_CASE_FOLD_RANGE 0
312 #define FC_CASE_FOLD_EVEN_ODD 1
313 #define FC_CASE_FOLD_FULL 2
315 typedef struct _FcCaseFold
{
319 short offset
; /* lower - upper for RANGE, table id for FULL */
322 #define FC_MAX_FILE_LEN 4096
325 * The per-user ~/.fonts.cache-<version> file is loaded into
326 * this data structure. Each directory gets a substructure
327 * which is validated by comparing the directory timestamp with
328 * that saved in the cache. When valid, the entire directory cache
329 * can be immediately loaded without reading the directory. Otherwise,
330 * the files are checked individually; updated files are loaded into the
331 * cache which is then rewritten to the users home directory
334 #define FC_CACHE_MAGIC 0x12345678
335 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
336 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
338 typedef struct _FcGlobalCacheInfo
{
345 typedef struct _FcGlobalCacheFile
{
346 struct _FcGlobalCacheFile
*next
;
347 FcGlobalCacheInfo info
;
352 typedef struct _FcGlobalCacheDir FcGlobalCacheDir
;
354 typedef struct _FcGlobalCacheSubdir
{
355 struct _FcGlobalCacheSubdir
*next
;
356 FcGlobalCacheDir
*ent
;
357 } FcGlobalCacheSubdir
;
359 struct _FcGlobalCacheDir
{
360 struct _FcGlobalCacheDir
*next
;
361 FcGlobalCacheInfo info
;
363 FcGlobalCacheFile
*ents
[FC_GLOBAL_CACHE_FILE_HASH_SIZE
];
364 FcGlobalCacheSubdir
*subdirs
;
367 typedef struct _FcGlobalCache
{
368 FcGlobalCacheDir
*ents
[FC_GLOBAL_CACHE_DIR_HASH_SIZE
];
376 FcChar8
*file
; /* original file name */
377 FcChar8
*new; /* temp file name -- write data here */
378 FcChar8
*lck
; /* lockfile name (used for locking) */
379 FcChar8
*tmp
; /* tmpfile name (used for locking) */
390 * File names loaded from the configuration -- saved here as the
391 * cache file must be consulted before the directories are scanned,
392 * and those directives may occur in any order
394 FcStrSet
*configDirs
; /* directories to scan for fonts */
395 FcChar8
*cache
; /* name of per-user cache file */
397 * Set of allowed blank chars -- used to
398 * trim fonts of bogus glyphs
402 * List of directories containing fonts,
403 * built by recursively scanning the set
404 * of configured directories
408 * Names of all of the configuration files used
409 * to create this configuration
411 FcStrSet
*configFiles
; /* config files loaded */
413 * Substitution instructions for patterns and fonts;
414 * maxObjects is used to allocate appropriate intermediate storage
415 * while performing a whole set of substitutions
417 FcSubst
*substPattern
; /* substitutions for patterns */
418 FcSubst
*substFont
; /* substitutions for fonts */
419 int maxObjects
; /* maximum number of tests in all substs */
421 * List of patterns used to control font file selection
423 FcStrSet
*acceptGlobs
;
424 FcStrSet
*rejectGlobs
;
425 FcFontSet
*acceptPatterns
;
426 FcFontSet
*rejectPatterns
;
428 * The set of fonts loaded from the listed directories; the
429 * order within the set does not determine the font selection,
430 * except in the case of identical matches in which case earlier fonts
431 * match preferrentially
433 FcFontSet
*fonts
[FcSetApplication
+ 1];
435 * Fontconfig can periodically rescan the system configuration
436 * and font directories. This rescanning occurs when font
437 * listing requests are made, but no more often than rescanInterval
440 time_t rescanTime
; /* last time information was scanned */
441 int rescanInterval
; /* interval between scans */
444 extern FcConfig
*_fcConfig
;
446 typedef struct _FcCharMap FcCharMap
;
453 FcCacheNextOffset(int fd
);
456 FcCacheForce(FcBool force
);
459 FcCacheClearStatic(void);
462 FcCachePrepareSerialize(FcConfig
* config
);
465 FcCacheSerialize (FcConfig
* config
);
468 FcCacheRead (FcConfig
*config
);
471 FcCacheWrite (FcConfig
* config
);
476 FcConfigAddConfigDir (FcConfig
*config
,
480 FcConfigAddFontDir (FcConfig
*config
,
484 FcConfigAddDir (FcConfig
*config
,
488 FcConfigAddConfigFile (FcConfig
*config
,
492 FcConfigSetCache (FcConfig
*config
,
496 FcConfigAddBlank (FcConfig
*config
,
500 FcConfigAddEdit (FcConfig
*config
,
506 FcConfigSetFonts (FcConfig
*config
,
511 FcConfigCompareValue (const FcValue m
,
516 FcConfigGlobAdd (FcConfig
*config
,
521 FcConfigAcceptFilename (FcConfig
*config
,
522 const FcChar8
*filename
);
525 FcConfigPatternsAdd (FcConfig
*config
,
530 FcConfigAcceptFont (FcConfig
*config
,
531 const FcPattern
*font
);
535 FcCharSetFreeze (FcCharSet
*cs
);
538 FcCharSetCopyPtr (FcCharSetPtr src
);
541 FcCharSetThawAll (void);
544 FcNameUnparseCharSet (FcStrBuf
*buf
, const FcCharSet
*c
);
547 FcNameParseCharSet (FcChar8
*string
);
550 FcCharSetFindLeafCreate (FcCharSet
*fcs
, FcChar32 ucs4
);
553 FcCharSetPtrDestroy (FcCharSetPtr fcs
);
556 FcCharSetClearStatic(void);
559 FcCharSetPrepareSerialize(FcCharSet
*c
);
562 FcCharSetSerialize(FcCharSet
*c
);
565 FcCharSetPtrCreateDynamic(FcCharSet
*c
);
568 FcCharSetGetLeaf(const FcCharSet
*c
, int i
);
571 FcCharSetGetNumbers(const FcCharSet
*c
);
574 FcCharSetRead (int fd
, FcCache metadata
);
577 FcCharSetWrite (int fd
, FcCache
*metadata
);
581 FcValueListPrint (const FcValueListPtr l
);
584 FcLangSetPrint (const FcLangSet
*ls
);
590 FcTestPrint (const FcTest
*test
);
593 FcExprPrint (const FcExpr
*expr
);
596 FcEditPrint (const FcEdit
*edit
);
599 FcSubstPrint (const FcSubst
*subst
);
605 FcCharSetPtrU (FcCharSetPtr mi
);
610 FcFileIsDir (const FcChar8
*file
);
613 FcFileScanConfig (FcFontSet
*set
,
622 FcDirScanConfig (FcFontSet
*set
,
636 FcFreeTypeIsExclusiveLang (const FcChar8
*lang
);
639 FcFreeTypeHasLang (FcPattern
*pattern
, const FcChar8
*lang
);
642 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4
, const FcCharMap
*map
);
645 FcFreeTypePrivateToUcs4 (FcChar32
private, const FcCharMap
*map
);
648 FcFreeTypeGetPrivateMap (FT_Encoding encoding
);
653 FcFontSetClearStatic (void);
656 FcFontSetPrepareSerialize (FcFontSet
* s
);
659 FcFontSetSerialize (FcFontSet
* s
);
662 FcFontSetRead(int fd
, FcConfig
* config
, FcCache metadata
);
665 FcFontSetWrite(int fd
, FcConfig
* config
, FcCache
* metadata
);
669 FcConfigparse (void);
675 FcConfigerror (char *fmt
, ...);
678 FcConfigSaveField (const char *field
);
681 FcTestDestroy (FcTest
*test
);
684 FcExprCreateInteger (int i
);
687 FcExprCreateDouble (double d
);
690 FcExprCreateString (const FcChar8
*s
);
693 FcExprCreateMatrix (const FcMatrix
*m
);
696 FcExprCreateBool (FcBool b
);
699 FcExprCreateNil (void);
702 FcExprCreateField (const char *field
);
705 FcExprCreateConst (const FcChar8
*constant
);
708 FcExprCreateOp (FcExpr
*left
, FcOp op
, FcExpr
*right
);
711 FcExprDestroy (FcExpr
*e
);
714 FcEditDestroy (FcEdit
*e
);
722 FcMemAlloc (int kind
, int size
);
725 FcMemFree (int kind
, int size
);
729 FcFreeTypeLangSet (const FcCharSet
*charset
,
730 const FcChar8
*exclusiveLang
);
733 FcLangCompare (const FcChar8
*s1
, const FcChar8
*s2
);
736 FcCharSetForLang (const FcChar8
*lang
);
739 FcLangSetPromote (const FcChar8
*lang
);
742 FcNameParseLangSet (const FcChar8
*string
);
745 FcNameUnparseLangSet (FcStrBuf
*buf
, const FcLangSet
*ls
);
748 FcLangSetClearStatic (void);
751 FcLangSetPrepareSerialize (FcLangSet
*l
);
754 FcLangSetSerialize (FcLangSet
*l
);
757 FcLangSetPtrU (FcLangSetPtr li
);
760 FcLangSetPtrCreateDynamic (FcLangSet
*l
);
763 FcLangSetPtrDestroy (FcLangSetPtr li
);
766 FcLangSetRead (int fd
, FcCache metadata
);
769 FcLangSetWrite (int fd
, FcCache
*metadata
);
774 FcListPatternMatchAny (const FcPattern
*p
,
775 const FcPattern
*font
);
782 FcNameBool (const FcChar8
*v
, FcBool
*result
);
786 FcValueListDestroy (FcValueListPtr l
);
789 FcPatternFindElt (const FcPattern
*p
, const char *object
);
792 FcPatternInsertElt (FcPattern
*p
, const char *object
);
795 FcPatternAddWithBinding (FcPattern
*p
,
798 FcValueBinding binding
,
802 FcPatternFreeze (FcPattern
*p
);
805 FcPatternFini (void);
808 FcPatternAppend (FcPattern
*p
, FcPattern
*s
);
811 FcObjectClearStatic(void);
814 FcObjectStaticName (const char *name
);
817 FcObjectRead (int fd
, FcCache metadata
);
820 FcObjectWrite (int fd
, FcCache
* metadata
);
823 FcObjectPtrU (FcObjectPtr p
);
826 FcObjectPtrCompare (FcObjectPtr a
, FcObjectPtr b
);
829 FcObjectPtrDestroy (FcObjectPtr p
);
832 FcPatternPrepareSerialize (FcPattern
*p
);
835 FcValueListClearStatic (void);
838 FcPatternClearStatic (void);
841 FcValueListPtrU(FcValueListPtr p
);
844 FcPatternEltU (FcPatternEltPtr pei
);
847 FcValueListPtrCreateDynamic(FcValueList
* p
);
850 FcValueListPrepareSerialize (FcValueList
*p
);
853 FcValueListSerialize(FcValueList
*pi
);
856 FcPatternSerialize (FcPattern
* p
);
859 FcPatternRead (int fd
, FcCache metadata
);
862 FcPatternWrite (int fd
, FcCache
*metadata
);
865 FcPatternEltRead (int fd
, FcCache metadata
);
868 FcPatternEltWrite (int fd
, FcCache
*metadata
);
871 FcValueListRead (int fd
, FcCache metadata
);
874 FcValueListWrite (int fd
, FcCache
*metadata
);
880 extern const FcMatrixPtr FcIdentityMatrix
;
883 FcMatrixFree (FcMatrix
*mat
);
886 FcMatrixPtrDestroy (FcMatrixPtr mi
);
889 FcMatrixPrepareSerialize(FcMatrix
*m
);
892 FcMatrixSerialize(FcMatrix
*m
);
895 FcMatrixPtrU (FcMatrixPtr mi
);
898 FcMatrixPtrCreateDynamic (FcMatrix
*m
);
901 FcMatrixClearStatic (void);
904 FcMatrixWrite (int fd
, FcCache
*metadata
);
907 FcMatrixRead (int fd
, FcCache metadata
);
911 FcStrSetPtrU (const FcStrSetPtr set
);
914 FcStrSetPtrCreateDynamic (const FcStrSet
* set
);
917 FcStrSetClearStatic (void);
920 FcStrSetPrepareSerialize (const FcStrSet
*set
);
923 FcStrSetSort (FcStrSet
* set
);
926 FcStrSetGet (const FcStrSet
*set
, int i
);
929 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
);
932 FcStrFree (FcChar8
*s
);
935 FcStrBufInit (FcStrBuf
*buf
, FcChar8
*init
, int size
);
938 FcStrBufDestroy (FcStrBuf
*buf
);
941 FcStrBufDone (FcStrBuf
*buf
);
944 FcStrBufChar (FcStrBuf
*buf
, FcChar8 c
);
947 FcStrBufString (FcStrBuf
*buf
, const FcChar8
*s
);
950 FcStrBufData (FcStrBuf
*buf
, const FcChar8
*s
, int len
);
953 FcStrSetSerialize (FcStrSet
*set
);
956 FcStrSetRead (int fd
, FcCache metadata
);
959 FcStrSetWrite (int fd
, FcCache
*metadata
);
962 FcStrCmpIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
965 FcStrContainsIgnoreBlanksAndCase (const FcChar8
*s1
, const FcChar8
*s2
);
968 FcStrContainsIgnoreCase (const FcChar8
*s1
, const FcChar8
*s2
);
971 FcStrUsesHome (const FcChar8
*s
);
974 FcStrLastSlash (const FcChar8
*path
);
977 FcStrHashIgnoreCase (const FcChar8
*s
);
979 #endif /* _FC_INT_H_ */