2 * fontconfig/fontconfig/fontconfig.h
4 * Copyright © 2001 Keith Packard
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 the author(s) not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. The authors make no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE AUTHOR(S) 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.
25 #ifndef _FONTCONFIG_H_
26 #define _FONTCONFIG_H_
28 #include <sys/types.h>
32 #if defined(__GNUC__) && (__GNUC__ >= 4)
33 #define FC_ATTRIBUTE_SENTINEL(x) __attribute__((__sentinel__(0)))
35 #define FC_ATTRIBUTE_SENTINEL(x)
42 typedef unsigned char FcChar8;
43 typedef unsigned short FcChar16;
44 typedef unsigned int FcChar32;
48 * Current Fontconfig version number. This same number
49 * must appear in the fontconfig configure.in file. Yes,
50 * it'a a pain to synchronize version numbers like this.
57 #define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION))
60 * Current font cache file format version
61 * This is appended to the cache files so that multiple
62 * versions of the library will peacefully coexist
64 * Change this value whenever the disk format for the cache file
65 * changes in any non-compatible way. Try to avoid such changes as
66 * it means multiple copies of the font information.
69 #define FC_CACHE_VERSION "3"
74 #define FC_FAMILY "family" /* String */
75 #define FC_STYLE "style" /* String */
76 #define FC_SLANT "slant" /* Int */
77 #define FC_WEIGHT "weight" /* Int */
78 #define FC_SIZE "size" /* Double */
79 #define FC_ASPECT "aspect" /* Double */
80 #define FC_PIXEL_SIZE "pixelsize" /* Double */
81 #define FC_SPACING "spacing" /* Int */
82 #define FC_FOUNDRY "foundry" /* String */
83 #define FC_ANTIALIAS "antialias" /* Bool (depends) */
84 #define FC_HINTING "hinting" /* Bool (true) */
85 #define FC_HINT_STYLE "hintstyle" /* Int */
86 #define FC_VERTICAL_LAYOUT "verticallayout" /* Bool (false) */
87 #define FC_AUTOHINT "autohint" /* Bool (false) */
88 #define FC_GLOBAL_ADVANCE "globaladvance" /* Bool (true) */
89 #define FC_WIDTH "width" /* Int */
90 #define FC_FILE "file" /* String */
91 #define FC_INDEX "index" /* Int */
92 #define FC_FT_FACE "ftface" /* FT_Face */
93 #define FC_RASTERIZER "rasterizer" /* String */
94 #define FC_OUTLINE "outline" /* Bool */
95 #define FC_SCALABLE "scalable" /* Bool */
96 #define FC_SCALE "scale" /* double */
97 #define FC_DPI "dpi" /* double */
98 #define FC_RGBA "rgba" /* Int */
99 #define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
100 #define FC_SOURCE "source" /* String (deprecated) */
101 #define FC_CHARSET "charset" /* CharSet */
102 #define FC_LANG "lang" /* String RFC 3066 langs */
103 #define FC_FONTVERSION "fontversion" /* Int from 'head' table */
104 #define FC_FULLNAME "fullname" /* String */
105 #define FC_FAMILYLANG "familylang" /* String RFC 3066 langs */
106 #define FC_STYLELANG "stylelang" /* String RFC 3066 langs */
107 #define FC_FULLNAMELANG "fullnamelang" /* String RFC 3066 langs */
108 #define FC_CAPABILITY "capability" /* String */
109 #define FC_FONTFORMAT "fontformat" /* String */
110 #define FC_EMBOLDEN "embolden" /* Bool - true if emboldening needed*/
111 #define FC_EMBEDDED_BITMAP "embeddedbitmap" /* Bool - true to enable embedded bitmaps */
112 #define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */
113 #define FC_LCD_FILTER "lcdfilter" /* Int */
115 #define FC_CACHE_SUFFIX ".cache-"FC_CACHE_VERSION
116 #define FC_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION
117 #define FC_USER_CACHE_FILE ".fonts.cache-"FC_CACHE_VERSION
119 /* Adjust outline rasterizer */
120 #define FC_CHAR_WIDTH "charwidth" /* Int */
121 #define FC_CHAR_HEIGHT "charheight"/* Int */
122 #define FC_MATRIX "matrix" /* FcMatrix */
124 #define FC_WEIGHT_THIN 0
125 #define FC_WEIGHT_EXTRALIGHT 40
126 #define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
127 #define FC_WEIGHT_LIGHT 50
128 #define FC_WEIGHT_BOOK 75
129 #define FC_WEIGHT_REGULAR 80
130 #define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
131 #define FC_WEIGHT_MEDIUM 100
132 #define FC_WEIGHT_DEMIBOLD 180
133 #define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD
134 #define FC_WEIGHT_BOLD 200
135 #define FC_WEIGHT_EXTRABOLD 205
136 #define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
137 #define FC_WEIGHT_BLACK 210
138 #define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
139 #define FC_WEIGHT_EXTRABLACK 215
140 #define FC_WEIGHT_ULTRABLACK FC_WEIGHT_EXTRABLACK
142 #define FC_SLANT_ROMAN 0
143 #define FC_SLANT_ITALIC 100
144 #define FC_SLANT_OBLIQUE 110
146 #define FC_WIDTH_ULTRACONDENSED 50
147 #define FC_WIDTH_EXTRACONDENSED 63
148 #define FC_WIDTH_CONDENSED 75
149 #define FC_WIDTH_SEMICONDENSED 87
150 #define FC_WIDTH_NORMAL 100
151 #define FC_WIDTH_SEMIEXPANDED 113
152 #define FC_WIDTH_EXPANDED 125
153 #define FC_WIDTH_EXTRAEXPANDED 150
154 #define FC_WIDTH_ULTRAEXPANDED 200
156 #define FC_PROPORTIONAL 0
159 #define FC_CHARCELL 110
161 /* sub-pixel order */
162 #define FC_RGBA_UNKNOWN 0
163 #define FC_RGBA_RGB 1
164 #define FC_RGBA_BGR 2
165 #define FC_RGBA_VRGB 3
166 #define FC_RGBA_VBGR 4
167 #define FC_RGBA_NONE 5
170 #define FC_HINT_NONE 0
171 #define FC_HINT_SLIGHT 1
172 #define FC_HINT_MEDIUM 2
173 #define FC_HINT_FULL 3
176 #define FC_LCD_NONE 0
177 #define FC_LCD_DEFAULT 1
178 #define FC_LCD_LIGHT 2
179 #define FC_LCD_LEGACY 3
181 typedef enum _FcType {
193 typedef struct _FcMatrix {
194 double xx, xy, yx, yy;
197 #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \
198 (m)->xy = (m)->yx = 0)
201 * A data structure to represent the available glyphs in a font.
202 * This is represented as a sparse boolean btree.
205 typedef struct _FcCharSet FcCharSet;
207 typedef struct _FcObjectType {
212 typedef struct _FcConstant {
218 typedef enum _FcResult {
219 FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId,
223 typedef struct _FcPattern FcPattern;
225 typedef struct _FcLangSet FcLangSet;
227 typedef struct _FcValue {
241 typedef struct _FcFontSet {
247 typedef struct _FcObjectSet {
250 const char **objects;
253 typedef enum _FcMatchKind {
254 FcMatchPattern, FcMatchFont, FcMatchScan
257 typedef enum _FcLangResult {
259 FcLangDifferentCountry = 1,
260 FcLangDifferentTerritory = 1,
261 FcLangDifferentLang = 2
264 typedef enum _FcSetName {
269 typedef struct _FcAtomic FcAtomic;
271 #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
272 #define _FCFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
273 #define _FCFUNCPROTOEND }
275 #define _FCFUNCPROTOBEGIN
276 #define _FCFUNCPROTOEND
279 typedef enum { FcEndianBig, FcEndianLittle } FcEndian;
281 typedef struct _FcConfig FcConfig;
283 typedef struct _FcGlobalCache FcFileCache;
285 typedef struct _FcBlanks FcBlanks;
287 typedef struct _FcStrList FcStrList;
289 typedef struct _FcStrSet FcStrSet;
291 typedef struct _FcCache FcCache;
297 FcBlanksCreate (void);
300 FcBlanksDestroy (FcBlanks *b);
303 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4);
306 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4);
311 FcStat (const FcChar8 *file, struct stat *statb);
313 FcPublic const FcChar8 *
314 FcCacheDir(const FcCache *c);
317 FcCacheCopySet(const FcCache *c);
319 FcPublic const FcChar8 *
320 FcCacheSubdir (const FcCache *c, int i);
323 FcCacheNumSubdir (const FcCache *c);
326 FcCacheNumFont (const FcCache *c);
329 FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config);
332 FcDirCacheValid (const FcChar8 *cache_file);
339 FcConfigEnableHome (FcBool enable);
342 FcConfigFilename (const FcChar8 *url);
345 FcConfigCreate (void);
348 FcConfigReference (FcConfig *config);
351 FcConfigDestroy (FcConfig *config);
354 FcConfigSetCurrent (FcConfig *config);
357 FcConfigGetCurrent (void);
360 FcConfigUptoDate (FcConfig *config);
363 FcConfigBuildFonts (FcConfig *config);
366 FcConfigGetFontDirs (FcConfig *config);
369 FcConfigGetConfigDirs (FcConfig *config);
372 FcConfigGetConfigFiles (FcConfig *config);
375 FcConfigGetCache (FcConfig *config);
378 FcConfigGetBlanks (FcConfig *config);
381 FcConfigGetCacheDirs (FcConfig *config);
384 FcConfigGetRescanInterval (FcConfig *config);
387 FcConfigSetRescanInterval (FcConfig *config, int rescanInterval);
390 FcConfigGetFonts (FcConfig *config,
394 FcConfigAppFontAddFile (FcConfig *config,
395 const FcChar8 *file);
398 FcConfigAppFontAddDir (FcConfig *config,
402 FcConfigAppFontClear (FcConfig *config);
405 FcConfigSubstituteWithPat (FcConfig *config,
411 FcConfigSubstitute (FcConfig *config,
417 FcCharSetCreate (void);
419 /* deprecated alias for FcCharSetCreate */
424 FcCharSetDestroy (FcCharSet *fcs);
427 FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4);
430 FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4);
433 FcCharSetCopy (FcCharSet *src);
436 FcCharSetEqual (const FcCharSet *a, const FcCharSet *b);
439 FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b);
442 FcCharSetUnion (const FcCharSet *a, const FcCharSet *b);
445 FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b);
448 FcCharSetMerge (FcCharSet *a, const FcCharSet *b, FcBool *changed);
451 FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4);
454 FcCharSetCount (const FcCharSet *a);
457 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
460 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
463 FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b);
465 #define FC_CHARSET_MAP_SIZE (256/32)
466 #define FC_CHARSET_DONE ((FcChar32) -1)
469 FcCharSetFirstPage (const FcCharSet *a,
470 FcChar32 map[FC_CHARSET_MAP_SIZE],
474 FcCharSetNextPage (const FcCharSet *a,
475 FcChar32 map[FC_CHARSET_MAP_SIZE],
479 * old coverage API, rather hard to use correctly
483 FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
487 FcValuePrint (const FcValue v);
490 FcPatternPrint (const FcPattern *p);
493 FcFontSetPrint (const FcFontSet *s);
497 FcDefaultSubstitute (FcPattern *pattern);
501 FcFileIsDir (const FcChar8 *file);
504 FcFileScan (FcFontSet *set,
512 FcDirScan (FcFontSet *set,
520 FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
523 FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file);
526 FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config);
529 FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat);
532 FcDirCacheUnload (FcCache *cache);
536 FcFreeTypeQuery (const FcChar8 *file, int id, FcBlanks *blanks, int *count);
541 FcFontSetCreate (void);
544 FcFontSetDestroy (FcFontSet *s);
547 FcFontSetAdd (FcFontSet *s, FcPattern *font);
551 FcInitLoadConfig (void);
554 FcInitLoadConfigAndFonts (void);
566 FcInitReinitialize (void);
569 FcInitBringUptoDate (void);
575 FcPublic const FcCharSet *
576 FcLangGetCharSet (const FcChar8 *lang);
579 FcLangSetCreate (void);
582 FcLangSetDestroy (FcLangSet *ls);
585 FcLangSetCopy (const FcLangSet *ls);
588 FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang);
591 FcLangSetDel (FcLangSet *ls, const FcChar8 *lang);
593 FcPublic FcLangResult
594 FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang);
596 FcPublic FcLangResult
597 FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb);
600 FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb);
603 FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb);
606 FcLangSetHash (const FcLangSet *ls);
609 FcLangSetGetLangs (const FcLangSet *ls);
612 FcLangSetUnion (const FcLangSet *a, const FcLangSet *b);
615 FcLangSetSubtract (const FcLangSet *a, const FcLangSet *b);
618 FcPublic FcObjectSet *
619 FcObjectSetCreate (void);
622 FcObjectSetAdd (FcObjectSet *os, const char *object);
625 FcObjectSetDestroy (FcObjectSet *os);
627 FcPublic FcObjectSet *
628 FcObjectSetVaBuild (const char *first, va_list va);
630 FcPublic FcObjectSet *
631 FcObjectSetBuild (const char *first, ...) FC_ATTRIBUTE_SENTINEL(0);
634 FcFontSetList (FcConfig *config,
641 FcFontList (FcConfig *config,
648 FcAtomicCreate (const FcChar8 *file);
651 FcAtomicLock (FcAtomic *atomic);
654 FcAtomicNewFile (FcAtomic *atomic);
657 FcAtomicOrigFile (FcAtomic *atomic);
660 FcAtomicReplaceOrig (FcAtomic *atomic);
663 FcAtomicDeleteNew (FcAtomic *atomic);
666 FcAtomicUnlock (FcAtomic *atomic);
669 FcAtomicDestroy (FcAtomic *atomic);
673 FcFontSetMatch (FcConfig *config,
680 FcFontMatch (FcConfig *config,
685 FcFontRenderPrepare (FcConfig *config,
690 FcFontSetSort (FcConfig *config,
699 FcFontSort (FcConfig *config,
706 FcFontSetSortDestroy (FcFontSet *fs);
710 FcMatrixCopy (const FcMatrix *mat);
713 FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2);
716 FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b);
719 FcMatrixRotate (FcMatrix *m, double c, double s);
722 FcMatrixScale (FcMatrix *m, double sx, double sy);
725 FcMatrixShear (FcMatrix *m, double sh, double sv);
730 FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
733 FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
735 FcPublic const FcObjectType *
736 FcNameGetObjectType (const char *object);
739 FcNameRegisterConstants (const FcConstant *consts, int nconsts);
742 FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
744 FcPublic const FcConstant *
745 FcNameGetConstant (const FcChar8 *string);
748 FcNameConstant (const FcChar8 *string, int *result);
751 FcNameParse (const FcChar8 *name);
754 FcNameUnparse (FcPattern *pat);
758 FcPatternCreate (void);
761 FcPatternDuplicate (const FcPattern *p);
764 FcPatternReference (FcPattern *p);
767 FcPatternFilter (FcPattern *p, const FcObjectSet *os);
770 FcValueDestroy (FcValue v);
773 FcValueEqual (FcValue va, FcValue vb);
776 FcValueSave (FcValue v);
779 FcPatternDestroy (FcPattern *p);
782 FcPatternEqual (const FcPattern *pa, const FcPattern *pb);
785 FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os);
788 FcPatternHash (const FcPattern *p);
791 FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append);
794 FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append);
797 FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v);
800 FcPatternDel (FcPattern *p, const char *object);
803 FcPatternRemove (FcPattern *p, const char *object, int id);
806 FcPatternAddInteger (FcPattern *p, const char *object, int i);
809 FcPatternAddDouble (FcPattern *p, const char *object, double d);
812 FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s);
815 FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s);
818 FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c);
821 FcPatternAddBool (FcPattern *p, const char *object, FcBool b);
824 FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls);
827 FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i);
830 FcPatternGetDouble (const FcPattern *p, const char *object, int n, double *d);
833 FcPatternGetString (const FcPattern *p, const char *object, int n, FcChar8 ** s);
836 FcPatternGetMatrix (const FcPattern *p, const char *object, int n, FcMatrix **s);
839 FcPatternGetCharSet (const FcPattern *p, const char *object, int n, FcCharSet **c);
842 FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b);
845 FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls);
848 FcPatternVaBuild (FcPattern *p, va_list va);
851 FcPatternBuild (FcPattern *p, ...) FC_ATTRIBUTE_SENTINEL(0);
854 FcPatternFormat (FcPattern *pat, const FcChar8 *format);
859 FcStrCopy (const FcChar8 *s);
862 FcStrCopyFilename (const FcChar8 *s);
865 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
868 FcStrPathPlus (const FcChar8 *s1, ...);
871 FcStrFree (FcChar8 *s);
873 /* These are ASCII only, suitable only for pattern element names */
874 #define FcIsUpper(c) ((0101 <= (c) && (c) <= 0132))
875 #define FcIsLower(c) ((0141 <= (c) && (c) <= 0172))
876 #define FcToLower(c) (FcIsUpper(c) ? (c) - 0101 + 0141 : (c))
879 FcStrDowncase (const FcChar8 *s);
882 FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
885 FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
887 FcPublic const FcChar8 *
888 FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
890 FcPublic const FcChar8 *
891 FcStrStr (const FcChar8 *s1, const FcChar8 *s2);
894 FcUtf8ToUcs4 (const FcChar8 *src_orig,
899 FcUtf8Len (const FcChar8 *string,
904 #define FC_UTF8_MAX_LEN 6
907 FcUcs4ToUtf8 (FcChar32 ucs4,
908 FcChar8 dest[FC_UTF8_MAX_LEN]);
911 FcUtf16ToUcs4 (const FcChar8 *src_orig,
914 int len); /* in bytes */
917 FcUtf16Len (const FcChar8 *string,
919 int len, /* in bytes */
924 FcStrDirname (const FcChar8 *file);
927 FcStrBasename (const FcChar8 *file);
930 FcStrSetCreate (void);
933 FcStrSetMember (FcStrSet *set, const FcChar8 *s);
936 FcStrSetEqual (FcStrSet *sa, FcStrSet *sb);
939 FcStrSetAdd (FcStrSet *set, const FcChar8 *s);
942 FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s);
945 FcStrSetDel (FcStrSet *set, const FcChar8 *s);
948 FcStrSetDestroy (FcStrSet *set);
951 FcStrListCreate (FcStrSet *set);
954 FcStrListNext (FcStrList *list);
957 FcStrListDone (FcStrList *list);
961 FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain);
965 #undef FC_ATTRIBUTE_SENTINEL
971 * Deprecated functions are placed here to help users fix their code without
972 * digging through documentation
975 #define FcConfigGetRescanInverval FcConfigGetRescanInverval_REPLACE_BY_FcConfigGetRescanInterval
976 #define FcConfigSetRescanInverval FcConfigSetRescanInverval_REPLACE_BY_FcConfigSetRescanInterval
980 #endif /* _FONTCONFIG_H_ */