]> git.wh0rd.org - fontconfig.git/blob - src/fcint.h
Switch fontconfig from libxml2 to expat
[fontconfig.git] / src / fcint.h
1 /*
2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.2 2002/02/15 06:01:28 keithp Exp $
3 *
4 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
5 *
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.
15 *
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.
23 */
24
25 #ifndef _FCINT_H_
26 #define _FCINT_H_
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <ctype.h>
32 #include <errno.h>
33 #include <unistd.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fontconfig/fontconfig.h>
37 #include <fontconfig/fcprivate.h>
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 typedef struct _FcMatcher {
43 char *object;
44 double (*compare) (char *object, FcValue value1, FcValue value2);
45 } FcMatcher;
46
47 typedef struct _FcSymbolic {
48 const char *name;
49 int value;
50 } FcSymbolic;
51
52 #ifndef FC_CONFIG_PATH
53 #define FC_CONFIG_PATH "fonts.conf"
54 #endif
55
56 #define FC_DBG_MATCH 1
57 #define FC_DBG_MATCHV 2
58 #define FC_DBG_EDIT 4
59 #define FC_DBG_FONTSET 8
60 #define FC_DBG_CACHE 16
61 #define FC_DBG_CACHEV 32
62 #define FC_DBG_PARSE 64
63 #define FC_DBG_SCAN 128
64 #define FC_DBG_MEMORY 512
65
66 #define FC_MEM_CHARSET 0
67 #define FC_MEM_CHARNODE 1
68 #define FC_MEM_FONTSET 2
69 #define FC_MEM_FONTPTR 3
70 #define FC_MEM_OBJECTSET 4
71 #define FC_MEM_OBJECTPTR 5
72 #define FC_MEM_MATRIX 6
73 #define FC_MEM_PATTERN 7
74 #define FC_MEM_PATELT 8
75 #define FC_MEM_VALLIST 9
76 #define FC_MEM_SUBSTATE 10
77 #define FC_MEM_STRING 11
78 #define FC_MEM_LISTBUCK 12
79 #define FC_MEM_NUM 13
80
81 typedef struct _FcValueList {
82 struct _FcValueList *next;
83 FcValue value;
84 } FcValueList;
85
86 typedef struct _FcPatternElt {
87 const char *object;
88 FcValueList *values;
89 } FcPatternElt;
90
91 struct _FcPattern {
92 int num;
93 int size;
94 FcPatternElt *elts;
95 };
96
97 typedef enum _FcOp {
98 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
99 FcOpNil,
100 FcOpField, FcOpConst,
101 FcOpAssign, FcOpAssignReplace,
102 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
103 FcOpQuest,
104 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, FcOpContains,
105 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
106 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
107 FcOpNot, FcOpComma, FcOpInvalid
108 } FcOp;
109
110 typedef struct _FcExpr {
111 FcOp op;
112 union {
113 int ival;
114 double dval;
115 FcChar8 *sval;
116 FcMatrix *mval;
117 FcBool bval;
118 FcCharSet *cval;
119 char *field;
120 FcChar8 *constant;
121 struct {
122 struct _FcExpr *left, *right;
123 } tree;
124 } u;
125 } FcExpr;
126
127 typedef enum _FcQual {
128 FcQualAny, FcQualAll
129 } FcQual;
130
131 typedef struct _FcTest {
132 struct _FcTest *next;
133 FcQual qual;
134 const char *field;
135 FcOp op;
136 FcExpr *expr;
137 } FcTest;
138
139 typedef struct _FcEdit {
140 struct _FcEdit *next;
141 const char *field;
142 FcOp op;
143 FcExpr *expr;
144 } FcEdit;
145
146 typedef struct _FcSubst {
147 struct _FcSubst *next;
148 FcTest *test;
149 FcEdit *edit;
150 } FcSubst;
151
152 typedef struct _FcCharLeaf FcCharLeaf;
153 typedef struct _FcCharBranch FcCharBranch;
154 typedef union _FcCharNode FcCharNode;
155
156 struct _FcCharLeaf {
157 FcChar32 map[256/32];
158 };
159
160 union _FcCharNode {
161 FcCharBranch *branch;
162 FcCharLeaf *leaf;
163 };
164
165 struct _FcCharBranch {
166 FcCharNode nodes[256];
167 };
168
169 struct _FcCharSet {
170 int levels;
171 int ref; /* reference count */
172 FcBool constant; /* shared constant */
173 FcCharNode node;
174 };
175
176 typedef struct _FcStrBuf {
177 FcChar8 *buf;
178 FcBool allocated;
179 FcBool failed;
180 int len;
181 int size;
182 } FcStrBuf;
183
184 typedef struct _FcFileCacheEnt {
185 struct _FcFileCacheEnt *next;
186 unsigned int hash;
187 FcChar8 *file;
188 int id;
189 time_t time;
190 FcChar8 *name;
191 FcBool referenced;
192 } FcFileCacheEnt;
193
194 #define FC_FILE_CACHE_HASH_SIZE 509
195
196 struct _FcFileCache {
197 FcFileCacheEnt *ents[FC_FILE_CACHE_HASH_SIZE];
198 FcBool updated;
199 int entries;
200 int referenced;
201 };
202
203 struct _FcBlanks {
204 int nblank;
205 int sblank;
206 FcChar32 *blanks;
207 };
208
209 struct _FcConfig {
210 /*
211 * File names loaded from the configuration -- saved here as the
212 * cache file must be consulted before the directories are scanned,
213 * and those directives may occur in any order
214 */
215 FcChar8 **dirs; /* directories containing fonts */
216 FcChar8 *cache; /* name of per-user cache file */
217 /*
218 * Set of allowed blank chars -- used to
219 * trim fonts of bogus glyphs
220 */
221 FcBlanks *blanks;
222 /*
223 * Names of all of the configuration files used
224 * to create this configuration
225 */
226 FcChar8 **configFiles; /* config files loaded */
227 /*
228 * Substitution instructions for patterns and fonts;
229 * maxObjects is used to allocate appropriate intermediate storage
230 * while performing a whole set of substitutions
231 */
232 FcSubst *substPattern; /* substitutions for patterns */
233 FcSubst *substFont; /* substitutions for fonts */
234 int maxObjects; /* maximum number of tests in all substs */
235 /*
236 * The set of fonts loaded from the listed directories; the
237 * order within the set does not determine the font selection,
238 * except in the case of identical matches in which case earlier fonts
239 * match preferrentially
240 */
241 FcFontSet *fonts[FcSetApplication + 1];
242 };
243
244 /* fcblanks.c */
245
246 /* fccache.c */
247
248 FcFileCache *
249 FcFileCacheCreate (void);
250
251 FcChar8 *
252 FcFileCacheFind (FcFileCache *cache,
253 const FcChar8 *file,
254 int id,
255 int *count);
256
257 void
258 FcFileCacheDestroy (FcFileCache *cache);
259
260 void
261 FcFileCacheLoad (FcFileCache *cache,
262 const FcChar8 *cache_file);
263
264 FcBool
265 FcFileCacheUpdate (FcFileCache *cache,
266 const FcChar8 *file,
267 int id,
268 const FcChar8 *name);
269
270 FcBool
271 FcFileCacheSave (FcFileCache *cache,
272 const FcChar8 *cache_file);
273
274 FcBool
275 FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file);
276
277 FcBool
278 FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file);
279
280 /* fccfg.c */
281
282 FcBool
283 FcConfigAddDir (FcConfig *config,
284 const FcChar8 *d);
285
286 FcBool
287 FcConfigAddConfigFile (FcConfig *config,
288 const FcChar8 *f);
289
290 FcBool
291 FcConfigSetCache (FcConfig *config,
292 const FcChar8 *c);
293
294 FcBool
295 FcConfigAddBlank (FcConfig *config,
296 FcChar32 blank);
297
298 FcBool
299 FcConfigAddEdit (FcConfig *config,
300 FcTest *test,
301 FcEdit *edit,
302 FcMatchKind kind);
303
304 void
305 FcConfigSetFonts (FcConfig *config,
306 FcFontSet *fonts,
307 FcSetName set);
308
309 FcBool
310 FcConfigCompareValue (const FcValue m,
311 FcOp op,
312 const FcValue v);
313
314 /* fccharset.c */
315 FcBool
316 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
317
318 FcCharSet *
319 FcNameParseCharSet (FcChar8 *string);
320
321 /* fcdbg.c */
322 void
323 FcValuePrint (FcValue v);
324
325 void
326 FcValueListPrint (FcValueList *l);
327
328 void
329 FcPatternPrint (FcPattern *p);
330
331 void
332 FcOpPrint (FcOp op);
333
334 void
335 FcTestPrint (FcTest *test);
336
337 void
338 FcExprPrint (FcExpr *expr);
339
340 void
341 FcEditPrint (FcEdit *edit);
342
343 void
344 FcSubstPrint (FcSubst *subst);
345
346 void
347 FcFontSetPrint (FcFontSet *s);
348
349 int
350 FcDebug (void);
351
352 /* fcdir.c */
353
354 /* fcfont.c */
355 int
356 FcFontDebug (void);
357
358 /* fcfs.c */
359 /* fcgram.y */
360 int
361 FcConfigparse (void);
362
363 int
364 FcConfigwrap (void);
365
366 void
367 FcConfigerror (char *fmt, ...);
368
369 char *
370 FcConfigSaveField (const char *field);
371
372 FcTest *
373 FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
374
375 void
376 FcTestDestroy (FcTest *test);
377
378 FcExpr *
379 FcExprCreateInteger (int i);
380
381 FcExpr *
382 FcExprCreateDouble (double d);
383
384 FcExpr *
385 FcExprCreateString (const FcChar8 *s);
386
387 FcExpr *
388 FcExprCreateMatrix (const FcMatrix *m);
389
390 FcExpr *
391 FcExprCreateBool (FcBool b);
392
393 FcExpr *
394 FcExprCreateNil (void);
395
396 FcExpr *
397 FcExprCreateField (const char *field);
398
399 FcExpr *
400 FcExprCreateConst (const FcChar8 *constant);
401
402 FcExpr *
403 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
404
405 void
406 FcExprDestroy (FcExpr *e);
407
408 FcEdit *
409 FcEditCreate (const char *field, FcOp op, FcExpr *expr);
410
411 void
412 FcEditDestroy (FcEdit *e);
413
414 /* fcinit.c */
415
416 void
417 FcMemReport (void);
418
419 void
420 FcMemAlloc (int kind, int size);
421
422 void
423 FcMemFree (int kind, int size);
424
425 /* fclist.c */
426
427 /* fcmatch.c */
428
429 /* fcname.c */
430
431 FcBool
432 FcNameBool (FcChar8 *v, FcBool *result);
433
434 FcBool
435 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
436
437 FcBool
438 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
439
440 /* fcpat.c */
441 void
442 FcValueListDestroy (FcValueList *l);
443
444 FcPatternElt *
445 FcPatternFind (FcPattern *p, const char *object, FcBool insert);
446
447 /* fcrender.c */
448
449 /* fcmatrix.c */
450 void
451 FcMatrixFree (FcMatrix *mat);
452
453 /* fcstr.c */
454 FcChar8 *
455 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
456
457 void
458 FcStrFree (FcChar8 *s);
459
460 void
461 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
462
463 void
464 FcStrBufDestroy (FcStrBuf *buf);
465
466 FcChar8 *
467 FcStrBufDone (FcStrBuf *buf);
468
469 FcBool
470 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
471
472 FcBool
473 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
474
475 FcBool
476 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
477
478 #endif /* _FC_INT_H_ */