]> git.wh0rd.org - fontconfig.git/blob - fontconfig/fontconfig.h
Add new FcAtomic datatype for config file locking
[fontconfig.git] / fontconfig / fontconfig.h
1 /*
2 * $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.5 2002/03/01 01:00:54 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 0
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 _FCFUNCPROTOBEGIN
232
233 /* fcblanks.c */
234 FcBlanks *
235 FcBlanksCreate (void);
236
237 void
238 FcBlanksDestroy (FcBlanks *b);
239
240 FcBool
241 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
242
243 FcBool
244 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
245
246 /* fccfg.c */
247 FcChar8 *
248 FcConfigFilename (const FcChar8 *url);
249
250 FcConfig *
251 FcConfigCreate (void);
252
253 void
254 FcConfigDestroy (FcConfig *config);
255
256 FcBool
257 FcConfigSetCurrent (FcConfig *config);
258
259 FcConfig *
260 FcConfigGetCurrent (void);
261
262 FcBool
263 FcConfigBuildFonts (FcConfig *config);
264
265 FcChar8 **
266 FcConfigGetDirs (FcConfig *config);
267
268 FcChar8 **
269 FcConfigGetConfigFiles (FcConfig *config);
270
271 FcChar8 *
272 FcConfigGetCache (FcConfig *config);
273
274 FcBlanks *
275 FcConfigGetBlanks (FcConfig *config);
276
277 FcFontSet *
278 FcConfigGetFonts (FcConfig *config,
279 FcSetName set);
280
281 FcBool
282 FcConfigAppFontAddFile (FcConfig *config,
283 const FcChar8 *file);
284
285 FcBool
286 FcConfigAppFontAddDir (FcConfig *config,
287 const FcChar8 *dir);
288
289 void
290 FcConfigAppFontClear (FcConfig *config);
291
292 FcBool
293 FcConfigSubstitute (FcConfig *config,
294 FcPattern *p,
295 FcMatchKind kind);
296
297 /* fccharset.c */
298 FcCharSet *
299 FcCharSetCreate (void);
300
301 void
302 FcCharSetDestroy (FcCharSet *fcs);
303
304 FcBool
305 FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
306
307 FcCharSet *
308 FcCharSetCopy (FcCharSet *src);
309
310 FcBool
311 FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
312
313 FcCharSet *
314 FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
315
316 FcCharSet *
317 FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
318
319 FcCharSet *
320 FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
321
322 FcBool
323 FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
324
325 FcChar32
326 FcCharSetCount (const FcCharSet *a);
327
328 FcChar32
329 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
330
331 FcChar32
332 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
333
334 FcChar32
335 FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
336
337 /* fcdbg.c */
338 void
339 FcValuePrint (FcValue v);
340
341 void
342 FcPatternPrint (FcPattern *p);
343
344 void
345 FcFontSetPrint (FcFontSet *s);
346
347 /* fcdefault.c */
348 void
349 FcDefaultSubstitute (FcPattern *pattern);
350
351 /* fcdir.c */
352 FcBool
353 FcFileScan (FcFontSet *set,
354 FcFileCache *cache,
355 FcBlanks *blanks,
356 const FcChar8 *file,
357 FcBool force);
358
359 FcBool
360 FcDirScan (FcFontSet *set,
361 FcFileCache *cache,
362 FcBlanks *blanks,
363 const FcChar8 *dir,
364 FcBool force);
365
366 FcBool
367 FcDirSave (FcFontSet *set, const FcChar8 *dir);
368
369 /* fcfreetype.c */
370 FcPattern *
371 FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
372
373 /* fcfs.c */
374
375 FcFontSet *
376 FcFontSetCreate (void);
377
378 void
379 FcFontSetDestroy (FcFontSet *s);
380
381 FcBool
382 FcFontSetAdd (FcFontSet *s, FcPattern *font);
383
384 /* fcinit.c */
385 FcBool
386 FcInitFonts (void);
387
388 FcBool
389 FcInitConfig (void);
390
391 FcBool
392 FcInit (void);
393
394 /* fclist.c */
395 FcObjectSet *
396 FcObjectSetCreate (void);
397
398 FcBool
399 FcObjectSetAdd (FcObjectSet *os, const char *object);
400
401 void
402 FcObjectSetDestroy (FcObjectSet *os);
403
404 FcObjectSet *
405 FcObjectSetVaBuild (const char *first, va_list va);
406
407 FcObjectSet *
408 FcObjectSetBuild (const char *first, ...);
409
410 FcFontSet *
411 FcFontSetList (FcConfig *config,
412 FcFontSet **sets,
413 int nsets,
414 FcPattern *p,
415 FcObjectSet *os);
416
417 FcFontSet *
418 FcFontList (FcConfig *config,
419 FcPattern *p,
420 FcObjectSet *os);
421
422 /* fcatomic.c */
423
424 FcAtomic *
425 FcAtomicCreate (const FcChar8 *file);
426
427 FcBool
428 FcAtomicLock (FcAtomic *atomic);
429
430 FcChar8 *
431 FcAtomicNewFile (FcAtomic *atomic);
432
433 FcChar8 *
434 FcAtomicOrigFile (FcAtomic *atomic);
435
436 FcBool
437 FcAtomicReplaceOrig (FcAtomic *atomic);
438
439 void
440 FcAtomicDeleteNew (FcAtomic *atomic);
441
442 void
443 FcAtomicUnlock (FcAtomic *atomic);
444
445 void
446 FcAtomicDestroy (FcAtomic *atomic);
447
448 /* fcmatch.c */
449 FcPattern *
450 FcFontSetMatch (FcConfig *config,
451 FcFontSet **sets,
452 int nsets,
453 FcPattern *p,
454 FcResult *result);
455
456 FcPattern *
457 FcFontMatch (FcConfig *config,
458 FcPattern *p,
459 FcResult *result);
460
461 /* fcmatrix.c */
462 FcMatrix *
463 FcMatrixCopy (const FcMatrix *mat);
464
465 FcBool
466 FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
467
468 void
469 FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
470
471 void
472 FcMatrixRotate (FcMatrix *m, double c, double s);
473
474 void
475 FcMatrixScale (FcMatrix *m, double sx, double sy);
476
477 void
478 FcMatrixShear (FcMatrix *m, double sh, double sv);
479
480 /* fcname.c */
481
482 FcBool
483 FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
484
485 FcBool
486 FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
487
488 const FcObjectType *
489 FcNameGetObjectType (const char *object);
490
491 FcBool
492 FcNameRegisterConstants (const FcConstant *consts, int nconsts);
493
494 FcBool
495 FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
496
497 const FcConstant *
498 FcNameGetConstant (FcChar8 *string);
499
500 FcBool
501 FcNameConstant (FcChar8 *string, int *result);
502
503 FcPattern *
504 FcNameParse (const FcChar8 *name);
505
506 FcChar8 *
507 FcNameUnparse (FcPattern *pat);
508
509 /* fcpat.c */
510 FcPattern *
511 FcPatternCreate (void);
512
513 FcPattern *
514 FcPatternDuplicate (FcPattern *p);
515
516 void
517 FcValueDestroy (FcValue v);
518
519 FcValue
520 FcValueSave (FcValue v);
521
522 void
523 FcPatternDestroy (FcPattern *p);
524
525 FcBool
526 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
527
528 FcResult
529 FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v);
530
531 FcBool
532 FcPatternDel (FcPattern *p, const char *object);
533
534 FcBool
535 FcPatternAddInteger (FcPattern *p, const char *object, int i);
536
537 FcBool
538 FcPatternAddDouble (FcPattern *p, const char *object, double d);
539
540 FcBool
541 FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
542
543 FcBool
544 FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
545
546 FcBool
547 FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
548
549 FcBool
550 FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
551
552 FcResult
553 FcPatternGetInteger (FcPattern *p, const char *object, int n, int *i);
554
555 FcResult
556 FcPatternGetDouble (FcPattern *p, const char *object, int n, double *d);
557
558 FcResult
559 FcPatternGetString (FcPattern *p, const char *object, int n, FcChar8 ** s);
560
561 FcResult
562 FcPatternGetMatrix (FcPattern *p, const char *object, int n, FcMatrix **s);
563
564 FcResult
565 FcPatternGetCharSet (FcPattern *p, const char *object, int n, FcCharSet **c);
566
567 FcResult
568 FcPatternGetBool (FcPattern *p, const char *object, int n, FcBool *b);
569
570 FcPattern *
571 FcPatternVaBuild (FcPattern *orig, va_list va);
572
573 FcPattern *
574 FcPatternBuild (FcPattern *orig, ...);
575
576 /* fcstr.c */
577
578 FcChar8 *
579 FcStrCopy (const FcChar8 *s);
580
581 #define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
582
583 int
584 FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
585
586 int
587 FcUtf8ToUcs4 (FcChar8 *src_orig,
588 FcChar32 *dst,
589 int len);
590
591 FcBool
592 FcUtf8Len (FcChar8 *string,
593 int len,
594 int *nchar,
595 int *wchar);
596
597 /* fcxml.c */
598 FcBool
599 FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
600
601 _FCFUNCPROTOEND
602
603 #endif /* _FONTCONFIG_H_ */