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