wcWrap.c revision 61b2299d
11ab64890Smrg/* $Xorg: wcWrap.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */ 21ab64890Smrg/* 31ab64890Smrg 41ab64890SmrgCopyright 1991, 1998 The Open Group 51ab64890Smrg 61ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its 71ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that 81ab64890Smrgthe above copyright notice appear in all copies and that both that 91ab64890Smrgcopyright notice and this permission notice appear in supporting 101ab64890Smrgdocumentation. 111ab64890Smrg 121ab64890SmrgThe above copyright notice and this permission notice shall be included 131ab64890Smrgin all copies or substantial portions of the Software. 141ab64890Smrg 151ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 161ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 171ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 181ab64890SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 191ab64890SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 201ab64890SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 211ab64890SmrgOTHER DEALINGS IN THE SOFTWARE. 221ab64890Smrg 231ab64890SmrgExcept as contained in this notice, the name of The Open Group shall 241ab64890Smrgnot be used in advertising or otherwise to promote the sale, use or 251ab64890Smrgother dealings in this Software without prior written authorization 261ab64890Smrgfrom The Open Group. 271ab64890Smrg 281ab64890Smrg*/ 291ab64890Smrg 301ab64890Smrg/* 311ab64890Smrg * Copyright 1991 by the Open Software Foundation 321ab64890Smrg * 331ab64890Smrg * Permission to use, copy, modify, distribute, and sell this software and its 341ab64890Smrg * documentation for any purpose is hereby granted without fee, provided that 351ab64890Smrg * the above copyright notice appear in all copies and that both that 361ab64890Smrg * copyright notice and this permission notice appear in supporting 371ab64890Smrg * documentation, and that the name of Open Software Foundation 381ab64890Smrg * not be used in advertising or publicity pertaining to distribution of the 391ab64890Smrg * software without specific, written prior permission. Open Software 401ab64890Smrg * Foundation makes no representations about the suitability of this 411ab64890Smrg * software for any purpose. It is provided "as is" without express or 421ab64890Smrg * implied warranty. 431ab64890Smrg * 441ab64890Smrg * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO 451ab64890Smrg * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 461ab64890Smrg * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE 4761b2299dSmrg * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 481ab64890Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 491ab64890Smrg * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 501ab64890Smrg * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 5161b2299dSmrg * 5261b2299dSmrg * M. Collins OSF 5361b2299dSmrg */ 541ab64890Smrg/* $XFree86: xc/lib/X11/wcWrap.c,v 1.6 2001/12/14 19:54:11 dawes Exp $ */ 551ab64890Smrg 561ab64890Smrg#ifdef HAVE_CONFIG_H 571ab64890Smrg#include <config.h> 581ab64890Smrg#endif 591ab64890Smrg#include "Xlibint.h" 601ab64890Smrg#include "Xlcint.h" 611ab64890Smrg 621ab64890Smrgvoid 631ab64890SmrgXwcDrawText( 641ab64890Smrg Display *dpy, 651ab64890Smrg Drawable d, 661ab64890Smrg GC gc, 671ab64890Smrg int x, 681ab64890Smrg int y, 691ab64890Smrg XwcTextItem *text_items, 701ab64890Smrg int nitems) 711ab64890Smrg{ 721ab64890Smrg register XFontSet fs = NULL; 731ab64890Smrg register XwcTextItem *p = text_items; 741ab64890Smrg register int i = nitems; 751ab64890Smrg register int esc; 761ab64890Smrg 771ab64890Smrg /* ignore leading items with no fontset */ 781ab64890Smrg while (i && !p->font_set) { 791ab64890Smrg i--; 801ab64890Smrg p++; 811ab64890Smrg } 821ab64890Smrg 831ab64890Smrg for (; --i >= 0; p++) { 841ab64890Smrg if (p->font_set) 851ab64890Smrg fs = p->font_set; 861ab64890Smrg x += p->delta; 871ab64890Smrg esc = (*fs->methods->wc_draw_string) (dpy, d, fs, gc, x, y, 881ab64890Smrg p->chars, p->nchars); 891ab64890Smrg if (!esc) 901ab64890Smrg esc = fs->methods->wc_escapement (fs, p->chars, p->nchars); 911ab64890Smrg x += esc; 921ab64890Smrg } 931ab64890Smrg} 941ab64890Smrg 951ab64890Smrgvoid 961ab64890SmrgXwcDrawString( 971ab64890Smrg Display *dpy, 981ab64890Smrg Drawable d, 991ab64890Smrg XFontSet font_set, 1001ab64890Smrg GC gc, 1011ab64890Smrg int x, 1021ab64890Smrg int y, 1031ab64890Smrg _Xconst wchar_t *text, 1041ab64890Smrg int text_len) 1051ab64890Smrg{ 1061ab64890Smrg (void)(*font_set->methods->wc_draw_string) (dpy, d, font_set, gc, x, y, 1071ab64890Smrg text, text_len); 1081ab64890Smrg} 1091ab64890Smrg 1101ab64890Smrgvoid 1111ab64890SmrgXwcDrawImageString( 1121ab64890Smrg Display *dpy, 1131ab64890Smrg Drawable d, 1141ab64890Smrg XFontSet font_set, 1151ab64890Smrg GC gc, 1161ab64890Smrg int x, 1171ab64890Smrg int y, 1181ab64890Smrg _Xconst wchar_t *text, 1191ab64890Smrg int text_len) 1201ab64890Smrg{ 1211ab64890Smrg (*font_set->methods->wc_draw_image_string) (dpy, d, font_set, gc, x, y, 1221ab64890Smrg text, text_len); 1231ab64890Smrg} 1241ab64890Smrg 12561b2299dSmrgint 1261ab64890SmrgXwcTextEscapement( 1271ab64890Smrg XFontSet font_set, 1281ab64890Smrg _Xconst wchar_t *text, 1291ab64890Smrg int text_len) 1301ab64890Smrg{ 1311ab64890Smrg return (*font_set->methods->wc_escapement) (font_set, text, text_len); 1321ab64890Smrg} 1331ab64890Smrg 1341ab64890Smrgint 1351ab64890SmrgXwcTextExtents( 1361ab64890Smrg XFontSet font_set, 1371ab64890Smrg _Xconst wchar_t *text, 1381ab64890Smrg int text_len, 1391ab64890Smrg XRectangle *overall_ink_extents, 1401ab64890Smrg XRectangle *overall_logical_extents) 1411ab64890Smrg{ 1421ab64890Smrg return (*font_set->methods->wc_extents) (font_set, text, text_len, 1431ab64890Smrg overall_ink_extents, 1441ab64890Smrg overall_logical_extents); 1451ab64890Smrg} 1461ab64890Smrg 1471ab64890SmrgStatus 1481ab64890SmrgXwcTextPerCharExtents( 1491ab64890Smrg XFontSet font_set, 1501ab64890Smrg _Xconst wchar_t *text, 1511ab64890Smrg int text_len, 1521ab64890Smrg XRectangle *ink_extents_buffer, 1531ab64890Smrg XRectangle *logical_extents_buffer, 1541ab64890Smrg int buffer_size, 1551ab64890Smrg int *num_chars, 1561ab64890Smrg XRectangle *max_ink_extents, 1571ab64890Smrg XRectangle *max_logical_extents) 1581ab64890Smrg{ 15961b2299dSmrg return (*font_set->methods->wc_extents_per_char) 16061b2299dSmrg (font_set, text, text_len, 1611ab64890Smrg ink_extents_buffer, logical_extents_buffer, 1621ab64890Smrg buffer_size, num_chars, max_ink_extents, max_logical_extents); 1631ab64890Smrg} 164