1
/* $Xorg: omTextEsc.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
3
* Copyright 1992, 1993 by TOSHIBA Corp.
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation for any purpose and without fee is hereby granted, provided
7
* that the above copyright notice appear in all copies and that both that
8
* copyright notice and this permission notice appear in supporting
9
* documentation, and that the name of TOSHIBA not be used in advertising
10
* or publicity pertaining to distribution of the software without specific,
11
* written prior permission. TOSHIBA make no representations about the
12
* suitability of this software for any purpose. It is provided "as is"
13
* without express or implied warranty.
15
* TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17
* TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23
* Author: Katsuhisa Yano TOSHIBA Corp.
24
* mopi@osa.ilab.toshiba.co.jp
26
/* $XFree86: xc/lib/X11/omTextEsc.c,v 1.5 2001/01/17 19:41:56 dawes Exp $ */
28
* Copyright 1995 by FUJITSU LIMITED
29
* This is source code modified by FUJITSU LIMITED under the Joint
30
* Development Agreement for the CDE/Motif PST.
34
#include "XomGeneric.h"
37
/* For VW/UDC start */
48
XOCGenericPart *gen = XOC_GENERIC(oc);
54
font_set = gen->font_set;
55
font_set_count = gen->font_set_num;
56
for( ; font_set_count-- ; font_set++) {
57
if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
58
vrotate = font_set->vrotate;
59
vrotate_num = font_set->vrotate_num;
60
for( ; vrotate_num-- ; vrotate++)
61
if(vrotate->font == font)
73
XOCGenericPart *gen = XOC_GENERIC(oc);
79
font_set = gen->font_set;
80
font_set_count = gen->font_set_num;
81
for( ; font_set_count-- ; font_set++) {
82
if(font_set->vmap_num > 0) {
83
vmap = font_set->vmap;
84
vmap_num = font_set->vmap_num;
85
for( ; vmap_num-- ; vmap++)
86
if(vmap->font == font)
94
escapement_vertical(oc, font, is_xchar2b, text, length)
103
int escapement = 0, i;
106
for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
107
if(is_rotate(oc, font) == True) {
108
escapement += _XTextHeight16(font, buf2b, 1);
110
escapement += (int) (font->max_bounds.ascent +
111
font->max_bounds.descent);
115
for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
116
if(is_rotate(oc, font) == True) {
117
escapement += _XTextHeight(font, buf, 1);
119
escapement += (int) (font->max_bounds.ascent +
120
font->max_bounds.descent);
128
extern FontData _XomGetFontDataFromFontSet();
131
TextWidthWithFontSet(font_set, oc, text, length)
139
unsigned char *ptr = (unsigned char *)text;
141
int ptr_len = length;
142
int escapement = 0, char_len = 0;
144
if(font_set == (FontSet) NULL)
147
is_xchar2b = font_set->is_xchar2b;
150
fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
151
is_xchar2b, FONTSCOPE);
156
* First, see if the "Best Match" font for the FontSet was set.
157
* If it was, use that font. If it was not set, then use the
158
* font defined by font_set->font_data[0] (which is what
159
* _XomGetFontDataFromFontSet() always seems to return for
160
* non-VW text). Note that given the new algorithm in
161
* parse_fontname() and parse_fontdata(), fs->font will
162
* *always* contain good data. We should probably remove
163
* the check for "fd->font", but we won't :-) -- jjw/pma (HP)
165
* Above comment and way this is done propagated from omText.c
166
* Note that fd->font is junk so using the result of the
167
* above call /needs/ to be ignored.
169
* Owen Taylor <otaylor@redhat.com> 12 Jul 2000
173
if(fd == (FontData) NULL ||
174
(font = font_set->font) == (XFontStruct *) NULL) {
176
if((font = fd->font) == (XFontStruct *) NULL)
180
switch(oc->core.orientation) {
181
case XOMOrientation_LTR_TTB:
182
case XOMOrientation_RTL_TTB:
184
char_len = ptr_len / sizeof(XChar2b);
185
escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
188
escapement += XTextWidth(font, (char *)ptr, char_len);
192
case XOMOrientation_TTB_LTR:
193
case XOMOrientation_TTB_RTL:
194
if(font_set->font == font) {
195
fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
199
if(fd == (FontData) NULL ||
200
(font = fd->font) == (XFontStruct *) NULL)
203
if(is_codemap(oc, fd->font) == False) {
204
fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
205
&ptr_len, is_xchar2b,
209
if(fd == (FontData) NULL ||
210
(font = fd->font) == (XFontStruct *) NULL)
216
char_len = ptr_len / sizeof(XChar2b);
219
escapement += escapement_vertical(oc, font, is_xchar2b,
220
(XPointer) ptr, char_len);
223
case XOMOrientation_Context:
241
_XomGenericTextEscapement(oc, type, text, length)
254
XChar2b xchar2b_buf[BUFSIZ], *buf;
256
int buf_len = 0, left = 0;
258
conv = _XomInitConverter(oc, type);
262
args[0] = (XPointer) &font;
263
args[1] = (XPointer) &is_xchar2b;
264
args[2] = (XPointer) &font_set;
268
left = buf_len = BUFSIZ;
270
if (_XomConvert(oc, conv, (XPointer *) &text, &length,
271
(XPointer *) &buf, &left, args, 3) < 0)
276
escapement += TextWidthWithFontSet(font_set, oc,
277
(XPointer) xchar2b_buf, buf_len);
285
#if NeedFunctionPrototypes
286
_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
288
_XmbGenericTextEscapement(oc, text, length)
294
return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
298
#if NeedFunctionPrototypes
299
_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
301
_XwcGenericTextEscapement(oc, text, length)
303
_Xconst wchar_t *text;
307
return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
311
#if NeedFunctionPrototypes
312
_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
314
_Xutf8GenericTextEscapement(oc, text, length)
320
return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,