utf8Wrap.c revision b4ee4795
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 * Copyright 1991 by the Open Software Foundation 30 * 31 * Permission to use, copy, modify, distribute, and sell this software and its 32 * documentation for any purpose is hereby granted without fee, provided that 33 * the above copyright notice appear in all copies and that both that 34 * copyright notice and this permission notice appear in supporting 35 * documentation, and that the name of Open Software Foundation 36 * not be used in advertising or publicity pertaining to distribution of the 37 * software without specific, written prior permission. Open Software 38 * Foundation makes no representations about the suitability of this 39 * software for any purpose. It is provided "as is" without express or 40 * implied warranty. 41 * 42 * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO 43 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 44 * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE 45 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 46 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 47 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 48 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 49 * 50 * M. Collins OSF 51 */ 52/* 53 * Copyright 2000 by Bruno Haible 54 * 55 * Permission to use, copy, modify, distribute, and sell this software 56 * and its documentation for any purpose is hereby granted without fee, 57 * provided that the above copyright notice appear in all copies and 58 * that both that copyright notice and this permission notice appear 59 * in supporting documentation, and that the name of Bruno Haible not 60 * be used in advertising or publicity pertaining to distribution of the 61 * software without specific, written prior permission. Bruno Haible 62 * makes no representations about the suitability of this software for 63 * any purpose. It is provided "as is" without express or implied 64 * warranty. 65 * 66 * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 67 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 68 * NO EVENT SHALL Bruno Haible BE LIABLE FOR ANY SPECIAL, INDIRECT OR 69 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 70 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 71 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 72 * OR PERFORMANCE OF THIS SOFTWARE. 73 */ 74 75#ifdef HAVE_CONFIG_H 76#include <config.h> 77#endif 78#include "Xlibint.h" 79#include "Xlcint.h" 80 81void 82Xutf8DrawText( 83 Display *dpy, 84 Drawable d, 85 GC gc, 86 int x, 87 int y, 88 XmbTextItem *text_items, 89 int nitems) 90{ 91 register XFontSet fs = NULL; 92 register XmbTextItem *p = text_items; 93 register int i = nitems; 94 register int esc; 95 96 /* ignore leading items with no fontset */ 97 while (i && !p->font_set) { 98 i--; 99 p++; 100 } 101 102 for (; --i >= 0; p++) { 103 if (p->font_set) 104 fs = p->font_set; 105 x += p->delta; 106 esc = (*fs->methods->utf8_draw_string) (dpy, d, fs, gc, x, y, 107 p->chars, p->nchars); 108 if (!esc) 109 esc = fs->methods->utf8_escapement (fs, p->chars, p->nchars); 110 x += esc; 111 } 112} 113 114void 115Xutf8DrawString( 116 Display *dpy, 117 Drawable d, 118 XFontSet font_set, 119 GC gc, 120 int x, 121 int y, 122 _Xconst char *text, 123 int text_len) 124{ 125 (void)(*font_set->methods->utf8_draw_string) (dpy, d, font_set, gc, x, y, 126 (char *)text, text_len); 127} 128 129 130void 131Xutf8DrawImageString( 132 Display *dpy, 133 Drawable d, 134 XFontSet font_set, 135 GC gc, 136 int x, 137 int y, 138 _Xconst char *text, 139 int text_len) 140{ 141 (*font_set->methods->utf8_draw_image_string) (dpy, d, font_set, gc, x, y, 142 (char *)text, text_len); 143} 144 145int 146Xutf8TextEscapement( 147 XFontSet font_set, 148 _Xconst char *text, 149 int text_len) 150{ 151 return (*font_set->methods->utf8_escapement) (font_set, 152 (char *)text, text_len); 153} 154 155int 156Xutf8TextExtents( 157 XFontSet font_set, 158 _Xconst char *text, 159 int text_len, 160 XRectangle *overall_ink_extents, 161 XRectangle *overall_logical_extents) 162{ 163 return (*font_set->methods->utf8_extents) (font_set, 164 (char *)text, text_len, 165 overall_ink_extents, 166 overall_logical_extents); 167} 168 169Status 170Xutf8TextPerCharExtents( 171 XFontSet font_set, 172 _Xconst char *text, 173 int text_len, 174 XRectangle *ink_extents_buffer, 175 XRectangle *logical_extents_buffer, 176 int buffer_size, 177 int *num_chars, 178 XRectangle *max_ink_extents, 179 XRectangle *max_logical_extents) 180{ 181 return (*font_set->methods->utf8_extents_per_char) 182 (font_set, (char *)text, text_len, 183 ink_extents_buffer, logical_extents_buffer, 184 buffer_size, num_chars, max_ink_extents, max_logical_extents); 185} 186