2 * Copyright © 2000 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
24 * These definitions are solely for use by the implementation of Xft
25 * and constitute no kind of standard. If you need any of these functions,
26 * please drop me a note. Either the library needs new functionality,
27 * or there's a way to do what you need using the existing published
28 * interfaces. keithp@freedesktop.org
36 #else /* X monolithic tree */
37 #define HAVE_STDLIB_H 1 /* assumed since all ANSI C platforms require it */
38 #include <X11/Xosdefs.h> /* get string.h or strings.h as appropriate */
55 #include <X11/Xutil.h>
57 #include <X11/Xlibint.h>
58 #define _XFT_NO_COMPAT_
60 #include <fontconfig/fcprivate.h>
61 #include <fontconfig/fcfreetype.h>
63 /* Added to <X11/Xfuncproto.h> in X11R6.9 and later */
65 # define _X_HIDDEN /**/
68 # define _X_EXPORT /**/
71 typedef struct _XftMatcher {
73 double (*compare) (char *object, FcValue value1, FcValue value2);
76 typedef struct _XftSymbolic {
82 * Glyphs are stored in this structure
84 typedef struct _XftGlyph {
87 unsigned long glyph_memory;
91 * A hash table translates Unicode values into glyph indicies
93 typedef struct _XftUcsHash {
99 * Many fonts can share the same underlying face data; this
100 * structure references that. Note that many faces may in fact
101 * live in the same font file; that is irrelevant to this structure
102 * which is concerned only with the individual faces themselves
105 typedef struct _XftFtFile {
106 struct _XftFtFile *next;
107 int ref; /* number of font infos using this file */
109 char *file; /* file name */
110 int id; /* font index within that file */
112 FT_F26Dot6 xsize; /* current xsize setting */
113 FT_F26Dot6 ysize; /* current ysize setting */
114 FT_Matrix matrix; /* current matrix setting */
116 int lock; /* lock count; can't unload unless 0 */
117 FT_Face face; /* pointer to face; only valid when lock */
121 * This structure holds the data extracted from a pattern
122 * needed to create a unique font object.
125 struct _XftFontInfo {
127 * Hash value (not include in hash value computation)
130 XftFtFile *file; /* face source */
134 FT_F26Dot6 xsize, ysize; /* pixel size */
135 FcBool antialias; /* doing antialiasing */
136 FcBool embolden; /* force emboldening */
137 int rgba; /* subpixel order */
138 int lcd_filter; /* lcd filter */
139 FT_Matrix matrix; /* glyph transformation matrix */
140 FcBool transform; /* non-identify matrix? */
141 FT_Int load_flags; /* glyph load flags */
142 FcBool render; /* whether to use the Render extension */
152 * Internal version of the font with private data
155 typedef struct _XftFontInt {
156 XftFont public; /* public fields */
157 XftFont *next; /* all fonts on display */
158 XftFont *hash_next; /* fonts in this hash chain */
159 XftFontInfo info; /* Data from pattern */
160 int ref; /* reference count */
162 * Per-glyph information, indexed by glyph ID
163 * This array follows the font in memory
166 int num_glyphs; /* size of glyphs/bitmaps arrays */
168 * Hash table to get from Unicode value to glyph ID
169 * This array follows the glyphs in memory
171 XftUcsHash *hash_table;
177 GlyphSet glyphset; /* Render glyphset */
178 XRenderPictFormat *format; /* Render format for glyphs */
180 * Glyph memory management fields
182 unsigned long glyph_memory;
183 unsigned long max_glyph_memory;
184 FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
187 typedef enum _XftClipType {
188 XftClipTypeNone, XftClipTypeRegion, XftClipTypeRectangles
191 typedef struct _XftClipRect {
197 #define XftClipRects(cr) ((XRectangle *) ((cr) + 1))
199 typedef union _XftClip {
207 unsigned int bits_per_pixel;
210 Visual *visual; /* NULL for bitmaps */
212 XftClipType clip_type;
225 * Instead of taking two round trips for each blending request,
226 * assume that if a particular drawable fails GetImage that it will
227 * fail for a "while"; use temporary pixmaps to avoid the errors
230 #define XFT_ASSUME_PIXMAP 20
232 typedef struct _XftSolidColor {
238 #define XFT_NUM_SOLID_COLOR 16
240 #define XFT_NUM_FONT_HASH 127
242 typedef struct _XftDisplayInfo {
243 struct _XftDisplayInfo *next;
249 XRenderPictFormat *solidFormat;
250 unsigned long glyph_memory;
251 unsigned long max_glyph_memory;
252 FcBool use_free_glyphs;
255 XftSolidColor colors[XFT_NUM_SOLID_COLOR];
256 XftFont *fontHash[XFT_NUM_FONT_HASH];
260 * By default, use no more than 4 meg of server memory total, and no
261 * more than 1 meg for any one font
263 #define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
264 #define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
267 * By default, keep the last 16 unreferenced fonts around to
268 * speed reopening them. Note that the glyph caching code
269 * will keep the global memory usage reasonably limited
271 #define XFT_DPY_MAX_UNREF_FONTS 16
273 extern XftDisplayInfo *_XftDisplayInfo;
275 #define XFT_DBG_OPEN 1
276 #define XFT_DBG_OPENV 2
277 #define XFT_DBG_RENDER 4
278 #define XFT_DBG_DRAW 8
279 #define XFT_DBG_REF 16
280 #define XFT_DBG_GLYPH 32
281 #define XFT_DBG_GLYPHV 64
282 #define XFT_DBG_CACHE 128
283 #define XFT_DBG_CACHEV 256
284 #define XFT_DBG_MEMORY 512
286 #define XFT_MEM_DRAW 0
287 #define XFT_MEM_FONT 1
288 #define XFT_MEM_FILE 2
289 #define XFT_MEM_GLYPH 3
290 #define XFT_MEM_NUM 4
293 void XftFontSetDestroy (FcFontSet *s);
294 FcBool XftMatrixEqual (_Xconst FcMatrix *mat1, _Xconst FcMatrix *mat2);
295 void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
296 void XftMatrixRotate (FcMatrix *m, double c, double s);
297 void XftMatrixScale (FcMatrix *m, double sx, double sy);
298 void XftMatrixShear (FcMatrix *m, double sh, double sv);
299 FcPattern *XftPatternCreate (void);
300 void XftValueDestroy (FcValue v);
301 void XftPatternDestroy (FcPattern *p);
302 FcBool XftPatternAdd (FcPattern *p, _Xconst char *object, FcValue value, FcBool append);
303 FcBool XftPatternDel (FcPattern *p, _Xconst char *object);
304 FcBool XftPatternAddInteger (FcPattern *p, _Xconst char *object, int i);
305 FcBool XftPatternAddDouble (FcPattern *p, _Xconst char *object, double i);
306 FcBool XftPatternAddMatrix (FcPattern *p, _Xconst char *object, FcMatrix *i);
307 FcBool XftPatternAddString (FcPattern *p, _Xconst char *object, char *i);
308 FcBool XftPatternAddBool (FcPattern *p, _Xconst char *object, FcBool i);
309 FcResult XftPatternGet (FcPattern *p, _Xconst char *object, int id, FcValue *v);
310 FcResult XftPatternGetInteger (FcPattern *p, _Xconst char *object, int id, int *i);
311 FcResult XftPatternGetDouble (FcPattern *p, _Xconst char *object, int id, double *i);
312 FcResult XftPatternGetString (FcPattern *p, _Xconst char *object, int id, char **i);
313 FcResult XftPatternGetMatrix (FcPattern *p, _Xconst char *object, int id, FcMatrix **i);
314 FcResult XftPatternGetBool (FcPattern *p, _Xconst char *object, int id, FcBool *i);
315 FcPattern *XftPatternDuplicate (FcPattern *orig);
316 FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
317 FcPattern *XftPatternBuild (FcPattern *orig, ...);
318 FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
319 FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
320 FcObjectSet *XftObjectSetCreate (void);
321 Bool XftObjectSetAdd (FcObjectSet *os, _Xconst char *object);
322 void XftObjectSetDestroy (FcObjectSet *os);
323 FcObjectSet *XftObjectSetVaBuild (_Xconst char *first, va_list va);
324 FcObjectSet *XftObjectSetBuild (_Xconst char *first, ...);
325 FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
329 XftRectCore (XftDraw *draw,
330 _Xconst XftColor *color,
334 unsigned int height);
337 XftGlyphCore (XftDraw *draw,
338 _Xconst XftColor *color,
342 _Xconst FT_UInt *glyphs,
346 XftGlyphSpecCore (XftDraw *draw,
347 _Xconst XftColor *color,
349 _Xconst XftGlyphSpec *glyphs,
353 XftGlyphFontSpecCore (XftDraw *draw,
354 _Xconst XftColor *color,
355 _Xconst XftGlyphFontSpec *glyphs,
364 _XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary);
367 _XftDisplayManageMemory (Display *dpy);
370 XftDefaultParseBool (const char *v);
373 XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
376 XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
379 XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
382 XftDisplayGetFontSet (Display *dpy);
386 XftDrawDepth (XftDraw *draw);
389 XftDrawBitsPerPixel (XftDraw *draw);
392 XftDrawRenderPrepare (XftDraw *draw);
400 _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix);
403 XftFontManageMemory (Display *dpy);
407 _XftFontUncacheGlyph (Display *dpy, XftFont *public);
410 _XftFontManageMemory (Display *dpy, XftFont *public);
417 XftMemAlloc (int kind, int size);
420 XftMemFree (int kind, int size);
424 XftListFontsPatternObjects (Display *dpy,
437 _XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
441 XftNativeByteOrder (void);
444 XftSwapCARD32 (CARD32 *data, int n);
447 XftSwapCARD24 (CARD8 *data, int width, int height);
450 XftSwapCARD16 (CARD16 *data, int n);
453 XftSwapImage (XImage *image);
456 #endif /* _XFT_INT_H_ */