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