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