2
* $XFree86: xc/lib/Xft1/xftrender.c,v 1.1.1.1 2002/02/15 01:26:15 keithp Exp $
4
* Copyright � 2000 Keith Packard, member of The XFree86 Project, Inc.
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.
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.
29
XftRenderString8 (Display *dpy, Picture src,
30
XftFontStruct *font, Picture dst,
33
XftChar8 *string, int len)
35
XftChar32 missing[XFT_NMISSING];
44
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
46
XftGlyphLoad (dpy, font, missing, nmissing);
47
XRenderCompositeString8 (dpy, PictOpOver, src, dst,
48
font->format, font->glyphset,
49
srcx, srcy, x, y, (char *) string, len);
53
XftRenderString16 (Display *dpy, Picture src,
54
XftFontStruct *font, Picture dst,
57
XftChar16 *string, int len)
59
XftChar32 missing[XFT_NMISSING];
68
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
70
XftGlyphLoad (dpy, font, missing, nmissing);
71
XRenderCompositeString16 (dpy, PictOpOver, src, dst,
72
font->format, font->glyphset,
73
srcx, srcy, x, y, string, len);
77
XftRenderString32 (Display *dpy, Picture src,
78
XftFontStruct *font, Picture dst,
81
XftChar32 *string, int len)
83
XftChar32 missing[XFT_NMISSING];
92
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
94
XftGlyphLoad (dpy, font, missing, nmissing);
95
XRenderCompositeString32 (dpy, PictOpOver, src, dst,
96
font->format, font->glyphset,
97
srcx, srcy, x, y, string, len);
101
XftRenderStringUtf8 (Display *dpy, Picture src,
102
XftFontStruct *font, Picture dst,
105
XftChar8 *string, int len)
109
XftChar32 lbuf[4096];
118
/* compute needed width */
119
if (!XftUtf8Len (string, len, &n, &width))
123
if (n * width > sizeof (lbuf))
125
d = (XftChar32 *) malloc (n * width);
137
clen = XftUtf8ToUcs4 (s, &c, rlen);
138
if (clen <= 0) /* malformed UTF8 string */
145
XftRenderString32 (dpy, src, font, dst, srcx, srcy, x, y,
151
dst16 = (XftChar16 *) d;
154
clen = XftUtf8ToUcs4 (s, &c, rlen);
155
if (clen <= 0) /* malformed UTF8 string */
161
dst16 = (XftChar16 *) d;
162
XftRenderString16 (dpy, src, font, dst, srcx, srcy, x, y,
168
dst8 = (XftChar8 *) d;
171
clen = XftUtf8ToUcs4 (s, &c, rlen);
172
if (clen <= 0) /* malformed UTF8 string */
178
dst8 = (XftChar8 *) d;
179
XftRenderString8 (dpy, src, font, dst, srcx, srcy, x, y,
188
XftRenderExtents8 (Display *dpy,
194
XftChar32 missing[XFT_NMISSING];
200
int left, right, top, bottom;
201
int overall_left, overall_right;
202
int overall_top, overall_bottom;
208
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
210
XftGlyphLoad (dpy, font, missing, nmissing);
217
gi = c < font->nrealized ? font->realized[c] : 0;
233
overall_left = x - gi->x;
234
overall_top = y - gi->y;
235
overall_right = overall_left + (int) gi->width;
236
overall_bottom = overall_top + (int) gi->height;
242
gi = c < font->nrealized ? font->realized[c] : 0;
247
right = left + (int) gi->width;
248
bottom = top + (int) gi->height;
249
if (left < overall_left)
251
if (top < overall_top)
253
if (right > overall_right)
254
overall_right = right;
255
if (bottom > overall_bottom)
256
overall_bottom = bottom;
260
extents->x = -overall_left;
261
extents->y = -overall_top;
262
extents->width = overall_right - overall_left;
263
extents->height = overall_bottom - overall_top;
269
XftRenderExtents16 (Display *dpy,
275
XftChar32 missing[XFT_NMISSING];
281
int left, right, top, bottom;
282
int overall_left, overall_right;
283
int overall_top, overall_bottom;
289
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
291
XftGlyphLoad (dpy, font, missing, nmissing);
298
gi = c < font->nrealized ? font->realized[c] : 0;
314
overall_left = x - gi->x;
315
overall_top = y - gi->y;
316
overall_right = overall_left + (int) gi->width;
317
overall_bottom = overall_top + (int) gi->height;
323
gi = c < font->nrealized ? font->realized[c] : 0;
328
right = left + (int) gi->width;
329
bottom = top + (int) gi->height;
330
if (left < overall_left)
332
if (top < overall_top)
334
if (right > overall_right)
335
overall_right = right;
336
if (bottom > overall_bottom)
337
overall_bottom = bottom;
341
extents->x = -overall_left;
342
extents->y = -overall_top;
343
extents->width = overall_right - overall_left;
344
extents->height = overall_bottom - overall_top;
350
XftRenderExtents32 (Display *dpy,
356
XftChar32 missing[XFT_NMISSING];
362
int left, right, top, bottom;
363
int overall_left, overall_right;
364
int overall_top, overall_bottom;
370
XftGlyphCheck (dpy, font, (XftChar32) *s++, missing, &nmissing);
372
XftGlyphLoad (dpy, font, missing, nmissing);
379
gi = c < font->nrealized ? font->realized[c] : 0;
395
overall_left = x - gi->x;
396
overall_top = y - gi->y;
397
overall_right = overall_left + (int) gi->width;
398
overall_bottom = overall_top + (int) gi->height;
404
gi = c < font->nrealized ? font->realized[c] : 0;
409
right = left + (int) gi->width;
410
bottom = top + (int) gi->height;
411
if (left < overall_left)
413
if (top < overall_top)
415
if (right > overall_right)
416
overall_right = right;
417
if (bottom > overall_bottom)
418
overall_bottom = bottom;
422
extents->x = -overall_left;
423
extents->y = -overall_top;
424
extents->width = overall_right - overall_left;
425
extents->height = overall_bottom - overall_top;
431
XftRenderExtentsUtf8 (Display *dpy,
437
XftChar32 missing[XFT_NMISSING];
444
int left, right, top, bottom;
445
int overall_left, overall_right;
446
int overall_top, overall_bottom;
453
clen = XftUtf8ToUcs4 (s, &c, l);
456
XftGlyphCheck (dpy, font, (XftChar32) c, missing, &nmissing);
461
XftGlyphLoad (dpy, font, missing, nmissing);
466
clen = XftUtf8ToUcs4 (string, &c, len);
474
gi = c < font->nrealized ? font->realized[c] : 0;
490
overall_left = x - gi->x;
491
overall_top = y - gi->y;
492
overall_right = overall_left + (int) gi->width;
493
overall_bottom = overall_top + (int) gi->height;
498
clen = XftUtf8ToUcs4 (string, &c, len);
503
gi = c < font->nrealized ? font->realized[c] : 0;
508
right = left + (int) gi->width;
509
bottom = top + (int) gi->height;
510
if (left < overall_left)
512
if (top < overall_top)
514
if (right > overall_right)
515
overall_right = right;
516
if (bottom > overall_bottom)
517
overall_bottom = bottom;
521
extents->x = -overall_left;
522
extents->y = -overall_top;
523
extents->width = overall_right - overall_left;
524
extents->height = overall_bottom - overall_top;