1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
/*
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* These definitions are solely for use by the implementation of Xft
* and constitute no kind of standard. If you need any of these functions,
* please drop me a note. Either the library needs new functionality,
* or there's a way to do what you need using the existing published
* interfaces. keithp@xfree86.org
*/
#ifndef _XFTINT_H_
#define _XFTINT_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#define _XFT_NO_COMPAT_
#include "Xft.h"
#include <fontconfig/fcprivate.h>
#include <fontconfig/fcfreetype.h>
typedef struct _XftMatcher {
char *object;
double (*compare) (char *object, FcValue value1, FcValue value2);
} XftMatcher;
typedef struct _XftSymbolic {
const char *name;
int value;
} XftSymbolic;
/*
* Glyphs are stored in this structure
*/
typedef struct _XftGlyph {
XGlyphInfo metrics;
void *bitmap;
unsigned long glyph_memory;
} XftGlyph;
/*
* A hash table translates Unicode values into glyph indicies
*/
typedef struct _XftUcsHash {
FcChar32 ucs4;
FT_UInt glyph;
} XftUcsHash;
/*
* Many fonts can share the same underlying face data; this
* structure references that. Note that many faces may in fact
* live in the same font file; that is irrelevant to this structure
* which is concerned only with the individual faces themselves
*/
typedef struct _XftFtFile {
struct _XftFtFile *next;
int ref; /* number of font infos using this file */
char *file; /* file name */
int id; /* font index within that file */
FT_F26Dot6 xsize; /* current xsize setting */
FT_F26Dot6 ysize; /* current ysize setting */
FT_Matrix matrix; /* current matrix setting */
int lock; /* lock count; can't unload unless 0 */
FT_Face face; /* pointer to face; only valid when lock */
} XftFtFile;
/*
* This structure holds the data extracted from a pattern
* needed to create a unique font object.
*/
struct _XftFontInfo {
/*
* Hash value (not include in hash value computation)
*/
FcChar32 hash;
XftFtFile *file; /* face source */
/*
* Rendering options
*/
FT_F26Dot6 xsize, ysize; /* pixel size */
FcBool antialias; /* doing antialiasing */
int rgba; /* subpixel order */
FT_Matrix matrix; /* glyph transformation matrix */
FcBool transform; /* non-identify matrix? */
FT_Int load_flags; /* glyph load flags */
FcBool render; /* whether to use the Render extension */
/*
* Internal fields
*/
int spacing;
FcBool minspace;
int char_width;
};
/*
* Internal version of the font with private data
*/
typedef struct _XftFontInt {
XftFont public; /* public fields */
XftFont *next; /* all fonts on display */
XftFont *hash_next; /* fonts in this hash chain */
XftFontInfo info; /* Data from pattern */
int ref; /* reference count */
/*
* Per-glyph information, indexed by glyph ID
* This array follows the font in memory
*/
XftGlyph **glyphs;
int num_glyphs; /* size of glyphs/bitmaps arrays */
/*
* Hash table to get from Unicode value to glyph ID
* This array follows the glyphs in memory
*/
XftUcsHash *hash_table;
int hash_value;
int rehash_value;
/*
* X specific fields
*/
GlyphSet glyphset; /* Render glyphset */
XRenderPictFormat *format; /* Render format for glyphs */
/*
* Glyph memory management fields
*/
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs; /* Use XRenderFreeGlyphs */
} XftFontInt;
typedef enum _XftClipType {
XftClipTypeNone, XftClipTypeRegion, XftClipTypeRectangles
} XftClipType;
typedef struct _XftClipRect {
int xOrigin;
int yOrigin;
int n;
} XftClipRect;
#define XftClipRects(cr) ((XRectangle *) ((cr) + 1))
typedef union _XftClip {
XftClipRect *rect;
Region region;
} XftClip;
struct _XftDraw {
Display *dpy;
int screen;
unsigned int bits_per_pixel;
unsigned int depth;
Drawable drawable;
Visual *visual; /* NULL for bitmaps */
Colormap colormap;
XftClipType clip_type;
XftClip clip;
int subwindow_mode;
struct {
Picture pict;
} render;
struct {
GC gc;
int use_pixmap;
} core;
};
/*
* Instead of taking two round trips for each blending request,
* assume that if a particular drawable fails GetImage that it will
* fail for a "while"; use temporary pixmaps to avoid the errors
*/
#define XFT_ASSUME_PIXMAP 20
typedef struct _XftSolidColor {
XRenderColor color;
int screen;
Picture pict;
} XftSolidColor;
#define XFT_NUM_SOLID_COLOR 16
#define XFT_NUM_FONT_HASH 127
typedef struct _XftDisplayInfo {
struct _XftDisplayInfo *next;
Display *display;
XExtCodes *codes;
FcPattern *defaults;
FcBool hasRender;
XftFont *fonts;
XRenderPictFormat *solidFormat;
unsigned long glyph_memory;
unsigned long max_glyph_memory;
FcBool use_free_glyphs;
int num_unref_fonts;
int max_unref_fonts;
XftSolidColor colors[XFT_NUM_SOLID_COLOR];
XftFont *fontHash[XFT_NUM_FONT_HASH];
} XftDisplayInfo;
/*
* By default, use no more than 4 meg of server memory total, and no
* more than 1 meg for any one font
*/
#define XFT_DPY_MAX_GLYPH_MEMORY (4 * 1024 * 1024)
#define XFT_FONT_MAX_GLYPH_MEMORY (1024 * 1024)
/*
* By default, keep the last 16 unreferenced fonts around to
* speed reopening them. Note that the glyph caching code
* will keep the global memory usage reasonably limited
*/
#define XFT_DPY_MAX_UNREF_FONTS 16
extern XftDisplayInfo *_XftDisplayInfo;
#define XFT_DBG_OPEN 1
#define XFT_DBG_OPENV 2
#define XFT_DBG_RENDER 4
#define XFT_DBG_DRAW 8
#define XFT_DBG_REF 16
#define XFT_DBG_GLYPH 32
#define XFT_DBG_GLYPHV 64
#define XFT_DBG_CACHE 128
#define XFT_DBG_CACHEV 256
#define XFT_DBG_MEMORY 512
#define XFT_MEM_DRAW 0
#define XFT_MEM_FONT 1
#define XFT_MEM_FILE 2
#define XFT_MEM_GLYPH 3
#define XFT_MEM_NUM 4
/* xftcompat.c */
void XftFontSetDestroy (FcFontSet *s);
FcBool XftMatrixEqual (_Xconst FcMatrix *mat1, _Xconst FcMatrix *mat2);
void XftMatrixMultiply (FcMatrix *result, FcMatrix *a, FcMatrix *b);
void XftMatrixRotate (FcMatrix *m, double c, double s);
void XftMatrixScale (FcMatrix *m, double sx, double sy);
void XftMatrixShear (FcMatrix *m, double sh, double sv);
FcPattern *XftPatternCreate (void);
void XftValueDestroy (FcValue v);
void XftPatternDestroy (FcPattern *p);
FcBool XftPatternAdd (FcPattern *p, _Xconst char *object, FcValue value, FcBool append);
FcBool XftPatternDel (FcPattern *p, _Xconst char *object);
FcBool XftPatternAddInteger (FcPattern *p, _Xconst char *object, int i);
FcBool XftPatternAddDouble (FcPattern *p, _Xconst char *object, double i);
FcBool XftPatternAddMatrix (FcPattern *p, _Xconst char *object, FcMatrix *i);
FcBool XftPatternAddString (FcPattern *p, _Xconst char *object, char *i);
FcBool XftPatternAddBool (FcPattern *p, _Xconst char *object, FcBool i);
FcResult XftPatternGet (FcPattern *p, _Xconst char *object, int id, FcValue *v);
FcResult XftPatternGetInteger (FcPattern *p, _Xconst char *object, int id, int *i);
FcResult XftPatternGetDouble (FcPattern *p, _Xconst char *object, int id, double *i);
FcResult XftPatternGetString (FcPattern *p, _Xconst char *object, int id, char **i);
FcResult XftPatternGetMatrix (FcPattern *p, _Xconst char *object, int id, FcMatrix **i);
FcResult XftPatternGetBool (FcPattern *p, _Xconst char *object, int id, FcBool *i);
FcPattern *XftPatternDuplicate (FcPattern *orig);
FcPattern *XftPatternVaBuild (FcPattern *orig, va_list va);
FcPattern *XftPatternBuild (FcPattern *orig, ...);
FcBool XftNameUnparse (FcPattern *pat, char *dest, int len);
FcBool XftGlyphExists (Display *dpy, XftFont *font, FcChar32 ucs4);
FcObjectSet *XftObjectSetCreate (void);
Bool XftObjectSetAdd (FcObjectSet *os, _Xconst char *object);
void XftObjectSetDestroy (FcObjectSet *os);
FcObjectSet *XftObjectSetVaBuild (_Xconst char *first, va_list va);
FcObjectSet *XftObjectSetBuild (_Xconst char *first, ...);
FcFontSet *XftListFontSets (FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os);
/* xftcore.c */
void
XftRectCore (XftDraw *draw,
_Xconst XftColor *color,
int x,
int y,
unsigned int width,
unsigned int height);
void
XftGlyphCore (XftDraw *draw,
_Xconst XftColor *color,
XftFont *public,
int x,
int y,
_Xconst FT_UInt *glyphs,
int nglyphs);
void
XftGlyphSpecCore (XftDraw *draw,
_Xconst XftColor *color,
XftFont *public,
_Xconst XftGlyphSpec *glyphs,
int nglyphs);
void
XftGlyphFontSpecCore (XftDraw *draw,
_Xconst XftColor *color,
_Xconst XftGlyphFontSpec *glyphs,
int nglyphs);
/* xftdbg.c */
int
XftDebug (void);
/* xftdpy.c */
XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary);
void
_XftDisplayManageMemory (Display *dpy);
int
XftDefaultParseBool (char *v);
FcBool
XftDefaultGetBool (Display *dpy, const char *object, int screen, FcBool def);
int
XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
double
XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
FcFontSet *
XftDisplayGetFontSet (Display *dpy);
/* xftdraw.c */
unsigned int
XftDrawDepth (XftDraw *draw);
unsigned int
XftDrawBitsPerPixel (XftDraw *draw);
FcBool
XftDrawRenderPrepare (XftDraw *draw);
/* xftextent.c */
/* xftfont.c */
/* xftfreetype.c */
FcBool
_XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix);
void
XftFontManageMemory (Display *dpy);
/* xftglyph.c */
void
_XftFontUncacheGlyph (Display *dpy, XftFont *public);
void
_XftFontManageMemory (Display *dpy, XftFont *public);
/* xftinit.c */
void
XftMemReport (void);
void
XftMemAlloc (int kind, int size);
void
XftMemFree (int kind, int size);
/* xftlist.c */
FcFontSet *
XftListFontsPatternObjects (Display *dpy,
int screen,
FcPattern *pattern,
FcObjectSet *os);
/* xftname.c */
void
_XftNameInit (void);
/* xftrender.c */
/* xftstr.c */
int
_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
/* xftswap.c */
int
XftNativeByteOrder (void);
void
XftSwapCARD32 (CARD32 *data, int n);
void
XftSwapCARD24 (CARD8 *data, int width, int height);
void
XftSwapCARD16 (CARD16 *data, int n);
void
XftSwapImage (XImage *image);
/* xftxlfd.c */
#endif /* _XFT_INT_H_ */
|