aboutsummaryrefslogtreecommitdiff
path: root/libX11/modules/om
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
committermarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
commit990bc3f015a4f8fce2eb918375defcd44980a845 (patch)
tree8e8301f19482b52cc00bd95b4593522cc93267af /libX11/modules/om
parent1af6fc1b5d93e54d6674de8b5870448b29f139a7 (diff)
downloadvcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.gz
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.bz2
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.zip
Used synchronise script to update files
Diffstat (limited to 'libX11/modules/om')
-rw-r--r--libX11/modules/om/Makefile.am2
-rw-r--r--libX11/modules/om/generic/omDefault.c898
-rw-r--r--libX11/modules/om/generic/omImText.c180
-rw-r--r--libX11/modules/om/generic/omText.c740
-rw-r--r--libX11/modules/om/generic/omTextEsc.c600
-rw-r--r--libX11/modules/om/generic/omTextExt.c270
-rw-r--r--libX11/modules/om/generic/omTextPer.c404
-rw-r--r--libX11/modules/om/generic/omXChar.c954
8 files changed, 2024 insertions, 2024 deletions
diff --git a/libX11/modules/om/Makefile.am b/libX11/modules/om/Makefile.am
index 24f4c06a2..cb22f5a42 100644
--- a/libX11/modules/om/Makefile.am
+++ b/libX11/modules/om/Makefile.am
@@ -1 +1 @@
-SUBDIRS=generic
+SUBDIRS=generic
diff --git a/libX11/modules/om/generic/omDefault.c b/libX11/modules/om/generic/omDefault.c
index 322690fa0..3f867ba65 100644
--- a/libX11/modules/om/generic/omDefault.c
+++ b/libX11/modules/om/generic/omDefault.c
@@ -1,449 +1,449 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-/*
- * (c) Copyright 1995 FUJITSU LIMITED
- * This is source code modified by FUJITSU LIMITED under the Joint
- * Development Agreement for the CDE/Motif PST.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-#include <X11/Xos.h>
-#include <X11/Xatom.h>
-#include <stdio.h>
-
-#define DefineLocalBuf char local_buf[BUFSIZ]
-#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
-#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
-
-static Bool
-wcs_to_mbs(
- XOC oc,
- char *to,
- _Xconst wchar_t *from,
- int length)
-{
- XlcConv conv;
- int to_left, ret;
-
- conv = _XomInitConverter(oc, XOMWideChar);
- if (conv == NULL)
- return False;
-
- to_left = length;
- ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
- &to_left, NULL, 0);
- if (ret != 0 || length > 0)
- return False;
-
- return True;
-}
-
-static Bool
-utf8_to_mbs(
- XOC oc,
- char *to,
- _Xconst char *from,
- int length)
-{
- XlcConv conv;
- int to_left, ret;
-
- conv = _XomInitConverter(oc, XOMUtf8String);
- if (conv == NULL)
- return False;
-
- to_left = length;
- ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
- &to_left, NULL, 0);
- if (ret != 0 || length > 0)
- return False;
-
- return True;
-}
-
-int
-_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
-{
- return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
-}
-
-int
-_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextEscapement(oc, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-int
-_Xutf8DefaultTextEscapement(XOC oc, _Xconst char *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (utf8_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextEscapement(oc, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-int
-_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- int direction, logical_ascent, logical_descent;
- XCharStruct overall;
-
- XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
- &logical_ascent, &logical_descent, &overall);
-
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(logical_ascent);
- overall_logical->width = overall.width;
- overall_logical->height = logical_ascent + logical_descent;
- }
-
- return overall.width;
-}
-
-int
-_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-int
-_Xutf8DefaultTextExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (utf8_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-Status
-_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- XFontStruct *font = *oc->core.font_info.font_struct_list;
- XCharStruct *def, *cs, overall;
- Bool first = True;
-
- if (buf_size < length)
- return 0;
-
- bzero((char *) &overall, sizeof(XCharStruct));
- *num_chars = 0;
-
- CI_GET_DEFAULT_INFO_1D(font, def)
-
- while (length-- > 0) {
- CI_GET_CHAR_INFO_1D(font, *text, def, cs)
- text++;
- if (cs == NULL)
- continue;
-
- ink_buf->x = overall.width + cs->lbearing;
- ink_buf->y = -(cs->ascent);
- ink_buf->width = cs->rbearing - cs->lbearing;
- ink_buf->height = cs->ascent + cs->descent;
- ink_buf++;
-
- logical_buf->x = overall.width;
- logical_buf->y = -(font->ascent);
- logical_buf->width = cs->width;
- logical_buf->height = font->ascent + font->descent;
- logical_buf++;
-
- if (first) {
- overall = *cs;
- first = False;
- } else {
- overall.ascent = max(overall.ascent, cs->ascent);
- overall.descent = max(overall.descent, cs->descent);
- overall.lbearing = min(overall.lbearing, overall.width +
- cs->lbearing);
- overall.rbearing = max(overall.rbearing, overall.width +
- cs->rbearing);
- overall.width += cs->width;
- }
-
- (*num_chars)++;
- }
-
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(font->ascent);
- overall_logical->width = overall.width;
- overall_logical->height = font->ascent + font->descent;
- }
-
- return 1;
-}
-
-Status
-_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- Status ret;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
- buf_size, num_chars, overall_ink,
- overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-Status
-_Xutf8DefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- Status ret;
-
- if (buf == NULL)
- return 0;
-
- if (utf8_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
- buf_size, num_chars, overall_ink,
- overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-int
-_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst char *text, int length)
-{
- XFontStruct *font = *oc->core.font_info.font_struct_list;
-
- XSetFont(dpy, gc, font->fid);
- XDrawString(dpy, d, gc, x, y, text, length);
-
- return XTextWidth(font, text, length);
-}
-
-int
-_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-int
-_Xutf8DefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst char *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret;
-
- if (buf == NULL)
- return 0;
-
- if (utf8_to_mbs(oc, buf, text, length) == False) {
- ret = 0;
- goto err;
- }
-
- ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-void
-_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst char *text, int length)
-{
- XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
- XDrawImageString(dpy, d, gc, x, y, text, length);
-}
-
-void
-_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
-
- if (buf == NULL)
- return;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-}
-
-void
-_Xutf8DefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst char *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
-
- if (buf == NULL)
- return;
-
- if (utf8_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+static Bool
+wcs_to_mbs(
+ XOC oc,
+ char *to,
+ _Xconst wchar_t *from,
+ int length)
+{
+ XlcConv conv;
+ int to_left, ret;
+
+ conv = _XomInitConverter(oc, XOMWideChar);
+ if (conv == NULL)
+ return False;
+
+ to_left = length;
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+static Bool
+utf8_to_mbs(
+ XOC oc,
+ char *to,
+ _Xconst char *from,
+ int length)
+{
+ XlcConv conv;
+ int to_left, ret;
+
+ conv = _XomInitConverter(oc, XOMUtf8String);
+ if (conv == NULL)
+ return False;
+
+ to_left = length;
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+int
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
+}
+
+int
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ int direction, logical_ascent, logical_descent;
+ XCharStruct overall;
+
+ XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
+ &logical_ascent, &logical_descent, &overall);
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+Status
+_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+ XCharStruct *def, *cs, overall;
+ Bool first = True;
+
+ if (buf_size < length)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ *num_chars = 0;
+
+ CI_GET_DEFAULT_INFO_1D(font, def)
+
+ while (length-- > 0) {
+ CI_GET_CHAR_INFO_1D(font, *text, def, cs)
+ text++;
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing, overall.width +
+ cs->lbearing);
+ overall.rbearing = max(overall.rbearing, overall.width +
+ cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(font->ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = font->ascent + font->descent;
+ }
+
+ return 1;
+}
+
+Status
+_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+Status
+_Xutf8DefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+
+ XSetFont(dpy, gc, font->fid);
+ XDrawString(dpy, d, gc, x, y, text, length);
+
+ return XTextWidth(font, text, length);
+}
+
+int
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+_Xutf8DefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False) {
+ ret = 0;
+ goto err;
+ }
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+void
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
+ XDrawImageString(dpy, d, gc, x, y, text, length);
+}
+
+void
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
+
+void
+_Xutf8DefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (utf8_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
diff --git a/libX11/modules/om/generic/omImText.c b/libX11/modules/om/generic/omImText.c
index 1bc08bc25..68086ff76 100644
--- a/libX11/modules/om/generic/omImText.c
+++ b/libX11/modules/om/generic/omImText.c
@@ -1,90 +1,90 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-
-#if 0
-extern int _XomGenericTextExtents(), _XomGenericDrawString();
-#endif
-
-#define GET_VALUE_MASK (GCFunction | GCForeground | GCBackground | GCFillStyle)
-#define SET_VALUE_MASK (GCFunction | GCForeground | GCFillStyle)
-
-static void
-_XomGenericDrawImageString(
- Display *dpy,
- Drawable d,
- XOC oc,
- GC gc,
- int x, int y,
- XOMTextType type,
- XPointer text,
- int length)
-{
- XGCValues values;
- XRectangle extent;
-
- XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
-
- XSetFunction(dpy, gc, GXcopy);
- XSetForeground(dpy, gc, values.background);
- XSetFillStyle(dpy, gc, FillSolid);
-
- _XomGenericTextExtents(oc, type, text, length, 0, &extent);
- XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
- extent.height);
-
- XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
-
- _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
-}
-
-void
-_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst char *text, int length)
-{
- _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
- (XPointer) text, length);
-}
-
-void
-_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst wchar_t *text, int length)
-{
- _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
- (XPointer) text, length);
-}
-
-void
-_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst char *text, int length)
-{
- _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
- (XPointer) text, length);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+
+#if 0
+extern int _XomGenericTextExtents(), _XomGenericDrawString();
+#endif
+
+#define GET_VALUE_MASK (GCFunction | GCForeground | GCBackground | GCFillStyle)
+#define SET_VALUE_MASK (GCFunction | GCForeground | GCFillStyle)
+
+static void
+_XomGenericDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ int x, int y,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XGCValues values;
+ XRectangle extent;
+
+ XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
+
+ XSetFunction(dpy, gc, GXcopy);
+ XSetForeground(dpy, gc, values.background);
+ XSetFillStyle(dpy, gc, FillSolid);
+
+ _XomGenericTextExtents(oc, type, text, length, 0, &extent);
+ XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
+ extent.height);
+
+ XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
+
+ _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
+}
+
+void
+_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+void
+_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
+
+void
+_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
+ (XPointer) text, length);
+}
diff --git a/libX11/modules/om/generic/omText.c b/libX11/modules/om/generic/omText.c
index bfceca96e..fd957d491 100644
--- a/libX11/modules/om/generic/omText.c
+++ b/libX11/modules/om/generic/omText.c
@@ -1,370 +1,370 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-/*
- * Copyright 1995 by FUJITSU LIMITED
- * This is source code modified by FUJITSU LIMITED under the Joint
- * Development Agreement for the CDE/Motif PST.
- */
-/*
- * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-#include <stdio.h>
-
-/* For VW/UDC */
-
-static int
-is_rotate(
- XOC oc,
- XFontStruct *font)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- VRotate vrotate;
- int font_set_count;
- int vrotate_num;
-
- font_set = gen->font_set;
- font_set_count = gen->font_set_num;
- for( ; font_set_count-- ; font_set++) {
- if((font_set->vrotate_num > 0) && (font_set->vrotate)) {
- vrotate = font_set->vrotate;
- vrotate_num = font_set->vrotate_num;
- for( ; vrotate_num-- ; vrotate++)
- if(vrotate->font == font)
- return True;
- }
- }
- return False;
-}
-
-static int
-is_codemap(
- XOC oc,
- XFontStruct *font)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- FontData vmap;
- int font_set_count;
- int vmap_num;
-
- font_set = gen->font_set;
- font_set_count = gen->font_set_num;
- for( ; font_set_count-- ; font_set++) {
- if(font_set->vmap_num > 0) {
- vmap = font_set->vmap;
- vmap_num = font_set->vmap_num;
- for( ; vmap_num-- ; vmap++)
- if(vmap->font == font)
- return True;
- }
- }
- return False;
-}
-
-static int
-draw_vertical(
- Display *dpy,
- Drawable d,
- XOC oc,
- GC gc,
- XFontStruct *font,
- Bool is_xchar2b,
- int x, int y,
- XPointer text,
- int length)
-{
- XChar2b *buf2b;
- char *buf;
- int wx = 0, wy = 0;
- int direction = 0;
- int font_ascent_return = 0, font_descent_return = 0;
- int i;
- XCharStruct overall;
-
- wy = y;
- if (is_xchar2b) {
- for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
- if(is_rotate(oc, font) == True) {
- XTextExtents16(font, buf2b, 1,
- &direction, &font_ascent_return,
- &font_descent_return, &overall);
- wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
- (int) overall.lbearing;
- wy += overall.ascent;
- XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
- wy += overall.descent;
- } else {
- wx = x - (int)((font->max_bounds.rbearing -
- font->min_bounds.lbearing) >> 1) -
- (int) font->min_bounds.lbearing;
- wy += font->max_bounds.ascent;
- XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
- wy += font->max_bounds.descent;
- }
- }
- } else {
- for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
- if(is_rotate(oc, font) == True) {
- XTextExtents(font, buf, 1,
- &direction, &font_ascent_return,
- &font_descent_return, &overall);
- wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
- (int) overall.lbearing;
- wy += overall.ascent;
- XDrawString(dpy, d, gc, wx, wy, buf, 1);
- wy += overall.descent;
- } else {
- wx = x - (int)((font->max_bounds.rbearing -
- font->min_bounds.lbearing) >> 1) -
- (int) font->min_bounds.lbearing;
- wy += font->max_bounds.ascent;
- XDrawString(dpy, d, gc, wx, wy, buf, 1);
- wy += font->max_bounds.descent;
- }
- }
- }
- return wy;
-}
-
-#define VMAP 0
-#define VROTATE 1
-#define FONTSCOPE 2
-
-static int
-DrawStringWithFontSet(
- Display *dpy,
- Drawable d,
- XOC oc,
- FontSet fs,
- GC gc,
- int x, int y,
- XPointer text,
- int length)
-{
- XFontStruct *font;
- Bool is_xchar2b;
- unsigned char *ptr;
- int ptr_len, char_len = 0;
- FontData fd;
- int ret = 0;
-
- ptr = (unsigned char *)text;
- is_xchar2b = fs->is_xchar2b;
-
- while (length > 0) {
- fd = _XomGetFontDataFromFontSet(fs,
- ptr,length,&ptr_len,is_xchar2b,FONTSCOPE);
- if(ptr_len <= 0)
- break;
-
- /* First, see if the "Best Match" font for the FontSet was set.
- * If it was, use that font. If it was not set, then use the
- * font defined by font_set->font_data[0] (which is what
- * _XomGetFontDataFromFontSet() always seems to return for
- * non-VW text). Note that given the new algorithm in
- * parse_fontname() and parse_fontdata(), fs->font will
- * *always* contain good data. We should probably remove
- * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
- */
- if((font = fs->font) == (XFontStruct *) NULL){
-
- if(fd == (FontData) NULL ||
- (font = fd->font) == (XFontStruct *) NULL)
- break;
- }
-
- switch(oc->core.orientation) {
- case XOMOrientation_LTR_TTB:
- case XOMOrientation_RTL_TTB:
- XSetFont(dpy, gc, font->fid);
-
- if (is_xchar2b) {
- char_len = ptr_len / sizeof(XChar2b);
- XDrawString16(dpy, d, gc, x, y, (XChar2b *)ptr, char_len);
- x += XTextWidth16(font, (XChar2b *)ptr, char_len);
- } else {
- char_len = ptr_len;
- XDrawString(dpy, d, gc, x, y, (char *)ptr, char_len);
- x += XTextWidth(font, (char *)ptr, char_len);
- }
- break;
- case XOMOrientation_TTB_RTL:
- case XOMOrientation_TTB_LTR:
- if(fs->font == font) {
- fd = _XomGetFontDataFromFontSet(fs,
- ptr,length,&ptr_len,is_xchar2b,VMAP);
- if(ptr_len <= 0)
- break;
- if(fd == (FontData) NULL ||
- (font = fd->font) == (XFontStruct *) NULL)
- break;
-
- if(is_codemap(oc, fd->font) == False) {
- fd = _XomGetFontDataFromFontSet(fs,
- ptr,length,&ptr_len,is_xchar2b,VROTATE);
- if(ptr_len <= 0)
- break;
- if(fd == (FontData) NULL ||
- (font = fd->font) == (XFontStruct *) NULL)
- break;
- }
- }
-
- if(is_xchar2b)
- char_len = ptr_len / sizeof(XChar2b);
- else
- char_len = ptr_len;
- XSetFont(dpy, gc, font->fid);
- y = draw_vertical(dpy, d, oc, gc, font, is_xchar2b, x, y,
- (char *)ptr, char_len);
- break;
-
- case XOMOrientation_Context:
- /* never used? */
- break;
- }
-
- if(char_len <= 0)
- break;
-
- length -= char_len;
- ptr += ptr_len;
- }
-
- switch(oc->core.orientation) {
- case XOMOrientation_LTR_TTB:
- case XOMOrientation_RTL_TTB:
- ret = x;
- break;
- case XOMOrientation_TTB_RTL:
- case XOMOrientation_TTB_LTR:
- ret = y;
- break;
- case XOMOrientation_Context:
- /* not used? */
- break;
- }
- return ret;
-}
-
-/* For VW/UDC */
-
-int
-_XomGenericDrawString(
- Display *dpy,
- Drawable d,
- XOC oc,
- GC gc,
- int x, int y,
- XOMTextType type,
- XPointer text,
- int length)
-{
- XlcConv conv;
- XFontStruct *font;
- Bool is_xchar2b;
-/* VW/UDC */
- XPointer args[3];
- FontSet fs;
-/* VW/UDC */
- XChar2b xchar2b_buf[BUFSIZ], *buf;
- int start_x = x;
- int start_y = y;
- int left = 0, buf_len = 0;
- int next = 0;
-
- conv = _XomInitConverter(oc, type);
- if (conv == NULL)
- return -1;
-
- args[0] = (XPointer) &font;
- args[1] = (XPointer) &is_xchar2b;
- args[2] = (XPointer) &fs;
-
- while (length > 0) {
- buf = xchar2b_buf;
- left = buf_len = BUFSIZ;
-
- if (_XomConvert(oc, conv, (XPointer *) &text, &length,
- (XPointer *) &buf, &left, args, 3) < 0)
- break;
- buf_len -= left;
-
-/* For VW/UDC */
- next = DrawStringWithFontSet(dpy, d, oc, fs, gc, x, y,
- (XPointer)xchar2b_buf, buf_len);
-
- switch(oc->core.orientation) {
- case XOMOrientation_LTR_TTB:
- case XOMOrientation_RTL_TTB:
- x = next;
- break;
- case XOMOrientation_TTB_RTL:
- case XOMOrientation_TTB_LTR:
- y = next;
- break;
- case XOMOrientation_Context:
- /* not used */
- break;
- }
-/* For VW/UDC */
- }
-
- x -= start_x;
- y -= start_y;
-
- return x;
-}
-
-int
-_XmbGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst char *text, int length)
-{
- return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMMultiByte,
- (XPointer) text, length);
-}
-
-int
-_XwcGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst wchar_t *text, int length)
-{
- return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMWideChar,
- (XPointer) text, length);
-}
-
-int
-_Xutf8GenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst char *text, int length)
-{
- return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMUtf8String,
- (XPointer) text, length);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC */
+
+static int
+is_rotate(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+draw_vertical(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ XFontStruct *font,
+ Bool is_xchar2b,
+ int x, int y,
+ XPointer text,
+ int length)
+{
+ XChar2b *buf2b;
+ char *buf;
+ int wx = 0, wy = 0;
+ int direction = 0;
+ int font_ascent_return = 0, font_descent_return = 0;
+ int i;
+ XCharStruct overall;
+
+ wy = y;
+ if (is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents16(font, buf2b, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents(font, buf, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ }
+ return wy;
+}
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+static int
+DrawStringWithFontSet(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ FontSet fs,
+ GC gc,
+ int x, int y,
+ XPointer text,
+ int length)
+{
+ XFontStruct *font;
+ Bool is_xchar2b;
+ unsigned char *ptr;
+ int ptr_len, char_len = 0;
+ FontData fd;
+ int ret = 0;
+
+ ptr = (unsigned char *)text;
+ is_xchar2b = fs->is_xchar2b;
+
+ while (length > 0) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+
+ /* First, see if the "Best Match" font for the FontSet was set.
+ * If it was, use that font. If it was not set, then use the
+ * font defined by font_set->font_data[0] (which is what
+ * _XomGetFontDataFromFontSet() always seems to return for
+ * non-VW text). Note that given the new algorithm in
+ * parse_fontname() and parse_fontdata(), fs->font will
+ * *always* contain good data. We should probably remove
+ * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+ */
+ if((font = fs->font) == (XFontStruct *) NULL){
+
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ XSetFont(dpy, gc, font->fid);
+
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ XDrawString16(dpy, d, gc, x, y, (XChar2b *)ptr, char_len);
+ x += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ XDrawString(dpy, d, gc, x, y, (char *)ptr, char_len);
+ x += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ if(fs->font == font) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ ptr,length,&ptr_len,is_xchar2b,VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ XSetFont(dpy, gc, font->fid);
+ y = draw_vertical(dpy, d, oc, gc, font, is_xchar2b, x, y,
+ (char *)ptr, char_len);
+ break;
+
+ case XOMOrientation_Context:
+ /* never used? */
+ break;
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ ret = x;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ ret = y;
+ break;
+ case XOMOrientation_Context:
+ /* not used? */
+ break;
+ }
+ return ret;
+}
+
+/* For VW/UDC */
+
+int
+_XomGenericDrawString(
+ Display *dpy,
+ Drawable d,
+ XOC oc,
+ GC gc,
+ int x, int y,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet fs;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int start_x = x;
+ int start_y = y;
+ int left = 0, buf_len = 0;
+ int next = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return -1;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &fs;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* For VW/UDC */
+ next = DrawStringWithFontSet(dpy, d, oc, fs, gc, x, y,
+ (XPointer)xchar2b_buf, buf_len);
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ x = next;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ y = next;
+ break;
+ case XOMOrientation_Context:
+ /* not used */
+ break;
+ }
+/* For VW/UDC */
+ }
+
+ x -= start_x;
+ y -= start_y;
+
+ return x;
+}
+
+int
+_XmbGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+int
+_XwcGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
+
+int
+_Xutf8GenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMUtf8String,
+ (XPointer) text, length);
+}
diff --git a/libX11/modules/om/generic/omTextEsc.c b/libX11/modules/om/generic/omTextEsc.c
index df1fb10c0..cb444f441 100644
--- a/libX11/modules/om/generic/omTextEsc.c
+++ b/libX11/modules/om/generic/omTextEsc.c
@@ -1,300 +1,300 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-/*
- * Copyright 1995 by FUJITSU LIMITED
- * This is source code modified by FUJITSU LIMITED under the Joint
- * Development Agreement for the CDE/Motif PST.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-#include <stdio.h>
-
-/* For VW/UDC start */
-
-#define VMAP 0
-#define VROTATE 1
-#define FONTSCOPE 2
-
-static int
-is_rotate(
- XOC oc,
- XFontStruct *font)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- VRotate vrotate;
- int font_set_count;
- int vrotate_num;
-
- font_set = gen->font_set;
- font_set_count = gen->font_set_num;
- for( ; font_set_count-- ; font_set++) {
- if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
- vrotate = font_set->vrotate;
- vrotate_num = font_set->vrotate_num;
- for( ; vrotate_num-- ; vrotate++)
- if(vrotate->font == font)
- return True;
- }
- }
- return False;
-}
-
-static int
-is_codemap(
- XOC oc,
- XFontStruct *font)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- FontData vmap;
- int font_set_count;
- int vmap_num;
-
- font_set = gen->font_set;
- font_set_count = gen->font_set_num;
- for( ; font_set_count-- ; font_set++) {
- if(font_set->vmap_num > 0) {
- vmap = font_set->vmap;
- vmap_num = font_set->vmap_num;
- for( ; vmap_num-- ; vmap++)
- if(vmap->font == font)
- return True;
- }
- }
- return False;
-}
-
-static int
-escapement_vertical(
- XOC oc,
- XFontStruct *font,
- Bool is_xchar2b,
- XPointer text,
- int length)
-{
- XChar2b *buf2b;
- char *buf;
- int escapement = 0, i;
-
- if(is_xchar2b) {
- for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
- if(is_rotate(oc, font) == True) {
- escapement += _XTextHeight16(font, buf2b, 1);
- } else {
- escapement += (int) (font->max_bounds.ascent +
- font->max_bounds.descent);
- }
- }
- } else {
- for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
- if(is_rotate(oc, font) == True) {
- escapement += _XTextHeight(font, buf, 1);
- } else {
- escapement += (int) (font->max_bounds.ascent +
- font->max_bounds.descent);
- }
- }
- }
- return escapement;
-}
-
-
-static int
-TextWidthWithFontSet(
- FontSet font_set,
- XOC oc,
- XPointer text,
- int length)
-{
- FontData fd;
- XFontStruct *font;
- unsigned char *ptr = (unsigned char *)text;
- Bool is_xchar2b;
- int ptr_len = length;
- int escapement = 0, char_len = 0;
-
- if(font_set == (FontSet) NULL)
- return escapement;
-
- is_xchar2b = font_set->is_xchar2b;
-
- while(length > 0) {
- fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
- is_xchar2b, FONTSCOPE);
- if(ptr_len <= 0)
- break;
-
- /*
- * First, see if the "Best Match" font for the FontSet was set.
- * If it was, use that font. If it was not set, then use the
- * font defined by font_set->font_data[0] (which is what
- * _XomGetFontDataFromFontSet() always seems to return for
- * non-VW text). Note that given the new algorithm in
- * parse_fontname() and parse_fontdata(), fs->font will
- * *always* contain good data. We should probably remove
- * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
- *
- * Above comment and way this is done propagated from omText.c
- * Note that fd->font is junk so using the result of the
- * above call /needs/ to be ignored.
- *
- * Owen Taylor <otaylor@redhat.com> 12 Jul 2000
- *
- */
-
- if(fd == (FontData) NULL ||
- (font = font_set->font) == (XFontStruct *) NULL) {
-
- if((font = fd->font) == (XFontStruct *) NULL)
- break;
- }
-
- switch(oc->core.orientation) {
- case XOMOrientation_LTR_TTB:
- case XOMOrientation_RTL_TTB:
- if (is_xchar2b) {
- char_len = ptr_len / sizeof(XChar2b);
- escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
- } else {
- char_len = ptr_len;
- escapement += XTextWidth(font, (char *)ptr, char_len);
- }
- break;
-
- case XOMOrientation_TTB_LTR:
- case XOMOrientation_TTB_RTL:
- if(font_set->font == font) {
- fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
- is_xchar2b, VMAP);
- if(ptr_len <= 0)
- break;
- if(fd == (FontData) NULL ||
- (font = fd->font) == (XFontStruct *) NULL)
- break;
-
- if(is_codemap(oc, fd->font) == False) {
- fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
- &ptr_len, is_xchar2b,
- VROTATE);
- if(ptr_len <= 0)
- break;
- if(fd == (FontData) NULL ||
- (font = fd->font) == (XFontStruct *) NULL)
- break;
- }
- }
-
- if(is_xchar2b)
- char_len = ptr_len / sizeof(XChar2b);
- else
- char_len = ptr_len;
- escapement += escapement_vertical(oc, font, is_xchar2b,
- (XPointer) ptr, char_len);
- break;
-
- case XOMOrientation_Context:
- /* not used? */
- break;
- }
-
- if(char_len <= 0)
- break;
-
- length -= char_len;
- ptr += ptr_len;
- }
-
- return escapement;
-}
-
-/* For VW/UDC end */
-
-static int
-_XomGenericTextEscapement(
- XOC oc,
- XOMTextType type,
- XPointer text,
- int length)
-{
- XlcConv conv;
- XFontStruct *font;
- Bool is_xchar2b;
-/* VW/UDC */
- XPointer args[3];
- FontSet font_set;
-/* VW/UDC */
- XChar2b xchar2b_buf[BUFSIZ], *buf;
- int escapement = 0;
- int buf_len = 0, left = 0;
-
- conv = _XomInitConverter(oc, type);
- if (conv == NULL)
- return escapement;
-
- args[0] = (XPointer) &font;
- args[1] = (XPointer) &is_xchar2b;
- args[2] = (XPointer) &font_set;
-
- while (length > 0) {
- buf = xchar2b_buf;
- left = buf_len = BUFSIZ;
-
- if (_XomConvert(oc, conv, (XPointer *) &text, &length,
- (XPointer *) &buf, &left, args, 3) < 0)
- break;
- buf_len -= left;
-
-/* VW/UDC */
- escapement += TextWidthWithFontSet(font_set, oc,
- (XPointer) xchar2b_buf, buf_len);
-/* VW/UDC */
- }
-
- return escapement;
-}
-
-int
-_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
-{
- return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
-}
-
-int
-_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
-{
- return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
-}
-
-int
-_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
-{
- return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,
- length);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC start */
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+static int
+is_rotate(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(
+ XOC oc,
+ XFontStruct *font)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+escapement_vertical(
+ XOC oc,
+ XFontStruct *font,
+ Bool is_xchar2b,
+ XPointer text,
+ int length)
+{
+ XChar2b *buf2b;
+ char *buf;
+ int escapement = 0, i;
+
+ if(is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight16(font, buf2b, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight(font, buf, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ }
+ return escapement;
+}
+
+
+static int
+TextWidthWithFontSet(
+ FontSet font_set,
+ XOC oc,
+ XPointer text,
+ int length)
+{
+ FontData fd;
+ XFontStruct *font;
+ unsigned char *ptr = (unsigned char *)text;
+ Bool is_xchar2b;
+ int ptr_len = length;
+ int escapement = 0, char_len = 0;
+
+ if(font_set == (FontSet) NULL)
+ return escapement;
+
+ is_xchar2b = font_set->is_xchar2b;
+
+ while(length > 0) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+
+ /*
+ * First, see if the "Best Match" font for the FontSet was set.
+ * If it was, use that font. If it was not set, then use the
+ * font defined by font_set->font_data[0] (which is what
+ * _XomGetFontDataFromFontSet() always seems to return for
+ * non-VW text). Note that given the new algorithm in
+ * parse_fontname() and parse_fontdata(), fs->font will
+ * *always* contain good data. We should probably remove
+ * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+ *
+ * Above comment and way this is done propagated from omText.c
+ * Note that fd->font is junk so using the result of the
+ * above call /needs/ to be ignored.
+ *
+ * Owen Taylor <otaylor@redhat.com> 12 Jul 2000
+ *
+ */
+
+ if(fd == (FontData) NULL ||
+ (font = font_set->font) == (XFontStruct *) NULL) {
+
+ if((font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ escapement += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+
+ case XOMOrientation_TTB_LTR:
+ case XOMOrientation_TTB_RTL:
+ if(font_set->font == font) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
+ &ptr_len, is_xchar2b,
+ VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ escapement += escapement_vertical(oc, font, is_xchar2b,
+ (XPointer) ptr, char_len);
+ break;
+
+ case XOMOrientation_Context:
+ /* not used? */
+ break;
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ return escapement;
+}
+
+/* For VW/UDC end */
+
+static int
+_XomGenericTextEscapement(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet font_set;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int escapement = 0;
+ int buf_len = 0, left = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return escapement;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &font_set;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* VW/UDC */
+ escapement += TextWidthWithFontSet(font_set, oc,
+ (XPointer) xchar2b_buf, buf_len);
+/* VW/UDC */
+ }
+
+ return escapement;
+}
+
+int
+_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
+}
+
+int
+_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
+}
+
+int
+_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
+{
+ return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,
+ length);
+}
diff --git a/libX11/modules/om/generic/omTextExt.c b/libX11/modules/om/generic/omTextExt.c
index baeadf6b0..22f99d8f5 100644
--- a/libX11/modules/om/generic/omTextExt.c
+++ b/libX11/modules/om/generic/omTextExt.c
@@ -1,135 +1,135 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-#include <stdio.h>
-
-int
-_XomGenericTextExtents(
- XOC oc,
- XOMTextType type,
- XPointer text,
- int length,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- XlcConv conv;
- XFontStruct *font;
- Bool is_xchar2b;
- XPointer args[2];
- XChar2b xchar2b_buf[BUFSIZ], *buf;
- int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent;
- XCharStruct overall, tmp_overall;
- int buf_len, left;
- Bool first = True;
-
- conv = _XomInitConverter(oc, type);
- if (conv == NULL)
- return 0;
-
- bzero((char *) &overall, sizeof(XCharStruct));
- logical_ascent = logical_descent = 0;
-
- args[0] = (XPointer) &font;
- args[1] = (XPointer) &is_xchar2b;
-
- while (length > 0) {
- buf = xchar2b_buf;
- left = buf_len = BUFSIZ;
-
- if (_XomConvert(oc, conv, (XPointer *) &text, &length,
- (XPointer *) &buf, &left, args, 2) < 0)
- break;
- buf_len -= left;
-
- if (is_xchar2b)
- XTextExtents16(font, xchar2b_buf, buf_len, &direction,
- &tmp_ascent, &tmp_descent, &tmp_overall);
- else
- XTextExtents(font, (char *) xchar2b_buf, buf_len, &direction,
- &tmp_ascent, &tmp_descent, &tmp_overall);
-
- if (first) { /* initialize overall */
- overall = tmp_overall;
- logical_ascent = tmp_ascent;
- logical_descent = tmp_descent;
- first = False;
- } else {
- overall.lbearing = min(overall.lbearing,
- overall.width + tmp_overall.lbearing);
- overall.rbearing = max(overall.rbearing,
- overall.width + tmp_overall.rbearing);
- overall.ascent = max(overall.ascent, tmp_overall.ascent);
- overall.descent = max(overall.descent, tmp_overall.descent);
- overall.width += tmp_overall.width;
- logical_ascent = max(logical_ascent, tmp_ascent);
- logical_descent = max(logical_descent, tmp_descent);
- }
- }
-
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(logical_ascent);
- overall_logical->width = overall.width;
- overall_logical->height = logical_ascent + logical_descent;
- }
-
- return overall.width;
-}
-
-int
-_XmbGenericTextExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- return _XomGenericTextExtents(oc, XOMMultiByte, (XPointer) text, length,
- overall_ink, overall_logical);
-}
-
-int
-_XwcGenericTextExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- return _XomGenericTextExtents(oc, XOMWideChar, (XPointer) text, length,
- overall_ink, overall_logical);
-}
-
-int
-_Xutf8GenericTextExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- return _XomGenericTextExtents(oc, XOMUtf8String, (XPointer) text, length,
- overall_ink, overall_logical);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+int
+_XomGenericTextExtents(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent;
+ XCharStruct overall, tmp_overall;
+ int buf_len, left;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (is_xchar2b)
+ XTextExtents16(font, xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+ else
+ XTextExtents(font, (char *) xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+
+ if (first) { /* initialize overall */
+ overall = tmp_overall;
+ logical_ascent = tmp_ascent;
+ logical_descent = tmp_descent;
+ first = False;
+ } else {
+ overall.lbearing = min(overall.lbearing,
+ overall.width + tmp_overall.lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + tmp_overall.rbearing);
+ overall.ascent = max(overall.ascent, tmp_overall.ascent);
+ overall.descent = max(overall.descent, tmp_overall.descent);
+ overall.width += tmp_overall.width;
+ logical_ascent = max(logical_ascent, tmp_ascent);
+ logical_descent = max(logical_descent, tmp_descent);
+ }
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+_XmbGenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMMultiByte, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
+
+int
+_XwcGenericTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMWideChar, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
+
+int
+_Xutf8GenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+{
+ return _XomGenericTextExtents(oc, XOMUtf8String, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
diff --git a/libX11/modules/om/generic/omTextPer.c b/libX11/modules/om/generic/omTextPer.c
index ae08fe6a4..c66848aa2 100644
--- a/libX11/modules/om/generic/omTextPer.c
+++ b/libX11/modules/om/generic/omTextPer.c
@@ -1,202 +1,202 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XomGeneric.h"
-#include <stdio.h>
-
-static Status
-_XomGenericTextPerCharExtents(
- XOC oc,
- XOMTextType type,
- XPointer text,
- int length,
- XRectangle *ink_buf,
- XRectangle *logical_buf,
- int buf_size,
- int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- XlcConv conv;
- XFontStruct *font;
- Bool is_xchar2b;
- XPointer args[2];
- XChar2b xchar2b_buf[BUFSIZ], *xchar2b_ptr;
- char *xchar_ptr = NULL;
- XCharStruct *def, *cs, overall;
- int buf_len, left, require_num;
- int logical_ascent, logical_descent;
- Bool first = True;
-
- conv = _XomInitConverter(oc, type);
- if (conv == NULL)
- return 0;
-
- bzero((char *) &overall, sizeof(XCharStruct));
- logical_ascent = logical_descent = require_num = *num_chars = 0;
-
- args[0] = (XPointer) &font;
- args[1] = (XPointer) &is_xchar2b;
-
- while (length > 0) {
- xchar2b_ptr = xchar2b_buf;
- left = buf_len = BUFSIZ;
-
- if (_XomConvert(oc, conv, (XPointer *) &text, &length,
- (XPointer *) &xchar2b_ptr, &left, args, 2) < 0)
- break;
- buf_len -= left;
-
- if (require_num) {
- require_num += buf_len;
- continue;
- }
- if (buf_size < buf_len) {
- require_num = *num_chars + buf_len;
- continue;
- }
- buf_size -= buf_len;
-
- if (first) {
- logical_ascent = font->ascent;
- logical_descent = font->descent;
- } else {
- logical_ascent = max(logical_ascent, font->ascent);
- logical_descent = max(logical_descent, font->descent);
- }
-
- if (is_xchar2b) {
- CI_GET_DEFAULT_INFO_2D(font, def)
- xchar2b_ptr = xchar2b_buf;
- } else {
- CI_GET_DEFAULT_INFO_1D(font, def)
- xchar_ptr = (char *) xchar2b_buf;
- }
-
- while (buf_len-- > 0) {
- if (is_xchar2b) {
- CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1,
- xchar2b_ptr->byte2, def, cs)
- xchar2b_ptr++;
- } else {
- CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs)
- xchar_ptr++;
- }
- if (cs == NULL)
- continue;
-
- ink_buf->x = overall.width + cs->lbearing;
- ink_buf->y = -(cs->ascent);
- ink_buf->width = cs->rbearing - cs->lbearing;
- ink_buf->height = cs->ascent + cs->descent;
- ink_buf++;
-
- logical_buf->x = overall.width;
- logical_buf->y = -(font->ascent);
- logical_buf->width = cs->width;
- logical_buf->height = font->ascent + font->descent;
- logical_buf++;
-
- if (first) {
- overall = *cs;
- first = False;
- } else {
- overall.ascent = max(overall.ascent, cs->ascent);
- overall.descent = max(overall.descent, cs->descent);
- overall.lbearing = min(overall.lbearing,
- overall.width + cs->lbearing);
- overall.rbearing = max(overall.rbearing,
- overall.width + cs->rbearing);
- overall.width += cs->width;
- }
-
- (*num_chars)++;
- }
- }
-
- if (require_num) {
- *num_chars = require_num;
- return 0;
- } else {
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(logical_ascent);
- overall_logical->width = overall.width;
- overall_logical->height = logical_ascent + logical_descent;
- }
- }
-
- return 1;
-}
-
-Status
-_XmbGenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- return _XomGenericTextPerCharExtents(oc, XOMMultiByte, (XPointer) text,
- length, ink_buf, logical_buf, buf_size,
- num_chars, overall_ink,
- overall_logical);
-}
-
-Status
-_XwcGenericTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- return _XomGenericTextPerCharExtents(oc, XOMWideChar, (XPointer) text,
- length, ink_buf, logical_buf, buf_size,
- num_chars, overall_ink,
- overall_logical);
-}
-
-Status
-_Xutf8GenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- return _XomGenericTextPerCharExtents(oc, XOMUtf8String, (XPointer) text,
- length, ink_buf, logical_buf, buf_size,
- num_chars, overall_ink,
- overall_logical);
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+static Status
+_XomGenericTextPerCharExtents(
+ XOC oc,
+ XOMTextType type,
+ XPointer text,
+ int length,
+ XRectangle *ink_buf,
+ XRectangle *logical_buf,
+ int buf_size,
+ int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *xchar2b_ptr;
+ char *xchar_ptr = NULL;
+ XCharStruct *def, *cs, overall;
+ int buf_len, left, require_num;
+ int logical_ascent, logical_descent;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = require_num = *num_chars = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ xchar2b_ptr = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &xchar2b_ptr, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (require_num) {
+ require_num += buf_len;
+ continue;
+ }
+ if (buf_size < buf_len) {
+ require_num = *num_chars + buf_len;
+ continue;
+ }
+ buf_size -= buf_len;
+
+ if (first) {
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+ } else {
+ logical_ascent = max(logical_ascent, font->ascent);
+ logical_descent = max(logical_descent, font->descent);
+ }
+
+ if (is_xchar2b) {
+ CI_GET_DEFAULT_INFO_2D(font, def)
+ xchar2b_ptr = xchar2b_buf;
+ } else {
+ CI_GET_DEFAULT_INFO_1D(font, def)
+ xchar_ptr = (char *) xchar2b_buf;
+ }
+
+ while (buf_len-- > 0) {
+ if (is_xchar2b) {
+ CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1,
+ xchar2b_ptr->byte2, def, cs)
+ xchar2b_ptr++;
+ } else {
+ CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs)
+ xchar_ptr++;
+ }
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing,
+ overall.width + cs->lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+ }
+
+ if (require_num) {
+ *num_chars = require_num;
+ return 0;
+ } else {
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+ }
+
+ return 1;
+}
+
+Status
+_XmbGenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMMultiByte, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
+
+Status
+_XwcGenericTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMWideChar, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
+
+Status
+_Xutf8GenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+{
+ return _XomGenericTextPerCharExtents(oc, XOMUtf8String, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
diff --git a/libX11/modules/om/generic/omXChar.c b/libX11/modules/om/generic/omXChar.c
index ff517d5e5..61c8c0b89 100644
--- a/libX11/modules/om/generic/omXChar.c
+++ b/libX11/modules/om/generic/omXChar.c
@@ -1,477 +1,477 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-/*
- * Copyright 1995 by FUJITSU LIMITED
- * This is source code modified by FUJITSU LIMITED under the Joint
- * Development Agreement for the CDE/Motif PST.
- *
- * Modifier: Takanori Tateno FUJITSU LIMITED
- *
- */
-/*
- * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XlcPublic.h"
-#include "XomGeneric.h"
-#include <stdio.h>
-
-/* for VW/UDC start */
-static Bool
-ismatch_scopes(
- FontData fontdata,
- unsigned long *value,
- Bool is_shift)
-{
- register int scopes_num = fontdata->scopes_num;
- FontScope scopes = fontdata->scopes;
- if (!scopes_num)
- return False;
-
- if(fontdata->font == NULL)
- return False;
-
- for(;scopes_num--;scopes++)
- if ((scopes->start <= (*value & 0x7f7f)) &&
- ((scopes->end) >= (*value & 0x7f7f))){
- if(is_shift == True) {
- if(scopes->shift){
- if(scopes->shift_direction == '+'){
- *value += scopes->shift ;
- } else if( scopes->shift_direction == '-'){
- *value -= scopes->shift ;
- }
- }
- }
- return True;
- }
-
- return False;
-}
-
-static int
-check_vertical_fonttype(
- char *name)
-{
- char *ptr;
- int type = 0;
-
- if(name == (char *)NULL || (int) strlen(name) <= 0)
- return False;
-
- /* Obtains the pointer of CHARSET_ENCODING_FIELD. */
- if((ptr = strchr(name, '-')) == (char *) NULL)
- return False;
- ptr++;
-
- /* Obtains the pointer of vertical_map font type. */
- if((ptr = strchr(ptr, '.')) == (char *) NULL)
- return False;
- ptr++;
-
- switch(*ptr) {
- case '1':
- type = 1; break;
- case '2':
- type = 2; break;
- case '3':
- type = 3; break;
- }
- return type;
-}
-
-/*
-*/
-#define VMAP 0
-#define VROTATE 1
-#define FONTSCOPE 2
-
-FontData
-_XomGetFontDataFromFontSet(
- FontSet fs,
- unsigned char *str,
- int len,
- int *len_ret,
- int is2b,
- int type) /* VMAP , VROTATE , else */
-{
- unsigned long value;
- int num,i,hit,csize;
- FontData fontdata;
- unsigned char *c;
- int vfont_type;
-
- c = str;
- hit = -1;
- if(type == VMAP){
- fontdata = fs->vmap;
- num = fs->vmap_num;
- } else if(type == VROTATE){
- fontdata = (FontData)fs->vrotate;
- num = fs->vrotate_num;
- } else {
- if(fs->font_data_count <= 0 || fs->font_data == (FontData)NULL) {
- fontdata = fs->substitute;
- num = fs->substitute_num;
- }else {
- fontdata = fs->font_data;
- num = fs->font_data_count;
- }
- /* CDExc20229 fix */
- if(fontdata == NULL || num == 0){
- return(NULL);
- }
- }
-
-
- if(is2b){
- csize = 2;
- } else {
- csize = 1;
- }
-
- for(;len;len--){
- if(is2b){
- value = (((unsigned long)*c) << 8)|(unsigned long)*(c + 1);
- } else {
- value = (unsigned long)*c;
- }
-
- /* ### NOTE: This routine DOES NOT WORK!
- * ### We can work around the problem in the calling routine,
- * ### but we really need to understand this better. As it
- * ### stands, the algorithm ALWAYS returns "fontdata[0]"
- * ### for non-VW text! This is clearly wrong. In fact,
- * ### given the new parse_font[name|data]() algorithms,
- * ### we may not even need this routine to do anything
- * ### for non-VW text (since font_set->font always contains
- * ### the best font for this fontset). -- jjw/pma (HP)
- */
- for (i=0;i<num;i++) {
- if(type == VROTATE) {
- if(fontdata[i].font) {
- /* If the num_cr equal zero, all character is rotated. */
- if(fontdata[i].scopes_num == 0) {
- break;
- } else {
- /* The vertical rotate glyph is not have code shift. */
- if (ismatch_scopes(&(fontdata[i]),&value,False)) {
- break;
- }
- }
- }
- } else if(type == VMAP) {
- if(fontdata[i].font) {
- vfont_type = check_vertical_fonttype(fontdata[i].name);
- if(vfont_type == 0 || vfont_type == 1) {
- break;
- } else if(vfont_type == 2 || vfont_type == 3) {
- if(fontdata[i].scopes_num <= 0)
- break;
-
- if (ismatch_scopes(&(fontdata[i]),&value,True)) {
- break;
- }
- }
- }
- } else { /* FONTSCOPE */
- if(fontdata[i].font) {
- if(fontdata[i].scopes_num <= 0)
- break;
- if (ismatch_scopes(&(fontdata[i]),&value,True)){
- break;
- }
- }
- }
- }
- if((hit != -1) && (i != hit)){
- break;
- }
- if(i == num){
- if( type == VROTATE || type == VMAP){
- /* Change 1996.01.23 start */
- if(fs->font_data_count <= 0 ||
- fs->font_data == (FontData)NULL)
- fontdata = fs->substitute;
- else
- fontdata = fs->font_data;
- /* Change 1996.01.23 end */
- }
- hit = 0;
- c += csize;
- break;
- }
- if( hit == -1 ) hit = i;
- if(is2b){
- *c = (unsigned char)(value >> 8);
- *(c + 1) = (unsigned char)(value);
- } else {
- *c = (unsigned char)value;
- }
- c += csize;
- }
- *len_ret = (c - str);
- return(&(fontdata[hit]));
-}
-/* for VW/UDC end */
-
-static FontSet
-_XomGetFontSetFromCharSet(
- XOC oc,
- XlcCharSet charset)
-{
- register FontSet font_set = XOC_GENERIC(oc)->font_set;
- register int num = XOC_GENERIC(oc)->font_set_num;
- XlcCharSet *charset_list;
- int charset_count;
-
- for ( ; num-- > 0; font_set++) {
- charset_count = font_set->charset_count;
- charset_list = font_set->charset_list;
- for ( ; charset_count-- > 0; charset_list++)
- if (*charset_list == charset)
- return font_set;
- }
-
- return (FontSet) NULL;
-}
-
-#ifdef MUSTCOPY
-static void
-cs_to_xchar2b(
- register char *from,
- register XChar2b *to,
- register length)
-{
- while (length-- > 0) {
- to->byte1 = *from++;
- to->byte2 = *from++;
- to++;
- }
-}
-
-static void
-cs_to_xchar2b_gl(
- register char *from,
- register XChar2b *to,
- register length)
-{
- while (length-- > 0) {
- to->byte1 = *from++ & 0x7f;
- to->byte2 = *from++ & 0x7f;
- to++;
- }
-}
-
-static void
-cs_to_xchar2b_gr(
- register char *from,
- register XChar2b *to,
- register length)
-{
- while (length-- > 0) {
- to->byte1 = *from++ | 0x80;
- to->byte2 = *from++ | 0x80;
- to++;
- }
-}
-#endif
-
-static void
-shift_to_gl(
- register char *text,
- register int length)
-{
- while (length-- > 0)
- *text++ &= 0x7f;
-}
-
-static void
-shift_to_gr(
- register char *text,
- register int length)
-{
- while (length-- > 0)
- *text++ |= 0x80;
-}
-
-static Bool
-load_font(
- XOC oc,
- FontSet font_set)
-{
- font_set->font = XLoadQueryFont(oc->core.om->core.display,
- oc->core.font_info.font_name_list[font_set->id]);
- if (font_set->font == NULL)
- return False;
-
- oc->core.font_info.font_struct_list[font_set->id] = font_set->font;
- XFreeFontInfo(NULL, font_set->info, 1);
- font_set->info = NULL;
-
- if (font_set->font->min_byte1 || font_set->font->max_byte1)
- font_set->is_xchar2b = True;
- else
- font_set->is_xchar2b = False;
-
- return True;
-}
-
-int
-_XomConvert(
- XOC oc,
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XPointer cs, lc_args[1];
- XlcCharSet charset;
- int length, cs_left, ret;
- FontSet font_set;
-#ifdef MUSTCOPY
- XChar2b *xchar2b;
- char *buf, buf_local[BUFSIZ];
-#endif
-
- cs = *to;
- cs_left = *to_left;
- lc_args[0] = (XPointer) &charset;
-
- ret = _XlcConvert(conv, from, from_left, &cs, &cs_left, lc_args, 1);
- if (ret < 0)
- return -1;
-
- font_set = _XomGetFontSetFromCharSet(oc, charset);
- if (font_set == NULL)
- return -1;
-
- if (font_set->font == NULL && load_font(oc, font_set) == False)
- return -1;
-
- length = *to_left - cs_left;
-
-#ifdef MUSTCOPY
- if (font_set->is_xchar2b) {
- buf = (length > BUFSIZ) ? Xmalloc(length) : buf_local;
- if (buf == NULL)
- return -1;
- memcpy(buf, (char *) *to, length);
-
- xchar2b = (XChar2b *) *to;
- length >>= 1;
-
- if (font_set->side == charset->side)
- cs_to_xchar2b(buf, xchar2b, length);
- else if (font_set->side == XlcGL)
- cs_to_xchar2b_gl(buf, xchar2b, length);
- else if (font_set->side == XlcGR)
- cs_to_xchar2b_gr(buf, xchar2b, length);
- else
- cs_to_xchar2b(buf, xchar2b, length);
-
- if (buf != buf_local)
- Xfree(buf);
-
- *to = (XPointer) (xchar2b + length);
- *to_left -= length;
- } else
-#endif
- {
- if (font_set->side != charset->side) {
- if (font_set->side == XlcGL)
- shift_to_gl(*to, length);
- else if (font_set->side == XlcGR)
- shift_to_gr(*to, length);
- }
-
- if (font_set->is_xchar2b)
- length >>= 1;
- *to = cs;
- *to_left -= length;
- }
-
- *((XFontStruct **) args[0]) = font_set->font;
- *((Bool *) args[1]) = font_set->is_xchar2b;
- if(num_args >= 3){
- *((FontSet *) args[2]) = font_set;
- }
-
- return ret;
-}
-
-XlcConv
-_XomInitConverter(
- XOC oc,
- XOMTextType type)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- XlcConv *convp;
- const char *conv_type;
- XlcConv conv;
- XLCd lcd;
-
- switch (type) {
- case XOMWideChar:
- convp = &gen->wcs_to_cs;
- conv_type = XlcNWideChar;
- break;
- case XOMMultiByte:
- convp = &gen->mbs_to_cs;
- conv_type = XlcNMultiByte;
- break;
- case XOMUtf8String:
- convp = &gen->utf8_to_cs;
- conv_type = XlcNUtf8String;
- break;
- default:
- return (XlcConv) NULL;
- }
-
- conv = *convp;
- if (conv) {
- _XlcResetConverter(conv);
- return conv;
- }
-
- lcd = oc->core.om->core.lcd;
-
- conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNFontCharSet);
- if (conv == (XlcConv) NULL) {
- conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
- if (conv == (XlcConv) NULL)
- return (XlcConv) NULL;
- }
-
- *convp = conv;
- return conv;
-}
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* for VW/UDC start */
+static Bool
+ismatch_scopes(
+ FontData fontdata,
+ unsigned long *value,
+ Bool is_shift)
+{
+ register int scopes_num = fontdata->scopes_num;
+ FontScope scopes = fontdata->scopes;
+ if (!scopes_num)
+ return False;
+
+ if(fontdata->font == NULL)
+ return False;
+
+ for(;scopes_num--;scopes++)
+ if ((scopes->start <= (*value & 0x7f7f)) &&
+ ((scopes->end) >= (*value & 0x7f7f))){
+ if(is_shift == True) {
+ if(scopes->shift){
+ if(scopes->shift_direction == '+'){
+ *value += scopes->shift ;
+ } else if( scopes->shift_direction == '-'){
+ *value -= scopes->shift ;
+ }
+ }
+ }
+ return True;
+ }
+
+ return False;
+}
+
+static int
+check_vertical_fonttype(
+ char *name)
+{
+ char *ptr;
+ int type = 0;
+
+ if(name == (char *)NULL || (int) strlen(name) <= 0)
+ return False;
+
+ /* Obtains the pointer of CHARSET_ENCODING_FIELD. */
+ if((ptr = strchr(name, '-')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ /* Obtains the pointer of vertical_map font type. */
+ if((ptr = strchr(ptr, '.')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ switch(*ptr) {
+ case '1':
+ type = 1; break;
+ case '2':
+ type = 2; break;
+ case '3':
+ type = 3; break;
+ }
+ return type;
+}
+
+/*
+*/
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+FontData
+_XomGetFontDataFromFontSet(
+ FontSet fs,
+ unsigned char *str,
+ int len,
+ int *len_ret,
+ int is2b,
+ int type) /* VMAP , VROTATE , else */
+{
+ unsigned long value;
+ int num,i,hit,csize;
+ FontData fontdata;
+ unsigned char *c;
+ int vfont_type;
+
+ c = str;
+ hit = -1;
+ if(type == VMAP){
+ fontdata = fs->vmap;
+ num = fs->vmap_num;
+ } else if(type == VROTATE){
+ fontdata = (FontData)fs->vrotate;
+ num = fs->vrotate_num;
+ } else {
+ if(fs->font_data_count <= 0 || fs->font_data == (FontData)NULL) {
+ fontdata = fs->substitute;
+ num = fs->substitute_num;
+ }else {
+ fontdata = fs->font_data;
+ num = fs->font_data_count;
+ }
+ /* CDExc20229 fix */
+ if(fontdata == NULL || num == 0){
+ return(NULL);
+ }
+ }
+
+
+ if(is2b){
+ csize = 2;
+ } else {
+ csize = 1;
+ }
+
+ for(;len;len--){
+ if(is2b){
+ value = (((unsigned long)*c) << 8)|(unsigned long)*(c + 1);
+ } else {
+ value = (unsigned long)*c;
+ }
+
+ /* ### NOTE: This routine DOES NOT WORK!
+ * ### We can work around the problem in the calling routine,
+ * ### but we really need to understand this better. As it
+ * ### stands, the algorithm ALWAYS returns "fontdata[0]"
+ * ### for non-VW text! This is clearly wrong. In fact,
+ * ### given the new parse_font[name|data]() algorithms,
+ * ### we may not even need this routine to do anything
+ * ### for non-VW text (since font_set->font always contains
+ * ### the best font for this fontset). -- jjw/pma (HP)
+ */
+ for (i=0;i<num;i++) {
+ if(type == VROTATE) {
+ if(fontdata[i].font) {
+ /* If the num_cr equal zero, all character is rotated. */
+ if(fontdata[i].scopes_num == 0) {
+ break;
+ } else {
+ /* The vertical rotate glyph is not have code shift. */
+ if (ismatch_scopes(&(fontdata[i]),&value,False)) {
+ break;
+ }
+ }
+ }
+ } else if(type == VMAP) {
+ if(fontdata[i].font) {
+ vfont_type = check_vertical_fonttype(fontdata[i].name);
+ if(vfont_type == 0 || vfont_type == 1) {
+ break;
+ } else if(vfont_type == 2 || vfont_type == 3) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+
+ if (ismatch_scopes(&(fontdata[i]),&value,True)) {
+ break;
+ }
+ }
+ }
+ } else { /* FONTSCOPE */
+ if(fontdata[i].font) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+ if (ismatch_scopes(&(fontdata[i]),&value,True)){
+ break;
+ }
+ }
+ }
+ }
+ if((hit != -1) && (i != hit)){
+ break;
+ }
+ if(i == num){
+ if( type == VROTATE || type == VMAP){
+ /* Change 1996.01.23 start */
+ if(fs->font_data_count <= 0 ||
+ fs->font_data == (FontData)NULL)
+ fontdata = fs->substitute;
+ else
+ fontdata = fs->font_data;
+ /* Change 1996.01.23 end */
+ }
+ hit = 0;
+ c += csize;
+ break;
+ }
+ if( hit == -1 ) hit = i;
+ if(is2b){
+ *c = (unsigned char)(value >> 8);
+ *(c + 1) = (unsigned char)(value);
+ } else {
+ *c = (unsigned char)value;
+ }
+ c += csize;
+ }
+ *len_ret = (c - str);
+ return(&(fontdata[hit]));
+}
+/* for VW/UDC end */
+
+static FontSet
+_XomGetFontSetFromCharSet(
+ XOC oc,
+ XlcCharSet charset)
+{
+ register FontSet font_set = XOC_GENERIC(oc)->font_set;
+ register int num = XOC_GENERIC(oc)->font_set_num;
+ XlcCharSet *charset_list;
+ int charset_count;
+
+ for ( ; num-- > 0; font_set++) {
+ charset_count = font_set->charset_count;
+ charset_list = font_set->charset_list;
+ for ( ; charset_count-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return font_set;
+ }
+
+ return (FontSet) NULL;
+}
+
+#ifdef MUSTCOPY
+static void
+cs_to_xchar2b(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++;
+ to->byte2 = *from++;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gl(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ & 0x7f;
+ to->byte2 = *from++ & 0x7f;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gr(
+ register char *from,
+ register XChar2b *to,
+ register length)
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ | 0x80;
+ to->byte2 = *from++ | 0x80;
+ to++;
+ }
+}
+#endif
+
+static void
+shift_to_gl(
+ register char *text,
+ register int length)
+{
+ while (length-- > 0)
+ *text++ &= 0x7f;
+}
+
+static void
+shift_to_gr(
+ register char *text,
+ register int length)
+{
+ while (length-- > 0)
+ *text++ |= 0x80;
+}
+
+static Bool
+load_font(
+ XOC oc,
+ FontSet font_set)
+{
+ font_set->font = XLoadQueryFont(oc->core.om->core.display,
+ oc->core.font_info.font_name_list[font_set->id]);
+ if (font_set->font == NULL)
+ return False;
+
+ oc->core.font_info.font_struct_list[font_set->id] = font_set->font;
+ XFreeFontInfo(NULL, font_set->info, 1);
+ font_set->info = NULL;
+
+ if (font_set->font->min_byte1 || font_set->font->max_byte1)
+ font_set->is_xchar2b = True;
+ else
+ font_set->is_xchar2b = False;
+
+ return True;
+}
+
+int
+_XomConvert(
+ XOC oc,
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XPointer cs, lc_args[1];
+ XlcCharSet charset;
+ int length, cs_left, ret;
+ FontSet font_set;
+#ifdef MUSTCOPY
+ XChar2b *xchar2b;
+ char *buf, buf_local[BUFSIZ];
+#endif
+
+ cs = *to;
+ cs_left = *to_left;
+ lc_args[0] = (XPointer) &charset;
+
+ ret = _XlcConvert(conv, from, from_left, &cs, &cs_left, lc_args, 1);
+ if (ret < 0)
+ return -1;
+
+ font_set = _XomGetFontSetFromCharSet(oc, charset);
+ if (font_set == NULL)
+ return -1;
+
+ if (font_set->font == NULL && load_font(oc, font_set) == False)
+ return -1;
+
+ length = *to_left - cs_left;
+
+#ifdef MUSTCOPY
+ if (font_set->is_xchar2b) {
+ buf = (length > BUFSIZ) ? Xmalloc(length) : buf_local;
+ if (buf == NULL)
+ return -1;
+ memcpy(buf, (char *) *to, length);
+
+ xchar2b = (XChar2b *) *to;
+ length >>= 1;
+
+ if (font_set->side == charset->side)
+ cs_to_xchar2b(buf, xchar2b, length);
+ else if (font_set->side == XlcGL)
+ cs_to_xchar2b_gl(buf, xchar2b, length);
+ else if (font_set->side == XlcGR)
+ cs_to_xchar2b_gr(buf, xchar2b, length);
+ else
+ cs_to_xchar2b(buf, xchar2b, length);
+
+ if (buf != buf_local)
+ Xfree(buf);
+
+ *to = (XPointer) (xchar2b + length);
+ *to_left -= length;
+ } else
+#endif
+ {
+ if (font_set->side != charset->side) {
+ if (font_set->side == XlcGL)
+ shift_to_gl(*to, length);
+ else if (font_set->side == XlcGR)
+ shift_to_gr(*to, length);
+ }
+
+ if (font_set->is_xchar2b)
+ length >>= 1;
+ *to = cs;
+ *to_left -= length;
+ }
+
+ *((XFontStruct **) args[0]) = font_set->font;
+ *((Bool *) args[1]) = font_set->is_xchar2b;
+ if(num_args >= 3){
+ *((FontSet *) args[2]) = font_set;
+ }
+
+ return ret;
+}
+
+XlcConv
+_XomInitConverter(
+ XOC oc,
+ XOMTextType type)
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XlcConv *convp;
+ const char *conv_type;
+ XlcConv conv;
+ XLCd lcd;
+
+ switch (type) {
+ case XOMWideChar:
+ convp = &gen->wcs_to_cs;
+ conv_type = XlcNWideChar;
+ break;
+ case XOMMultiByte:
+ convp = &gen->mbs_to_cs;
+ conv_type = XlcNMultiByte;
+ break;
+ case XOMUtf8String:
+ convp = &gen->utf8_to_cs;
+ conv_type = XlcNUtf8String;
+ break;
+ default:
+ return (XlcConv) NULL;
+ }
+
+ conv = *convp;
+ if (conv) {
+ _XlcResetConverter(conv);
+ return conv;
+ }
+
+ lcd = oc->core.om->core.lcd;
+
+ conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNFontCharSet);
+ if (conv == (XlcConv) NULL) {
+ conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ }
+
+ *convp = conv;
+ return conv;
+}