2 * Copyright 1992, 1993 by TOSHIBA Corp.
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of TOSHIBA not be used in advertising
9 * or publicity pertaining to distribution of the software without specific,
10 * written prior permission. TOSHIBA make no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
14 * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 * Author: Katsuhisa Yano TOSHIBA Corp.
23 * mopi@osa.ilab.toshiba.co.jp
26 * Copyright 1995 by FUJITSU LIMITED
27 * This is source code modified by FUJITSU LIMITED under the Joint
28 * Development Agreement for the CDE/Motif PST.
35 #include "XomGeneric.h"
38 /* For VW/UDC start */
49 XOCGenericPart *gen = XOC_GENERIC(oc);
55 font_set = gen->font_set;
56 font_set_count = gen->font_set_num;
57 for( ; font_set_count-- ; font_set++) {
58 if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
59 vrotate = font_set->vrotate;
60 vrotate_num = font_set->vrotate_num;
61 for( ; vrotate_num-- ; vrotate++)
62 if(vrotate->font == font)
74 XOCGenericPart *gen = XOC_GENERIC(oc);
80 font_set = gen->font_set;
81 font_set_count = gen->font_set_num;
82 for( ; font_set_count-- ; font_set++) {
83 if(font_set->vmap_num > 0) {
84 vmap = font_set->vmap;
85 vmap_num = font_set->vmap_num;
86 for( ; vmap_num-- ; vmap++)
87 if(vmap->font == font)
104 int escapement = 0, i;
107 for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
108 if(is_rotate(oc, font) == True) {
109 escapement += _XTextHeight16(font, buf2b, 1);
111 escapement += (int) (font->max_bounds.ascent +
112 font->max_bounds.descent);
116 for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
117 if(is_rotate(oc, font) == True) {
118 escapement += _XTextHeight(font, buf, 1);
120 escapement += (int) (font->max_bounds.ascent +
121 font->max_bounds.descent);
130 TextWidthWithFontSet(
138 unsigned char *ptr = (unsigned char *)text;
140 int ptr_len = length;
141 int escapement = 0, char_len = 0;
143 if(font_set == (FontSet) NULL)
146 is_xchar2b = font_set->is_xchar2b;
149 fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
150 is_xchar2b, FONTSCOPE);
155 * First, see if the "Best Match" font for the FontSet was set.
156 * If it was, use that font. If it was not set, then use the
157 * font defined by font_set->font_data[0] (which is what
158 * _XomGetFontDataFromFontSet() always seems to return for
159 * non-VW text). Note that given the new algorithm in
160 * parse_fontname() and parse_fontdata(), fs->font will
161 * *always* contain good data. We should probably remove
162 * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
164 * Above comment and way this is done propagated from omText.c
165 * Note that fd->font is junk so using the result of the
166 * above call /needs/ to be ignored.
168 * Owen Taylor <otaylor@redhat.com> 12 Jul 2000
172 if(fd == (FontData) NULL ||
173 (font = font_set->font) == (XFontStruct *) NULL) {
175 if((font = fd->font) == (XFontStruct *) NULL)
179 switch(oc->core.orientation) {
180 case XOMOrientation_LTR_TTB:
181 case XOMOrientation_RTL_TTB:
183 char_len = ptr_len / sizeof(XChar2b);
184 escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
187 escapement += XTextWidth(font, (char *)ptr, char_len);
191 case XOMOrientation_TTB_LTR:
192 case XOMOrientation_TTB_RTL:
193 if(font_set->font == font) {
194 fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
198 if(fd == (FontData) NULL ||
199 (font = fd->font) == (XFontStruct *) NULL)
202 if(is_codemap(oc, fd->font) == False) {
203 fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
204 &ptr_len, is_xchar2b,
208 if(fd == (FontData) NULL ||
209 (font = fd->font) == (XFontStruct *) NULL)
215 char_len = ptr_len / sizeof(XChar2b);
218 escapement += escapement_vertical(oc, font, is_xchar2b,
219 (XPointer) ptr, char_len);
222 case XOMOrientation_Context:
240 _XomGenericTextEscapement(
253 XChar2b xchar2b_buf[BUFSIZ], *buf;
255 int buf_len = 0, left = 0;
257 conv = _XomInitConverter(oc, type);
261 args[0] = (XPointer) &font;
262 args[1] = (XPointer) &is_xchar2b;
263 args[2] = (XPointer) &font_set;
267 left = buf_len = BUFSIZ;
269 if (_XomConvert(oc, conv, (XPointer *) &text, &length,
270 (XPointer *) &buf, &left, args, 3) < 0)
275 escapement += TextWidthWithFontSet(font_set, oc,
276 (XPointer) xchar2b_buf, buf_len);
284 _XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
286 return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
290 _XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
292 return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
296 _Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
298 return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,