]> git.wh0rd.org - fontconfig.git/blob - src/fcint.h
Change files from ISO-Latin-1 to UTF-8
[fontconfig.git] / src / fcint.h
1 /*
2 * $RCSId: xc/lib/fontconfig/src/fcint.h,v 1.27 2002/08/31 22:17:32 keithp Exp $
3 *
4 * Copyright © 2000 Keith Packard
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 #ifdef _WIN32
57 #define FC_SEARCH_PATH_SEPARATOR ';'
58 #else
59 #define FC_SEARCH_PATH_SEPARATOR ':'
60 #endif
61
62 #define FC_DBG_MATCH 1
63 #define FC_DBG_MATCHV 2
64 #define FC_DBG_EDIT 4
65 #define FC_DBG_FONTSET 8
66 #define FC_DBG_CACHE 16
67 #define FC_DBG_CACHEV 32
68 #define FC_DBG_PARSE 64
69 #define FC_DBG_SCAN 128
70 #define FC_DBG_SCANV 256
71 #define FC_DBG_MEMORY 512
72 #define FC_DBG_CONFIG 1024
73
74 #define FC_MEM_CHARSET 0
75 #define FC_MEM_CHARLEAF 1
76 #define FC_MEM_FONTSET 2
77 #define FC_MEM_FONTPTR 3
78 #define FC_MEM_OBJECTSET 4
79 #define FC_MEM_OBJECTPTR 5
80 #define FC_MEM_MATRIX 6
81 #define FC_MEM_PATTERN 7
82 #define FC_MEM_PATELT 8
83 #define FC_MEM_VALLIST 9
84 #define FC_MEM_SUBSTATE 10
85 #define FC_MEM_STRING 11
86 #define FC_MEM_LISTBUCK 12
87 #define FC_MEM_STRSET 13
88 #define FC_MEM_STRLIST 14
89 #define FC_MEM_CONFIG 15
90 #define FC_MEM_LANGSET 16
91 #define FC_MEM_ATOMIC 17
92 #define FC_MEM_BLANKS 18
93 #define FC_MEM_CACHE 19
94 #define FC_MEM_STRBUF 20
95 #define FC_MEM_SUBST 21
96 #define FC_MEM_OBJECTTYPE 22
97 #define FC_MEM_CONSTANT 23
98 #define FC_MEM_TEST 24
99 #define FC_MEM_EXPR 25
100 #define FC_MEM_VSTACK 26
101 #define FC_MEM_ATTR 27
102 #define FC_MEM_PSTACK 28
103
104 #define FC_MEM_NUM 29
105
106 typedef enum _FcValueBinding {
107 FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
108 } FcValueBinding;
109
110 typedef struct _FcValueList {
111 struct _FcValueList *next;
112 FcValue value;
113 FcValueBinding binding;
114 } FcValueList;
115
116 typedef struct _FcPatternElt {
117 const char *object;
118 FcValueList *values;
119 } FcPatternElt;
120
121
122 struct _FcPattern {
123 int num;
124 int size;
125 FcPatternElt *elts;
126 int ref;
127 };
128
129 typedef enum _FcOp {
130 FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet,
131 FcOpNil,
132 FcOpField, FcOpConst,
133 FcOpAssign, FcOpAssignReplace,
134 FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
135 FcOpQuest,
136 FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
137 FcOpContains, FcOpListing, FcOpNotContains,
138 FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
139 FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
140 FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc,
141 FcOpInvalid
142 } FcOp;
143
144 typedef struct _FcExpr {
145 FcOp op;
146 union {
147 int ival;
148 double dval;
149 FcChar8 *sval;
150 FcMatrix *mval;
151 FcBool bval;
152 FcCharSet *cval;
153 char *field;
154 FcChar8 *constant;
155 struct {
156 struct _FcExpr *left, *right;
157 } tree;
158 } u;
159 } FcExpr;
160
161 typedef enum _FcQual {
162 FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
163 } FcQual;
164
165 #define FcMatchDefault ((FcMatchKind) -1)
166
167 typedef struct _FcTest {
168 struct _FcTest *next;
169 FcMatchKind kind;
170 FcQual qual;
171 const char *field;
172 FcOp op;
173 FcExpr *expr;
174 } FcTest;
175
176 typedef struct _FcEdit {
177 struct _FcEdit *next;
178 const char *field;
179 FcOp op;
180 FcExpr *expr;
181 FcValueBinding binding;
182 } FcEdit;
183
184 typedef struct _FcSubst {
185 struct _FcSubst *next;
186 FcTest *test;
187 FcEdit *edit;
188 } FcSubst;
189
190 typedef struct _FcCharLeaf {
191 FcChar32 map[256/32];
192 } FcCharLeaf;
193
194 #define FC_REF_CONSTANT -1
195
196 struct _FcCharSet {
197 int ref; /* reference count */
198 int num; /* size of leaves and numbers arrays */
199 FcCharLeaf **leaves;
200 FcChar16 *numbers;
201 };
202
203 struct _FcStrSet {
204 int ref; /* reference count */
205 int num;
206 int size;
207 FcChar8 **strs;
208 };
209
210 struct _FcStrList {
211 FcStrSet *set;
212 int n;
213 };
214
215 typedef struct _FcStrBuf {
216 FcChar8 *buf;
217 FcBool allocated;
218 FcBool failed;
219 int len;
220 int size;
221 } FcStrBuf;
222
223 /*
224 * To map adobe glyph names to unicode values, a precomputed hash
225 * table is used
226 */
227
228 typedef struct _FcGlyphName {
229 FcChar32 ucs; /* unicode value */
230 FcChar8 name[1]; /* name extends beyond struct */
231 } FcGlyphName;
232
233 #define FC_MAX_FILE_LEN 4096
234
235 /*
236 * The per-user ~/.fonts.cache-<version> file is loaded into
237 * this data structure. Each directory gets a substructure
238 * which is validated by comparing the directory timestamp with
239 * that saved in the cache. When valid, the entire directory cache
240 * can be immediately loaded without reading the directory. Otherwise,
241 * the files are checked individually; updated files are loaded into the
242 * cache which is then rewritten to the users home directory
243 */
244
245 #define FC_GLOBAL_CACHE_DIR_HASH_SIZE 37
246 #define FC_GLOBAL_CACHE_FILE_HASH_SIZE 67
247
248 typedef struct _FcGlobalCacheInfo {
249 unsigned int hash;
250 FcChar8 *file;
251 time_t time;
252 FcBool referenced;
253 } FcGlobalCacheInfo;
254
255 typedef struct _FcGlobalCacheFile {
256 struct _FcGlobalCacheFile *next;
257 FcGlobalCacheInfo info;
258 int id;
259 FcChar8 *name;
260 } FcGlobalCacheFile;
261
262 typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
263
264 typedef struct _FcGlobalCacheSubdir {
265 struct _FcGlobalCacheSubdir *next;
266 FcGlobalCacheDir *ent;
267 } FcGlobalCacheSubdir;
268
269 struct _FcGlobalCacheDir {
270 struct _FcGlobalCacheDir *next;
271 FcGlobalCacheInfo info;
272 int len;
273 FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
274 FcGlobalCacheSubdir *subdirs;
275 };
276
277 typedef struct _FcGlobalCache {
278 FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];
279 FcBool updated;
280 FcBool broken;
281 int entries;
282 int referenced;
283 } FcGlobalCache;
284
285 struct _FcAtomic {
286 FcChar8 *file; /* original file name */
287 FcChar8 *new; /* temp file name -- write data here */
288 FcChar8 *lck; /* lockfile name (used for locking) */
289 FcChar8 *tmp; /* tmpfile name (used for locking) */
290 };
291
292 struct _FcBlanks {
293 int nblank;
294 int sblank;
295 FcChar32 *blanks;
296 };
297
298 struct _FcConfig {
299 /*
300 * File names loaded from the configuration -- saved here as the
301 * cache file must be consulted before the directories are scanned,
302 * and those directives may occur in any order
303 */
304 FcStrSet *configDirs; /* directories to scan for fonts */
305 FcChar8 *cache; /* name of per-user cache file */
306 /*
307 * Set of allowed blank chars -- used to
308 * trim fonts of bogus glyphs
309 */
310 FcBlanks *blanks;
311 /*
312 * List of directories containing fonts,
313 * built by recursively scanning the set
314 * of configured directories
315 */
316 FcStrSet *fontDirs;
317 /*
318 * Names of all of the configuration files used
319 * to create this configuration
320 */
321 FcStrSet *configFiles; /* config files loaded */
322 /*
323 * Substitution instructions for patterns and fonts;
324 * maxObjects is used to allocate appropriate intermediate storage
325 * while performing a whole set of substitutions
326 */
327 FcSubst *substPattern; /* substitutions for patterns */
328 FcSubst *substFont; /* substitutions for fonts */
329 int maxObjects; /* maximum number of tests in all substs */
330 /*
331 * List of patterns used to control font file selection
332 */
333 FcStrSet *acceptGlobs;
334 FcStrSet *rejectGlobs;
335 FcFontSet *acceptPatterns;
336 FcFontSet *rejectPatterns;
337 /*
338 * The set of fonts loaded from the listed directories; the
339 * order within the set does not determine the font selection,
340 * except in the case of identical matches in which case earlier fonts
341 * match preferrentially
342 */
343 FcFontSet *fonts[FcSetApplication + 1];
344 /*
345 * Fontconfig can periodically rescan the system configuration
346 * and font directories. This rescanning occurs when font
347 * listing requests are made, but no more often than rescanInterval
348 * seconds apart.
349 */
350 time_t rescanTime; /* last time information was scanned */
351 int rescanInterval; /* interval between scans */
352 };
353
354 extern FcConfig *_fcConfig;
355
356 typedef struct _FcCharMap FcCharMap;
357
358 /* fcblanks.c */
359
360 /* fccache.c */
361
362 FcGlobalCache *
363 FcGlobalCacheCreate (void);
364
365 void
366 FcGlobalCacheDestroy (FcGlobalCache *cache);
367
368 FcBool
369 FcGlobalCacheCheckTime (const FcChar8*file, FcGlobalCacheInfo *info);
370
371 void
372 FcGlobalCacheReferenced (FcGlobalCache *cache,
373 FcGlobalCacheInfo *info);
374
375 void
376 FcGlobalCacheReferenceSubdir (FcGlobalCache *cache,
377 const FcChar8 *dir);
378
379 FcGlobalCacheDir *
380 FcGlobalCacheDirGet (FcGlobalCache *cache,
381 const FcChar8 *dir,
382 int len,
383 FcBool create_missing);
384
385 FcBool
386 FcGlobalCacheScanDir (FcFontSet *set,
387 FcStrSet *dirs,
388 FcGlobalCache *cache,
389 const FcChar8 *dir,
390 FcConfig *config);
391
392 FcGlobalCacheFile *
393 FcGlobalCacheFileGet (FcGlobalCache *cache,
394 const FcChar8 *file,
395 int id,
396 int *count);
397
398
399 void
400 FcGlobalCacheLoad (FcGlobalCache *cache,
401 const FcChar8 *cache_file);
402
403 FcBool
404 FcGlobalCacheUpdate (FcGlobalCache *cache,
405 const FcChar8 *file,
406 int id,
407 const FcChar8 *name);
408
409 FcBool
410 FcGlobalCacheSave (FcGlobalCache *cache,
411 const FcChar8 *cache_file);
412
413 FcBool
414 FcDirCacheReadDir (FcFontSet *set,
415 FcStrSet *dirs,
416 const FcChar8 *dir,
417 FcConfig *config);
418
419 FcBool
420 FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
421
422 /* fccfg.c */
423
424 FcBool
425 FcConfigAddConfigDir (FcConfig *config,
426 const FcChar8 *d);
427
428 FcBool
429 FcConfigAddFontDir (FcConfig *config,
430 const FcChar8 *d);
431
432 FcBool
433 FcConfigAddDir (FcConfig *config,
434 const FcChar8 *d);
435
436 FcBool
437 FcConfigAddConfigFile (FcConfig *config,
438 const FcChar8 *f);
439
440 FcBool
441 FcConfigSetCache (FcConfig *config,
442 const FcChar8 *c);
443
444 FcBool
445 FcConfigAddBlank (FcConfig *config,
446 FcChar32 blank);
447
448 FcBool
449 FcConfigAddEdit (FcConfig *config,
450 FcTest *test,
451 FcEdit *edit,
452 FcMatchKind kind);
453
454 void
455 FcConfigSetFonts (FcConfig *config,
456 FcFontSet *fonts,
457 FcSetName set);
458
459 FcBool
460 FcConfigCompareValue (const FcValue m,
461 FcOp op,
462 const FcValue v);
463
464 FcBool
465 FcConfigGlobAdd (FcConfig *config,
466 const FcChar8 *glob,
467 FcBool accept);
468
469 FcBool
470 FcConfigAcceptFilename (FcConfig *config,
471 const FcChar8 *filename);
472
473 FcBool
474 FcConfigPatternsAdd (FcConfig *config,
475 FcPattern *pattern,
476 FcBool accept);
477
478 FcBool
479 FcConfigAcceptFont (FcConfig *config,
480 const FcPattern *font);
481
482 /* fccharset.c */
483 FcCharSet *
484 FcCharSetFreeze (FcCharSet *cs);
485
486 void
487 FcCharSetThawAll (void);
488
489 FcBool
490 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
491
492 FcCharSet *
493 FcNameParseCharSet (FcChar8 *string);
494
495 FcCharLeaf *
496 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
497
498 /* fcdbg.c */
499 void
500 FcValueListPrint (const FcValueList *l);
501
502 void
503 FcLangSetPrint (const FcLangSet *ls);
504
505 void
506 FcOpPrint (FcOp op);
507
508 void
509 FcTestPrint (const FcTest *test);
510
511 void
512 FcExprPrint (const FcExpr *expr);
513
514 void
515 FcEditPrint (const FcEdit *edit);
516
517 void
518 FcSubstPrint (const FcSubst *subst);
519
520 int
521 FcDebug (void);
522
523 /* fcdir.c */
524
525 FcBool
526 FcFileIsDir (const FcChar8 *file);
527
528 FcBool
529 FcFileScanConfig (FcFontSet *set,
530 FcStrSet *dirs,
531 FcFileCache *cache,
532 FcBlanks *blanks,
533 const FcChar8 *file,
534 FcBool force,
535 FcConfig *config);
536
537 FcBool
538 FcDirScanConfig (FcFontSet *set,
539 FcStrSet *dirs,
540 FcFileCache *cache,
541 FcBlanks *blanks,
542 const FcChar8 *dir,
543 FcBool force,
544 FcConfig *config);
545
546 /* fcfont.c */
547 int
548 FcFontDebug (void);
549
550 /* fcfreetype.c */
551 FcBool
552 FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
553
554 FcBool
555 FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
556
557 FcChar32
558 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
559
560 FcChar32
561 FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
562
563 const FcCharMap *
564 FcFreeTypeGetPrivateMap (FT_Encoding encoding);
565
566 /* fcfs.c */
567 /* fcgram.y */
568 int
569 FcConfigparse (void);
570
571 int
572 FcConfigwrap (void);
573
574 void
575 FcConfigerror (char *fmt, ...);
576
577 char *
578 FcConfigSaveField (const char *field);
579
580 FcTest *
581 FcTestCreate (FcMatchKind kind,
582 FcQual qual,
583 const FcChar8 *field,
584 FcOp compare,
585 FcExpr *expr);
586
587 void
588 FcTestDestroy (FcTest *test);
589
590 FcExpr *
591 FcExprCreateInteger (int i);
592
593 FcExpr *
594 FcExprCreateDouble (double d);
595
596 FcExpr *
597 FcExprCreateString (const FcChar8 *s);
598
599 FcExpr *
600 FcExprCreateMatrix (const FcMatrix *m);
601
602 FcExpr *
603 FcExprCreateBool (FcBool b);
604
605 FcExpr *
606 FcExprCreateNil (void);
607
608 FcExpr *
609 FcExprCreateField (const char *field);
610
611 FcExpr *
612 FcExprCreateConst (const FcChar8 *constant);
613
614 FcExpr *
615 FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
616
617 void
618 FcExprDestroy (FcExpr *e);
619
620 FcEdit *
621 FcEditCreate (const char *field, FcOp op, FcExpr *expr, FcValueBinding binding);
622
623 void
624 FcEditDestroy (FcEdit *e);
625
626 /* fcinit.c */
627
628 void
629 FcMemReport (void);
630
631 void
632 FcMemAlloc (int kind, int size);
633
634 void
635 FcMemFree (int kind, int size);
636
637 /* fclang.c */
638 FcLangSet *
639 FcFreeTypeLangSet (const FcCharSet *charset,
640 const FcChar8 *exclusiveLang);
641
642 FcLangResult
643 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
644
645 const FcCharSet *
646 FcCharSetForLang (const FcChar8 *lang);
647
648 FcLangSet *
649 FcLangSetPromote (const FcChar8 *lang);
650
651 FcLangSet *
652 FcNameParseLangSet (const FcChar8 *string);
653
654 FcBool
655 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
656
657 /* fclist.c */
658
659 FcBool
660 FcListPatternMatchAny (const FcPattern *p,
661 const FcPattern *font);
662
663 /* fcmatch.c */
664
665 /* fcname.c */
666
667 FcBool
668 FcNameBool (FcChar8 *v, FcBool *result);
669
670 /* fcpat.c */
671 void
672 FcValueListDestroy (FcValueList *l);
673
674 FcPatternElt *
675 FcPatternFindElt (const FcPattern *p, const char *object);
676
677 FcPatternElt *
678 FcPatternInsertElt (FcPattern *p, const char *object);
679
680 FcBool
681 FcPatternAddWithBinding (FcPattern *p,
682 const char *object,
683 FcValue value,
684 FcValueBinding binding,
685 FcBool append);
686
687 FcPattern *
688 FcPatternFreeze (FcPattern *p);
689
690 void
691 FcPatternThawAll (void);
692
693 FcBool
694 FcPatternAppend (FcPattern *p, FcPattern *s);
695
696 const char *
697 FcObjectStaticName (const char *name);
698
699 /* fcrender.c */
700
701 /* fcmatrix.c */
702
703 extern const FcMatrix FcIdentityMatrix;
704
705 void
706 FcMatrixFree (FcMatrix *mat);
707
708 /* fcstr.c */
709 FcChar8 *
710 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
711
712 void
713 FcStrFree (FcChar8 *s);
714
715 void
716 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
717
718 void
719 FcStrBufDestroy (FcStrBuf *buf);
720
721 FcChar8 *
722 FcStrBufDone (FcStrBuf *buf);
723
724 FcBool
725 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
726
727 FcBool
728 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
729
730 FcBool
731 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
732
733 int
734 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
735
736 const FcChar8 *
737 FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
738
739 const FcChar8 *
740 FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
741
742 FcBool
743 FcStrUsesHome (const FcChar8 *s);
744
745 FcChar8 *
746 FcStrLastSlash (const FcChar8 *path);
747
748 #endif /* _FC_INT_H_ */