1/*
2
3Copyright 1991, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28
29/*
30 * Copyright 1991 by the Open Software Foundation
31 *
32 * Permission to use, copy, modify, distribute, and sell this software and its
33 * documentation for any purpose is hereby granted without fee, provided that
34 * the above copyright notice appear in all copies and that both that
35 * copyright notice and this permission notice appear in supporting
36 * documentation, and that the name of Open Software Foundation
37 * not be used in advertising or publicity pertaining to distribution of the
38 * software without specific, written prior permission.  Open Software
39 * Foundation makes no representations about the suitability of this
40 * software for any purpose.  It is provided "as is" without express or
41 * implied warranty.
42 *
43 * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
44 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
45 * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE
46 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
47 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
48 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
49 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
50 *
51 *		 M. Collins		OSF
52 */
53
54#ifdef HAVE_CONFIG_H
55#include <config.h>
56#endif
57#include "Xlibint.h"
58#include "Xlcint.h"
59
60void
61XwcDrawText(
62    Display            *dpy,
63    Drawable            d,
64    GC                  gc,
65    int                 x,
66    int                 y,
67    XwcTextItem        *text_items,
68    int                 nitems)
69{
70    register XFontSet fs = NULL;
71    register XwcTextItem *p = text_items;
72    register int i = nitems;
73    register int esc;
74
75    /* ignore leading items with no fontset */
76    while (i && !p->font_set) {
77	i--;
78	p++;
79    }
80
81    for (; --i >= 0; p++) {
82	if (p->font_set)
83	    fs = p->font_set;
84	x += p->delta;
85	esc = (*fs->methods->wc_draw_string) (dpy, d, fs, gc, x, y,
86					      p->chars, p->nchars);
87	if (!esc)
88	    esc = fs->methods->wc_escapement (fs, p->chars, p->nchars);
89	x += esc;
90    }
91}
92
93void
94XwcDrawString(
95    Display            *dpy,
96    Drawable            d,
97    XFontSet            font_set,
98    GC                  gc,
99    int                 x,
100    int                 y,
101    _Xconst wchar_t    *text,
102    int                 text_len)
103{
104    (void)(*font_set->methods->wc_draw_string) (dpy, d, font_set, gc, x, y,
105						text, text_len);
106}
107
108void
109XwcDrawImageString(
110    Display            *dpy,
111    Drawable            d,
112    XFontSet            font_set,
113    GC                  gc,
114    int                 x,
115    int                 y,
116    _Xconst wchar_t    *text,
117    int                 text_len)
118{
119    (*font_set->methods->wc_draw_image_string) (dpy, d, font_set, gc, x, y,
120						text, text_len);
121}
122
123int
124XwcTextEscapement(
125    XFontSet            font_set,
126    _Xconst wchar_t    *text,
127    int                 text_len)
128{
129    return (*font_set->methods->wc_escapement) (font_set, text, text_len);
130}
131
132int
133XwcTextExtents(
134    XFontSet            font_set,
135    _Xconst wchar_t    *text,
136    int                 text_len,
137    XRectangle         *overall_ink_extents,
138    XRectangle         *overall_logical_extents)
139{
140    return (*font_set->methods->wc_extents) (font_set, text, text_len,
141					     overall_ink_extents,
142					     overall_logical_extents);
143}
144
145Status
146XwcTextPerCharExtents(
147    XFontSet            font_set,
148    _Xconst wchar_t    *text,
149    int                 text_len,
150    XRectangle         *ink_extents_buffer,
151    XRectangle         *logical_extents_buffer,
152    int                 buffer_size,
153    int                *num_chars,
154    XRectangle         *max_ink_extents,
155    XRectangle         *max_logical_extents)
156{
157    return (*font_set->methods->wc_extents_per_char)
158	      (font_set, text, text_len,
159	       ink_extents_buffer, logical_extents_buffer,
160	       buffer_size, num_chars, max_ink_extents, max_logical_extents);
161}
162