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