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