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