]> git.wh0rd.org Git - fontconfig.git/blob - src/fcint.h
0bd06f559c54c4ac6d7d2d18bf804c1508d0715e
[fontconfig.git] / src / fcint.h
1 /*
2  * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.3 2002/02/18 22:29: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 extern FcConfig *_fcConfig;
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 (FcStrBuf *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 FcOpPrint (FcOp op);
332
333 void
334 FcTestPrint (FcTest *test);
335
336 void
337 FcExprPrint (FcExpr *expr);
338
339 void
340 FcEditPrint (FcEdit *edit);
341
342 void
343 FcSubstPrint (FcSubst *subst);
344
345 void
346 FcFontSetPrint (FcFontSet *s);
347
348 int
349 FcDebug (void);
350
351 /* fcdir.c */
352
353 /* fcfont.c */
354 int
355 FcFontDebug (void);
356     
357 /* fcfs.c */
358 /* fcgram.y */
359 int
360 FcConfigparse (void);
361
362 int
363 FcConfigwrap (void);
364     
365 void
366 FcConfigerror (char *fmt, ...);
367     
368 char *
369 FcConfigSaveField (const char *field);
370
371 FcTest *
372 FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
373
374 void
375 FcTestDestroy (FcTest *test);
376
377 FcExpr *
378 FcExprCreateInteger (int i);
379
380 FcExpr *
381 FcExprCreateDouble (double d);
382
383 FcExpr *
384 FcExprCreateString (const FcChar8 *s);
385
386 FcExpr *
387 FcExprCreateMatrix (const FcMatrix *m);
388
389 FcExpr *
390 FcExprCreateBool (FcBool b);
391
392 FcExpr *
393 FcExprCreateNil (void);
394
395 FcExpr *
396 FcExprCreateField (const char *field);
397
398 FcExpr *
399 FcExprCreateConst (const FcChar8 *constant);
400
401 FcExpr *
402 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
403
404 void
405 FcExprDestroy (FcExpr *e);
406
407 FcEdit *
408 FcEditCreate (const char *field, FcOp op, FcExpr *expr);
409
410 void
411 FcEditDestroy (FcEdit *e);
412
413 /* fcinit.c */
414
415 void
416 FcMemReport (void);
417
418 void
419 FcMemAlloc (int kind, int size);
420
421 void
422 FcMemFree (int kind, int size);
423
424 /* fclist.c */
425
426 /* fcmatch.c */
427
428 /* fcname.c */
429
430 FcBool
431 FcNameBool (FcChar8 *v, FcBool *result);
432
433 /* fcpat.c */
434 void
435 FcValueListDestroy (FcValueList *l);
436     
437 FcPatternElt *
438 FcPatternFind (FcPattern *p, const char *object, FcBool insert);
439
440 /* fcrender.c */
441
442 /* fcmatrix.c */
443 void
444 FcMatrixFree (FcMatrix *mat);
445
446 /* fcstr.c */
447 FcChar8 *
448 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
449     
450 void
451 FcStrFree (FcChar8 *s);
452
453 void
454 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
455
456 void
457 FcStrBufDestroy (FcStrBuf *buf);
458
459 FcChar8 *
460 FcStrBufDone (FcStrBuf *buf);
461
462 FcBool
463 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
464
465 FcBool
466 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
467
468 FcBool
469 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
470
471 #endif /* _FC_INT_H_ */