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