]> git.wh0rd.org Git - fontconfig.git/blob - src/fcint.h
Update fontconfig and libxml2 to get them working with in-tree build
[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         char        *sval;
118         FcMatrix    *mval;
119         FcBool      bval;
120         FcCharSet   *cval;
121         char        *field;
122         char        *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     char                    *file;
190     int                     id;
191     time_t                  time;
192     char                    *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     char        **dirs;             /* directories containing fonts */
218     char        *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     char        **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 char *
254 FcFileCacheFind (FcFileCache    *cache,
255                  const char     *file,
256                  int            id,
257                  int            *count);
258
259 void
260 FcFileCacheDestroy (FcFileCache *cache);
261
262 void
263 FcFileCacheLoad (FcFileCache    *cache,
264                  const char     *cache_file);
265
266 FcBool
267 FcFileCacheUpdate (FcFileCache  *cache,
268                    const char   *file,
269                    int          id,
270                    const char   *name);
271
272 FcBool
273 FcFileCacheSave (FcFileCache    *cache,
274                  const char     *cache_file);
275
276 FcBool
277 FcFileCacheReadDir (FcFontSet *set, const char *cache_file);
278
279 FcBool
280 FcFileCacheWriteDir (FcFontSet *set, const char *cache_file);
281     
282 /* fccfg.c */
283
284 FcBool
285 FcConfigAddDir (FcConfig    *config,
286                 const char  *d);
287
288 FcBool
289 FcConfigAddConfigFile (FcConfig     *config,
290                        const char   *f);
291
292 FcBool
293 FcConfigSetCache (FcConfig      *config,
294                   const char    *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 FcBool
356 FcFileScan (FcFontSet   *set,
357             FcFileCache *cache,
358             FcBlanks    *blanks,
359             const char  *file,
360             FcBool      force);
361
362 FcBool
363 FcDirScan (FcFontSet    *set,
364            FcFileCache  *cache,
365            FcBlanks     *blanks,
366            const char   *dir,
367            FcBool       force);
368
369 FcBool
370 FcDirSave (FcFontSet *set, const char *dir);
371
372 /* fcfont.c */
373 int
374 FcFontDebug (void);
375     
376 /* fcfs.c */
377 /* fcgram.y */
378 int
379 FcConfigparse (void);
380
381 int
382 FcConfigwrap (void);
383     
384 void
385 FcConfigerror (char *fmt, ...);
386     
387 char *
388 FcConfigSaveField (const char *field);
389
390 FcTest *
391 FcTestCreate (FcQual qual, const char *field, FcOp compare, FcExpr *expr);
392
393 void
394 FcTestDestroy (FcTest *test);
395
396 FcExpr *
397 FcExprCreateInteger (int i);
398
399 FcExpr *
400 FcExprCreateDouble (double d);
401
402 FcExpr *
403 FcExprCreateString (const char *s);
404
405 FcExpr *
406 FcExprCreateMatrix (const FcMatrix *m);
407
408 FcExpr *
409 FcExprCreateBool (FcBool b);
410
411 FcExpr *
412 FcExprCreateNil (void);
413
414 FcExpr *
415 FcExprCreateField (const char *field);
416
417 FcExpr *
418 FcExprCreateConst (const char *constant);
419
420 FcExpr *
421 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
422
423 void
424 FcExprDestroy (FcExpr *e);
425
426 FcEdit *
427 FcEditCreate (const char *field, FcOp op, FcExpr *expr);
428
429 void
430 FcEditDestroy (FcEdit *e);
431
432 /* fcinit.c */
433
434 void
435 FcMemReport (void);
436
437 void
438 FcMemAlloc (int kind, int size);
439
440 void
441 FcMemFree (int kind, int size);
442
443 /* fclist.c */
444
445 /* fcmatch.c */
446
447 /* fcname.c */
448 FcBool
449 FcNameConstant (char *string, int *result);
450
451 FcBool
452 FcNameBool (char *v, FcBool *result);
453
454 FcBool
455 FcNameBufChar (FcNameBuf *buf, FcChar8 c);
456
457 FcBool
458 FcNameBufString (FcNameBuf *buf, const FcChar8 *s);
459
460 /* fcpat.c */
461 void
462 FcValueListDestroy (FcValueList *l);
463     
464 FcPatternElt *
465 FcPatternFind (FcPattern *p, const char *object, FcBool insert);
466
467 /* fcrender.c */
468
469 /* fcmatrix.c */
470 void
471 FcMatrixFree (FcMatrix *mat);
472
473 /* fcstr.c */
474 char *
475 FcStrPlus (const char *s1, const char *s2);
476     
477 void
478 FcStrFree (char *s);
479
480 #endif /* _FC_INT_H_ */