]> git.wh0rd.org - fontconfig.git/blob - src/fcint.h
Add binding property to edit element
[fontconfig.git] / src / fcint.h
1 /*
2 * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.16 2002/07/06 23:47:44 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 FcValue value;
92 FcValueBinding binding;
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 int ref;
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 FcValueBinding binding;
155 } FcEdit;
156
157 typedef struct _FcSubst {
158 struct _FcSubst *next;
159 FcTest *test;
160 FcEdit *edit;
161 } FcSubst;
162
163 typedef struct _FcCharLeaf {
164 FcChar32 map[256/32];
165 } FcCharLeaf;
166
167 typedef enum _FcLangResult {
168 FcLangEqual, FcLangDifferentCountry, FcLangDifferentLang
169 } FcLangResult;
170
171 struct _FcCharSet {
172 int ref; /* reference count */
173 FcBool constant; /* in hash table constant */
174 int num; /* size of leaves and numbers arrays */
175 FcCharLeaf **leaves;
176 FcChar16 *numbers;
177 };
178
179 struct _FcStrSet {
180 int ref; /* reference count */
181 int num;
182 int size;
183 FcChar8 **strs;
184 };
185
186 struct _FcStrList {
187 FcStrSet *set;
188 int n;
189 };
190
191 typedef struct _FcStrBuf {
192 FcChar8 *buf;
193 FcBool allocated;
194 FcBool failed;
195 int len;
196 int size;
197 } FcStrBuf;
198
199 /*
200 * The per-user ~/.fonts.cache file is loaded into
201 * this data structure. Each directory gets a substructure
202 * which is validated by comparing the directory timestamp with
203 * that saved in the cache. When valid, the entire directory cache
204 * can be immediately loaded without reading the directory. Otherwise,
205 * the files are checked individually; updated files are loaded into the
206 * cache which is then rewritten to the users home directory
207 */
208
209 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
210 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
211
212 typedef struct _FcGlobalCacheInfo {
213 unsigned int hash;
214 FcChar8 *file;
215 time_t time;
216 FcBool referenced;
217 } FcGlobalCacheInfo;
218
219 typedef struct _FcGlobalCacheFile {
220 struct _FcGlobalCacheFile *next;
221 FcGlobalCacheInfo info;
222 int id;
223 FcChar8 *name;
224 } FcGlobalCacheFile;
225
226 typedef struct _FcGlobalCacheSubdir {
227 struct _FcGlobalCacheSubdir *next;
228 FcChar8 *file;
229 } FcGlobalCacheSubdir;
230
231 typedef struct _FcGlobalCacheDir {
232 struct _FcGlobalCacheDir *next;
233 FcGlobalCacheInfo info;
234 int len;
235 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
236 FcGlobalCacheSubdir *subdirs;
237 } FcGlobalCacheDir;
238
239 typedef struct _FcGlobalCache {
240 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
241 FcBool updated;
242 FcBool broken;
243 int entries;
244 int referenced;
245 } FcGlobalCache;
246
247 struct _FcAtomic {
248 FcChar8 *file; /* original file name */
249 FcChar8 *new; /* temp file name -- write data here */
250 FcChar8 *lck; /* lockfile name (used for locking) */
251 FcChar8 *tmp; /* tmpfile name (used for locking) */
252 };
253
254 struct _FcBlanks {
255 int nblank;
256 int sblank;
257 FcChar32 *blanks;
258 };
259
260 struct _FcConfig {
261 /*
262 * File names loaded from the configuration -- saved here as the
263 * cache file must be consulted before the directories are scanned,
264 * and those directives may occur in any order
265 */
266 FcStrSet *configDirs; /* directories to scan for fonts */
267 FcChar8 *cache; /* name of per-user cache file */
268 /*
269 * Set of allowed blank chars -- used to
270 * trim fonts of bogus glyphs
271 */
272 FcBlanks *blanks;
273 /*
274 * List of directories containing fonts,
275 * built by recursively scanning the set
276 * of configured directories
277 */
278 FcStrSet *fontDirs;
279 /*
280 * Names of all of the configuration files used
281 * to create this configuration
282 */
283 FcStrSet *configFiles; /* config files loaded */
284 /*
285 * Substitution instructions for patterns and fonts;
286 * maxObjects is used to allocate appropriate intermediate storage
287 * while performing a whole set of substitutions
288 */
289 FcSubst *substPattern; /* substitutions for patterns */
290 FcSubst *substFont; /* substitutions for fonts */
291 int maxObjects; /* maximum number of tests in all substs */
292 /*
293 * The set of fonts loaded from the listed directories; the
294 * order within the set does not determine the font selection,
295 * except in the case of identical matches in which case earlier fonts
296 * match preferrentially
297 */
298 FcFontSet *fonts[FcSetApplication + 1];
299 /*
300 * Fontconfig can periodically rescan the system configuration
301 * and font directories. This rescanning occurs when font
302 * listing requests are made, but no more often than rescanInterval
303 * seconds apart.
304 */
305 time_t rescanTime; /* last time information was scanned */
306 int rescanInterval; /* interval between scans */
307 };
308
309 extern FcConfig *_fcConfig;
310
311 typedef struct _FcCharMap FcCharMap;
312
313 /* fcblanks.c */
314
315 /* fccache.c */
316
317 FcGlobalCache *
318 FcGlobalCacheCreate (void);
319
320 void
321 FcGlobalCacheDestroy (FcGlobalCache *cache);
322
323 FcBool
324 FcGlobalCacheCheckTime (FcGlobalCacheInfo *info);
325
326 void
327 FcGlobalCacheReferenced (FcGlobalCache *cache,
328 FcGlobalCacheInfo *info);
329
330 FcGlobalCacheDir *
331 FcGlobalCacheDirGet (FcGlobalCache *cache,
332 const FcChar8 *dir,
333 int len,
334 FcBool create_missing);
335
336 FcBool
337 FcGlobalCacheScanDir (FcFontSet *set,
338 FcStrSet *dirs,
339 FcGlobalCache *cache,
340 const FcChar8 *dir);
341
342 FcGlobalCacheFile *
343 FcGlobalCacheFileGet (FcGlobalCache *cache,
344 const FcChar8 *file,
345 int id,
346 int *count);
347
348
349 void
350 FcGlobalCacheLoad (FcGlobalCache *cache,
351 const FcChar8 *cache_file);
352
353 FcBool
354 FcGlobalCacheUpdate (FcGlobalCache *cache,
355 const FcChar8 *file,
356 int id,
357 const FcChar8 *name);
358
359 FcBool
360 FcGlobalCacheSave (FcGlobalCache *cache,
361 const FcChar8 *cache_file);
362
363 FcBool
364 FcDirCacheValid (const FcChar8 *cache_file);
365
366 FcBool
367 FcDirCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
368
369 FcBool
370 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
371
372 /* fccfg.c */
373
374 FcBool
375 FcConfigAddConfigDir (FcConfig *config,
376 const FcChar8 *d);
377
378 FcBool
379 FcConfigAddFontDir (FcConfig *config,
380 const FcChar8 *d);
381
382 FcBool
383 FcConfigAddDir (FcConfig *config,
384 const FcChar8 *d);
385
386 FcBool
387 FcConfigAddConfigFile (FcConfig *config,
388 const FcChar8 *f);
389
390 FcBool
391 FcConfigSetCache (FcConfig *config,
392 const FcChar8 *c);
393
394 FcBool
395 FcConfigAddBlank (FcConfig *config,
396 FcChar32 blank);
397
398 FcBool
399 FcConfigAddEdit (FcConfig *config,
400 FcTest *test,
401 FcEdit *edit,
402 FcMatchKind kind);
403
404 void
405 FcConfigSetFonts (FcConfig *config,
406 FcFontSet *fonts,
407 FcSetName set);
408
409 FcBool
410 FcConfigCompareValue (const FcValue m,
411 FcOp op,
412 const FcValue v);
413
414 /* fccharset.c */
415 FcCharSet *
416 FcCharSetFreeze (FcCharSet *cs);
417
418 FcBool
419 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
420
421 FcCharSet *
422 FcNameParseCharSet (FcChar8 *string);
423
424 FcChar32
425 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
426
427 FcChar32
428 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
429
430 const FcCharMap *
431 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
432
433 /* fcdbg.c */
434 void
435 FcValueListPrint (FcValueList *l);
436
437 void
438 FcOpPrint (FcOp op);
439
440 void
441 FcTestPrint (FcTest *test);
442
443 void
444 FcExprPrint (FcExpr *expr);
445
446 void
447 FcEditPrint (FcEdit *edit);
448
449 void
450 FcSubstPrint (FcSubst *subst);
451
452 int
453 FcDebug (void);
454
455 /* fcdir.c */
456
457 /* fcfont.c */
458 int
459 FcFontDebug (void);
460
461 /* fcfreetype.c */
462 FcBool
463 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
464
465 FcBool
466 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
467
468 /* fcfs.c */
469 /* fcgram.y */
470 int
471 FcConfigparse (void);
472
473 int
474 FcConfigwrap (void);
475
476 void
477 FcConfigerror (char *fmt, ...);
478
479 char *
480 FcConfigSaveField (const char *field);
481
482 FcTest *
483 FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
484
485 void
486 FcTestDestroy (FcTest *test);
487
488 FcExpr *
489 FcExprCreateInteger (int i);
490
491 FcExpr *
492 FcExprCreateDouble (double d);
493
494 FcExpr *
495 FcExprCreateString (const FcChar8 *s);
496
497 FcExpr *
498 FcExprCreateMatrix (const FcMatrix *m);
499
500 FcExpr *
501 FcExprCreateBool (FcBool b);
502
503 FcExpr *
504 FcExprCreateNil (void);
505
506 FcExpr *
507 FcExprCreateField (const char *field);
508
509 FcExpr *
510 FcExprCreateConst (const FcChar8 *constant);
511
512 FcExpr *
513 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
514
515 void
516 FcExprDestroy (FcExpr *e);
517
518 FcEdit *
519 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
520
521 void
522 FcEditDestroy (FcEdit *e);
523
524 /* fcinit.c */
525
526 void
527 FcMemReport (void);
528
529 void
530 FcMemAlloc (int kind, int size);
531
532 void
533 FcMemFree (int kind, int size);
534
535 /* fclang.c */
536 FcBool
537 FcFreeTypeSetLang (FcPattern *pattern,
538 FcCharSet *charset,
539 const FcChar8 *exclusiveLang);
540
541 FcLangResult
542 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
543
544 const FcCharSet *
545 FcCharSetForLang (const FcChar8 *lang);
546
547 /* fclist.c */
548
549 /* fcmatch.c */
550
551 /* fcname.c */
552
553 FcBool
554 FcNameBool (FcChar8 *v, FcBool *result);
555
556 /* fcpat.c */
557 void
558 FcValueListDestroy (FcValueList *l);
559
560 FcPatternElt *
561 FcPatternFindElt (const FcPattern *p, const char *object);
562
563 FcPatternElt *
564 FcPatternInsertElt (FcPattern *p, const char *object);
565
566 FcBool
567 FcPatternAddWithBinding (FcPattern *p,
568 const char *object,
569 FcValue value,
570 FcValueBinding binding,
571 FcBool append);
572
573 /* fcrender.c */
574
575 /* fcmatrix.c */
576
577 extern const FcMatrix FcIdentityMatrix;
578
579 void
580 FcMatrixFree (FcMatrix *mat);
581
582 /* fcstr.c */
583 FcChar8 *
584 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
585
586 void
587 FcStrFree (FcChar8 *s);
588
589 void
590 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
591
592 void
593 FcStrBufDestroy (FcStrBuf *buf);
594
595 FcChar8 *
596 FcStrBufDone (FcStrBuf *buf);
597
598 FcBool
599 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
600
601 FcBool
602 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
603
604 FcBool
605 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
606
607 int
608 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
609
610 #endif /* _FC_INT_H_ */