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