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 /**/
72 # if (FREETYPE_MAJOR > 2 || \
73 (FREETYPE_MAJOR == 2 && (FREETYPE_MINOR > 1 || \
74 (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 5))))
75 # define HAVE_FT_BITMAP_SIZE_Y_PPEM 1
77 # define HAVE_FT_BITMAP_SIZE_Y_PPEM 0
81 typedef struct _XftMatcher {
83 double (*compare) (char *object, FcValue value1, FcValue value2);
86 typedef struct _XftSymbolic {
92 * Glyphs are stored in this structure
94 typedef struct _XftGlyph {
97 unsigned long glyph_memory;
101 * A hash table translates Unicode values into glyph indicies
103 typedef struct _XftUcsHash {
109 * Many fonts can share the same underlying face data; this
110 * structure references that. Note that many faces may in fact
111 * live in the same font file; that is irrelevant to this structure
112 * which is concerned only with the individual faces themselves
115 typedef struct _XftFtFile {
116 struct _XftFtFile *next;
117 int ref; /* number of font infos using this file */
119 char *file; /* file name */
120 int id; /* font index within that file */
122 FT_F26Dot6 xsize; /* current xsize setting */
123 FT_F26Dot6 ysize; /* current ysize setting */
124 FT_Matrix matrix; /* current matrix setting */
126 int lock; /* lock count; can't unload unless 0 */
127 FT_Face face; /* pointer to face; only valid when lock */
131 * This structure holds the data extracted from a pattern
132 * needed to create a unique font object.
135 struct _XftFontInfo {
137 * Hash value (not include in hash value computation)
140 XftFtFile *file; /* face source */
144 FT_F26Dot6 xsize, ysize; /* pixel size */
145 FcBool antialias; /* doing antialiasing */
146 FcBool embolden; /* force emboldening */
147 int rgba; /* subpixel order */
148 FT_Matrix matrix; /* glyph transformation matrix */
149 FcBool transform; /* non-identify matrix? */
150 FT_Int load_flags; /* glyph load flags */
151 FcBool render; /* whether to use the Render extension */
161 * Internal version of the font with private data
164 typedef struct _XftFontInt {
165 XftFont public; /* public fields */
166 XftFont *next; /* all fonts on display */
167 XftFont *hash_next; /* fonts in this hash chain */
168 XftFontInfo info; /* Data from pattern */
169 int ref; /* reference count */
171 * Per-glyph information, indexed by glyph ID
172 * This array follows the font in memory
175 int num_glyphs; /* size of glyphs/bitmaps arrays */
177 * Hash table to get from Unicode value to glyph ID
178 * This array follows the glyphs in memory
180 XftUcsHash *hash_table;
186 GlyphSet glyphset; /* Render glyphset */
187 XRenderPictFormat *format; /* Render format for glyphs */
189 * Glyph memory management fields
191 unsigned long glyph_memory;
192 unsigned long max_glyph_memory;
193 FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
196 typedef enum _XftClipType {
197 XftClipTypeNone, XftClipTypeRegion, XftClipTypeRectangles
200 typedef struct _XftClipRect {
206 #define XftClipRects(cr) ((XRectangle *) ((cr) + 1))
208 typedef union _XftClip {
216 unsigned int bits_per_pixel;
219 Visual *visual; /* NULL for bitmaps */
221 XftClipType clip_type;
234 * Instead of taking two round trips for each blending request,
235 * assume that if a particular drawable fails GetImage that it will
236 * fail for a "while"; use temporary pixmaps to avoid the errors
239 #define XFT_ASSUME_PIXMAP 20
241 typedef struct _XftSolidColor {
247 #define XFT_NUM_SOLID_COLOR 16
249 #define XFT_NUM_FONT_HASH 127
251 typedef struct _XftDisplayInfo {
252 struct _XftDisplayInfo *next;
258 XRenderPictFormat *solidFormat;
259 unsigned long glyph_memory;
260 unsigned long max_glyph_memory;
261 FcBool use_free_glyphs;
264 XftSolidColor colors[XFT_NUM_SOLID_COLOR];
265 XftFont *fontHash[XFT_NUM_FONT_HASH];
269 * By default, use no more than 4 meg of server memory total, and no
270 * more than 1 meg for any one font
272 #define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
273 #define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
276 * By default, keep the last 16 unreferenced fonts around to
277 * speed reopening them. Note that the glyph caching code
278 * will keep the global memory usage reasonably limited
280 #define XFT_DPY_MAX_UNREF_FONTS 16
282 extern XftDisplayInfo *_XftDisplayInfo;
284 #define XFT_DBG_OPEN 1
285 #define XFT_DBG_OPENV 2
286 #define XFT_DBG_RENDER 4
287 #define XFT_DBG_DRAW 8
288 #define XFT_DBG_REF 16
289 #define XFT_DBG_GLYPH 32
290 #define XFT_DBG_GLYPHV 64
291 #define XFT_DBG_CACHE 128
292 #define XFT_DBG_CACHEV 256
293 #define XFT_DBG_MEMORY 512
295 #define XFT_MEM_DRAW 0
296 #define XFT_MEM_FONT 1
297 #define XFT_MEM_FILE 2
298 #define XFT_MEM_GLYPH 3
299 #define XFT_MEM_NUM 4
302 void XftFontSetDestroy (FcFontSet *s);
303 FcBool XftMatrixEqual (_Xconst FcMatrix *mat1, _Xconst FcMatrix *mat2);
304 void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
305 void XftMatrixRotate (FcMatrix *m, double c, double s);
306 void XftMatrixScale (FcMatrix *m, double sx, double sy);
307 void XftMatrixShear (FcMatrix *m, double sh, double sv);
308 FcPattern *XftPatternCreate (void);
309 void XftValueDestroy (FcValue v);
310 void XftPatternDestroy (FcPattern *p);
311 FcBool XftPatternAdd (FcPattern *p, _Xconst char *object, FcValue value, FcBool append);
312 FcBool XftPatternDel (FcPattern *p, _Xconst char *object);
313 FcBool XftPatternAddInteger (FcPattern *p, _Xconst char *object, int i);
314 FcBool XftPatternAddDouble (FcPattern *p, _Xconst char *object, double i);
315 FcBool XftPatternAddMatrix (FcPattern *p, _Xconst char *object, FcMatrix *i);
316 FcBool XftPatternAddString (FcPattern *p, _Xconst char *object, char *i);
317 FcBool XftPatternAddBool (FcPattern *p, _Xconst char *object, FcBool i);
318 FcResult XftPatternGet (FcPattern *p, _Xconst char *object, int id, FcValue *v);
319 FcResult XftPatternGetInteger (FcPattern *p, _Xconst char *object, int id, int *i);
320 FcResult XftPatternGetDouble (FcPattern *p, _Xconst char *object, int id, double *i);
321 FcResult XftPatternGetString (FcPattern *p, _Xconst char *object, int id, char **i);
322 FcResult XftPatternGetMatrix (FcPattern *p, _Xconst char *object, int id, FcMatrix **i);
323 FcResult XftPatternGetBool (FcPattern *p, _Xconst char *object, int id, FcBool *i);
324 FcPattern *XftPatternDuplicate (FcPattern *orig);
325 FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
326 FcPattern *XftPatternBuild (FcPattern *orig, ...);
327 FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
328 FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
329 FcObjectSet *XftObjectSetCreate (void);
330 Bool XftObjectSetAdd (FcObjectSet *os, _Xconst char *object);
331 void XftObjectSetDestroy (FcObjectSet *os);
332 FcObjectSet *XftObjectSetVaBuild (_Xconst char *first, va_list va);
333 FcObjectSet *XftObjectSetBuild (_Xconst char *first, ...);
334 FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
338 XftRectCore (XftDraw *draw,
339 _Xconst XftColor *color,
343 unsigned int height);
346 XftGlyphCore (XftDraw *draw,
347 _Xconst XftColor *color,
351 _Xconst FT_UInt *glyphs,
355 XftGlyphSpecCore (XftDraw *draw,
356 _Xconst XftColor *color,
358 _Xconst XftGlyphSpec *glyphs,
362 XftGlyphFontSpecCore (XftDraw *draw,
363 _Xconst XftColor *color,
364 _Xconst XftGlyphFontSpec *glyphs,
373 _XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary);
376 _XftDisplayManageMemory (Display *dpy);
379 XftDefaultParseBool (char *v);
382 XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
385 XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
388 XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
391 XftDisplayGetFontSet (Display *dpy);
395 XftDrawDepth (XftDraw *draw);
398 XftDrawBitsPerPixel (XftDraw *draw);
401 XftDrawRenderPrepare (XftDraw *draw);
409 _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix);
412 XftFontManageMemory (Display *dpy);
416 _XftFontUncacheGlyph (Display *dpy, XftFont *public);
419 _XftFontManageMemory (Display *dpy, XftFont *public);
426 XftMemAlloc (int kind, int size);
429 XftMemFree (int kind, int size);
433 XftListFontsPatternObjects (Display *dpy,
446 _XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
450 XftNativeByteOrder (void);
453 XftSwapCARD32 (CARD32 *data, int n);
456 XftSwapCARD24 (CARD8 *data, int width, int height);
459 XftSwapCARD16 (CARD16 *data, int n);
462 XftSwapImage (XImage *image);
465 #endif /* _XFT_INT_H_ */