diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /libX11/modules/om/generic | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'libX11/modules/om/generic')
-rw-r--r-- | libX11/modules/om/generic/Makefile.am | 40 | ||||
-rw-r--r-- | libX11/modules/om/generic/Makefile.in | 578 | ||||
-rw-r--r-- | libX11/modules/om/generic/omDefault.c | 451 | ||||
-rw-r--r-- | libX11/modules/om/generic/omGeneric.c | 2187 | ||||
-rw-r--r-- | libX11/modules/om/generic/omImText.c | 92 | ||||
-rw-r--r-- | libX11/modules/om/generic/omText.c | 372 | ||||
-rw-r--r-- | libX11/modules/om/generic/omTextEsc.c | 302 | ||||
-rw-r--r-- | libX11/modules/om/generic/omTextExt.c | 137 | ||||
-rw-r--r-- | libX11/modules/om/generic/omTextPer.c | 204 | ||||
-rw-r--r-- | libX11/modules/om/generic/omXChar.c | 479 |
10 files changed, 4842 insertions, 0 deletions
diff --git a/libX11/modules/om/generic/Makefile.am b/libX11/modules/om/generic/Makefile.am new file mode 100644 index 000000000..043ee6068 --- /dev/null +++ b/libX11/modules/om/generic/Makefile.am @@ -0,0 +1,40 @@ +AM_CFLAGS= \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/include/X11 \ + -I$(top_builddir)/include \ + -I$(top_builddir)/include/X11 \ + -I$(top_srcdir)/src/xcms \ + -I$(top_srcdir)/src/xkb \ + -I$(top_srcdir)/src/xlibi18n \ + -I$(top_srcdir)/src \ + $(X11_CFLAGS) \ + $(BIGFONT_CFLAGS) \ + $(XDMCP_CFLAGS) \ + -D_BSD_SOURCE \ + $(MALLOC_ZERO_CFLAGS) + +if XLIB_LOADABLE_I18N + +commonlibdir = $(X11_LOCALELIBDIR)/common +commonlib_LTLIBRARIES=xomGeneric.la +xomGeneric_la_LDFLAGS = -module -version-number 2:0:0 +xomGeneric_la_LIBADD = $(I18N_MODULE_LIBS) + +else + +noinst_LTLIBRARIES = libxomGeneric.la + +endif + + +xomGeneric_la_SOURCES = \ + omDefault.c \ + omGeneric.c \ + omImText.c \ + omText.c \ + omTextEsc.c \ + omTextExt.c \ + omTextPer.c \ + omXChar.c + +libxomGeneric_la_SOURCES = $(xomGeneric_la_SOURCES) diff --git a/libX11/modules/om/generic/Makefile.in b/libX11/modules/om/generic/Makefile.in new file mode 100644 index 000000000..b3d239e65 --- /dev/null +++ b/libX11/modules/om/generic/Makefile.in @@ -0,0 +1,578 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = modules/om/generic +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/config.h \ + $(top_builddir)/include/X11/XlibConf.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(commonlibdir)" +commonlibLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(commonlib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libxomGeneric_la_LIBADD = +am__objects_1 = omDefault.lo omGeneric.lo omImText.lo omText.lo \ + omTextEsc.lo omTextExt.lo omTextPer.lo omXChar.lo +am_libxomGeneric_la_OBJECTS = $(am__objects_1) +libxomGeneric_la_OBJECTS = $(am_libxomGeneric_la_OBJECTS) +@XLIB_LOADABLE_I18N_FALSE@am_libxomGeneric_la_rpath = +am__DEPENDENCIES_1 = +@XLIB_LOADABLE_I18N_TRUE@xomGeneric_la_DEPENDENCIES = \ +@XLIB_LOADABLE_I18N_TRUE@ $(am__DEPENDENCIES_1) +am_xomGeneric_la_OBJECTS = omDefault.lo omGeneric.lo omImText.lo \ + omText.lo omTextEsc.lo omTextExt.lo omTextPer.lo omXChar.lo +xomGeneric_la_OBJECTS = $(am_xomGeneric_la_OBJECTS) +xomGeneric_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(xomGeneric_la_LDFLAGS) $(LDFLAGS) -o $@ +@XLIB_LOADABLE_I18N_TRUE@am_xomGeneric_la_rpath = -rpath \ +@XLIB_LOADABLE_I18N_TRUE@ $(commonlibdir) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11 +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxomGeneric_la_SOURCES) $(xomGeneric_la_SOURCES) +DIST_SOURCES = $(libxomGeneric_la_SOURCES) $(xomGeneric_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +AMTAR = @AMTAR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BIGFONT_CFLAGS = @BIGFONT_CFLAGS@ +BIGFONT_LIBS = @BIGFONT_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GREP = @GREP@ +I18N_MODULE_LIBS = @I18N_MODULE_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEYSYMDEF = @KEYSYMDEF@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINT = @LINT@ +LINTLIB = @LINTLIB@ +LINT_FLAGS = @LINT_FLAGS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WCHAR32 = @WCHAR32@ +X11_CFLAGS = @X11_CFLAGS@ +X11_DATADIR = @X11_DATADIR@ +X11_EXTRA_DEPS = @X11_EXTRA_DEPS@ +X11_LIBDIR = @X11_LIBDIR@ +X11_LIBS = @X11_LIBS@ +X11_LOCALEDATADIR = @X11_LOCALEDATADIR@ +X11_LOCALEDIR = @X11_LOCALEDIR@ +X11_LOCALELIBDIR = @X11_LOCALELIBDIR@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XERRORDB = @XERRORDB@ +XKBPROTO_CFLAGS = @XKBPROTO_CFLAGS@ +XKBPROTO_LIBS = @XKBPROTO_LIBS@ +XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@ +XKEYSYMDB = @XKEYSYMDB@ +XLOCALEDATADIR = @XLOCALEDATADIR@ +XLOCALEDIR = @XLOCALEDIR@ +XLOCALELIBDIR = @XLOCALELIBDIR@ +XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@ +XPROTO_CFLAGS = @XPROTO_CFLAGS@ +XPROTO_LIBS = @XPROTO_LIBS@ +XTHREADLIB = @XTHREADLIB@ +XTHREADS = @XTHREADS@ +XTHREAD_CFLAGS = @XTHREAD_CFLAGS@ +XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@ +XUSE_MTSAFE_API = @XUSE_MTSAFE_API@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/include/X11 \ + -I$(top_builddir)/include \ + -I$(top_builddir)/include/X11 \ + -I$(top_srcdir)/src/xcms \ + -I$(top_srcdir)/src/xkb \ + -I$(top_srcdir)/src/xlibi18n \ + -I$(top_srcdir)/src \ + $(X11_CFLAGS) \ + $(BIGFONT_CFLAGS) \ + $(XDMCP_CFLAGS) \ + -D_BSD_SOURCE \ + $(MALLOC_ZERO_CFLAGS) + +@XLIB_LOADABLE_I18N_TRUE@commonlibdir = $(X11_LOCALELIBDIR)/common +@XLIB_LOADABLE_I18N_TRUE@commonlib_LTLIBRARIES = xomGeneric.la +@XLIB_LOADABLE_I18N_TRUE@xomGeneric_la_LDFLAGS = -module -version-number 2:0:0 +@XLIB_LOADABLE_I18N_TRUE@xomGeneric_la_LIBADD = $(I18N_MODULE_LIBS) +@XLIB_LOADABLE_I18N_FALSE@noinst_LTLIBRARIES = libxomGeneric.la +xomGeneric_la_SOURCES = \ + omDefault.c \ + omGeneric.c \ + omImText.c \ + omText.c \ + omTextEsc.c \ + omTextExt.c \ + omTextPer.c \ + omXChar.c + +libxomGeneric_la_SOURCES = $(xomGeneric_la_SOURCES) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign modules/om/generic/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign modules/om/generic/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-commonlibLTLIBRARIES: $(commonlib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(commonlibdir)" || $(MKDIR_P) "$(DESTDIR)$(commonlibdir)" + @list='$(commonlib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(commonlibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(commonlibdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(commonlibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(commonlibdir)/$$f"; \ + else :; fi; \ + done + +uninstall-commonlibLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(commonlib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(commonlibdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(commonlibdir)/$$p"; \ + done + +clean-commonlibLTLIBRARIES: + -test -z "$(commonlib_LTLIBRARIES)" || rm -f $(commonlib_LTLIBRARIES) + @list='$(commonlib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxomGeneric.la: $(libxomGeneric_la_OBJECTS) $(libxomGeneric_la_DEPENDENCIES) + $(LINK) $(am_libxomGeneric_la_rpath) $(libxomGeneric_la_OBJECTS) $(libxomGeneric_la_LIBADD) $(LIBS) +xomGeneric.la: $(xomGeneric_la_OBJECTS) $(xomGeneric_la_DEPENDENCIES) + $(xomGeneric_la_LINK) $(am_xomGeneric_la_rpath) $(xomGeneric_la_OBJECTS) $(xomGeneric_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omDefault.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omGeneric.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omImText.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omText.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omTextEsc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omTextExt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omTextPer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omXChar.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(commonlibdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-commonlibLTLIBRARIES clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-commonlibLTLIBRARIES + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-commonlibLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-commonlibLTLIBRARIES clean-generic clean-libtool \ + clean-noinstLTLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-commonlibLTLIBRARIES install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-commonlibLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libX11/modules/om/generic/omDefault.c b/libX11/modules/om/generic/omDefault.c new file mode 100644 index 000000000..57dd975ad --- /dev/null +++ b/libX11/modules/om/generic/omDefault.c @@ -0,0 +1,451 @@ +/* $Xorg: omDefault.c,v 1.3 2000/08/17 19:45:21 cpqbld Exp $ */ +/* + * 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. + */ +/* $XFree86: xc/lib/X11/omDefault.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */ + +#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/omGeneric.c b/libX11/modules/om/generic/omGeneric.c new file mode 100644 index 000000000..3a813b35d --- /dev/null +++ b/libX11/modules/om/generic/omGeneric.c @@ -0,0 +1,2187 @@ +/* $Xorg: omGeneric.c,v 1.6 2000/08/17 19:45:21 cpqbld Exp $ */ +/* #define FONTDEBUG */ +/* + * 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 + * + */ +/* $XFree86: xc/lib/X11/omGeneric.c,v 3.27 2003/05/27 22:26:27 tsi Exp $ */ + +/* + * Fixed the algorithms in parse_fontname() and parse_fontdata() + * to improve the logic for determining which font should be + * returned for a given CharSet. We even added some comments + * so that you can figure out what in the heck we're doing. We + * realize this is a departure from the norm, but hey, we're + * rebels! :-) :-) + * + * Modifiers: Jeff Walls, Paul Anderson: HEWLETT-PACKARD + */ +/* + * Cleaned up mess, removed some blabla + * Egbert Eich, SuSE Linux AG + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "Xlibint.h" +#include "XomGeneric.h" +#include "XlcGeneric.h" +#include <X11/Xos.h> +#include <X11/Xatom.h> +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#define MAXFONTS 100 +#define PIXEL_SIZE_FIELD 7 +#define POINT_SIZE_FIELD 8 +#define CHARSET_ENCODING_FIELD 14 +#define XLFD_MAX_LEN 255 + +#if 0 +extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement(), + _Xutf8DefaultTextEscapement(); +extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents(), + _Xutf8DefaultTextExtents(); +extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents(), + _Xutf8DefaultTextPerCharExtents(); +extern int _XmbDefaultDrawString(), _XwcDefaultDrawString(), + _Xutf8DefaultDrawString(); +extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString(), + _Xutf8DefaultDrawImageString(); + +extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement(), + _Xutf8GenericTextEscapement(); +extern int _XmbGenericTextExtents(), _XwcGenericTextExtents(), + _Xutf8GenericTextExtents(); +extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents(), + _Xutf8GenericTextPerCharExtents(); +extern int _XmbGenericDrawString(), _XwcGenericDrawString(), + _Xutf8GenericDrawString(); +extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString(), + _Xutf8GenericDrawImageString(); + +extern void _XlcDbg_printValue (const char *str, char **value, int num); +#endif + +/* For VW/UDC start */ + +static FontData +init_fontdata( + FontData font_data, + int font_data_count) +{ + FontData fd; + int i; + + fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count); + if(fd == (FontData) NULL) + return False; + + memset(fd, 0x00, sizeof(FontData) * font_data_count); + for(i = 0 ; i < font_data_count ; i++) + fd[i] = font_data[i]; + + return fd; +} + +static VRotate +init_vrotate( + FontData font_data, + int font_data_count, + int type, + CodeRange code_range, + int code_range_num) +{ + VRotate vrotate; + int i; + + if(type == VROTATE_NONE) + return (VRotate)NULL; + + vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count); + if(vrotate == (VRotate) NULL) + return False; + + memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count); + for(i = 0 ; i < font_data_count ; i++) { + vrotate[i].charset_name = font_data[i].name; + vrotate[i].side = font_data[i].side; + if(type == VROTATE_PART) { + vrotate[i].num_cr = code_range_num; + vrotate[i].code_range = code_range; + } + } + + return vrotate; +} + +static Bool +init_fontset( + XOC oc) +{ + XOCGenericPart *gen; + FontSet font_set; + OMData data; + int count; + + count = XOM_GENERIC(oc->core.om)->data_num; + data = XOM_GENERIC(oc->core.om)->data; + + font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count); + if (font_set == NULL) + return False; + memset((char *) font_set, 0x00, sizeof(FontSetRec) * count); + + gen = XOC_GENERIC(oc); + gen->font_set_num = count; + gen->font_set = font_set; + + for ( ; count-- > 0; data++, font_set++) { + font_set->charset_count = data->charset_count; + font_set->charset_list = data->charset_list; + + if((font_set->font_data = init_fontdata(data->font_data, + data->font_data_count)) == NULL) + goto err; + font_set->font_data_count = data->font_data_count; + if((font_set->substitute = init_fontdata(data->substitute, + data->substitute_num)) == NULL) + goto err; + font_set->substitute_num = data->substitute_num; + if((font_set->vmap = init_fontdata(data->vmap, + data->vmap_num)) == NULL) + goto err; + font_set->vmap_num = data->vmap_num; + + if(data->vrotate_type != VROTATE_NONE) { + /* A vrotate member is specified primary font data */ + /* as initial value. */ + if((font_set->vrotate = init_vrotate(data->font_data, + data->font_data_count, + data->vrotate_type, + data->vrotate, + data->vrotate_num)) == NULL) + goto err; + font_set->vrotate_num = data->font_data_count; + } + } + return True; + +err: + if(font_set->font_data) + Xfree(font_set->font_data); + if(font_set->substitute) + Xfree(font_set->substitute); + if(font_set->vmap) + Xfree(font_set->vmap); + if(font_set->vrotate) + Xfree(font_set->vrotate); + if(font_set) + Xfree(font_set); + gen->font_set = (FontSet) NULL; + gen->font_set_num = 0; + return False; +} + +/* For VW/UDC end */ + +static char * +get_prop_name( + Display *dpy, + XFontStruct *fs) +{ + unsigned long fp; + + if (XGetFontProperty(fs, XA_FONT, &fp)) + return XGetAtomName(dpy, fp); + + return (char *) NULL; +} + +/* For VW/UDC start */ + +static Bool +load_fontdata( + XOC oc, + FontData font_data, + int font_data_num) +{ + Display *dpy = oc->core.om->core.display; + FontData fd = font_data; + + if(font_data == NULL) return(True); + for( ; font_data_num-- ; fd++) { + if(fd->xlfd_name != (char *) NULL && fd->font == NULL) { + fd->font = XLoadQueryFont(dpy, fd->xlfd_name); + if (fd->font == NULL){ + return False; + } + } + } + return True; +} + +static Bool +load_fontset_data( + XOC oc, + FontSet font_set) +{ + Display *dpy = oc->core.om->core.display; + + if(font_set->font_name == (char *)NULL) return False ; + + /* If font_set->font is not NULL, it contains the *best* + * match font for this FontSet. + * -- jjw/pma (HP) + */ + if(font_set->font == NULL) { + font_set->font = XLoadQueryFont(dpy, font_set->font_name); + if (font_set->font == NULL){ + return False; + } + } + return True; +} + +static Bool +load_font( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + int num = gen->font_set_num; + + for ( ; num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + if (load_fontset_data (oc, font_set) != True) + return False; +#ifndef TESTVERSION + if(load_fontdata(oc, font_set->font_data, + font_set->font_data_count) != True) + return False; + + if(load_fontdata(oc, font_set->substitute, + font_set->substitute_num) != True) + return False; +#endif + +/* Add 1996.05.20 */ + if( oc->core.orientation == XOMOrientation_TTB_RTL || + oc->core.orientation == XOMOrientation_TTB_LTR ){ + if (font_set->vpart_initialize == 0) { + load_fontdata(oc, font_set->vmap, font_set->vmap_num); + load_fontdata(oc, (FontData) font_set->vrotate, + font_set->vrotate_num); + font_set->vpart_initialize = 1; + } + } + + if (font_set->font->min_byte1 || font_set->font->max_byte1) + font_set->is_xchar2b = True; + else + font_set->is_xchar2b = False; + } + + return True; +} + +/* For VW/UDC end */ + +static Bool +load_font_info( + XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + char **fn_list; + int fn_num, num = gen->font_set_num; + + for ( ; num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + if (font_set->info == NULL) { + fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num, + &font_set->info); + if (font_set->info == NULL) + return False; + + XFreeFontNames(fn_list); + } + } + + return True; +} + +/* For Vertical Writing start */ + +static void +check_fontset_extents( + XCharStruct *overall, + int *logical_ascent, + int *logical_descent, + XFontStruct *font) +{ + overall->lbearing = min(overall->lbearing, font->min_bounds.lbearing); + overall->rbearing = max(overall->rbearing, font->max_bounds.rbearing); + overall->ascent = max(overall->ascent, font->max_bounds.ascent); + overall->descent = max(overall->descent, font->max_bounds.descent); + overall->width = max(overall->width, font->max_bounds.width); + *logical_ascent = max(*logical_ascent, font->ascent); + *logical_descent = max(*logical_descent, font->descent); +} + +/* For Vertical Writing end */ + +static void +set_fontset_extents( + XOC oc) +{ + XRectangle *ink = &oc->core.font_set_extents.max_ink_extent; + XRectangle *logical = &oc->core.font_set_extents.max_logical_extent; + XFontStruct **font_list, *font; + XCharStruct overall; + int logical_ascent, logical_descent; + int num = oc->core.font_info.num_font; + + font_list = oc->core.font_info.font_struct_list; + font = *font_list++; + overall = font->max_bounds; + overall.lbearing = font->min_bounds.lbearing; + logical_ascent = font->ascent; + logical_descent = font->descent; + + /* For Vertical Writing start */ + + while (--num > 0) { + font = *font_list++; + check_fontset_extents(&overall, &logical_ascent, &logical_descent, + font); + } + + { + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + FontData font_data; + int font_set_num = gen->font_set_num; + int font_data_count; + + for( ; font_set_num-- ; font_set++) { + if(font_set->vmap_num > 0) { + font_data = font_set->vmap; + font_data_count = font_set->vmap_num; + for( ; font_data_count-- ; font_data++) { + if(font_data->font != NULL) { + check_fontset_extents(&overall, &logical_ascent, + &logical_descent, + font_data->font); + } + } + } + + if(font_set->vrotate_num > 0) { + font_data = (FontData) font_set->vrotate; + font_data_count = font_set->vrotate_num; + for( ; font_data_count-- ; font_data++) { + if(font_data != NULL) + if(font_data->font != NULL) { + check_fontset_extents(&overall, &logical_ascent, + &logical_descent, + font_data->font); + } + } + } + } + } + + /* For Vertical Writing start */ + + ink->x = overall.lbearing; + ink->y = -(overall.ascent); + ink->width = overall.rbearing - overall.lbearing; + ink->height = overall.ascent + overall.descent; + + logical->x = 0; + logical->y = -(logical_ascent); + logical->width = overall.width; + logical->height = logical_ascent + logical_descent; +} + +static Bool +init_core_part( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + int font_set_num; + XFontStruct **font_struct_list; + char **font_name_list, *font_name_buf; + int count, length; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + count = length = 0; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + length += strlen(font_set->font_name) + 1; + + count++; + } + if (count == 0) + return False; + + font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count); + if (font_struct_list == NULL) + return False; + + font_name_list = (char **) Xmalloc(sizeof(char *) * count); + if (font_name_list == NULL) + goto err; + + font_name_buf = (char *) Xmalloc(length); + if (font_name_buf == NULL) + goto err; + + oc->core.font_info.num_font = count; + oc->core.font_info.font_name_list = font_name_list; + oc->core.font_info.font_struct_list = font_struct_list; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for (count = 0; font_set_num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + + font_set->id = count; + if (font_set->font) + *font_struct_list++ = font_set->font; + else + *font_struct_list++ = font_set->info; + strcpy(font_name_buf, font_set->font_name); + Xfree(font_set->font_name); + *font_name_list++ = font_set->font_name = font_name_buf; + font_name_buf += strlen(font_name_buf) + 1; + + count++; + } + + set_fontset_extents(oc); + + return True; + +err: + if (font_name_list) + Xfree(font_name_list); + Xfree(font_struct_list); + + return False; +} + +static char * +get_font_name( + XOC oc, + char *pattern) +{ + char **list, *name; + int count = 0; + + list = XListFonts(oc->core.om->core.display, pattern, 1, &count); + if (list == NULL) + return NULL; + + name = (char *) Xmalloc(strlen(*list) + 1); + if (name) + strcpy(name, *list); + + XFreeFontNames(list); + + return name; +} + +/* For VW/UDC start*/ + +static char * +get_rotate_fontname( + char *font_name) +{ + char *pattern = NULL, *ptr = NULL; + char *fields[CHARSET_ENCODING_FIELD]; + char str_pixel[32], str_point[4]; + char *rotate_font_ptr = NULL; + int pixel_size = 0; + int field_num = 0, len = 0; + + if(font_name == (char *) NULL || (len = strlen(font_name)) <= 0 + || len > XLFD_MAX_LEN) + return NULL; + + pattern = (char *)Xmalloc(len + 1); + if(!pattern) + return NULL; + strcpy(pattern, font_name); + + memset(fields, 0, sizeof(char *) * 14); + ptr = pattern; + while(isspace(*ptr)) { + ptr++; + } + if(*ptr == '-') + ptr++; + + for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && ptr && *ptr ; + ptr++, field_num++) { + fields[field_num] = ptr; + + if((ptr = strchr(ptr, '-'))) { + *ptr = '\0'; + } + } + + if(field_num < CHARSET_ENCODING_FIELD) + return NULL; + + /* Pixel Size field : fields[6] */ + for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) { + if(!isdigit(*ptr)) { + if(*ptr == '['){ /* 960730 */ + strcpy(pattern, font_name); + return(pattern); + } + if(pattern) + Xfree(pattern); + return NULL; + } + } + pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]); + sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size); + fields[6] = str_pixel; + + /* Point Size field : fields[7] */ + strcpy(str_point, "*"); + fields[POINT_SIZE_FIELD - 1] = str_point; + + len = 0; + for (field_num = 0; field_num < CHARSET_ENCODING_FIELD && + fields[field_num]; field_num++) { + len += 1 + strlen(fields[field_num]); + } + + /* Max XLFD length is 255 */ + if (len > XLFD_MAX_LEN) + return NULL; + + rotate_font_ptr = (char *)Xmalloc(len + 1); + if(!rotate_font_ptr) + return NULL; + + rotate_font_ptr[0] = '\0'; + + for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && + fields[field_num] ; field_num++) { + sprintf(rotate_font_ptr, "%s-%s", rotate_font_ptr, fields[field_num]); + } + + if(pattern) + Xfree(pattern); + + return rotate_font_ptr; +} + +static Bool +is_match_charset( + FontData font_data, + char *font_name) +{ + char *last; + int length, name_len; + + name_len = strlen(font_name); + last = font_name + name_len; + + length = strlen(font_data->name); + if (length > name_len) + return False; + + if (_XlcCompareISOLatin1(last - length, font_data->name) == 0) + return True; + + return False; +} + +#if 0 +static char * +get_font_name_from_list( + XOC oc, + char *pattern, + FontData font_data) +{ + char **list, *name = (char *)NULL, *fname; + int count = 0, i; + + list = XListFonts(oc->core.om->core.display, pattern, MAXFONTS, &count); + if (list == NULL) + return NULL; + + for (i = 0; i < count; i++) { + fname = list[i]; + if(is_match_charset(font_data, fname) == True) { + name = (char *) Xmalloc(strlen(fname) + 1); + if (name) + strcpy(name, fname); + break; + } + } + + XFreeFontNames(list); + + return name; +} +#endif + +static int +parse_all_name( + XOC oc, + FontData font_data, + char *pattern) +{ + +#ifdef OLDCODE + if(is_match_charset(font_data, pattern) != True) + return False; + + font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1); + if(font_data->xlfd_name == NULL) + return (-1); + + strcpy(font_data->xlfd_name, pattern); + return True; +#else /* OLDCODE */ + Display *dpy = oc->core.om->core.display; + char **fn_list = NULL, *prop_fname = NULL; + int list_num; + XFontStruct *fs_list; + if(is_match_charset(font_data, pattern) != True) { + /* + * pattern should not contain any wildcard (execpt '?') + * this was probably added to make this case insensitive. + */ + if ((fn_list = XListFontsWithInfo(dpy, pattern, + MAXFONTS, + &list_num, &fs_list)) == NULL) { + return False; + } + /* shouldn't we loop here ? */ + else if ((prop_fname = get_prop_name(dpy, fs_list)) == NULL) { + XFreeFontInfo(fn_list, fs_list, list_num); + return False; + } + else if ((is_match_charset(font_data, prop_fname) != True)) { + XFree(prop_fname); + XFreeFontInfo(fn_list, fs_list, list_num); + return False; + } + else { + font_data->xlfd_name = prop_fname; + XFreeFontInfo(fn_list, fs_list, list_num); + return True; + } + } + + font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1); + if(font_data->xlfd_name == NULL) + return (-1); + + strcpy(font_data->xlfd_name, pattern); + return True; +#endif /* OLDCODE */ +} + +static int +parse_omit_name( + XOC oc, + FontData font_data, + char *pattern) +{ + char* last = (char *) NULL; + char* base_name; + char buf[XLFD_MAX_LEN + 1]; + int length = 0; + int num_fields; + /* + * If the font specified by "pattern" is expandable to be + * a member of "font_data"'s FontSet, we've found a match. + */ + if(is_match_charset(font_data, pattern) == True) { + if ((font_data->xlfd_name = get_font_name(oc, pattern)) != NULL) { + return True; + } + } + + length = strlen (pattern); + + if (length > XLFD_MAX_LEN) + return -1; + + strcpy(buf, pattern); + last = buf + length - 1; + + /* Replace the original encoding with the encoding for this FontSet. */ + + /* Figure out how many fields have been specified in this xlfd. */ + for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++) + if (*base_name == '-') num_fields++; + + switch (num_fields) { + case 12: + /* This is the best way to have specifed the fontset. In this + * case, there is no original encoding. E.g., + * -*-*-*-*-*-*-14-*-*-*-*-* + * To this, we'll append a dash: + * -*-*-*-*-*-*-14-*-*-*-*-*- + * then append the encoding to get: + * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0 + */ + /* + * Take care of: + * -*-*-*-*-*-*-14-*-*-*-*- + */ + if (*(last) == '-') + *++last = '*'; + + *++last = '-'; + break; + case 13: + /* Got the charset, not the encoding, zap the charset In this + * case, there is no original encoding, but there is a charset. E.g., + * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990 + * To this, we remove the charset: + * -*-*-*-*-*-*-14-*-*-*-*-*- + * then append the new encoding to get: + * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0 + */ + last = strrchr (buf, '-'); + num_fields = 12; + break; + case 14: + /* Both the charset and the encoding are specified. Get rid + * of them so that we can append the new charset encoding. E.g., + * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990-0 + * To this, we'll remove the encoding and charset to get: + * -*-*-*-*-*-*-14-*-*-*-*-*- + * then append the new encoding to get: + * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0 + */ + last = strrchr (buf, '-'); + *last = '\0'; + last = strrchr (buf, '-'); + num_fields = 12; + break; + default: + if (*last != '-') + *++last = '-'; + break; + } + + /* At this point, "last" is pointing to the last "-" in the + * xlfd, and all xlfd's at this point take a form similar to: + * -*-*-*-*-*-*-14-*-*-*-*-*- + * (i.e., no encoding). + * After the strcpy, we'll end up with something similar to: + * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0 + * + * If the modified font is found in the current FontSet, + * we've found a match. + */ + + last++; + + if ((last - buf) + strlen(font_data->name) > XLFD_MAX_LEN) + return -1; + + strcpy(last, font_data->name); + if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL) + return True; + + /* This may mot be needed anymore as XListFonts() takes care of this */ + while (num_fields < 12) { + if ((last - buf) > (XLFD_MAX_LEN - 2)) + return -1; + *last = '*'; + *(last + 1) = '-'; + strcpy(last + 2, font_data->name); + num_fields++; + last+=2; + if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL) + return True; + } + + + return False; +} + + +typedef enum{C_PRIMARY, C_SUBSTITUTE, C_VMAP, C_VROTATE } ClassType; + +static int +parse_fontdata( + XOC oc, + FontSet font_set, + FontData font_data, + int font_data_count, + char **name_list, + int name_list_count, + ClassType class, + FontDataRec *font_data_return) +{ + + char **cur_name_list = name_list; + char *font_name = (char *) NULL; + char *pattern = (char *) NULL; + int found_num = 0, ret = 0; + int count = name_list_count; + + if(name_list == NULL || count <= 0) { + return False; + } + + if(font_data == NULL || font_data_count <= 0) { + return False; + } + + /* Loop through each font encoding defined in the "font_data" FontSet. */ + for ( ; font_data_count-- > 0; font_data++) { + Bool is_found = False; + font_name = (char *) NULL; + count = name_list_count; + cur_name_list = name_list; + + /* + * Loop through each font specified by the user + * in the call to XCreateFontset(). + */ + while (count-- > 0) { + pattern = *cur_name_list++; + if (pattern == NULL || *pattern == '\0') + continue; +#ifdef FONTDEBUG + fprintf(stderr,"Font pattern: %s %s\n", + pattern,font_data->name); +#endif + + /* + * If the current font is fully specified (i.e., the + * xlfd contains no wildcards) and the font exists on + * the X Server, we have a match. + */ + if (strchr(pattern, '*') == NULL && + (font_name = get_font_name(oc, pattern))) { + /* + * Find the full xlfd name for this font. If the font is + * already in xlfd format, it is simply returned. If the + * font is an alias for another font, the xlfd of the + * aliased font is returned. + */ + ret = parse_all_name(oc, font_data, font_name); + Xfree(font_name); + + if (ret == -1) return -1; + if (ret == False) continue; + /* + * Since there was an exact match of a fully-specified font + * or a font alias, we can return now since the desired font + * was found for the current font encoding for this FontSet. + * + * Previous implementations of this algorithm would + * not return here. Instead, they continued searching + * through the font encodings for this FontSet. The side-effect + * of that behavior is you may return a "substitute" match + * instead of an "exact" match. We believe there should be a + * preference on exact matches. Therefore, as soon as we + * find one, we bail. + * + * Also, previous implementations seemed to think it was + * important to find either a primary or substitute font + * for each Font encoding in the FontSet before returning an + * acceptable font. We don't believe this is necessary. + * All the client cares about is finding a reasonable font + * for what was passed in. If we find an exact match, + * there's no reason to look any further. + * + * -- jjw/pma (HP) + */ + if (font_data_return) { + font_data_return->xlfd_name = (char *)Xmalloc + (strlen(font_data->xlfd_name) + 1); + if (!font_data_return->xlfd_name) return -1; + + strcpy (font_data_return->xlfd_name, font_data->xlfd_name); + + font_data_return->side = font_data->side; + } +#ifdef FONTDEBUG + fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name); +#endif + + return True; + } + /* + * If the font name is not fully specified + * (i.e., it has wildcards), we have more work to do. + * See the comments in parse_omit_name() + * for the list of things to do. + */ + ret = parse_omit_name(oc, font_data, pattern); + + if (ret == -1) return -1; + if (ret == False) continue; + + /* + * A font which matched the wild-carded specification was found. + * Only update the return data if a font has not yet been found. + * This maintains the convention that FontSets listed higher in + * a CodeSet in the Locale Database have higher priority than + * those FontSets listed lower in the CodeSet. In the following + * example: + * + * fs1 { + * charset HP-JIS:GR + * font JISX0208.1990-0:GL;\ + * JISX0208.1990-1:GR;\ + * JISX0208.1983-0:GL;\ + * JISX0208.1983-1:GR + * } + * + * a font found in the JISX0208.1990-0 FontSet will have a + * higher priority than a font found in the JISX0208.1983-0 + * FontSet. + */ + if (font_data_return && font_data_return->xlfd_name == NULL) { + +#ifdef FONTDEBUG + fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name); +#endif + font_data_return->xlfd_name = (char *)Xmalloc + (strlen(font_data->xlfd_name) + 1); + if (!font_data_return->xlfd_name) return -1; + + strcpy (font_data_return->xlfd_name, font_data->xlfd_name); + font_data_return->side = font_data->side; + } + + found_num++; + is_found = True; + + break; + } + + switch(class) { + case C_PRIMARY: + if(is_found == False) { + /* + * Did not find a font for the current FontSet. Check the + * FontSet's "substitute" font for a match. If we find a + * match, we'll keep searching in hopes of finding an exact + * match later down the FontSet list. + * + * when we return and we have found a font font_data_return + * contains the first (ie. best) match no matter if this + * is a C_PRIMARY or a C_SUBSTITUTE font + */ + ret = parse_fontdata(oc, font_set, font_set->substitute, + font_set->substitute_num, name_list, + name_list_count, C_SUBSTITUTE, + font_data_return); + if (ret == -1) return -1; + if (ret == False) continue; + + found_num++; + is_found = True; + } +#ifdef TESTVERSION + else + return True; +#endif + break; + + case C_SUBSTITUTE: + case C_VMAP: + if(is_found == True) + return True; + break; + + case C_VROTATE: + if(is_found == True) { + char *rotate_name; + + if((rotate_name = get_rotate_fontname(font_data->xlfd_name)) + != NULL) { + Xfree(font_data->xlfd_name); + font_data->xlfd_name = rotate_name; + + return True; + } + Xfree(font_data->xlfd_name); + font_data->xlfd_name = NULL; + return False; + } + break; + } + } + + if(class == C_PRIMARY && found_num >= 1) + return True; + + return False; +} + + +static int +parse_vw( + XOC oc, + FontSet font_set, + char **name_list, + int count) +{ + FontData vmap = font_set->vmap; + VRotate vrotate = font_set->vrotate; + int vmap_num = font_set->vmap_num; + int vrotate_num = font_set->vrotate_num; + int ret = 0, i = 0; + + if(vmap_num > 0) { + if(parse_fontdata(oc, font_set, vmap, vmap_num, name_list, + count, C_VMAP,NULL) == -1) + return (-1); + } + + if(vrotate_num > 0) { + ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num, + name_list, count, C_VROTATE, NULL); + if(ret == -1) { + return (-1); + } else if(ret == False) { + CodeRange code_range; + int num_cr; + int sub_num = font_set->substitute_num; + + code_range = vrotate[0].code_range; /* ? */ + num_cr = vrotate[0].num_cr; /* ? */ + for(i = 0 ; i < vrotate_num ; i++) { + if(vrotate[i].xlfd_name) + Xfree(vrotate[i].xlfd_name); + } + Xfree(vrotate); + + if(sub_num > 0) { + vrotate = font_set->vrotate = (VRotate)Xmalloc + (sizeof(VRotateRec) * sub_num); + if(font_set->vrotate == (VRotate)NULL) + return (-1); + memset(font_set->vrotate, 0x00, sizeof(VRotateRec) * sub_num); + + for(i = 0 ; i < sub_num ; i++) { + vrotate[i].charset_name = font_set->substitute[i].name; + vrotate[i].side = font_set->substitute[i].side; + vrotate[i].code_range = code_range; + vrotate[i].num_cr = num_cr; + } + vrotate_num = font_set->vrotate_num = sub_num; + } else { + vrotate = font_set->vrotate = (VRotate)NULL; + } + + ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num, + name_list, count, C_VROTATE, NULL); + if(ret == -1) + return (-1); + } + } + + return True; +} + +static int +parse_fontname( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + FontDataRec font_data_return; + char *base_name, **name_list; + int font_set_num = 0; + int found_num = 0; + int count = 0; + int ret; + int i; + + name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count); + if (name_list == NULL) + return -1; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + /* Loop through all of the CharSets defined in the Locale + * database for the current Locale. + */ + for( ; font_set_num-- > 0 ; font_set++) { + if(font_set->font_name) + continue; + + if(font_set->font_data_count > 0) { + + /* + * If there are a non-zero number of FontSets defined + * for this CharSet. + * Try to find a font for this CharSet. If we find an + * acceptable font, we save the information for return + * to the client. If we do not find an acceptable font, + * a "missing_charset" will be reported to the client + * for this CharSet. + */ + font_data_return. xlfd_name = NULL; + font_data_return.side = XlcUnknown; + + ret = parse_fontdata(oc, font_set, font_set->font_data, + font_set->font_data_count, + name_list, count, C_PRIMARY, + &font_data_return); + if(ret == -1) { + goto err; + } else if(ret == True) { + /* + * We can't just loop thru fontset->font_data to + * find the first (ie. best) match: parse_fontdata + * will try a substitute font if no primary one could + * be matched. It returns the required information in + * font_data_return. + */ + font_set->font_name = (char *)Xmalloc + (strlen(font_data_return.xlfd_name) + 1); + if(font_set->font_name == (char *) NULL) + goto err; + strcpy(font_set->font_name, font_data_return.xlfd_name); + font_set->side = font_data_return.side; + + Xfree (font_data_return.xlfd_name); + font_data_return.xlfd_name = NULL; + + if(parse_vw(oc, font_set, name_list, count) == -1) + goto err; + found_num++; + } + + } else if(font_set->substitute_num > 0) { + /* + * If there are no FontSets defined for this + * CharSet. We can only find "substitute" fonts. + */ + ret = parse_fontdata(oc, font_set, font_set->substitute, + font_set->substitute_num, + name_list, count, C_SUBSTITUTE, NULL); + if(ret == -1) { + goto err; + } else if(ret == True) { + for(i=0;i<font_set->substitute_num;i++){ + if(font_set->substitute[i].xlfd_name != NULL){ + break; + } + } + font_set->font_name = (char *)Xmalloc + (strlen(font_set->substitute[i].xlfd_name) + 1); + if(font_set->font_name == (char *) NULL) + goto err; + strcpy(font_set->font_name,font_set->substitute[i].xlfd_name); + font_set->side = font_set->substitute[i].side; + if(parse_vw(oc, font_set, name_list, count) == -1) + goto err; + + found_num++; + } + } + } + + base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); + if (base_name == NULL) + goto err; + + strcpy(base_name, oc->core.base_name_list); + oc->core.base_name_list = base_name; + + XFreeStringList(name_list); + + return found_num; + +err: + XFreeStringList(name_list); + /* Prevent this from being freed twice */ + oc->core.base_name_list = NULL; + + return -1; +} + +/* For VW/UDC end*/ + +static Bool +set_missing_list( + XOC oc) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set; + char **charset_list, *charset_buf; + int count, length, font_set_num; + int result = 1; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + count = length = 0; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->info || font_set->font) { + continue; + } + + /* Change 1996.01.23 start */ + if(font_set->font_data_count <= 0 || + font_set->font_data == (FontData)NULL) { + if(font_set->substitute_num <= 0 || + font_set->substitute == (FontData)NULL) { + if(font_set->charset_list != NULL){ + length += + strlen(font_set->charset_list[0]->encoding_name) + 1; + } else { + length += 1; + } + } else { + length += strlen(font_set->substitute->name) + 1; + } + } else { + length += strlen(font_set->font_data->name) + 1; + } + /* Change 1996.01.23 end */ + count++; + } + + if (count < 1) { + return True; + } + + charset_list = (char **) Xmalloc(sizeof(char *) * count); + if (charset_list == NULL) { + return False; + } + + charset_buf = (char *) Xmalloc(length); + if (charset_buf == NULL) { + Xfree(charset_list); + return False; + } + + oc->core.missing_list.charset_list = charset_list; + oc->core.missing_list.charset_count = count; + + font_set = gen->font_set; + font_set_num = gen->font_set_num; + + for ( ; font_set_num-- > 0; font_set++) { + if (font_set->info || font_set->font) { + continue; + } + + /* Change 1996.01.23 start */ + if(font_set->font_data_count <= 0 || + font_set->font_data == (FontData)NULL) { + if(font_set->substitute_num <= 0 || + font_set->substitute == (FontData)NULL) { + if(font_set->charset_list != NULL){ + strcpy(charset_buf, + font_set->charset_list[0]->encoding_name); + } else { + strcpy(charset_buf, ""); + } + result = 0; + } else { + strcpy(charset_buf, font_set->substitute->name); + } + } else { + strcpy(charset_buf, font_set->font_data->name); + } + /* Change 1996.01.23 end */ + *charset_list++ = charset_buf; + charset_buf += strlen(charset_buf) + 1; + } + + if(result == 0) { + return(False); + } + + return True; +} + +static Bool +create_fontset( + XOC oc) +{ + XOMGenericPart *gen = XOM_GENERIC(oc->core.om); + int found_num; + + if (init_fontset(oc) == False) + return False; + + found_num = parse_fontname(oc); + if (found_num <= 0) { + if (found_num == 0) + set_missing_list(oc); + return False; + } + + if (gen->on_demand_loading == True) { + if (load_font_info(oc) == False) + return False; + } else { + if (load_font(oc) == False) + return False; + } + + if (init_core_part(oc) == False) + return False; + + if (set_missing_list(oc) == False) + return False; + + return True; +} + +/* For VW/UDC start */ +static void +free_fontdataOC( + Display *dpy, + FontData font_data, + int font_data_count) +{ + for( ; font_data_count-- ; font_data++) { + if(font_data->xlfd_name){ + Xfree(font_data->xlfd_name); + font_data->xlfd_name = NULL; + } + if(font_data->font){ /* ADD 1996.01.7 */ + if(font_data->font->fid) /* Add 1996.01.23 */ + XFreeFont(dpy,font_data->font); /* ADD 1996.01.7 */ + else /* Add 1996.01.23 */ + XFreeFontInfo(NULL, font_data->font, 1);/* Add 1996.01.23 */ + font_data->font = NULL; + } +/* + * font_data->name and font_data->scopes belong to the OM not OC. + * To save space this data is shared between OM and OC. We are + * not allowed to free it here. + * It has been moved to free_fontdataOM() + */ +/* + if(font_data->scopes){ + Xfree(font_data->scopes); + font_data->scopes = NULL; + } + if(font_data->name){ + Xfree(font_data->name); + font_data->name = NULL; + } +*/ + } +} + +static void destroy_fontdata( + XOCGenericPart *gen, + Display *dpy) +{ + FontSet font_set = (FontSet) NULL; + int font_set_num = 0; + + if (gen->font_set) { + font_set = gen->font_set; + font_set_num = gen->font_set_num; + for( ; font_set_num-- ; font_set++) { + if (font_set->font) { + if(font_set->font->fid) + XFreeFont(dpy,font_set->font); + else + XFreeFontInfo(NULL, font_set->font, 1); + font_set->font = NULL; + } + if(font_set->font_data) { + if (font_set->info) + XFreeFontInfo(NULL, font_set->info, 1); + free_fontdataOC(dpy, + font_set->font_data, font_set->font_data_count); + Xfree(font_set->font_data); + font_set->font_data = NULL; + } + if(font_set->substitute) { + free_fontdataOC(dpy, + font_set->substitute, font_set->substitute_num); + Xfree(font_set->substitute); + font_set->substitute = NULL; + } + if(font_set->vmap) { + free_fontdataOC(dpy, + font_set->vmap, font_set->vmap_num); + Xfree(font_set->vmap); + font_set->vmap = NULL; + } + if(font_set->vrotate) { + free_fontdataOC(dpy, + (FontData)font_set->vrotate, + font_set->vrotate_num); + Xfree(font_set->vrotate); + font_set->vrotate = NULL; + } + } + Xfree(gen->font_set); + gen->font_set = NULL; + } +} +/* For VW/UDC end */ + +static void +destroy_oc( + XOC oc) +{ + Display *dpy = oc->core.om->core.display; + XOCGenericPart *gen = XOC_GENERIC(oc); + + if (gen->mbs_to_cs) + _XlcCloseConverter(gen->mbs_to_cs); + + if (gen->wcs_to_cs) + _XlcCloseConverter(gen->wcs_to_cs); + + if (gen->utf8_to_cs) + _XlcCloseConverter(gen->utf8_to_cs); + +/* For VW/UDC start */ /* Change 1996.01.8 */ + destroy_fontdata(gen,dpy); +/* +*/ +/* For VW/UDC end */ + + if (oc->core.base_name_list) + Xfree(oc->core.base_name_list); + + if (oc->core.font_info.font_name_list) + XFreeStringList(oc->core.font_info.font_name_list); + + if (oc->core.font_info.font_struct_list) { + Xfree(oc->core.font_info.font_struct_list); + } + + if (oc->core.missing_list.charset_list) + XFreeStringList(oc->core.missing_list.charset_list); + +#ifdef notdef + if (oc->core.res_name) + Xfree(oc->core.res_name); + if (oc->core.res_class) + Xfree(oc->core.res_class); +#endif + + Xfree(oc); +} + +static char * +set_oc_values( + XOC oc, + XlcArgList args, + int num_args) +{ + XOCGenericPart *gen = XOC_GENERIC(oc); + FontSet font_set = gen->font_set; + char *ret; + int num = gen->font_set_num; + + if (oc->core.resources == NULL) + return NULL; + + ret = _XlcSetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcSetMask); + if(ret != NULL){ + return(ret); + } else { + for ( ; num-- > 0; font_set++) { + if (font_set->font_name == NULL) + continue; + if (font_set->vpart_initialize != 0) + continue; + if( oc->core.orientation == XOMOrientation_TTB_RTL || + oc->core.orientation == XOMOrientation_TTB_LTR ){ + load_fontdata(oc, font_set->vmap, font_set->vmap_num); + load_fontdata(oc, (FontData) font_set->vrotate, + font_set->vrotate_num); + font_set->vpart_initialize = 1; + } + } + return(NULL); + } +} + +static char * +get_oc_values( + XOC oc, + XlcArgList args, + int num_args) +{ + if (oc->core.resources == NULL) + return NULL; + + return _XlcGetValues((XPointer) oc, oc->core.resources, + oc->core.num_resources, args, num_args, XlcGetMask); +} + +static XOCMethodsRec oc_default_methods = { + destroy_oc, + set_oc_values, + get_oc_values, + _XmbDefaultTextEscapement, + _XmbDefaultTextExtents, + _XmbDefaultTextPerCharExtents, + _XmbDefaultDrawString, + _XmbDefaultDrawImageString, + _XwcDefaultTextEscapement, + _XwcDefaultTextExtents, + _XwcDefaultTextPerCharExtents, + _XwcDefaultDrawString, + _XwcDefaultDrawImageString, + _Xutf8DefaultTextEscapement, + _Xutf8DefaultTextExtents, + _Xutf8DefaultTextPerCharExtents, + _Xutf8DefaultDrawString, + _Xutf8DefaultDrawImageString +}; + +static XOCMethodsRec oc_generic_methods = { + destroy_oc, + set_oc_values, + get_oc_values, + _XmbGenericTextEscapement, + _XmbGenericTextExtents, + _XmbGenericTextPerCharExtents, + _XmbGenericDrawString, + _XmbGenericDrawImageString, + _XwcGenericTextEscapement, + _XwcGenericTextExtents, + _XwcGenericTextPerCharExtents, + _XwcGenericDrawString, + _XwcGenericDrawImageString, + _Xutf8GenericTextEscapement, + _Xutf8GenericTextExtents, + _Xutf8GenericTextPerCharExtents, + _Xutf8GenericDrawString, + _Xutf8GenericDrawImageString +}; + +typedef struct _XOCMethodsListRec { + const char *name; + XOCMethods methods; +} XOCMethodsListRec, *XOCMethodsList; + +static XOCMethodsListRec oc_methods_list[] = { + { "default", &oc_default_methods }, + { "generic", &oc_generic_methods } +}; + +static XlcResource oc_resources[] = { + { XNBaseFontName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask }, + { XNOMAutomatic, NULLQUARK, sizeof(Bool), + XOffsetOf(XOCRec, core.om_automatic), XlcGetMask }, + { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOCRec, core.missing_list), XlcGetMask }, + { XNDefaultString, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.default_string), XlcGetMask }, + { XNOrientation, NULLQUARK, sizeof(XOrientation), + XOffsetOf(XOCRec, core.orientation), XlcDefaultMask | XlcSetMask | XlcGetMask }, + { XNResourceName, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask }, + { XNResourceClass, NULLQUARK, sizeof(char *), + XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask }, + { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo), + XOffsetOf(XOCRec, core.font_info), XlcGetMask } +}; + +static XOC +create_oc( + XOM om, + XlcArgList args, + int num_args) +{ + XOC oc; + XOMGenericPart *gen = XOM_GENERIC(om); + XOCMethodsList methods_list = oc_methods_list; + int count; + + oc = (XOC) Xmalloc(sizeof(XOCGenericRec)); + if (oc == NULL) + return (XOC) NULL; + bzero((char *) oc, sizeof(XOCGenericRec)); + + oc->core.om = om; + + if (oc_resources[0].xrm_name == NULLQUARK) + _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources)); + + if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources), + args, num_args, XlcCreateMask | XlcDefaultMask)) + goto err; + + if (oc->core.base_name_list == NULL) + goto err; + + oc->core.resources = oc_resources; + oc->core.num_resources = XlcNumber(oc_resources); + + if (create_fontset(oc) == False) + goto err; + + oc->methods = &oc_generic_methods; + + if (gen->object_name) { + count = XlcNumber(oc_methods_list); + + for ( ; count-- > 0; methods_list++) { + if (!_XlcCompareISOLatin1(gen->object_name, methods_list->name)) { + oc->methods = methods_list->methods; + break; + } + } + } + + return oc; + +err: + destroy_oc(oc); + + return (XOC) NULL; +} + +static void +free_fontdataOM( + FontData font_data, + int font_data_count) +{ + for( ; font_data_count-- ; font_data++) { + if(font_data->name){ + Xfree(font_data->name); + font_data->name = NULL; + } + if(font_data->scopes){ + Xfree(font_data->scopes); + font_data->scopes = NULL; + } + } +} + +static Status +close_om( + XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + int count; + + if ((data = gen->data)) { + for (count = gen->data_num; count-- > 0; data++) { + if (data->charset_list){ + Xfree(data->charset_list); + data->charset_list = NULL; + } + /* free font_data for om */ + if (data->font_data) { + free_fontdataOM(data->font_data,data->font_data_count); + Xfree(data->font_data); + data->font_data = NULL; + } + /* free substitute for om */ + if (data->substitute) { + free_fontdataOM(data->substitute,data->substitute_num); + Xfree(data->substitute); + data->substitute = NULL; + } + /* free vmap for om */ + if (data->vmap) { + free_fontdataOM(data->vmap,data->vmap_num); + Xfree(data->vmap); + data->vmap = NULL; + } + /* free vrotate for om */ + if (data->vrotate) { + Xfree(data->vrotate); + data->vrotate = NULL; + } + } + Xfree(gen->data); + gen->data = NULL; + } + + if (gen->object_name){ + Xfree(gen->object_name); + gen->object_name = NULL; + } + + if (om->core.res_name){ + Xfree(om->core.res_name); + om->core.res_name = NULL; + } + if (om->core.res_class){ + Xfree(om->core.res_class); + om->core.res_class = NULL; + } + if (om->core.required_charset.charset_list && + om->core.required_charset.charset_count > 0){ + XFreeStringList(om->core.required_charset.charset_list); + om->core.required_charset.charset_list = NULL; + } else { + Xfree((char*)om->core.required_charset.charset_list); + om->core.required_charset.charset_list = NULL; + } + if (om->core.orientation_list.orientation){ + Xfree(om->core.orientation_list.orientation); + om->core.orientation_list.orientation = NULL; + } + + Xfree(om); + + return 1; +} + +static char * +set_om_values( + XOM om, + XlcArgList args, + int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _XlcSetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcSetMask); +} + +static char * +get_om_values( + XOM om, + XlcArgList args, + int num_args) +{ + if (om->core.resources == NULL) + return NULL; + + return _XlcGetValues((XPointer) om, om->core.resources, + om->core.num_resources, args, num_args, XlcGetMask); +} + +static XOMMethodsRec methods = { + close_om, + set_om_values, + get_om_values, + create_oc +}; + +static XlcResource om_resources[] = { + { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList), + XOffsetOf(XOMRec, core.required_charset), XlcGetMask }, + { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation), + XOffsetOf(XOMRec, core.orientation_list), XlcGetMask }, + { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask }, + { XNContextualDrawing, NULLQUARK, sizeof(Bool), + XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask } +}; + +static XOM +create_om( + XLCd lcd, + Display *dpy, + XrmDatabase rdb, + _Xconst char *res_name, + _Xconst char *res_class) +{ + XOM om; + + om = (XOM) Xmalloc(sizeof(XOMGenericRec)); + if (om == NULL) + return (XOM) NULL; + bzero((char *) om, sizeof(XOMGenericRec)); + + om->methods = &methods; + om->core.lcd = lcd; + om->core.display = dpy; + om->core.rdb = rdb; + if (res_name) { + om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1); + if (om->core.res_name == NULL) + goto err; + strcpy(om->core.res_name, res_name); + } + if (res_class) { + om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1); + if (om->core.res_class == NULL) + goto err; + strcpy(om->core.res_class, res_class); + } + + if (om_resources[0].xrm_name == NULLQUARK) + _XlcCompileResourceList(om_resources, XlcNumber(om_resources)); + + om->core.resources = om_resources; + om->core.num_resources = XlcNumber(om_resources); + + return om; + +err: + close_om(om); + + return (XOM) NULL; +} + +static OMData +add_data( + XOM om) +{ + XOMGenericPart *gen = XOM_GENERIC(om); + OMData new; + int num; + + if ((num = gen->data_num)) + new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec)); + else + new = (OMData) Xmalloc(sizeof(OMDataRec)); + + if (new == NULL) + return NULL; + + gen->data_num = num + 1; + gen->data = new; + + new += num; + bzero((char *) new, sizeof(OMDataRec)); + + return new; +} + +/* For VW/UDC */ + +FontData +read_EncodingInfo( + int count, + char **value) +{ + FontData font_data,ret; + char *buf, *bufptr,*scp; + int len; + font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count); + if (font_data == NULL) + return NULL; + bzero((char *) font_data, sizeof(FontDataRec) * count); + + ret = font_data; + for ( ; count-- > 0; font_data++) { +/* + strcpy(buf, *value++); +*/ + buf = *value; value++; + if ((bufptr = strchr(buf, ':'))) { + len = (int)(bufptr - buf); + bufptr++ ; + } else + len = strlen(buf); + font_data->name = (char *) Xmalloc(len + 1); + if (font_data->name == NULL) + return NULL; + strncpy(font_data->name, buf,len); + font_data->name[len] = 0; + if (bufptr && _XlcCompareISOLatin1(bufptr, "GL") == 0) + font_data->side = XlcGL; + else if (bufptr && _XlcCompareISOLatin1(bufptr, "GR") == 0) + font_data->side = XlcGR; + else + font_data->side = XlcGLGR; + + if (bufptr && (scp = strchr(bufptr, '['))){ + font_data->scopes = _XlcParse_scopemaps(scp,&(font_data->scopes_num)); + } + } + return(ret); +} + +static CodeRange read_vrotate( + int count, + char **value, + int *type, + int *vrotate_num) +{ + CodeRange range; + if(!strcmp(value[0],"all")){ + *type = VROTATE_ALL ; + *vrotate_num = 0 ; + return (NULL); + } else if(*(value[0]) == '['){ + *type = VROTATE_PART ; + range = (CodeRange) _XlcParse_scopemaps(value[0],vrotate_num); + return (range); + } else { + *type = VROTATE_NONE ; + *vrotate_num = 0 ; + return (NULL); + } +} + +static void read_vw( + XLCd lcd, + OMData font_set, + int num) +{ + char **value, buf[BUFSIZ]; + int count; + + sprintf(buf, "fs%d.font.vertical_map", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + _XlcDbg_printValue(buf,value,count); + font_set->vmap_num = count; + font_set->vmap = read_EncodingInfo(count,value); + } + + sprintf(buf, "fs%d.font.vertical_rotate", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + _XlcDbg_printValue(buf,value,count); + font_set->vrotate = read_vrotate(count,value,&(font_set->vrotate_type), + &(font_set->vrotate_num)); + } +} +/* VW/UDC end */ +static Bool +init_om( + XOM om) +{ + XLCd lcd = om->core.lcd; + XOMGenericPart *gen = XOM_GENERIC(om); + OMData data; + XlcCharSet *charset_list; + FontData font_data; + char **required_list; + XOrientation *orientation; + char **value, buf[BUFSIZ], *bufptr; + int count = 0, num = 0, length = 0; + + _XlcGetResource(lcd, "XLC_FONTSET", "on_demand_loading", &value, &count); + if (count > 0 && _XlcCompareISOLatin1(*value, "True") == 0) + gen->on_demand_loading = True; + + _XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count); + if (count > 0) { + gen->object_name = (char *) Xmalloc(strlen(*value) + 1); + if (gen->object_name == NULL) + return False; + strcpy(gen->object_name, *value); + } + + for (num = 0; ; num++) { + + sprintf(buf, "fs%d.charset.name", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + + if( count < 1){ + sprintf(buf, "fs%d.charset", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) + break; + } + + data = add_data(om); + if (data == NULL) + return False; + + charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count); + if (charset_list == NULL) + return False; + data->charset_list = charset_list; + data->charset_count = count; + + while (count-- > 0){ + *charset_list++ = _XlcGetCharSet(*value++); + } + sprintf(buf, "fs%d.charset.udc_area", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if( count > 0){ + UDCArea udc; + int i,flag = 0; + udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec)); + if (udc == NULL) + return False; + for(i=0;i<count;i++){ + sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), + &(udc[i].end)); + } + for(i=0;i<data->charset_count;i++){ + if(data->charset_list[i]->udc_area == NULL){ + data->charset_list[i]->udc_area = udc; + data->charset_list[i]->udc_area_num = count; + flag = 1; + } + } + if(flag == 0){ + Xfree(udc); + } + } + + sprintf(buf, "fs%d.font.primary", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1){ + sprintf(buf, "fs%d.font", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) + return False; + } + + font_data = read_EncodingInfo(count,value); + if (font_data == NULL) + return False; + + data->font_data = font_data; + data->font_data_count = count; + + sprintf(buf, "fs%d.font.substitute", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count > 0){ + font_data = read_EncodingInfo(count,value); + if (font_data == NULL) + return False; + data->substitute = font_data; + data->substitute_num = count; + } else { + sprintf(buf, "fs%d.font", num); + _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count); + if (count < 1) { + data->substitute = NULL; + data->substitute_num = 0; + } else { + font_data = read_EncodingInfo(count,value); + data->substitute = font_data; + data->substitute_num = count; + } + } + read_vw(lcd,data,num); + length += strlen(data->font_data->name) + 1; + } + + /* required charset list */ + required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num); + if (required_list == NULL) + return False; + + bufptr = (char *) Xmalloc(length); + if (bufptr == NULL) { + Xfree(required_list); + return False; + } + + om->core.required_charset.charset_list = required_list; + om->core.required_charset.charset_count = gen->data_num; + + count = gen->data_num; + data = gen->data; + + for ( ; count-- > 0; data++) { + strcpy(bufptr, data->font_data->name); + *required_list++ = bufptr; + bufptr += strlen(bufptr) + 1; + } + + /* orientation list */ + orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2); + if (orientation == NULL) + return False; + + orientation[0] = XOMOrientation_LTR_TTB; + orientation[1] = XOMOrientation_TTB_RTL; + om->core.orientation_list.orientation = orientation; + om->core.orientation_list.num_orientation = 2; + + /* directional dependent drawing */ + om->core.directional_dependent = False; + + /* contexual drawing */ + om->core.contextual_drawing = False; + + /* context dependent */ + om->core.context_dependent = False; + + return True; +} + +XOM +_XomGenericOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, + _Xconst char *res_name, _Xconst char *res_class) +{ + XOM om; + + om = create_om(lcd, dpy, rdb, res_name, res_class); + if (om == NULL) + return (XOM) NULL; + + if (init_om(om) == False) + goto err; + + return om; + +err: + close_om(om); + + return (XOM) NULL; +} + +Bool +_XInitOM( + XLCd lcd) +{ + lcd->methods->open_om = _XomGenericOpenOM; + + return True; +} diff --git a/libX11/modules/om/generic/omImText.c b/libX11/modules/om/generic/omImText.c new file mode 100644 index 000000000..627c45b83 --- /dev/null +++ b/libX11/modules/om/generic/omImText.c @@ -0,0 +1,92 @@ +/* $Xorg: omImText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */ +/* + * 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 + */ +/* $XFree86: xc/lib/X11/omImText.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */ + +#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 new file mode 100644 index 000000000..189aabd1e --- /dev/null +++ b/libX11/modules/om/generic/omText.c @@ -0,0 +1,372 @@ +/* $Xorg: omText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */ +/* + * 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 + */ +/* $XFree86: xc/lib/X11/omText.c,v 1.9 2003/04/22 13:57:45 pascal Exp $ */ +/* + * 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 new file mode 100644 index 000000000..03b76d9f1 --- /dev/null +++ b/libX11/modules/om/generic/omTextEsc.c @@ -0,0 +1,302 @@ +/* $Xorg: omTextEsc.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */ +/* + * 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 + */ +/* $XFree86: xc/lib/X11/omTextEsc.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */ +/* + * 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 new file mode 100644 index 000000000..4117e60f9 --- /dev/null +++ b/libX11/modules/om/generic/omTextExt.c @@ -0,0 +1,137 @@ +/* $Xorg: omTextExt.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */ +/* + * 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 + */ +/* $XFree86: xc/lib/X11/omTextExt.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */ + +#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 new file mode 100644 index 000000000..17a186571 --- /dev/null +++ b/libX11/modules/om/generic/omTextPer.c @@ -0,0 +1,204 @@ +/* $Xorg: omTextPer.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */ +/* + * 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 + */ +/* $XFree86: xc/lib/X11/omTextPer.c,v 1.6 2003/04/13 19:22:22 dawes Exp $ */ + +#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 new file mode 100644 index 000000000..c910cfed4 --- /dev/null +++ b/libX11/modules/om/generic/omXChar.c @@ -0,0 +1,479 @@ +/* $Xorg: omXChar.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */ +/* + * 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) + */ +/* $XFree86: xc/lib/X11/omXChar.c,v 1.6tsi Exp $ */ + +#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; +} |