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>
36 #include <libxml/parserInternals.h>
37 #include <fontconfig/fontconfig.h>
38 #include <fontconfig/fcprivate.h>
39 #include <fontconfig/fcxml.h>
44 typedef struct _FcMatcher {
46 double (*compare) (char *object, FcValue value1, FcValue value2);
49 typedef struct _FcSymbolic {
54 #ifndef FC_CONFIG_PATH
55 #define FC_CONFIG_PATH "fonts.conf"
58 #define FC_DBG_MATCH 1
59 #define FC_DBG_MATCHV 2
61 #define FC_DBG_FONTSET 8
62 #define FC_DBG_CACHE 16
63 #define FC_DBG_CACHEV 32
64 #define FC_DBG_PARSE 64
65 #define FC_DBG_SCAN 128
66 #define FC_DBG_MEMORY 512
68 #define FC_MEM_CHARSET 0
69 #define FC_MEM_CHARNODE 1
70 #define FC_MEM_FONTSET 2
71 #define FC_MEM_FONTPTR 3
72 #define FC_MEM_OBJECTSET 4
73 #define FC_MEM_OBJECTPTR 5
74 #define FC_MEM_MATRIX 6
75 #define FC_MEM_PATTERN 7
76 #define FC_MEM_PATELT 8
77 #define FC_MEM_VALLIST 9
78 #define FC_MEM_SUBSTATE 10
79 #define FC_MEM_STRING 11
80 #define FC_MEM_LISTBUCK 12
83 typedef struct _FcValueList {
84 struct _FcValueList *next;
88 typedef struct _FcPatternElt {
100 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
102 FcOpField, FcOpConst,
103 FcOpAssign, FcOpAssignReplace,
104 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
106 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
107 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
108 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
109 FcOpNot, FcOpComma, FcOpInvalid
112 typedef struct _FcExpr {
124 struct _FcExpr *left, *right;
129 typedef enum _FcQual {
133 typedef struct _FcTest {
134 struct _FcTest *next;
141 typedef struct _FcEdit {
142 struct _FcEdit *next;
148 typedef struct _FcSubst {
149 struct _FcSubst *next;
154 typedef struct _FcCharLeaf FcCharLeaf;
155 typedef struct _FcCharBranch FcCharBranch;
156 typedef union _FcCharNode FcCharNode;
159 FcChar32 map[256/32];
163 FcCharBranch *branch;
167 struct _FcCharBranch {
168 FcCharNode nodes[256];
173 int ref; /* reference count */
174 FcBool constant; /* shared constant */
178 typedef struct _FcNameBuf {
186 typedef struct _FcFileCacheEnt {
187 struct _FcFileCacheEnt *next;
196 #define FC_FILE_CACHE_HASH_SIZE 509
198 struct _FcFileCache {
199 FcFileCacheEnt *ents[FC_FILE_CACHE_HASH_SIZE];
213 * File names loaded from the configuration -- saved here as the
214 * cache file must be consulted before the directories are scanned,
215 * and those directives may occur in any order
217 FcChar8 **dirs; /* directories containing fonts */
218 FcChar8 *cache; /* name of per-user cache file */
220 * Set of allowed blank chars -- used to
221 * trim fonts of bogus glyphs
225 * Names of all of the configuration files used
226 * to create this configuration
228 FcChar8 **configFiles; /* config files loaded */
230 * Substitution instructions for patterns and fonts;
231 * maxObjects is used to allocate appropriate intermediate storage
232 * while performing a whole set of substitutions
234 FcSubst *substPattern; /* substitutions for patterns */
235 FcSubst *substFont; /* substitutions for fonts */
236 int maxObjects; /* maximum number of tests in all substs */
238 * The set of fonts loaded from the listed directories; the
239 * order within the set does not determine the font selection,
240 * except in the case of identical matches in which case earlier fonts
241 * match preferrentially
243 FcFontSet *fonts[FcSetApplication + 1];
251 FcFileCacheCreate (void);
254 FcFileCacheFind (FcFileCache *cache,
260 FcFileCacheDestroy (FcFileCache *cache);
263 FcFileCacheLoad (FcFileCache *cache,
264 const FcChar8 *cache_file);
267 FcFileCacheUpdate (FcFileCache *cache,
270 const FcChar8 *name);
273 FcFileCacheSave (FcFileCache *cache,
274 const FcChar8 *cache_file);
277 FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file);
280 FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file);
285 FcConfigAddDir (FcConfig *config,
289 FcConfigAddConfigFile (FcConfig *config,
293 FcConfigSetCache (FcConfig *config,
297 FcConfigAddBlank (FcConfig *config,
301 FcConfigAddEdit (FcConfig *config,
307 FcConfigSetFonts (FcConfig *config,
312 FcConfigCompareValue (const FcValue m,
318 FcNameUnparseCharSet (FcNameBuf *buf, const FcCharSet *c);
321 FcNameParseCharSet (FcChar8 *string);
325 FcValuePrint (FcValue v);
328 FcValueListPrint (FcValueList *l);
331 FcPatternPrint (FcPattern *p);
337 FcTestPrint (FcTest *test);
340 FcExprPrint (FcExpr *expr);
343 FcEditPrint (FcEdit *edit);
346 FcSubstPrint (FcSubst *subst);
349 FcFontSetPrint (FcFontSet *s);
363 FcConfigparse (void);
369 FcConfigerror (char *fmt, ...);
372 FcConfigSaveField (const char *field);
375 FcTestCreate (FcQual qual, const char *field, FcOp compare, FcExpr *expr);
378 FcTestDestroy (FcTest *test);
381 FcExprCreateInteger (int i);
384 FcExprCreateDouble (double d);
387 FcExprCreateString (const FcChar8 *s);
390 FcExprCreateMatrix (const FcMatrix *m);
393 FcExprCreateBool (FcBool b);
396 FcExprCreateNil (void);
399 FcExprCreateField (const char *field);
402 FcExprCreateConst (const FcChar8 *constant);
405 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
408 FcExprDestroy (FcExpr *e);
411 FcEditCreate (const char *field, FcOp op, FcExpr *expr);
414 FcEditDestroy (FcEdit *e);
422 FcMemAlloc (int kind, int size);
425 FcMemFree (int kind, int size);
434 FcNameBool (FcChar8 *v, FcBool *result);
437 FcNameBufChar (FcNameBuf *buf, FcChar8 c);
440 FcNameBufString (FcNameBuf *buf, const FcChar8 *s);
444 FcValueListDestroy (FcValueList *l);
447 FcPatternFind (FcPattern *p, const char *object, FcBool insert);
453 FcMatrixFree (FcMatrix *mat);
457 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
460 FcStrFree (FcChar8 *s);
462 #endif /* _FC_INT_H_ */