]> git.wh0rd.org - fontconfig.git/blob - fontconfig/fontconfig.h
Add const to a bunch of string APIs
[fontconfig.git] / fontconfig / fontconfig.h
1 /*
2 * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.26 2002/08/19 19:32:04 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 FcTypeLangSet
114 } FcType;
115
116 typedef struct _FcMatrix {
117 double xx, xy, yx, yy;
118 } FcMatrix;
119
120 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \
121 (m)->xy = (m)->yx = 0)
122
123 /*
124 * A data structure to represent the available glyphs in a font.
125 * This is represented as a sparse boolean btree.
126 */
127
128 typedef struct _FcCharSet FcCharSet;
129
130 typedef struct _FcObjectType {
131 const char *object;
132 FcType type;
133 } FcObjectType;
134
135 typedef struct _FcConstant {
136 const FcChar8 *name;
137 const char *object;
138 int value;
139 } FcConstant;
140
141 typedef enum _FcResult {
142 FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId
143 } FcResult;
144
145 typedef struct _FcPattern FcPattern;
146
147 typedef struct _FcLangSet FcLangSet;
148
149 typedef struct _FcValue {
150 FcType type;
151 union {
152 const FcChar8 *s;
153 int i;
154 FcBool b;
155 double d;
156 const FcMatrix *m;
157 const FcCharSet *c;
158 void *f;
159 const FcPattern *p;
160 const FcLangSet *l;
161 } u;
162 } FcValue;
163
164 typedef struct _FcFontSet {
165 int nfont;
166 int sfont;
167 FcPattern **fonts;
168 } FcFontSet;
169
170 typedef struct _FcObjectSet {
171 int nobject;
172 int sobject;
173 const char **objects;
174 } FcObjectSet;
175
176 typedef enum _FcMatchKind {
177 FcMatchPattern, FcMatchFont
178 } FcMatchKind;
179
180 typedef enum _FcLangResult {
181 FcLangEqual, FcLangDifferentCountry, FcLangDifferentLang
182 } FcLangResult;
183
184 typedef enum _FcSetName {
185 FcSetSystem = 0,
186 FcSetApplication = 1
187 } FcSetName;
188
189 typedef struct _FcAtomic FcAtomic;
190
191 #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
192 #define _FCFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
193 #define _FCFUNCPROTOEND }
194 #else
195 #define _FCFUNCPROTOBEGIN
196 #define _FCFUNCPROTOEND
197 #endif
198
199 typedef enum { FcEndianBig, FcEndianLittle } FcEndian;
200
201 typedef struct _FcConfig FcConfig;
202
203 typedef struct _FcGlobalCache FcFileCache;
204
205 typedef struct _FcBlanks FcBlanks;
206
207 typedef struct _FcStrList FcStrList;
208
209 typedef struct _FcStrSet FcStrSet;
210
211 _FCFUNCPROTOBEGIN
212
213 FcBool
214 FcDirCacheValid (const FcChar8 *cache_file);
215
216 /* fcblanks.c */
217 FcBlanks *
218 FcBlanksCreate (void);
219
220 void
221 FcBlanksDestroy (FcBlanks *b);
222
223 FcBool
224 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
225
226 FcBool
227 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
228
229 /* fccfg.c */
230 FcChar8 *
231 FcConfigFilename (const FcChar8 *url);
232
233 FcConfig *
234 FcConfigCreate (void);
235
236 void
237 FcConfigDestroy (FcConfig *config);
238
239 FcBool
240 FcConfigSetCurrent (FcConfig *config);
241
242 FcConfig *
243 FcConfigGetCurrent (void);
244
245 FcBool
246 FcConfigUptoDate (FcConfig *config);
247
248 FcBool
249 FcConfigBuildFonts (FcConfig *config);
250
251 FcStrList *
252 FcConfigGetFontDirs (FcConfig *config);
253
254 FcStrList *
255 FcConfigGetConfigDirs (FcConfig *config);
256
257 FcStrList *
258 FcConfigGetConfigFiles (FcConfig *config);
259
260 FcChar8 *
261 FcConfigGetCache (FcConfig *config);
262
263 FcBlanks *
264 FcConfigGetBlanks (FcConfig *config);
265
266 int
267 FcConfigGetRescanInverval (FcConfig *config);
268
269 FcBool
270 FcConfigSetRescanInverval (FcConfig *config, int rescanInterval);
271
272 FcFontSet *
273 FcConfigGetFonts (FcConfig *config,
274 FcSetName set);
275
276 FcBool
277 FcConfigAppFontAddFile (FcConfig *config,
278 const FcChar8 *file);
279
280 FcBool
281 FcConfigAppFontAddDir (FcConfig *config,
282 const FcChar8 *dir);
283
284 void
285 FcConfigAppFontClear (FcConfig *config);
286
287 FcBool
288 FcConfigSubstituteWithPat (FcConfig *config,
289 FcPattern *p,
290 FcPattern *p_pat,
291 FcMatchKind kind);
292
293 FcBool
294 FcConfigSubstitute (FcConfig *config,
295 FcPattern *p,
296 FcMatchKind kind);
297
298 /* fccharset.c */
299 FcCharSet *
300 FcCharSetCreate (void);
301
302 void
303 FcCharSetDestroy (FcCharSet *fcs);
304
305 FcBool
306 FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
307
308 FcCharSet *
309 FcCharSetCopy (FcCharSet *src);
310
311 FcBool
312 FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
313
314 FcCharSet *
315 FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
316
317 FcCharSet *
318 FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
319
320 FcCharSet *
321 FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
322
323 FcBool
324 FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
325
326 FcChar32
327 FcCharSetCount (const FcCharSet *a);
328
329 FcChar32
330 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
331
332 FcChar32
333 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
334
335 FcBool
336 FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b);
337
338 #define FC_CHARSET_MAP_SIZE (256/32)
339 #define FC_CHARSET_DONE ((FcChar32) -1)
340
341 FcChar32
342 FcCharSetFirstPage (const FcCharSet *a,
343 FcChar32 map[FC_CHARSET_MAP_SIZE],
344 FcChar32 *next);
345
346 FcChar32
347 FcCharSetNextPage (const FcCharSet *a,
348 FcChar32 map[FC_CHARSET_MAP_SIZE],
349 FcChar32 *next);
350
351
352 /* fcdbg.c */
353 void
354 FcValuePrint (const FcValue v);
355
356 void
357 FcPatternPrint (const FcPattern *p);
358
359 void
360 FcFontSetPrint (const FcFontSet *s);
361
362 /* fcdefault.c */
363 void
364 FcDefaultSubstitute (FcPattern *pattern);
365
366 /* fcdir.c */
367 FcBool
368 FcFileScan (FcFontSet *set,
369 FcStrSet *dirs,
370 FcFileCache *cache,
371 FcBlanks *blanks,
372 const FcChar8 *file,
373 FcBool force);
374
375 FcBool
376 FcDirScan (FcFontSet *set,
377 FcStrSet *dirs,
378 FcFileCache *cache,
379 FcBlanks *blanks,
380 const FcChar8 *dir,
381 FcBool force);
382
383 FcBool
384 FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
385
386 /* fcfreetype.c */
387 FcPattern *
388 FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
389
390 /* fcfs.c */
391
392 FcFontSet *
393 FcFontSetCreate (void);
394
395 void
396 FcFontSetDestroy (FcFontSet *s);
397
398 FcBool
399 FcFontSetAdd (FcFontSet *s, FcPattern *font);
400
401 /* fcinit.c */
402 FcConfig *
403 FcInitLoadConfig (void);
404
405 FcConfig *
406 FcInitLoadConfigAndFonts (void);
407
408 FcBool
409 FcInit (void);
410
411 int
412 FcGetVersion (void);
413
414 FcBool
415 FcInitReinitialize (void);
416
417 FcBool
418 FcInitBringUptoDate (void);
419
420 /* fclang.c */
421 FcLangSet *
422 FcLangSetCreate (void);
423
424 void
425 FcLangSetDestroy (FcLangSet *ls);
426
427 FcLangSet *
428 FcLangSetCopy (const FcLangSet *ls);
429
430 FcBool
431 FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang);
432
433 FcLangResult
434 FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang);
435
436 FcLangResult
437 FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb);
438
439 FcBool
440 FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb);
441
442 FcChar32
443 FcLangSetHash (const FcLangSet *ls);
444
445 /* fclist.c */
446 FcObjectSet *
447 FcObjectSetCreate (void);
448
449 FcBool
450 FcObjectSetAdd (FcObjectSet *os, const char *object);
451
452 void
453 FcObjectSetDestroy (FcObjectSet *os);
454
455 FcObjectSet *
456 FcObjectSetVaBuild (const char *first, va_list va);
457
458 FcObjectSet *
459 FcObjectSetBuild (const char *first, ...);
460
461 FcFontSet *
462 FcFontSetList (FcConfig *config,
463 FcFontSet **sets,
464 int nsets,
465 FcPattern *p,
466 FcObjectSet *os);
467
468 FcFontSet *
469 FcFontList (FcConfig *config,
470 FcPattern *p,
471 FcObjectSet *os);
472
473 /* fcatomic.c */
474
475 FcAtomic *
476 FcAtomicCreate (const FcChar8 *file);
477
478 FcBool
479 FcAtomicLock (FcAtomic *atomic);
480
481 FcChar8 *
482 FcAtomicNewFile (FcAtomic *atomic);
483
484 FcChar8 *
485 FcAtomicOrigFile (FcAtomic *atomic);
486
487 FcBool
488 FcAtomicReplaceOrig (FcAtomic *atomic);
489
490 void
491 FcAtomicDeleteNew (FcAtomic *atomic);
492
493 void
494 FcAtomicUnlock (FcAtomic *atomic);
495
496 void
497 FcAtomicDestroy (FcAtomic *atomic);
498
499 /* fcmatch.c */
500 FcPattern *
501 FcFontSetMatch (FcConfig *config,
502 FcFontSet **sets,
503 int nsets,
504 FcPattern *p,
505 FcResult *result);
506
507 FcPattern *
508 FcFontMatch (FcConfig *config,
509 FcPattern *p,
510 FcResult *result);
511
512 FcPattern *
513 FcFontRenderPrepare (FcConfig *config,
514 FcPattern *pat,
515 FcPattern *font);
516
517 FcFontSet *
518 FcFontSetSort (FcConfig *config,
519 FcFontSet **sets,
520 int nsets,
521 FcPattern *p,
522 FcBool trim,
523 FcCharSet **csp,
524 FcResult *result);
525
526 FcFontSet *
527 FcFontSort (FcConfig *config,
528 FcPattern *p,
529 FcBool trim,
530 FcCharSet **csp,
531 FcResult *result);
532
533 void
534 FcFontSetSortDestroy (FcFontSet *fs);
535
536 /* fcmatrix.c */
537 FcMatrix *
538 FcMatrixCopy (const FcMatrix *mat);
539
540 FcBool
541 FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
542
543 void
544 FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
545
546 void
547 FcMatrixRotate (FcMatrix *m, double c, double s);
548
549 void
550 FcMatrixScale (FcMatrix *m, double sx, double sy);
551
552 void
553 FcMatrixShear (FcMatrix *m, double sh, double sv);
554
555 /* fcname.c */
556
557 FcBool
558 FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
559
560 FcBool
561 FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
562
563 const FcObjectType *
564 FcNameGetObjectType (const char *object);
565
566 FcBool
567 FcNameRegisterConstants (const FcConstant *consts, int nconsts);
568
569 FcBool
570 FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
571
572 const FcConstant *
573 FcNameGetConstant (FcChar8 *string);
574
575 FcBool
576 FcNameConstant (FcChar8 *string, int *result);
577
578 FcPattern *
579 FcNameParse (const FcChar8 *name);
580
581 FcChar8 *
582 FcNameUnparse (FcPattern *pat);
583
584 /* fcpat.c */
585 FcPattern *
586 FcPatternCreate (void);
587
588 FcPattern *
589 FcPatternDuplicate (FcPattern *p);
590
591 void
592 FcPatternReference (FcPattern *p);
593
594 void
595 FcValueDestroy (FcValue v);
596
597 FcBool
598 FcValueEqual (FcValue va, FcValue vb);
599
600 FcValue
601 FcValueSave (FcValue v);
602
603 void
604 FcPatternDestroy (FcPattern *p);
605
606 FcBool
607 FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
608
609 FcBool
610 FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
611
612 FcChar32
613 FcPatternHash (const FcPattern *p);
614
615 FcBool
616 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
617
618 FcBool
619 FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
620
621 FcResult
622 FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
623
624 FcBool
625 FcPatternDel (FcPattern *p, const char *object);
626
627 FcBool
628 FcPatternAddInteger (FcPattern *p, const char *object, int i);
629
630 FcBool
631 FcPatternAddDouble (FcPattern *p, const char *object, double d);
632
633 FcBool
634 FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
635
636 FcBool
637 FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
638
639 FcBool
640 FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
641
642 FcBool
643 FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
644
645 FcBool
646 FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
647
648 FcResult
649 FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
650
651 FcResult
652 FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
653
654 FcResult
655 FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 ** s);
656
657 FcResult
658 FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
659
660 FcResult
661 FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
662
663 FcResult
664 FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
665
666 FcResult
667 FcPatternGetLangSet (FcPattern *p, const char *object, int n, FcLangSet **ls);
668
669 FcPattern *
670 FcPatternVaBuild (FcPattern *orig, va_list va);
671
672 FcPattern *
673 FcPatternBuild (FcPattern *orig, ...);
674
675 /* fcstr.c */
676
677 FcChar8 *
678 FcStrCopy (const FcChar8 *s);
679
680 FcChar8 *
681 FcStrCopyFilename (const FcChar8 *s);
682
683 #define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
684
685 int
686 FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
687
688 int
689 FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
690
691 int
692 FcUtf8ToUcs4 (const FcChar8 *src_orig,
693 FcChar32 *dst,
694 int len);
695
696 FcBool
697 FcUtf8Len (const FcChar8 *string,
698 int len,
699 int *nchar,
700 int *wchar);
701
702 #define FC_UTF8_MAX_LEN 6
703
704 int
705 FcUcs4ToUtf8 (FcChar32 ucs4,
706 FcChar8 dest[FC_UTF8_MAX_LEN]);
707
708 int
709 FcUtf16ToUcs4 (const FcChar8 *src_orig,
710 FcEndian endian,
711 FcChar32 *dst,
712 int len); /* in bytes */
713
714 FcBool
715 FcUtf16Len (const FcChar8 *string,
716 FcEndian endian,
717 int len, /* in bytes */
718 int *nchar,
719 int *wchar);
720
721 FcChar8 *
722 FcStrDirname (const FcChar8 *file);
723
724 FcChar8 *
725 FcStrBasename (const FcChar8 *file);
726
727 FcStrSet *
728 FcStrSetCreate (void);
729
730 FcBool
731 FcStrSetMember (FcStrSet *set, const FcChar8 *s);
732
733 FcBool
734 FcStrSetEqual (FcStrSet *sa, FcStrSet *sb);
735
736 FcBool
737 FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
738
739 FcBool
740 FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
741
742 FcBool
743 FcStrSetDel (FcStrSet *set, const FcChar8 *s);
744
745 void
746 FcStrSetDestroy (FcStrSet *set);
747
748 FcStrList *
749 FcStrListCreate (FcStrSet *set);
750
751 FcChar8 *
752 FcStrListNext (FcStrList *list);
753
754 void
755 FcStrListDone (FcStrList *list);
756
757 /* fcxml.c */
758 FcBool
759 FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
760
761 _FCFUNCPROTOEND
762
763 #endif /* _FONTCONFIG_H_ */