]> git.wh0rd.org - fontconfig.git/blob - fontconfig/fontconfig.h
Various config changes plus a couple of optimizations from Owen
[fontconfig.git] / fontconfig / fontconfig.h
1 /*
2 * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.25 2002/08/11 18:10:41 keithp Exp $
3 *
4 * Copyright © 2001 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 _FONTCONFIG_H_
26 #define _FONTCONFIG_H_
27
28 #include <stdarg.h>
29
30 typedef unsigned char FcChar8;
31 typedef unsigned short FcChar16;
32 typedef unsigned int FcChar32;
33 typedef int FcBool;
34
35 /*
36 * Current Fontconfig version number
37 */
38 #define FC_MAJOR 1
39 #define FC_MINOR 0
40 #define FC_REVISION 1
41
42 #define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
43
44 #define FcTrue 1
45 #define FcFalse 0
46
47 #define FC_FAMILY "family" /* String */
48 #define FC_STYLE "style" /* String */
49 #define FC_SLANT "slant" /* Int */
50 #define FC_WEIGHT "weight" /* Int */
51 #define FC_SIZE "size" /* Double */
52 #define FC_ASPECT "aspect" /* Double */
53 #define FC_PIXEL_SIZE "pixelsize" /* Double */
54 #define FC_SPACING "spacing" /* Int */
55 #define FC_FOUNDRY "foundry" /* String */
56 #define FC_ANTIALIAS "antialias" /* Bool (depends) */
57 #define FC_HINTING "hinting" /* Bool (true) */
58 #define FC_VERTICAL_LAYOUT "verticallayout" /* Bool (false) */
59 #define FC_AUTOHINT "autohint" /* Bool (false) */
60 #define FC_GLOBAL_ADVANCE "globaladvance" /* Bool (true) */
61 #define FC_FILE "file" /* String */
62 #define FC_INDEX "index" /* Int */
63 #define FC_FT_FACE "ftface" /* FT_Face */
64 #define FC_RASTERIZER "rasterizer" /* String */
65 #define FC_OUTLINE "outline" /* Bool */
66 #define FC_SCALABLE "scalable" /* Bool */
67 #define FC_SCALE "scale" /* double */
68 #define FC_DPI "dpi" /* double */
69 #define FC_RGBA "rgba" /* Int */
70 #define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
71 #define FC_SOURCE "source" /* String (X11, freetype) */
72 #define FC_CHARSET "charset" /* CharSet */
73 #define FC_LANG "lang" /* String OS/2 CodePageRange */
74
75 #define FC_DIR_CACHE_FILE "fonts.cache"
76 #define FC_USER_CACHE_FILE ".fonts.cache"
77
78 /* Adjust outline rasterizer */
79 #define FC_CHAR_WIDTH "charwidth" /* Int */
80 #define FC_CHAR_HEIGHT "charheight"/* Int */
81 #define FC_MATRIX "matrix" /* FcMatrix */
82
83 #define FC_WEIGHT_LIGHT 0
84 #define FC_WEIGHT_MEDIUM 100
85 #define FC_WEIGHT_DEMIBOLD 180
86 #define FC_WEIGHT_BOLD 200
87 #define FC_WEIGHT_BLACK 210
88
89 #define FC_SLANT_ROMAN 0
90 #define FC_SLANT_ITALIC 100
91 #define FC_SLANT_OBLIQUE 110
92
93 #define FC_PROPORTIONAL 0
94 #define FC_MONO 100
95 #define FC_CHARCELL 110
96
97 /* sub-pixel order */
98 #define FC_RGBA_NONE 0
99 #define FC_RGBA_RGB 1
100 #define FC_RGBA_BGR 2
101 #define FC_RGBA_VRGB 3
102 #define FC_RGBA_VBGR 4
103
104 typedef enum _FcType {
105 FcTypeVoid,
106 FcTypeInteger,
107 FcTypeDouble,
108 FcTypeString,
109 FcTypeBool,
110 FcTypeMatrix,
111 FcTypeCharSet,
112 FcTypeFTFace
113 } FcType;
114
115 typedef struct _FcMatrix {
116 double xx, xy, yx, yy;
117 } FcMatrix;
118
119 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \
120 (m)->xy = (m)->yx = 0)
121
122 /*
123 * A data structure to represent the available glyphs in a font.
124 * This is represented as a sparse boolean btree.
125 */
126
127 typedef struct _FcCharSet FcCharSet;
128
129 typedef struct _FcObjectType {
130 const char *object;
131 FcType type;
132 } FcObjectType;
133
134 typedef struct _FcConstant {
135 const FcChar8 *name;
136 const char *object;
137 int value;
138 } FcConstant;
139
140 typedef enum _FcResult {
141 FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId
142 } FcResult;
143
144 typedef struct _FcPattern FcPattern;
145
146 typedef struct _FcValue {
147 FcType type;
148 union {
149 const FcChar8 *s;
150 int i;
151 FcBool b;
152 double d;
153 const FcMatrix *m;
154 const FcCharSet *c;
155 void *f;
156 const FcPattern *p;
157 } u;
158 } FcValue;
159
160 typedef struct _FcFontSet {
161 int nfont;
162 int sfont;
163 FcPattern **fonts;
164 } FcFontSet;
165
166 typedef struct _FcObjectSet {
167 int nobject;
168 int sobject;
169 const char **objects;
170 } FcObjectSet;
171
172 typedef enum _FcMatchKind {
173 FcMatchPattern, FcMatchFont
174 } FcMatchKind;
175
176 typedef enum _FcSetName {
177 FcSetSystem = 0,
178 FcSetApplication = 1
179 } FcSetName;
180
181 typedef struct _FcAtomic FcAtomic;
182
183 #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
184 #define _FCFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
185 #define _FCFUNCPROTOEND }
186 #else
187 #define _FCFUNCPROTOBEGIN
188 #define _FCFUNCPROTOEND
189 #endif
190
191 typedef enum { FcEndianBig, FcEndianLittle } FcEndian;
192
193 typedef struct _FcConfig FcConfig;
194
195 typedef struct _FcGlobalCache FcFileCache;
196
197 typedef struct _FcBlanks FcBlanks;
198
199 typedef struct _FcStrList FcStrList;
200
201 typedef struct _FcStrSet FcStrSet;
202
203 _FCFUNCPROTOBEGIN
204
205 FcBool
206 FcDirCacheValid (const FcChar8 *cache_file);
207
208 /* fcblanks.c */
209 FcBlanks *
210 FcBlanksCreate (void);
211
212 void
213 FcBlanksDestroy (FcBlanks *b);
214
215 FcBool
216 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
217
218 FcBool
219 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
220
221 /* fccfg.c */
222 FcChar8 *
223 FcConfigFilename (const FcChar8 *url);
224
225 FcConfig *
226 FcConfigCreate (void);
227
228 void
229 FcConfigDestroy (FcConfig *config);
230
231 FcBool
232 FcConfigSetCurrent (FcConfig *config);
233
234 FcConfig *
235 FcConfigGetCurrent (void);
236
237 FcBool
238 FcConfigUptoDate (FcConfig *config);
239
240 FcBool
241 FcConfigBuildFonts (FcConfig *config);
242
243 FcStrList *
244 FcConfigGetFontDirs (FcConfig *config);
245
246 FcStrList *
247 FcConfigGetConfigDirs (FcConfig *config);
248
249 FcStrList *
250 FcConfigGetConfigFiles (FcConfig *config);
251
252 FcChar8 *
253 FcConfigGetCache (FcConfig *config);
254
255 FcBlanks *
256 FcConfigGetBlanks (FcConfig *config);
257
258 int
259 FcConfigGetRescanInverval (FcConfig *config);
260
261 FcBool
262 FcConfigSetRescanInverval (FcConfig *config, int rescanInterval);
263
264 FcFontSet *
265 FcConfigGetFonts (FcConfig *config,
266 FcSetName set);
267
268 FcBool
269 FcConfigAppFontAddFile (FcConfig *config,
270 const FcChar8 *file);
271
272 FcBool
273 FcConfigAppFontAddDir (FcConfig *config,
274 const FcChar8 *dir);
275
276 void
277 FcConfigAppFontClear (FcConfig *config);
278
279 FcBool
280 FcConfigSubstituteWithPat (FcConfig *config,
281 FcPattern *p,
282 FcPattern *p_pat,
283 FcMatchKind kind);
284
285 FcBool
286 FcConfigSubstitute (FcConfig *config,
287 FcPattern *p,
288 FcMatchKind kind);
289
290 /* fccharset.c */
291 FcCharSet *
292 FcCharSetCreate (void);
293
294 void
295 FcCharSetDestroy (FcCharSet *fcs);
296
297 FcBool
298 FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
299
300 FcCharSet *
301 FcCharSetCopy (FcCharSet *src);
302
303 FcBool
304 FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
305
306 FcCharSet *
307 FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
308
309 FcCharSet *
310 FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
311
312 FcCharSet *
313 FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
314
315 FcBool
316 FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
317
318 FcChar32
319 FcCharSetCount (const FcCharSet *a);
320
321 FcChar32
322 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
323
324 FcChar32
325 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
326
327 FcBool
328 FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b);
329
330 #define FC_CHARSET_MAP_SIZE (256/32)
331 #define FC_CHARSET_DONE ((FcChar32) -1)
332
333 FcChar32
334 FcCharSetFirstPage (const FcCharSet *a,
335 FcChar32 map[FC_CHARSET_MAP_SIZE],
336 FcChar32 *next);
337
338 FcChar32
339 FcCharSetNextPage (const FcCharSet *a,
340 FcChar32 map[FC_CHARSET_MAP_SIZE],
341 FcChar32 *next);
342
343
344 /* fcdbg.c */
345 void
346 FcValuePrint (const FcValue v);
347
348 void
349 FcPatternPrint (const FcPattern *p);
350
351 void
352 FcFontSetPrint (const FcFontSet *s);
353
354 /* fcdefault.c */
355 void
356 FcDefaultSubstitute (FcPattern *pattern);
357
358 /* fcdir.c */
359 FcBool
360 FcFileScan (FcFontSet *set,
361 FcStrSet *dirs,
362 FcFileCache *cache,
363 FcBlanks *blanks,
364 const FcChar8 *file,
365 FcBool force);
366
367 FcBool
368 FcDirScan (FcFontSet *set,
369 FcStrSet *dirs,
370 FcFileCache *cache,
371 FcBlanks *blanks,
372 const FcChar8 *dir,
373 FcBool force);
374
375 FcBool
376 FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
377
378 /* fcfreetype.c */
379 FcPattern *
380 FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
381
382 /* fcfs.c */
383
384 FcFontSet *
385 FcFontSetCreate (void);
386
387 void
388 FcFontSetDestroy (FcFontSet *s);
389
390 FcBool
391 FcFontSetAdd (FcFontSet *s, FcPattern *font);
392
393 /* fcinit.c */
394 FcConfig *
395 FcInitLoadConfig (void);
396
397 FcConfig *
398 FcInitLoadConfigAndFonts (void);
399
400 FcBool
401 FcInit (void);
402
403 int
404 FcGetVersion (void);
405
406 FcBool
407 FcInitReinitialize (void);
408
409 FcBool
410 FcInitBringUptoDate (void);
411
412 /* fclist.c */
413 FcObjectSet *
414 FcObjectSetCreate (void);
415
416 FcBool
417 FcObjectSetAdd (FcObjectSet *os, const char *object);
418
419 void
420 FcObjectSetDestroy (FcObjectSet *os);
421
422 FcObjectSet *
423 FcObjectSetVaBuild (const char *first, va_list va);
424
425 FcObjectSet *
426 FcObjectSetBuild (const char *first, ...);
427
428 FcFontSet *
429 FcFontSetList (FcConfig *config,
430 FcFontSet **sets,
431 int nsets,
432 FcPattern *p,
433 FcObjectSet *os);
434
435 FcFontSet *
436 FcFontList (FcConfig *config,
437 FcPattern *p,
438 FcObjectSet *os);
439
440 /* fcatomic.c */
441
442 FcAtomic *
443 FcAtomicCreate (const FcChar8 *file);
444
445 FcBool
446 FcAtomicLock (FcAtomic *atomic);
447
448 FcChar8 *
449 FcAtomicNewFile (FcAtomic *atomic);
450
451 FcChar8 *
452 FcAtomicOrigFile (FcAtomic *atomic);
453
454 FcBool
455 FcAtomicReplaceOrig (FcAtomic *atomic);
456
457 void
458 FcAtomicDeleteNew (FcAtomic *atomic);
459
460 void
461 FcAtomicUnlock (FcAtomic *atomic);
462
463 void
464 FcAtomicDestroy (FcAtomic *atomic);
465
466 /* fcmatch.c */
467 FcPattern *
468 FcFontSetMatch (FcConfig *config,
469 FcFontSet **sets,
470 int nsets,
471 FcPattern *p,
472 FcResult *result);
473
474 FcPattern *
475 FcFontMatch (FcConfig *config,
476 FcPattern *p,
477 FcResult *result);
478
479 FcPattern *
480 FcFontRenderPrepare (FcConfig *config,
481 FcPattern *pat,
482 FcPattern *font);
483
484 FcFontSet *
485 FcFontSetSort (FcConfig *config,
486 FcFontSet **sets,
487 int nsets,
488 FcPattern *p,
489 FcBool trim,
490 FcCharSet **csp,
491 FcResult *result);
492
493 FcFontSet *
494 FcFontSort (FcConfig *config,
495 FcPattern *p,
496 FcBool trim,
497 FcCharSet **csp,
498 FcResult *result);
499
500 void
501 FcFontSetSortDestroy (FcFontSet *fs);
502
503 /* fcmatrix.c */
504 FcMatrix *
505 FcMatrixCopy (const FcMatrix *mat);
506
507 FcBool
508 FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
509
510 void
511 FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
512
513 void
514 FcMatrixRotate (FcMatrix *m, double c, double s);
515
516 void
517 FcMatrixScale (FcMatrix *m, double sx, double sy);
518
519 void
520 FcMatrixShear (FcMatrix *m, double sh, double sv);
521
522 /* fcname.c */
523
524 FcBool
525 FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
526
527 FcBool
528 FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
529
530 const FcObjectType *
531 FcNameGetObjectType (const char *object);
532
533 FcBool
534 FcNameRegisterConstants (const FcConstant *consts, int nconsts);
535
536 FcBool
537 FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
538
539 const FcConstant *
540 FcNameGetConstant (FcChar8 *string);
541
542 FcBool
543 FcNameConstant (FcChar8 *string, int *result);
544
545 FcPattern *
546 FcNameParse (const FcChar8 *name);
547
548 FcChar8 *
549 FcNameUnparse (FcPattern *pat);
550
551 /* fcpat.c */
552 FcPattern *
553 FcPatternCreate (void);
554
555 FcPattern *
556 FcPatternDuplicate (FcPattern *p);
557
558 void
559 FcPatternReference (FcPattern *p);
560
561 void
562 FcValueDestroy (FcValue v);
563
564 FcBool
565 FcValueEqual (FcValue va, FcValue vb);
566
567 FcValue
568 FcValueSave (FcValue v);
569
570 void
571 FcPatternDestroy (FcPattern *p);
572
573 FcBool
574 FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
575
576 FcBool
577 FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
578
579 FcChar32
580 FcPatternHash (const FcPattern *p);
581
582 FcBool
583 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
584
585 FcBool
586 FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
587
588 FcResult
589 FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
590
591 FcBool
592 FcPatternDel (FcPattern *p, const char *object);
593
594 FcBool
595 FcPatternAddInteger (FcPattern *p, const char *object, int i);
596
597 FcBool
598 FcPatternAddDouble (FcPattern *p, const char *object, double d);
599
600 FcBool
601 FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
602
603 FcBool
604 FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
605
606 FcBool
607 FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
608
609 FcBool
610 FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
611
612 FcResult
613 FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
614
615 FcResult
616 FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
617
618 FcResult
619 FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 ** s);
620
621 FcResult
622 FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
623
624 FcResult
625 FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
626
627 FcResult
628 FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
629
630 FcPattern *
631 FcPatternVaBuild (FcPattern *orig, va_list va);
632
633 FcPattern *
634 FcPatternBuild (FcPattern *orig, ...);
635
636 /* fcstr.c */
637
638 FcChar8 *
639 FcStrCopy (const FcChar8 *s);
640
641 FcChar8 *
642 FcStrCopyFilename (const FcChar8 *s);
643
644 #define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
645
646 int
647 FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
648
649 int
650 FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
651
652 int
653 FcUtf8ToUcs4 (FcChar8 *src_orig,
654 FcChar32 *dst,
655 int len);
656
657 FcBool
658 FcUtf8Len (FcChar8 *string,
659 int len,
660 int *nchar,
661 int *wchar);
662
663 #define FC_UTF8_MAX_LEN 6
664
665 int
666 FcUcs4ToUtf8 (FcChar32 ucs4,
667 FcChar8 dest[FC_UTF8_MAX_LEN]);
668
669 int
670 FcUtf16ToUcs4 (FcChar8 *src_orig,
671 FcEndian endian,
672 FcChar32 *dst,
673 int len); /* in bytes */
674
675 FcBool
676 FcUtf16Len (FcChar8 *string,
677 FcEndian endian,
678 int len, /* in bytes */
679 int *nchar,
680 int *wchar);
681
682 FcChar8 *
683 FcStrDirname (const FcChar8 *file);
684
685 FcChar8 *
686 FcStrBasename (const FcChar8 *file);
687
688 FcStrSet *
689 FcStrSetCreate (void);
690
691 FcBool
692 FcStrSetMember (FcStrSet *set, const FcChar8 *s);
693
694 FcBool
695 FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
696
697 FcBool
698 FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
699
700 FcBool
701 FcStrSetDel (FcStrSet *set, const FcChar8 *s);
702
703 void
704 FcStrSetDestroy (FcStrSet *set);
705
706 FcStrList *
707 FcStrListCreate (FcStrSet *set);
708
709 FcChar8 *
710 FcStrListNext (FcStrList *list);
711
712 void
713 FcStrListDone (FcStrList *list);
714
715 /* fcxml.c */
716 FcBool
717 FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
718
719 _FCFUNCPROTOEND
720
721 #endif /* _FONTCONFIG_H_ */