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 /xorg-server/hw/xprint/ps | |
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 'xorg-server/hw/xprint/ps')
30 files changed, 11419 insertions, 0 deletions
diff --git a/xorg-server/hw/xprint/ps/Makefile.am b/xorg-server/hw/xprint/ps/Makefile.am new file mode 100644 index 000000000..08638b19d --- /dev/null +++ b/xorg-server/hw/xprint/ps/Makefile.am @@ -0,0 +1,42 @@ +noinst_LTLIBRARIES = libps.la + +INCLUDES = -I$(top_srcdir)/hw/xprint + +AM_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAGS@ @FREETYPE_CFLAGS@ \ + -D_XP_PRINT_SERVER_ -DXP_PSTEXT + +libps_la_SOURCES = \ + PsArc.c \ + PsArea.c \ + PsAttr.c \ + PsAttVal.c \ + PsCache.c \ + PsColor.c \ + PsDef.h \ + PsFonts.c \ + PsGC.c \ + Ps.h \ + PsImageUtil.c \ + PsInit.c \ + PsLine.c \ + PsMisc.c \ + psout.c \ + psout.h \ + PsPixel.c \ + PsPixmap.c \ + PsPolygon.c \ + PsPrint.c \ + PsSpans.c \ + PsText.c \ + PsWindow.c + +EXTRA_DIST = PsFTFonts.c \ + psout_ft.c \ + psout_ftpstype1.c \ + psout_ftpstype3.c \ + ttf2pt1wrap.c + +if XP_USE_FREETYPE + AM_CFLAGS += -DXP_USE_FREETYPE + libps_la_SOURCES += $(EXTRA_DIST) +endif diff --git a/xorg-server/hw/xprint/ps/Makefile.in b/xorg-server/hw/xprint/ps/Makefile.in new file mode 100644 index 000000000..41c44a3b5 --- /dev/null +++ b/xorg-server/hw/xprint/ps/Makefile.in @@ -0,0 +1,693 @@ +# 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@ +@XP_USE_FREETYPE_TRUE@am__append_1 = -DXP_USE_FREETYPE +@XP_USE_FREETYPE_TRUE@am__append_2 = $(EXTRA_DIST) +subdir = hw/xprint/ps +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)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libps_la_LIBADD = +am__libps_la_SOURCES_DIST = PsArc.c PsArea.c PsAttr.c PsAttVal.c \ + PsCache.c PsColor.c PsDef.h PsFonts.c PsGC.c Ps.h \ + PsImageUtil.c PsInit.c PsLine.c PsMisc.c psout.c psout.h \ + PsPixel.c PsPixmap.c PsPolygon.c PsPrint.c PsSpans.c PsText.c \ + PsWindow.c PsFTFonts.c psout_ft.c psout_ftpstype1.c \ + psout_ftpstype3.c ttf2pt1wrap.c +am__objects_1 = PsFTFonts.lo psout_ft.lo psout_ftpstype1.lo \ + psout_ftpstype3.lo ttf2pt1wrap.lo +@XP_USE_FREETYPE_TRUE@am__objects_2 = $(am__objects_1) +am_libps_la_OBJECTS = PsArc.lo PsArea.lo PsAttr.lo PsAttVal.lo \ + PsCache.lo PsColor.lo PsFonts.lo PsGC.lo PsImageUtil.lo \ + PsInit.lo PsLine.lo PsMisc.lo psout.lo PsPixel.lo PsPixmap.lo \ + PsPolygon.lo PsPrint.lo PsSpans.lo PsText.lo PsWindow.lo \ + $(am__objects_2) +libps_la_OBJECTS = $(am_libps_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +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 = $(libps_la_SOURCES) +DIST_SOURCES = $(am__libps_la_SOURCES_DIST) +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@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +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@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +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@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +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@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +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@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libps.la +INCLUDES = -I$(top_srcdir)/hw/xprint +AM_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAGS@ @FREETYPE_CFLAGS@ \ + -D_XP_PRINT_SERVER_ -DXP_PSTEXT $(am__append_1) +libps_la_SOURCES = PsArc.c PsArea.c PsAttr.c PsAttVal.c PsCache.c \ + PsColor.c PsDef.h PsFonts.c PsGC.c Ps.h PsImageUtil.c PsInit.c \ + PsLine.c PsMisc.c psout.c psout.h PsPixel.c PsPixmap.c \ + PsPolygon.c PsPrint.c PsSpans.c PsText.c PsWindow.c \ + $(am__append_2) +EXTRA_DIST = PsFTFonts.c \ + psout_ft.c \ + psout_ftpstype1.c \ + psout_ftpstype3.c \ + ttf2pt1wrap.c + +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 hw/xprint/ps/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xprint/ps/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 + +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 +libps.la: $(libps_la_OBJECTS) $(libps_la_DEPENDENCIES) + $(LINK) $(libps_la_OBJECTS) $(libps_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsArc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsArea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsAttVal.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsAttr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsCache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsColor.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsFTFonts.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsFonts.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsGC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsImageUtil.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsInit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsMisc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsPixel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsPixmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsPolygon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsPrint.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsSpans.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsText.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PsWindow.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psout.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psout_ft.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psout_ftpstype1.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/psout_ftpstype3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttf2pt1wrap.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: +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-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-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: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean 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-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 + +# 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/xorg-server/hw/xprint/ps/Ps.h b/xorg-server/hw/xprint/ps/Ps.h new file mode 100644 index 000000000..a25e9891a --- /dev/null +++ b/xorg-server/hw/xprint/ps/Ps.h @@ -0,0 +1,600 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: Ps.h +** * +** * Contents: defines and includes for the Ps driver +** * for a printing X server. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _PS_H_ +#define _PS_H_ + +#include <stdio.h> + +#ifdef abs +#undef abs /* this is because of a non-Spec1170ness in misc.h */ +#endif +#include <stdlib.h> +#include "scrnintstr.h" +#include "dix.h" + +#include "PsDef.h" +#include "psout.h" + +#include <X11/extensions/Print.h> +#include <X11/extensions/Printstr.h> + +#include "regionstr.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "gcstruct.h" + +/* + * Some sleazes to force the XrmDB stuff into the server + */ +#ifndef HAVE_XPointer +typedef char *XPointer; +#define Status int +#define True 1 +#define False 0 +#endif + +#include "misc.h" +#include <X11/Xfuncproto.h> +#include <X11/Xresource.h> +#include "attributes.h" + + +/* + * Public index variables from PsInit.c + */ + +extern DevPrivateKey PsScreenPrivateKey; +extern DevPrivateKey PsWindowPrivateKey; +extern DevPrivateKey PsContextPrivateKey; +extern DevPrivateKey PsPixmapPrivateKey; +extern XpValidatePoolsRec PsValidatePoolsRec; + +/* + * Display list structures + */ + +#define DPY_BLOCKSIZE 4096 + +typedef struct +{ + int mode; + int nPoints; + xPoint *pPoints; +} PsPolyPointsRec; + +typedef struct +{ + int nSegments; + xSegment *pSegments; +} PsSegmentsRec; + +typedef struct +{ + int nRects; + xRectangle *pRects; +} PsRectanglesRec; + +typedef struct +{ + int nArcs; + xArc *pArcs; +} PsArcsRec; + +typedef struct +{ + int x; + int y; + int count; + char *string; +} PsText8Rec; + +typedef struct +{ + int x; + int y; + int count; + unsigned short *string; +} PsText16Rec; + +typedef struct +{ + int depth; + int x; + int y; + int w; + int h; + int leftPad; + int format; + int res; /* image resolution */ + char *pData; +} PsImageRec; + +typedef struct +{ + int x; + int y; + int w; + int h; +} PsFrameRec; + +typedef enum +{ + PolyPointCmd, + PolyLineCmd, + PolySegmentCmd, + PolyRectangleCmd, + FillPolygonCmd, + PolyFillRectCmd, + PolyArcCmd, + PolyFillArcCmd, + Text8Cmd, + Text16Cmd, + TextI8Cmd, + TextI16Cmd, + PutImageCmd, + BeginFrameCmd, + EndFrameCmd +} DisplayElmType; + +typedef struct _DisplayElmRec +{ + DisplayElmType type; + GCPtr gc; + union + { + PsPolyPointsRec polyPts; + PsSegmentsRec segments; + PsRectanglesRec rects; + PsArcsRec arcs; + PsText8Rec text8; + PsText16Rec text16; + PsImageRec image; + PsFrameRec frame; + } c; +} DisplayElmRec; + +typedef DisplayElmRec *DisplayElmPtr; + +typedef struct _DisplayListRec +{ + struct _DisplayListRec *next; + int nelms; + DisplayElmRec elms[DPY_BLOCKSIZE]; +} DisplayListRec; + +typedef DisplayListRec *DisplayListPtr; + +/* + * Private structures + */ + +typedef struct +{ + XrmDatabase resDB; + Bool (*DestroyWindow)(WindowPtr); +} PsScreenPrivRec, *PsScreenPrivPtr; + +typedef struct PsFontTypeInfoRec PsFontTypeInfoRec; + +/* Structure to hold information about one font on disk + * Notes: + * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if + * they all use the same font on the disk) + * - the FreeType font download code uses multiple |PsFontTypeInfoRec| + * records for one font on disk if they differ in the encoding being + * used (this is an exception from the + * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better + * to rework that in a later step and add a new per-encoding structure). + */ +struct PsFontTypeInfoRec +{ + PsFontTypeInfoRec *next; /* Next record in list... */ + char *adobe_ps_name; /* PostScript font name (from the + * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */ + char *download_ps_name; /* PostScript font name used for font download */ + char *filename; /* File name of font */ +#ifdef XP_USE_FREETYPE + char *ft_download_encoding; /* encoding used for download */ + PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */ +#endif /* XP_USE_FREETYPE */ + int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */ + int font_type; /* See PSFTI_FONT_TYPE_* below... */ + Bool downloadableFont; /* Font can be downloaded */ + Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */ +}; + +#define PSFTI_FONT_TYPE_OTHER (0) +#define PSFTI_FONT_TYPE_PMF (1) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3) +#define PSFTI_FONT_TYPE_TRUETYPE (4) +/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */ +#define PSFTI_FONT_TYPE_FREETYPE (5) + +typedef struct PsFontInfoRec PsFontInfoRec; + +/* Structure which represents our context info for a single XLFD font + * Note that multiple |PsFontInfoRec| records can share the same + * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent + * different appearances of the same font on disk(=|PsFontTypeInfoRec|)). + */ +struct PsFontInfoRec +{ + PsFontInfoRec *next; /* Next record in list... */ + /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to + * identify a font */ + FontPtr font; /* The font this record is for */ + pointer font_fontPrivate; + PsFontTypeInfoRec *ftir; /* Record about the font file on disk */ + const char *dfl_name; /* XLFD for this font */ + int size; /* Font size. Use |mtx| if |size==0| */ + float mtx[4]; /* Transformation matrix (see |size|) */ +}; + +typedef struct +{ + char *jobFileName; + FILE *pJobFile; + GC lastGC; + unsigned char *dash; + int validGC; + ClientPtr getDocClient; + int getDocBufSize; + PsOutPtr pPsOut; + PsFontTypeInfoRec *fontTypeInfoRecords; + PsFontInfoRec *fontInfoRecords; +} PsContextPrivRec, *PsContextPrivPtr; + +typedef struct +{ + int validContext; + XpContextPtr context; +} PsWindowPrivRec, *PsWindowPrivPtr; + +typedef struct +{ + XpContextPtr context; + GC lastGC; + int validGC; + DisplayListPtr dispList; +} PsPixmapPrivRec, *PsPixmapPrivPtr; + +/* + * Macro functions + */ + +#define SEND_PS(f,c) fwrite( c, sizeof( char ), strlen( c ), f ) +#define MIN(a,b) (((a)<(b))?(a):(b)) +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +/* + * Functions in PsInit.c + */ + +extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc, + char **argv); +extern XpContextPtr PsGetContextFromWindow(WindowPtr win); + +/* + * Functions in PsCache.c + */ + +extern int PsBmIsImageCached(int gWidth, int gHeight, char *pBuffer); +extern int PsBmPutImageInCache(int gWidth, int gHeight, char *pBuffer); +extern void PsBmClearImageCache(void); + +/* + * Functions in PsPrint.c + */ + +extern int PsStartJob(XpContextPtr pCon, Bool sendClientData, ClientPtr client); +extern int PsEndJob(XpContextPtr pCon, Bool cancel); +extern int PsStartPage(XpContextPtr pCon, WindowPtr pWin); +extern int PsEndPage(XpContextPtr pCon, WindowPtr pWin); +extern int PsStartDoc(XpContextPtr pCon, XPDocumentType type); +extern int PsEndDoc(XpContextPtr pCon, Bool cancel); +extern int PsDocumentData(XpContextPtr pCon, DrawablePtr pDraw, char *pData, + int len_data, char *pFmt, int len_fmt, char *pOpt, int len_opt, + ClientPtr client); +extern int PsGetDocumentData(XpContextPtr pCon, ClientPtr client, + int maxBufferSize); + +/* + * Functions in PsGC.c + */ + +extern Bool PsCreateGC(GCPtr pGC); +extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable ); +extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable, + PsOutPtr *psOut, ColormapPtr *cMap); +extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); +extern void PsChangeGC(GCPtr pGC, unsigned long changes); +extern void PsCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +extern void PsDestroyGC(GCPtr pGC); +extern void PsChangeClip(GCPtr pGC, int type, pointer pValue, int nrects); +extern void PsDestroyClip(GCPtr pGC); +extern void PsCopyClip(GCPtr pgcDst, GCPtr pgcSrc); + +extern GCPtr PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc); + +/* + * Functions in PsMisc.c + */ + +extern void PsQueryBestSize(int type, short *pwidth, short *pheight, + ScreenPtr pScreen); +extern Bool PsCloseScreen(int index, ScreenPtr pScreen); +extern void PsLineAttrs(PsOutPtr psOut, GCPtr pGC, ColormapPtr cMap); +extern int PsGetMediumDimensions( + XpContextPtr pCon, + CARD16 *pWidth, + CARD16 *pHeight); +extern int PsGetReproducibleArea( + XpContextPtr pCon, + xRectangle *pRect); +extern int PsSetImageResolution( + XpContextPtr pCon, + int imageRes, + Bool *status); + +/* + * Functions in PsSpans.c + */ + +extern void PsFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, + DDXPointPtr pPoints, int *pWidths, int fSorted); +extern void PsSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc, + DDXPointPtr pPoints, int *pWidths, int nSpans, + int fSorted); + +/* + * Functions in PsArea.c + */ + +extern void PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, + int x, int y, int w, int h, int leftPad, int format, + int imageRes, char *pImage); +extern void PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, + int x, int y, int w, int h, int leftPad, + int format, int imageRes, char *pImage); +extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, + int x, int y, int w, int h, int leftPad, int format, + char *pImage); +extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage); +extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty); +extern RegionPtr PsCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long plane); + +/* + * Functions in PsPixel.c + */ + +extern void PsPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, + int nPoints, xPoint *pPoints); +extern void PsPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable, + int width, int height, int x, int y); + +/* + * Functions in PsLine.c + */ + +extern void PsPolyLine(DrawablePtr pDrawable, GCPtr pGC, int mode, + int nPoints, xPoint *pPoints); +extern void PsPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments, + xSegment *pSegments); + +/* + * Functions in PsPolygon.c + */ + +extern void PsPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRects, + xRectangle *pRects); +extern void PsFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int nPoints, DDXPointPtr pPoints); +extern void PsPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRects, + xRectangle *pRects); + +/* + * Functions in PsPolygon.c + */ + +extern void PsPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, + xArc *pArcs); +extern void PsPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, + xArc *pArcs); + +/* + * Functions in PsText.c + */ + +extern int PsPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, char *string); +extern int PsPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, unsigned short *string); +extern void PsImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, char *string); +extern void PsImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, unsigned short *string); +extern void PsImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + unsigned int nGlyphs, CharInfoPtr *pCharInfo, + pointer pGlyphBase); +extern void PsPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + unsigned int nGlyphs, CharInfoPtr *pCharInfo, + pointer pGlyphBase); + +/* + * Functions in PsWindow.c + */ + +extern Bool PsCreateWindow(WindowPtr pWin); +extern Bool PsMapWindow(WindowPtr pWin); +extern Bool PsPositionWindow(WindowPtr pWin, int x, int y); +extern Bool PsUnmapWindow(WindowPtr pWin); +extern void PsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr prgnSrc); +extern Bool PsChangeWindowAttributes(WindowPtr pWin, unsigned long mask); +extern Bool PsDestroyWindow(WindowPtr pWin); + +/* + * Functions in PsFonts.c + */ + +extern Bool PsRealizeFont(ScreenPtr pscr, FontPtr pFont); +extern Bool PsUnrealizeFont(ScreenPtr pscr, FontPtr pFont); +extern char *PsGetFontName(FontPtr pFont); +extern int PsGetFontSize(FontPtr pFont, float *mtx); +extern char *PsGetPSFontName(FontPtr pFont); +extern char *PsGetPSFaceOrFontName(FontPtr pFont); +extern int PsIsISOLatin1Encoding(FontPtr pFont); +extern char *PsGetEncodingName(FontPtr pFont); +extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont); +extern void PsFreeFontInfoRecords(PsContextPrivPtr priv); +extern PsFTDownloadFontType PsGetFTDownloadFontType(void); + +/* + * Functions in PsFTFonts.c + */ + +extern char *PsGetFTFontFileName(FontPtr pFont); +extern Bool PsIsFreeTypeFont(FontPtr pFont); + +/* + * Functions in PsAttr.c + */ + +extern char *PsGetAttributes(XpContextPtr pCon, XPAttributes pool); +extern char *PsGetOneAttribute(XpContextPtr pCon, XPAttributes pool, + char *attr); +extern int PsAugmentAttributes(XpContextPtr pCon, XPAttributes pool, + char *attrs); +extern int PsSetAttributes(XpContextPtr pCon, XPAttributes pool, char *attrs); + +/* + * Functions in PsColor.c + */ + +extern Bool PsCreateColormap(ColormapPtr pColor); +extern void PsDestroyColormap(ColormapPtr pColor); +extern void PsInstallColormap(ColormapPtr pColor); +extern void PsUninstallColormap(ColormapPtr pColor); +extern int PsListInstalledColormaps(ScreenPtr pScreen, XID *pCmapList); +extern void PsStoreColors(ColormapPtr pColor, int ndef, xColorItem *pdefs); +extern void PsResolveColor(unsigned short *pRed, unsigned short *pGreen, + unsigned short *pBlue, VisualPtr pVisual); +extern PsOutColor PsGetPixelColor(ColormapPtr cMap, int pixval); +extern void PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut, + ColormapPtr cMap); + +/* + * Functions in PsPixmap.c + */ + +extern PixmapPtr PsCreatePixmap(ScreenPtr pScreen, int width, int height, + int depth, unsigned usage_hint); +extern void PsScrubPixmap(PixmapPtr pPixmap); +extern Bool PsDestroyPixmap(PixmapPtr pPixmap); +extern DisplayListPtr PsGetFreeDisplayBlock(PsPixmapPrivPtr priv); +extern void PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable); +extern void PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable); +extern int PsCloneDisplayElm(PixmapPtr dst, + DisplayElmPtr elm, DisplayElmPtr newElm, + int xoff, int yoff); +extern void PsCopyDisplayList(PixmapPtr src, PixmapPtr dst, int xoff, + int yoff, int x, int y, int w, int h); +extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms); +extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); +extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); + +/* + * Functions in PsImageUtil.c + */ + +extern unsigned long +PsGetImagePixel(char *pImage, int depth, int w, int h, int leftPad, int format, + int px, int py); + +#endif /* _PS_H_ */ diff --git a/xorg-server/hw/xprint/ps/PsArc.c b/xorg-server/hw/xprint/ps/PsArc.c new file mode 100644 index 000000000..0684307dd --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsArc.c @@ -0,0 +1,181 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsArc.c +** * +** * Contents: Arc-drawing code for the PS DDX driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" + +void +PsPolyArc( + DrawablePtr pDrawable, + GCPtr pGC, + int nArcs, + xArc *pArcs) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyArcCmd; + elm->gc = gc; + elm->c.arcs.nArcs = nArcs; + elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc)); + memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + PsLineAttrs(psOut, pGC, cMap); + for( i=0 ; i<nArcs ; i++ ) + { + PsOut_DrawArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y, + (int)pArcs[i].width, (int)pArcs[i].height, + (float)pArcs[i].angle1/64., + (float)pArcs[i].angle2/64.); + } + } +} + +void +PsPolyFillArc( + DrawablePtr pDrawable, + GCPtr pGC, + int nArcs, + xArc *pArcs) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyFillArcCmd; + elm->gc = gc; + elm->c.arcs.nArcs = nArcs; + elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc)); + memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + PsArcEnum styl; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsSetFillColor(pDrawable, pGC, psOut, cMap); + PsLineAttrs(psOut, pGC, cMap); + if( pGC->arcMode==ArcChord ) styl = PsChord; + else styl = PsPieSlice; + for( i=0 ; i<nArcs ; i++ ) + { + PsOut_FillArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y, + (int)pArcs[i].width, (int)pArcs[i].height, + (float)pArcs[i].angle1/64., + (float)pArcs[i].angle2/64., styl); + } + } +} diff --git a/xorg-server/hw/xprint/ps/PsArea.c b/xorg-server/hw/xprint/ps/PsArea.c new file mode 100644 index 000000000..6ab9fa25c --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsArea.c @@ -0,0 +1,390 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996, 2000 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsArea.c +** * +** * Contents: Image and Area functions for the PS DDX driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" + + +void +PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, int imageRes, char *pImage) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + int size = PixmapBytePad(w, depth)*h; + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + elm = &disp->elms[disp->nelms]; + elm->type = PutImageCmd; + elm->gc = gc; + elm->c.image.depth = depth; + elm->c.image.x = x; + elm->c.image.y = y; + elm->c.image.w = w; + elm->c.image.h = h; + elm->c.image.leftPad = leftPad; + elm->c.image.format = format; + elm->c.image.res = imageRes; + elm->c.image.pData = (char *)xalloc(size); + memcpy(elm->c.image.pData, pImage, size); + disp->nelms += 1; + } + else + { + int i, j; + int r, c; + PsOutPtr psOut; + ColormapPtr cMap; + int pageRes, sw, sh; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + if (!imageRes) { + sw = w; + sh = h; + } else { + pageRes = XpGetResolution(XpGetPrintContext(requestingClient)); + sw = (float)w * (float)pageRes / (float)imageRes + 0.5; + sh = (float)h * (float)pageRes / (float)imageRes + 0.5; + } + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + + if( depth!=1 ) + { + PsOut_BeginImage(psOut, 0, 0, x, y, w, h, sw, sh, 3); + + for( r=0 ; r<h ; r++ ) + { + for( c=0 ; c<w ; c++ ) + { + unsigned long pv = PsGetImagePixel(pImage, depth, w, h, leftPad, format, c, r); + PsOutColor clr = PsGetPixelColor(cMap, pv); + /* XXX: This needs to be fixed for endian swapping and to support + * depths deeper than 8bit per R-,G-,B-gun... */ + unsigned long val = PSOUTCOLOR_TO_RGB24BIT(clr); + char *ipt = (char *)&val; +/* XXX: Is this the right way to detect the platform endianess ? */ +#if IMAGE_BYTE_ORDER == LSBFirst + { + long l; + swapl(&val, l); + } +#elif IMAGE_BYTE_ORDER == MSBFirst +#else +#error Unsupported byte order +#endif + PsOut_OutImageBytes(psOut, 3, &ipt[1]); + } + } + + PsOut_EndImage(psOut); + } + else + { + int rowsiz = BitmapBytePad(w); + int psrsiz = (w+7)/8; + PsOut_BeginImage(psOut, PsGetPixelColor(cMap, pGC->bgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r<h ; r++ ) + { + char *pt = &pImage[rowsiz*r]; + for( i=0 ; i<psrsiz ; i++ ) + { + int iv_, iv = (int)pt[i]&0xFF; + char c; +/* XXX: Is this the right way to detect the platform endianess ? */ +#if IMAGE_BYTE_ORDER == LSBFirst + { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); } +#elif IMAGE_BYTE_ORDER == MSBFirst + iv_ = iv; +#else +#error Unsupported byte order +#endif + c = iv_; + PsOut_OutImageBytes(psOut, 1, &c); + } + } + PsOut_EndImage(psOut); + } + } +} + +void +PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, int imageRes, char *pImage) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + int size = PixmapBytePad(w, depth)*h; + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + elm = &disp->elms[disp->nelms]; + elm->type = PutImageCmd; + elm->gc = gc; + elm->c.image.depth = depth; + elm->c.image.x = x; + elm->c.image.y = y; + elm->c.image.w = w; + elm->c.image.h = h; + elm->c.image.leftPad = leftPad; + elm->c.image.format = format; + elm->c.image.res = imageRes; + elm->c.image.pData = (char *)xalloc(size); + memcpy(elm->c.image.pData, pImage, size); + disp->nelms += 1; + } + else + { + int i, j; + int r, c; + PsOutPtr psOut; + ColormapPtr cMap; + int pageRes, sw, sh; +#ifdef BM_CACHE + long cache_id = 0; +#endif + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + if (!imageRes) { + sw = w; + sh = h; + } else { + pageRes = XpGetResolution(XpGetPrintContext(requestingClient)); + sw = (float)w * (float)pageRes / (float)imageRes + 0.5; + sh = (float)h * (float)pageRes / (float)imageRes + 0.5; + } + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + +#ifdef BM_CACHE + cache_id = PsBmIsImageCached(w, h, pImage); + + if(!cache_id) + { + cache_id = PsBmPutImageInCache(w, h, pImage); + + if(!cache_id) + return; + + PsOut_BeginImageCache(psOut, cache_id); +#endif + if( depth!=1 ) + { + PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); + + for( r=0 ; r<h ; r++ ) + { + for( c=0 ; c<w ; c++ ) + { + unsigned long pv = PsGetImagePixel(pImage, depth, w, h, leftPad, format, c, r); + PsOutColor clr = PsGetPixelColor(cMap, pv); + /* XXX: This needs to be fixed for endian swapping and to support + * depths deeper than 8bit per R-,G-,B-gun... */ + unsigned long val = PSOUTCOLOR_TO_RGB24BIT(clr); + char *ipt = (char *)&val; +/* XXX: Is this the right way to detect the platform endianess ? */ +#if IMAGE_BYTE_ORDER == LSBFirst + { + long l; + swapl(&val, l); + } +#elif IMAGE_BYTE_ORDER == MSBFirst +#else +#error Unsupported byte order +#endif + PsOut_OutImageBytes(psOut, 3, &ipt[1]); + } + } + + PsOut_EndImage(psOut); + } + else + { + int rowsiz = BitmapBytePad(w); + int psrsiz = (w+7)/8; + PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r<h ; r++ ) + { + char *pt = &pImage[rowsiz*r]; + for( i=0 ; i<psrsiz ; i++ ) + { + int iv_, iv = (int)pt[i]&0xFF; + char c; +/* XXX: Is this the right way to detect the platform endianess ? */ +#if IMAGE_BYTE_ORDER == LSBFirst + { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); } +#elif IMAGE_BYTE_ORDER == MSBFirst + iv_ = iv; +#else +#error Unsupported byte order +#endif + c = iv_; + PsOut_OutImageBytes(psOut, 1, &c); + } + } + PsOut_EndImage(psOut); + } +#ifdef BM_CACHE + PsOut_EndImageCache(psOut); + } + PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel), + PsGetPixelColor(cMap, pGC->fgPixel)); +#endif + } +} +void +PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage) +{ + XpContextPtr pcon; + if (requestingClient && (pcon = XpGetPrintContext(requestingClient))) + PsPutScaledImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, + pcon->imageRes, pImage); +} +void +PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage) +{ + XpContextPtr pcon; + if (requestingClient && (pcon = XpGetPrintContext(requestingClient))) + PsPutScaledImageIM(pDrawable, pGC, depth, x, y, w, h, leftPad, format, + pcon->imageRes, pImage); +} + +RegionPtr +PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, + int width, int height, int dstx, int dsty) +{ + PixmapPtr src = (PixmapPtr)pSrc; + PixmapPtr dst = (PixmapPtr)pDst; + + if( pSrc->type!=DRAWABLE_PIXMAP ) return NULL; + if( pDst->type!=DRAWABLE_PIXMAP ) + { + PsOutPtr psOut; + ColormapPtr cMap; + if( PsUpdateDrawableGC(pGC, pDst, &psOut, &cMap)==FALSE ) return NULL; + PsOut_Offset(psOut, pDst->x, pDst->y); + PsOut_BeginFrame(psOut, dstx-srcx, dsty-srcy, dstx, dsty, width, height); + PsReplayPixmap(src, pDst); + PsOut_EndFrame(psOut); + } + else PsCopyDisplayList(src, dst, dstx-srcx, dsty-srcy, dstx, dsty, + width, height); + return NULL; +} + +RegionPtr +PsCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, + int width, int height, int dstx, int dsty, unsigned long plane) +{ + PixmapPtr src = (PixmapPtr)pSrc; + PixmapPtr dst = (PixmapPtr)pDst; + + if( pSrc->type!=DRAWABLE_PIXMAP ) return NULL; + if( pDst->type!=DRAWABLE_PIXMAP ) + { + PsOutPtr psOut; + ColormapPtr cMap; + if( PsUpdateDrawableGC(pGC, pDst, &psOut, &cMap)==FALSE ) return NULL; + PsOut_Offset(psOut, pDst->x, pDst->y); + PsOut_BeginFrame(psOut, dstx-srcx, dsty-srcy, dstx, dsty, width, height); + PsReplayPixmap(src, pDst); + PsOut_EndFrame(psOut); + } + else PsCopyDisplayList(src, dst, dstx-srcx, dsty-srcy, dstx, dsty, + width, height); + return NULL; +} diff --git a/xorg-server/hw/xprint/ps/PsAttVal.c b/xorg-server/hw/xprint/ps/PsAttVal.c new file mode 100644 index 000000000..de2e6c8e4 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsAttVal.c @@ -0,0 +1,289 @@ +/* + */ +/* +(c) Copyright 1996 Hewlett-Packard Company +(c) Copyright 1996 International Business Machines Corp. +(c) Copyright 1996 Sun Microsystems, Inc. +(c) Copyright 1996 Novell, Inc. +(c) Copyright 1996 Digital Equipment Corp. +(c) Copyright 1996 Fujitsu Limited +(c) Copyright 1996 Hitachi, Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the copyright holders shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from said +copyright holders. +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "AttrValid.h" + +/* + * define valid values and defaults for Printer pool + */ +static XpOid ValidContentOrientationsOids[] = { + xpoid_val_content_orientation_portrait, + xpoid_val_content_orientation_landscape, + xpoid_val_content_orientation_reverse_portrait, + xpoid_val_content_orientation_reverse_landscape +}; +static XpOidList ValidContentOrientations = { + ValidContentOrientationsOids, XpNumber(ValidContentOrientationsOids) +}; + +static XpOid DefaultContentOrientationsOids[] = { + xpoid_val_content_orientation_portrait, + xpoid_val_content_orientation_landscape +}; +static XpOidList DefaultContentOrientations = { + DefaultContentOrientationsOids, XpNumber(DefaultContentOrientationsOids) +}; + +static XpOid ValidPlexesOids[] = { + xpoid_val_plex_simplex, xpoid_val_plex_duplex, xpoid_val_plex_tumble +}; +static XpOidList ValidPlexes = { + ValidPlexesOids, XpNumber(ValidPlexesOids) +}; + +static XpOid DefaultPlexesOids[] = { + xpoid_val_plex_simplex +}; +static XpOidList DefaultPlexes = { + DefaultPlexesOids, XpNumber(DefaultPlexesOids) +}; + +static unsigned long ValidPrinterResolutionsCards[] = { + 75, + 100, + 120, + 150, + 180, + 200, + 240, + 300, + 360, + 400, + 600, + 720, + 940, + 1200, + 1440, + 2400 +}; +static XpOidCardList ValidPrinterResolutions = { + ValidPrinterResolutionsCards, XpNumber(ValidPrinterResolutionsCards) +}; + +static unsigned long DefaultPrinterResolutionsCards[] = { + 75, + 100, + 120, + 150, + 180, + 200, + 240, + 300, + 360, + 400, + 600, + 720, + 940, + 1200 +}; +static XpOidCardList DefaultPrinterResolutions = { + DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards) +}; + +static XpOid ValidListfontsModesOids[] = { + xpoid_val_xp_list_internal_printer_fonts, xpoid_val_xp_list_glyph_fonts +}; +static XpOidList ValidListfontsModes = { + ValidListfontsModesOids, XpNumber(ValidListfontsModesOids) +}; + +static XpOid DefaultListfontsModesOids[] = { + xpoid_val_xp_list_glyph_fonts +}; +static XpOidList DefaultListfontsModes = { + DefaultListfontsModesOids, XpNumber(DefaultListfontsModesOids) +}; + +static XpOid ValidSetupProvisoOids[] = { + xpoid_val_xp_setup_mandatory, xpoid_val_xp_setup_optional +}; +static XpOidList ValidSetupProviso = { + + + ValidSetupProvisoOids, XpNumber(ValidSetupProvisoOids) +}; + +static XpOidDocFmt ValidDocFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } +}; +static XpOidDocFmtList ValidDocFormatsSupported = { + ValidDocFormatsSupportedFmts, XpNumber(ValidDocFormatsSupportedFmts) +}; + +static XpOidDocFmt DefaultDocFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } +}; +static XpOidDocFmtList DefaultDocFormatsSupported = { + DefaultDocFormatsSupportedFmts, XpNumber(DefaultDocFormatsSupportedFmts) +}; + +static XpOidDocFmt ValidEmbeddedFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } +}; +static XpOidDocFmtList ValidEmbeddedFormatsSupported = { + ValidEmbeddedFormatsSupportedFmts, XpNumber(ValidEmbeddedFormatsSupportedFmts) +}; + +static XpOidDocFmt DefaultEmbeddedFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } +}; +static XpOidDocFmtList DefaultEmbeddedFormatsSupported = { + DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts) +}; + +static XpOidDocFmt ValidRawFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } + +}; +static XpOidDocFmtList ValidRawFormatsSupported = { + ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts) +}; + +static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = { + { "Postscript", "2", NULL } +}; +static XpOidDocFmtList DefaultRawFormatsSupported = { + DefaultRawFormatsSupportedFmts, XpNumber(DefaultRawFormatsSupportedFmts) +}; + +static XpOid ValidInputTraysOids[] = { + xpoid_val_input_tray_manual, + xpoid_val_input_tray_main, + xpoid_val_input_tray_envelope, + xpoid_val_input_tray_large_capacity, + xpoid_val_input_tray_bottom +}; +static XpOidList ValidInputTrays = { + ValidInputTraysOids, XpNumber(ValidInputTraysOids) +}; + +static XpOid ValidMediumSizesOids[] = { + xpoid_val_medium_size_iso_a0, + xpoid_val_medium_size_iso_a1, + xpoid_val_medium_size_iso_a2, + xpoid_val_medium_size_iso_a3, + xpoid_val_medium_size_iso_a4, + xpoid_val_medium_size_iso_a5, + xpoid_val_medium_size_iso_a6, + xpoid_val_medium_size_iso_a7, + xpoid_val_medium_size_iso_a8, + xpoid_val_medium_size_iso_a9, + xpoid_val_medium_size_iso_a10, + xpoid_val_medium_size_iso_b0, + xpoid_val_medium_size_iso_b1, + xpoid_val_medium_size_iso_b2, + xpoid_val_medium_size_iso_b3, + xpoid_val_medium_size_iso_b4, + xpoid_val_medium_size_iso_b5, + xpoid_val_medium_size_iso_b6, + xpoid_val_medium_size_iso_b7, + xpoid_val_medium_size_iso_b8, + xpoid_val_medium_size_iso_b9, + xpoid_val_medium_size_iso_b10, + xpoid_val_medium_size_na_letter, + xpoid_val_medium_size_na_legal, + xpoid_val_medium_size_executive, + xpoid_val_medium_size_folio, + xpoid_val_medium_size_invoice, + xpoid_val_medium_size_ledger, + xpoid_val_medium_size_quarto, + xpoid_val_medium_size_iso_c3, + xpoid_val_medium_size_iso_c4, + xpoid_val_medium_size_iso_c5, + xpoid_val_medium_size_iso_c6, + xpoid_val_medium_size_iso_designated_long, + xpoid_val_medium_size_na_10x13_envelope, + xpoid_val_medium_size_na_9x12_envelope, + xpoid_val_medium_size_na_number_10_envelope, + xpoid_val_medium_size_na_7x9_envelope, + xpoid_val_medium_size_na_9x11_envelope, + xpoid_val_medium_size_na_10x14_envelope, + xpoid_val_medium_size_na_number_9_envelope, + xpoid_val_medium_size_na_6x9_envelope, + xpoid_val_medium_size_na_10x15_envelope, + xpoid_val_medium_size_monarch_envelope, + xpoid_val_medium_size_a, + xpoid_val_medium_size_b, + xpoid_val_medium_size_c, + xpoid_val_medium_size_d, + xpoid_val_medium_size_e, + xpoid_val_medium_size_jis_b0, + xpoid_val_medium_size_jis_b1, + xpoid_val_medium_size_jis_b2, + xpoid_val_medium_size_jis_b3, + xpoid_val_medium_size_jis_b4, + xpoid_val_medium_size_jis_b5, + xpoid_val_medium_size_jis_b6, + xpoid_val_medium_size_jis_b7, + xpoid_val_medium_size_jis_b8, + xpoid_val_medium_size_jis_b9, + xpoid_val_medium_size_jis_b10, + xpoid_val_medium_size_hp_2x_postcard, + xpoid_val_medium_size_hp_european_edp, + xpoid_val_medium_size_hp_mini, + xpoid_val_medium_size_hp_postcard, + xpoid_val_medium_size_hp_tabloid, + xpoid_val_medium_size_hp_us_edp, + xpoid_val_medium_size_hp_us_government_legal, + xpoid_val_medium_size_hp_us_government_letter, +}; +static XpOidList ValidMediumSizes = { + ValidMediumSizesOids, XpNumber(ValidMediumSizesOids) +}; + +static XpOidDocFmt DefaultDocumentFormat = { + "Postscript", "2", NULL +}; + + +/* + * init struct for XpValidate*Pool + */ +XpValidatePoolsRec PsValidatePoolsRec = { + &ValidContentOrientations, &DefaultContentOrientations, + &ValidDocFormatsSupported, &DefaultDocFormatsSupported, + &ValidInputTrays, &ValidMediumSizes, + &ValidPlexes, &DefaultPlexes, + &ValidPrinterResolutions, &DefaultPrinterResolutions, + &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported, + &ValidListfontsModes, &DefaultListfontsModes, + &ValidRawFormatsSupported, &DefaultRawFormatsSupported, + &ValidSetupProviso, + &DefaultDocumentFormat +}; diff --git a/xorg-server/hw/xprint/ps/PsAttr.c b/xorg-server/hw/xprint/ps/PsAttr.c new file mode 100644 index 000000000..0925716f5 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsAttr.c @@ -0,0 +1,116 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsAttr.c +** * +** * Contents: Attribute-handling functions for the PS driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "attributes.h" + +char * +PsGetAttributes( + XpContextPtr pCon, + XPAttributes pool) +{ + return XpGetAttributes(pCon, pool); +} + +char * +PsGetOneAttribute( + XpContextPtr pCon, + XPAttributes pool, + char *attr) +{ + return XpGetOneAttribute(pCon, pool, attr); +} + +int +PsAugmentAttributes( + XpContextPtr pCon, + XPAttributes pool, + char *attrs) +{ + return XpAugmentAttributes(pCon, pool, attrs); +} + +int +PsSetAttributes( + XpContextPtr pCon, + XPAttributes pool, + char *attrs) +{ + return XpSetAttributes(pCon, pool, attrs); +} diff --git a/xorg-server/hw/xprint/ps/PsCache.c b/xorg-server/hw/xprint/ps/PsCache.c new file mode 100644 index 000000000..5c823a13e --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsCache.c @@ -0,0 +1,328 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All Rights Reserved. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsCache.c +** * +** * Contents: Character-caching routines +** * +** * Created By: Jay Hobson (Sun MicroSystems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" +#include <X11/fonts/fntfil.h> +#include <X11/fonts/fntfilst.h> + +#define GET 0 +#define RESET 1 + +struct bm_cache_list { + struct bm_cache_list *next; + struct bm_cache_list *prev; + int height; + long id; + char *pBuffer; +}; + +struct bm_cache_head { + struct bm_cache_list *head; + int width; + struct bm_cache_head *next; + struct bm_cache_head *prev; +}; + +static struct bm_cache_head *bm_cache = NULL; + +static long +PsBmUniqueId(int func) +{ + static long unique_id = 0; + + if(func == RESET) + { + unique_id = 0; + return 0; + } + else + return ++unique_id; +} + +int +PsBmIsImageCached( + int gWidth, + int gHeight, + char *pBuffer) +{ + int return_val = 0; + struct bm_cache_head *pList = bm_cache; + + while(pList != NULL && !return_val) + { + if(pList->width == gWidth) + { + struct bm_cache_list *pItem = pList->head; + + while(pItem != NULL) + { + if(pItem->height == gHeight) + { + int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; + + if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length)) + { + return_val = pItem->id; + break; + } + } + else if(pItem->height > gHeight) + break; + + pItem = pItem->next; + } + } + else if(pList->width > gWidth) + break; + + pList = pList->next; + } + return return_val; +} + +int +PsBmPutImageInCache( + int gWidth, + int gHeight, + char *pBuffer) +{ + int return_val = 0; + struct bm_cache_head *pList = bm_cache; + struct bm_cache_list *pNew; + int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; + + if(gWidth == 1 && gHeight == 1 && pBuffer[0] == 0) + return return_val; + + pNew = (struct bm_cache_list *)malloc(sizeof(struct bm_cache_list)); + pNew->next = NULL; + pNew->prev = NULL; + pNew->height = gHeight; + pNew->id = PsBmUniqueId(GET); + pNew->pBuffer = (char *)malloc(sizeof(char)*length); + + memcpy(pNew->pBuffer, pBuffer, length); + + while(pList != NULL) + { + if(pList->width == gWidth) + { + struct bm_cache_list *pItem = pList->head; + + while(pItem != NULL) + { + if(pItem->height >= gHeight) + { + pNew->next = pItem; + pNew->prev = pItem->prev; + if(pItem->prev != NULL) + pItem->prev->next = pNew; + else + pList->head = pNew; + pItem->prev = pNew; + + return_val = pNew->id; + + break; + } + else if(pItem->next == NULL) + { + pNew->prev = pItem; + pItem->next = pNew; + + return_val = pNew->id; + + break; + } + + pItem = pItem->next; + } + + break; + } + + pList = pList->next; + } + + if(pList == NULL) + { + struct bm_cache_head *pNewList; + + pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head)); + + pNewList->next = NULL; + pNewList->prev = NULL; + pNewList->width = gWidth; + pNewList->head = pNew; + + if(bm_cache == NULL) + { + bm_cache = pNewList; + return_val = pNew->id; + } + else + { + pList = bm_cache; + + while(pList != NULL) + { + if(pList->width > gWidth) + { + pNewList->next = pList; + pNewList->prev = pList->prev; + + if(pList->prev != NULL) + pList->prev->next = pNewList; + else + bm_cache = pNewList; + pList->prev = pNewList; + + return_val = pNew->id; + + break; + } + else if(pList->next == NULL) + { + pNewList->prev = pList; + pList->next = pNewList; + + return_val = pNew->id; + + break; + } + + pList = pList->next; + } + } + } + + return return_val; +} + + +static void +PsBmClearImageCacheItem( + struct bm_cache_list *pItem) +{ + if(pItem != NULL) + { + if(pItem->pBuffer != NULL) + free(pItem->pBuffer); + pItem->pBuffer = NULL; + + if(pItem->next) + PsBmClearImageCacheItem(pItem->next); + pItem->next = NULL; + + free(pItem); + pItem = NULL; + } +} + +static void +PsBmClearImageCacheList( + struct bm_cache_head *pList) +{ + if(pList != NULL) + { + if(pList->head) + PsBmClearImageCacheItem(pList->head); + pList->head = NULL; + + if(pList->next) + PsBmClearImageCacheList(pList->next); + pList->next = NULL; + + free(pList); + pList = NULL; + } +} + +void +PsBmClearImageCache(void) +{ + PsBmClearImageCacheList(bm_cache); + + bm_cache = NULL; + + PsBmUniqueId(RESET); +} + diff --git a/xorg-server/hw/xprint/ps/PsColor.c b/xorg-server/hw/xprint/ps/PsColor.c new file mode 100644 index 000000000..a91272db0 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsColor.c @@ -0,0 +1,257 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsColor.c +** * +** * Contents: Color routines for the PS driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "mi.h" +#include "micmap.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "colormapst.h" + +Bool +PsCreateColormap(ColormapPtr pColor) +{ + return miInitializeColormap(pColor); +} + +void +PsDestroyColormap(ColormapPtr pColor) +{ + /* NO-OP */ +} + +void +PsInstallColormap(ColormapPtr pColor) +{ + miInstallColormap(pColor); +} + +void +PsUninstallColormap(ColormapPtr pColor) +{ + miUninstallColormap(pColor); +} + +int +PsListInstalledColormaps( + ScreenPtr pScreen, + XID *pCmapList) +{ + return miListInstalledColormaps(pScreen, pCmapList); +} + +void +PsStoreColors( + ColormapPtr pColor, + int ndef, + xColorItem *pdefs) +{ + int i; + for( i=0 ; i<ndef ; i++ ) + { + if( pdefs[i].flags&DoRed ) + pColor->red[pdefs[i].pixel].co.local.red = pdefs[i].red; + if( pdefs[i].flags&DoGreen ) + pColor->red[pdefs[i].pixel].co.local.green = pdefs[i].green; + if( pdefs[i].flags&DoBlue ) + pColor->red[pdefs[i].pixel].co.local.blue = pdefs[i].blue; + } +} + +void +PsResolveColor( + unsigned short *pRed, + unsigned short *pGreen, + unsigned short *pBlue, + VisualPtr pVisual) +{ + miResolveColor(pRed, pGreen, pBlue, pVisual); +} + +PsOutColor +PsGetPixelColor(ColormapPtr cMap, int pixval) +{ + VisualPtr v = cMap->pVisual; + switch( v->class ) + { + case TrueColor: + { + PsOutColor p = pixval; + PsOutColor r, g, b; + + r = (p & v->redMask) >> v->offsetRed; + g = (p & v->greenMask) >> v->offsetGreen; + b = (p & v->blueMask) >> v->offsetBlue; + + r = cMap->red[r].co.local.red; + g = cMap->green[g].co.local.green; + b = cMap->blue[b].co.local.blue; + +#ifdef PSOUT_USE_DEEPCOLOR + return((r<<32)|(g<<16)|b); +#else + r >>= 8; + g >>= 8; + b >>= 8; + + return((r<<16)|(g<<8)|b); +#endif /* PSOUT_USE_DEEPCOLOR */ + } + case PseudoColor: + case GrayScale: + case StaticGray: + { + PsOutColor r, g, b; + + if( pixval < 0 || pixval > v->ColormapEntries) + return(0); + + r = cMap->red[pixval].co.local.red; + g = cMap->red[pixval].co.local.green; + b = cMap->red[pixval].co.local.blue; + + if ((v->class | DynamicClass) == GrayScale) + { + /* rescale to gray (see |miResolveColor()|) */ + r = g = b = (30L*r + 59L*g + 11L*b) / 100L; + } + +#ifdef PSOUT_USE_DEEPCOLOR + return((r<<32)|(g<<16)|b); +#else + r >>= 8; + g >>= 8; + b >>= 8; + + return((r<<16)|(g<<8)|b); +#endif /* PSOUT_USE_DEEPCOLOR */ + } + default: + FatalError("PsGetPixelColor: Unsupported visual %x\n", + (int)cMap->pVisual->class); + break; + } + + return 0; /* NO-OP*/ +} + +void +PsSetFillColor(DrawablePtr pDrawable, GCPtr pGC, PsOutPtr psOut, + ColormapPtr cMap) +{ + switch(pGC->fillStyle) + { + case FillSolid: + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + break; + case FillTiled: + if( !PsOut_BeginPattern(psOut, pGC->tile.pixmap, + pGC->tile.pixmap->drawable.width, + pGC->tile.pixmap->drawable.height, PsTile, 0, 0) ) + { + PsReplayPixmap(pGC->tile.pixmap, pDrawable); + PsOut_EndPattern(psOut); + } + PsOut_SetPattern(psOut, pGC->tile.pixmap, PsTile); + break; + case FillStippled: + if( !PsOut_BeginPattern(psOut, pGC->stipple, + pGC->stipple->drawable.width, + pGC->stipple->drawable.height, PsStip, 0, + PsGetPixelColor(cMap, pGC->fgPixel)) ) + { + PsReplayPixmap(pGC->stipple, pDrawable); + PsOut_EndPattern(psOut); + } + PsOut_SetPattern(psOut, pGC->stipple, PsStip); + break; + case FillOpaqueStippled: + if( !PsOut_BeginPattern(psOut, pGC->stipple, + pGC->stipple->drawable.width, + pGC->stipple->drawable.height, PsOpStip, + PsGetPixelColor(cMap, pGC->bgPixel), + PsGetPixelColor(cMap, pGC->fgPixel)) ) + { + PsReplayPixmap(pGC->stipple, pDrawable); + PsOut_EndPattern(psOut); + } + PsOut_SetPattern(psOut, pGC->stipple, PsOpStip); + break; + } +} diff --git a/xorg-server/hw/xprint/ps/PsDef.h b/xorg-server/hw/xprint/ps/PsDef.h new file mode 100644 index 000000000..5af274dec --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsDef.h @@ -0,0 +1,96 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsDef.h +** * +** * Contents: extran defines and includes for the Ps driver +** * for a printing X server. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _PSDEF_H_ +#define _PSDEF_H_ + +#define DT_PRINT_JOB_HEADER "DT_PRINT_JOB_HEADER" +#define DT_PRINT_JOB_TRAILER "DT_PRINT_JOB_TRAILER" +#define DT_PRINT_JOB_COMMAND "DT_PRINT_JOB_COMMAND" +#define DT_PRINT_JOB_EXEC_COMMAND "DT_PRINT_JOB_EXEC_COMMAND" +#define DT_PRINT_JOB_EXEC_OPTIONS "DT_PRINT_JOB_EXEC_OPTION" +#define DT_PRINT_PAGE_HEADER "DT_PRINT_PAGE_HEADER" +#define DT_PRINT_PAGE_TRAILER "DT_PRINT_PAGE_TRAILER" +#define DT_PRINT_PAGE_COMMAND "DT_PRINT_PAGE_COMMAND" + +#define DT_IN_FILE_STRING "%(InFile)%" +#define DT_OUT_FILE_STRING "%(OutFile)%" +#define DT_ALLOWED_COMMANDS_FILE "printCommands" + +#endif /* _PSDEF_H_ */ diff --git a/xorg-server/hw/xprint/ps/PsFTFonts.c b/xorg-server/hw/xprint/ps/PsFTFonts.c new file mode 100644 index 000000000..8857ae43e --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsFTFonts.c @@ -0,0 +1,85 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <ctype.h> +#include <limits.h> +#include <sys/stat.h> + +#include "regionstr.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "scrnintstr.h" +#include <X11/fonts/fontxlfd.h> +#include <X11/fonts/fntfil.h> +#include <X11/fonts/fntfilst.h> + +#include "Ps.h" + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include <X11/fonts/ft.h> +#define NOT_IN_FTFUNCS +#include <X11/fonts/ftfuncs.h> + +char * +PsGetFTFontFileName(FontPtr pFont) +{ + FTFontPtr tf = (FTFontPtr)pFont->fontPrivate; + return tf->instance->face->filename; +} + +Bool +PsIsFreeTypeFont(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + /* "RASTERIZER_NAME" must match the rasterizer name set in + * xc/lib/font/FreeType/ftfuncs.c */ + Atom name = MakeAtom("RASTERIZER_NAME", 15, True); + Atom value = (Atom)0; + char *rv; + + for( i=0 ; i<nprops ; i++ ) + { + if( props[i].name==name ) + { value = props[i].value; break; } + } + if( !value ) + return False; + + rv = NameForAtom(value); + if( !rv ) + return False; + + if( memcmp(rv, "FreeType", 8) == 0 ) + return True; + + return False; +} + diff --git a/xorg-server/hw/xprint/ps/PsFonts.c b/xorg-server/hw/xprint/ps/PsFonts.c new file mode 100644 index 000000000..8ab631441 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsFonts.c @@ -0,0 +1,873 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsFonts.c +** * +** * Contents: Font code for PS driver. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "regionstr.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "scrnintstr.h" +#include <X11/fonts/fontxlfd.h> +#include <X11/fonts/fntfil.h> +#include <X11/fonts/fntfilst.h> + +#include "Ps.h" + +#include <ctype.h> +#include <limits.h> +#include <sys/stat.h> + +Bool +PsRealizeFont( + ScreenPtr pscr, + FontPtr pFont) +{ + return TRUE; +} + +Bool +PsUnrealizeFont( + ScreenPtr pscr, + FontPtr pFont) +{ + return TRUE; +} + +char * +PsGetFontName(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + Atom name = MakeAtom("FONT", 4, True); + Atom value = (Atom)0; + + for( i=0 ; i<nprops ; i++ ) + { + if( (Atom)props[i].name==name ) + { value = props[i].value; break; } + } + if( !value ) return (char *)0; + return NameForAtom(value); +} + +int +PsGetFontSize(FontPtr pFont, float *mtx) +{ + FontScalableRec vals; + char *name = PsGetFontName(pFont); + int value = 0; + + FontParseXLFDName(name, &vals, FONT_XLFD_REPLACE_NONE); + if( vals.values_supplied&PIXELSIZE_ARRAY ) + { + int i; + for( i=0 ; i<4 ; i++ ) + mtx[i] = (float)vals.pixel_matrix[i]; + } + else + { + value = vals.pixel; + if( !value ) value = 20; + } + return value; +} + +char * +PsGetPSFontName(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute + * name - changing the name will break printer-builtin fonts. */ + Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True); + Atom value = (Atom)0; + + for( i=0 ; i<nprops ; i++ ) + { + if( (Atom)props[i].name==name ) + { value = props[i].value; break; } + } + if( !value ) return (char *)0; + return NameForAtom(value); +} + +int +PsIsISOLatin1Encoding(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True); + Atom enc = MakeAtom("CHARSET_ENCODING", 16, True); + Atom rv = 0, ev = 0; + char *rp = 0; + char *ep = 0; + + for( i=0 ; i<nprops ; i++ ) + { + if( (Atom)props[i].name==reg ) rv = props[i].value; + if( (Atom)props[i].name==enc ) ev = props[i].value; + } + if( rv ) rp = NameForAtom(rv); + if( ev ) ep = NameForAtom(ev); + if( (!rp) || (!ep) ) return(0); + if( (char)tolower(rp[0])!='i' || + (char)tolower(rp[1])!='s' || + (char)tolower(rp[2])!='o' || + memcmp(&rp[3], "8859", 4)!=0 || + ep[0]!='1' ) return(0); + return(1); +} + +/* Return the encoding part of the XLFD (e.g. "*-iso8859-6.8x" etc.)*/ +char *PsGetEncodingName(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + Atom fnt = MakeAtom("FONT", 4, True); + Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True); + Atom enc = MakeAtom("CHARSET_ENCODING", 16, True); + Atom fv = 0, rv = 0, ev = 0; + char *fp = 0; + char *rp = 0; + char *ep = 0; + char *encname; + + for( i=0 ; i<nprops ; i++ ) + { + if( props[i].name==fnt ) fv = props[i].value; + if( props[i].name==reg ) rv = props[i].value; + if( props[i].name==enc ) ev = props[i].value; + } + if( fv ) fp = NameForAtom(fv); + if( rv ) rp = NameForAtom(rv); + if( ev ) ep = NameForAtom(ev); + + if( (!rp) || (!ep) || (!fp)) + return(0); + + encname = fp; + encname += strlen(encname) - (strlen(rp) + strlen(ep) + 1); + + return encname; +} + +/* strstr(), case-insensitive */ +static +char *str_case_str(const char *s, const char *find) +{ + size_t len; + char c, + sc; + + if ((c = tolower(*find++)) != '\0') + { + len = strlen(find); + do + { + do + { + if ((sc = tolower(*s++)) == '\0') + return NULL; + } while (sc != c); + } while (strncasecmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} + +/* Check if the font path element is a directory which can be examined + * (for example the font may be from a font server + * (e.g. pFont->fpe->name == "tcp/:7100")) + */ +static +Bool IsFPEaReadableDir(FontPtr pFont) +{ + const char *fpe_name = pFont->fpe->name; + if (!fpe_name) + return False; + +#define MODEL_FONTPATH_PREFIX "PRINTER:" +#define MODEL_FONTPATH_PREFIX_LEN 8 + /* Strip model-specific font path prefix if there is one... */ + if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN)) + fpe_name += MODEL_FONTPATH_PREFIX_LEN; + + if (access(fpe_name, F_OK) == 0) + { + return True; + } + + return False; +} + +static +char *getFontFilename(FontPtr pFont) +{ + FontDirectoryPtr dir; + const char *dlfnam; + FILE *file; + struct stat statb; + char buf[512]; + char *front, *fn; + char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */ + font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */ + +#ifdef XP_USE_FREETYPE + if( PsIsFreeTypeFont(pFont) ) + { + const char *fontname = PsGetFTFontFileName(pFont); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:"<NULL>"); +#endif /* DEBUG_gisburn */ + + if( !fontname ) + return NULL; + + return strdup(fontname); + } +#endif /* XP_USE_FREETYPE */ + + if (!IsFPEaReadableDir(pFont)) + { +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name); +#endif /* DEBUG_gisburn */ + return NULL; + } + + dir = pFont->fpe->private; + sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir"); + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + file = fopen(font_dir_fname, "r"); + if (file) + { + if (fstat (fileno(file), &statb) == -1) + return NULL; + + while( fgets(buf, sizeof(buf)-1, file) ) + { + if ((fn = strstr(buf, " -"))) + { + strcpy(font_file_fname, buf); + font_file_fname[fn - buf] = '\0'; + fn++; + if ((front = str_case_str(fn, "normal-"))) + { + fn[front - fn] = '\0'; + if (str_case_str(dlfnam, fn)) + { + char full_font_file_path[PATH_MAX]; + + fclose(file); + + sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname); + +#ifdef xDEBUG_gisburn + fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path); +#endif /* DEBUG_gisburn */ + return strdup(full_font_file_path); + } + } + } + } + } + font_file_fname[0] = '\0'; + fclose(file); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: returning NULL\n"); +#endif /* DEBUG_gisburn */ + + return NULL; +} + +static +PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontTypeInfoRec *rec; + const char *psname; + char *font_filename; + char *encname; +#ifdef XP_USE_FREETYPE + Bool is_freetypefont; +#endif /* XP_USE_FREETYPE */ + +#ifdef XP_USE_FREETYPE + is_freetypefont = PsIsFreeTypeFont(pFont); +#endif /* XP_USE_FREETYPE */ + encname = PsGetEncodingName(pFont); + + /* First try: Search by PostScript font name */ + psname = PsGetPSFontName(pFont); + if (psname) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if (rec->adobe_ps_name) + { + if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname)) && + (!strcmp(rec->ft_download_encoding, encname))) + { + return rec; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if (rec->adobe_ps_name) + { + if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname))) + { + return rec; + } + } + } + } + } + + /* Last attempt: Search by filename */ + font_filename = getFontFilename(pFont); + if (font_filename) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { + if (rec->filename) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) && + (!strcasecmp(rec->ft_download_encoding, encname)) ) + { + free(font_filename); + return rec; + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) ) + { + free(font_filename); + return rec; + } + } + } + } + + free(font_filename); + } + + return NULL; +} + +static +void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontTypeInfoRecords; + cPriv->fontTypeInfoRecords = add_rec; +} + +static +Bool strcaseendswith(const char *str, const char *suffix) +{ + const char *s; + + s = str + strlen(str) - strlen(suffix); + + if (!strcasecmp(s, suffix)) + return True; + + return False; +} + + +static +int getFontFileType( const char *filename ) +{ + int type; + + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( strcaseendswith(filename, ".pfb") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if( strcaseendswith(filename, ".pfa") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFA; + } + /* Is this a PMF(=Printer Metrics File) ? */ + else if( strcaseendswith(filename, ".pmf") ) + { + type = PSFTI_FONT_TYPE_PMF; + } + /* Is this a TrueType font file ? */ + else if( strcaseendswith(filename, ".ttf") || + strcaseendswith(filename, ".ttc") || + strcaseendswith(filename, ".otf") || + strcaseendswith(filename, ".otc") ) + { + type = PSFTI_FONT_TYPE_TRUETYPE; + } + else + { + type = PSFTI_FONT_TYPE_OTHER; + } + +#ifdef XP_USE_FREETYPE + { + XpContextPtr pCon; + char *downloadfonts; + pCon = XpGetPrintContext(requestingClient); + downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts"); + if( downloadfonts ) + { + /* Should we download PS Type1 fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) && + (strstr(downloadfonts, "pfa") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) && + (strstr(downloadfonts, "pfb") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + /* Should we download TrueType fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_TRUETYPE) && + ((strstr(downloadfonts, "ttf") != NULL) || + (strstr(downloadfonts, "ttc") != NULL) || + (strstr(downloadfonts, "otf") != NULL) || + (strstr(downloadfonts, "otc") != NULL)) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + } + } +#endif /* XP_USE_FREETYPE */ + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type); +#endif /* DEBUG_gisburn */ + return type; +} + +PsFTDownloadFontType PsGetFTDownloadFontType(void) +{ + PsFTDownloadFontType downloadfonttype; + XpContextPtr pCon; + char *psfonttype; + + pCon = XpGetPrintContext(requestingClient); + psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type"); + + if( !psfonttype || !strlen(psfonttype) ) + { + return PsFontType1; /* Default download font type is PS Type1 */ + } + + if( !strcmp(psfonttype, "bitmap") ) + { + downloadfonttype = PsFontBitmap; + } + else if( !strcmp(psfonttype, "pstype3") ) + { + downloadfonttype = PsFontType3; + } + else if( !strcmp(psfonttype, "pstype1") ) + { + downloadfonttype = PsFontType1; + } + else + { + FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype); + return 0; /* NO-OP, FatalError() will call |exit()| */ + } + + return downloadfonttype; +} + +static +PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + char *dlfnam; + PsFontTypeInfoRec *rec; + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontTypeInfoRec)); + + rec->next = NULL; + + if ((rec->filename = getFontFilename(pFont))) + { + rec->font_type = getFontFileType(rec->filename); + } + else + { + rec->filename = NULL; + rec->font_type = PSFTI_FONT_TYPE_OTHER; + } + + rec->adobe_ps_name = PsGetPSFontName(pFont); +#ifdef XP_USE_FREETYPE + rec->ft_download_encoding = PsGetEncodingName(pFont); + rec->ft_download_font_type = PsGetFTDownloadFontType(); +#endif /* XP_USE_FREETYPE */ + rec->download_ps_name = NULL; + +#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } } + + /* Set some flags based on the font type */ + switch( rec->font_type ) + { + case PSFTI_FONT_TYPE_PS_TYPE1_PFA: + case PSFTI_FONT_TYPE_PS_TYPE1_PFB: + rec->downloadableFont = True; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_PMF: + rec->downloadableFont = True; /* This font is in printer's ROM */ + SET_FONT_DOWNLOAD_STATUS(rec, True); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_TRUETYPE: + /* Note: TrueType font download not implemented */ + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + +#ifdef XP_USE_FREETYPE + case PSFTI_FONT_TYPE_FREETYPE: + if( rec->ft_download_font_type == PsFontType1 || + rec->ft_download_font_type == PsFontType3 ) + { + rec->downloadableFont = True; + } + else + { + rec->downloadableFont = False; + } + + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */ + break; +#endif /* XP_USE_FREETYPE */ + + case PSFTI_FONT_TYPE_OTHER: + default: + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + } + +#ifdef XP_USE_FREETYPE + if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) ) + { + char *s; + register int c; + + if( rec->adobe_ps_name ) + { + rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding); + } + else + { + /* Unfortunately not all TTF fonts have a PostScript font name (like + * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType, + * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we + * have to generate a font name + */ + char ftfontname[64]; + static long myfontindex = 0L; + sprintf(ftfontname, "psfont_%lx", myfontindex++); + + rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding); + + fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name); + } + + /* Make sure the font name we use for download is a valid PS font name */ + for( s = rec->download_ps_name ; *s != '\0'; s++ ) + { + c = *s; + + /* Check for allowed chars, invalid ones are replaced with a '_' + * (and check that the first char is not a digit) */ + if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) ) + { + *s = '_'; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if( rec->adobe_ps_name ) + { + rec->download_ps_name = strdup(rec->adobe_ps_name); + } + else + { + rec->download_ps_name = NULL; + } + } + + /* Safeguard - only treat font as downloadable when we have a PS font name!! */ + if (!rec->download_ps_name && rec->downloadableFont) + { + /* XXX: Log this message to the log when the logging service has been hook'ed up */ + fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam); + rec->downloadableFont = False; + } + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n", + ((rec->filename) ?(rec->filename) :("<null>")), + ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("<null>")), + ((rec->download_ps_name)?(rec->download_ps_name):("<null>"))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +static +PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontTypeInfoRec *rec; + char *dlfnam; + + if(!(dlfnam = PsGetFontName(pFont))) + return NULL; + + rec = PsFindFontTypeInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontTypeInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontTypeInfoRec(pDrawable, rec); + + return rec; +} + +static +void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv ) +{ + PsFontTypeInfoRec *curr, *next; + curr = priv->fontTypeInfoRecords; + while( curr != NULL ) + { + if (curr->filename) + free(curr->filename); /* Free memory allocated by |strdup()| */ + + if (curr->download_ps_name) + free(curr->download_ps_name); + + next = curr->next; + xfree(curr); + curr = next; + } +} + +static +PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontInfoRec *rec; + + if (!pFont) + return NULL; + + for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next ) + { + if ((rec->font == pFont) && + (rec->font_fontPrivate == pFont->fontPrivate)) + return rec; + } + + return NULL; +} + +static +void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontInfoRecords; + cPriv->fontInfoRecords = add_rec; +} + +static +PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + PsFontTypeInfoRec *ftir; + + if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont))) + return NULL; + + if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontInfoRec)); + + rec->font = pFont; + rec->font_fontPrivate = pFont->fontPrivate; + rec->ftir = ftir; + rec->next = NULL; + rec->dfl_name = PsGetFontName(pFont); + rec->size = PsGetFontSize(pFont, rec->mtx); + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n", + ((rec->dfl_name)?(rec->dfl_name):("<null>"))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + + rec = PsFindFontInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontInfoRec(pDrawable, rec); + + return rec; +} + +void PsFreeFontInfoRecords( PsContextPrivPtr priv ) +{ + PsFontInfoRec *curr, *next; + curr = priv->fontInfoRecords; + while( curr != NULL ) + { + next = curr->next; + xfree(curr); + curr = next; + } + + PsFreeFontTypeInfoRecords(priv); + + priv->fontTypeInfoRecords = NULL; + priv->fontInfoRecords = NULL; +} diff --git a/xorg-server/hw/xprint/ps/PsGC.c b/xorg-server/hw/xprint/ps/PsGC.c new file mode 100644 index 000000000..19898c90e --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsGC.c @@ -0,0 +1,418 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsGC.c +** * +** * Contents: Graphics Context handling for the PS driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "migc.h" +#include "scrnintstr.h" + +static GCOps PsGCOps = +{ + PsFillSpans, + PsSetSpans, + PsPutImage, + PsCopyArea, + PsCopyPlane, + PsPolyPoint, + PsPolyLine, + PsPolySegment, + PsPolyRectangle, + PsPolyArc, + PsFillPolygon, + PsPolyFillRect, + PsPolyFillArc, + PsPolyText8, + PsPolyText16, + PsImageText8, + PsImageText16, + PsImageGlyphBlt, + PsPolyGlyphBlt, + PsPushPixels +}; + + +static GCFuncs PsGCFuncs = +{ + PsValidateGC, + PsChangeGC, + PsCopyGC, + PsDestroyGC, + PsChangeClip, + PsDestroyClip, + PsCopyClip +}; + +Bool +PsCreateGC(pGC) + GCPtr pGC; +{ + pGC->clientClip = NULL; + pGC->clientClipType = CT_NONE; + + pGC->ops = &PsGCOps; + pGC->funcs = &PsGCFuncs; + + pGC->clientClip = (pointer)xalloc(sizeof(PsClipRec)); + memset(pGC->clientClip, 0, sizeof(PsClipRec)); + return TRUE; +} + +static int +PsGetDrawablePrivateStuff( + DrawablePtr pDrawable, + GC *gc, + unsigned long *valid, + PsOutPtr *psOut, + ColormapPtr *cMap) +{ + XpContextPtr pCon; + PsContextPrivPtr cPriv; + PsScreenPrivPtr sPriv; + + switch(pDrawable->type) + { + case DRAWABLE_PIXMAP: + return FALSE; + case DRAWABLE_WINDOW: + pCon = PsGetContextFromWindow((WindowPtr)pDrawable); + if( pCon==NULL ) return FALSE; + else + { + Colormap c; + ColormapPtr cmap; + + c = wColormap((WindowPtr)pDrawable); + cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP); + + cPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + sPriv = (PsScreenPrivPtr) + dixLookupPrivate(&pDrawable->pScreen->devPrivates, + PsScreenPrivateKey); + *gc = cPriv->lastGC; + *valid = cPriv->validGC; + *psOut = cPriv->pPsOut; + *cMap = cmap; + return TRUE; + } + default: + return FALSE; + } +} + +PsContextPrivPtr +PsGetPsContextPriv( DrawablePtr pDrawable ) +{ + XpContextPtr pCon; + + switch(pDrawable->type) + { + case DRAWABLE_PIXMAP: + return FALSE; + case DRAWABLE_WINDOW: + pCon = PsGetContextFromWindow((WindowPtr)pDrawable); + if (pCon != NULL) + { + return (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + } + } + return NULL; +} + +int +PsUpdateDrawableGC( + GCPtr pGC, + DrawablePtr pDrawable, + PsOutPtr *psOut, + ColormapPtr *cMap) +{ + GC dGC; + unsigned long valid; + int i; + PsContextPrivPtr cPriv; + BoxPtr boxes; + + if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap)) + return FALSE; + + switch (pDrawable->type) { + + case DRAWABLE_PIXMAP: + /* we don't support pixmaps yet! */ + return FALSE; + break; + case DRAWABLE_WINDOW: + if( pGC ) + { + RegionPtr pReg; + WindowPtr pWin = (WindowPtr)pDrawable; + Bool freeClip; + PsClipPtr clp = (PsClipPtr)pGC->clientClip; + if( clp->outterClips ) + { xfree(clp->outterClips); clp->outterClips = 0; } + clp->nOutterClips = 0; + if( pGC->subWindowMode==IncludeInferiors ) + { + pReg = NotClippedByChildren(pWin); + freeClip = TRUE; + } + else + { + pReg = &pWin->clipList; + freeClip = FALSE; + } + + if( pReg->data ) + { + boxes = (BoxPtr)((char *)pReg->data+sizeof(long)*2); + clp->nOutterClips = pReg->data->numRects; + clp->outterClips = + (PsRectPtr)xalloc(clp->nOutterClips*sizeof(PsRectRec)); + for( i=0 ; i<clp->nOutterClips ; i++ ) + { + clp->outterClips[i].x = boxes[i].x1; + clp->outterClips[i].y = boxes[i].y1; + clp->outterClips[i].w = (boxes[i].x2-boxes[i].x1)+1; + clp->outterClips[i].h = (boxes[i].y2-boxes[i].y1)+1; + } + } + + if( freeClip ) REGION_DESTROY(pGC->pScreen, pReg); + PsOut_Offset(*psOut, pDrawable->x, pDrawable->y); + PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip); + } + cPriv = (PsContextPrivPtr)dixLookupPrivate( + &PsGetContextFromWindow((WindowPtr)pDrawable)->devPrivates, + PsContextPrivateKey); + break; + } + return TRUE; +} + +void +PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) +{ + pGC->ops = &PsGCOps; +} + +void +PsChangeGC(GCPtr pGC, unsigned long changes) +{ +} + +void +PsCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) +{ +} + +void +PsDestroyGC(GCPtr pGC) +{ + PsDestroyClip(pGC); + xfree(pGC->clientClip); +} + +void +PsChangeClip(GCPtr pGC, int type, pointer pValue, int nrects) +{ + int i; + PsClipPtr clp = (PsClipPtr)pGC->clientClip; + RegionPtr rgn; + BoxPtr boxes; + xRectangle *rects; + + PsDestroyClip(pGC); + pGC->clientClipType = type; + switch(type) + { + case CT_NONE: break; + case CT_PIXMAP: + clp->elms = PsCreateFillElementList((PixmapPtr)pValue, &clp->nElms); + (*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue); + break; + case CT_REGION: + rgn = (RegionPtr)pValue; + boxes = (BoxPtr)((char *)rgn->data+sizeof(long)*2); + clp->nRects = rgn->data->numRects; + clp->rects = (PsRectPtr)xalloc(clp->nRects*sizeof(PsRectRec)); + for( i=0 ; i<clp->nRects ; i++ ) + { + clp->rects[i].x = boxes[i].x1; + clp->rects[i].y = boxes[i].y1; + clp->rects[i].w = (boxes[i].x2-boxes[i].x1)+1; + clp->rects[i].h = (boxes[i].y2-boxes[i].y1)+1; + } + REGION_DESTROY(pGC->pScreen, (RegionPtr)pValue); + break; + case CT_UNSORTED: + case CT_YSORTED: + case CT_YXSORTED: + case CT_YXBANDED: + rects = (xRectangle *)pValue; + clp->nRects = nrects; + clp->rects = (PsRectPtr)xalloc(clp->nRects*sizeof(PsRectRec)); + for( i=0 ; i<clp->nRects ; i++ ) + { + clp->rects[i].x = rects[i].x; + clp->rects[i].y = rects[i].y; + clp->rects[i].w = rects[i].width; + clp->rects[i].h = rects[i].height; + } + xfree(pValue); + break; + } +} + +void +PsDestroyClip(GCPtr pGC) +{ + PsClipPtr clp = (PsClipPtr)pGC->clientClip; + + if( clp->rects ) xfree(clp->rects); + if( clp->outterClips ) xfree(clp->outterClips); + clp->rects = (PsRectPtr)0; + clp->outterClips = (PsRectPtr)0; + clp->nRects = 0; + clp->nOutterClips = 0; + if( clp->elms ) PsDestroyFillElementList(clp->nElms, clp->elms); + clp->elms = (PsElmPtr)0; + clp->nElms = 0; + pGC->clientClipType = CT_NONE; +} + +void +PsCopyClip(GCPtr pDst, GCPtr pSrc) +{ + PsClipPtr src = (PsClipPtr)pSrc->clientClip; + PsClipPtr dst = (PsClipPtr)pDst->clientClip; + + PsDestroyClip(pDst); + pDst->clientClipType = pSrc->clientClipType; + *dst = *src; + if( src->rects ) + { + dst->rects = (PsRectPtr)xalloc(src->nRects*sizeof(PsRectRec)); + memcpy(dst->rects, src->rects, src->nRects*sizeof(PsRectRec)); + } + if( src->elms ) + dst->elms = PsCloneFillElementList(src->nElms, src->elms); +} + + +GCPtr +PsCreateAndCopyGC(DrawablePtr pDrawable, GCPtr pSrc) +{ + GCPtr pDst; + + if (pSrc == NULL) { + /* https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 ("'x11perf + * -copypixpix500' crashes Xprt's PostScript DDX [PsCreateAndCopyGC"): + * I have no clue whether this is the real fix or just wallpapering + * over the crash (that's why we warn here loudly when this + * happens) ... */ + fprintf(stderr, "PsCreateAndCopyGC: pSrc == NULL\n"); + return NULL; + } + + if ((pDst = + CreateScratchGC(pDrawable->pScreen, pDrawable->depth)) == NULL) + { + return NULL; + } + + if (CopyGC(pSrc, pDst, + GCFunction | GCPlaneMask | GCForeground | GCBackground | + GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | + GCFillStyle | GCFillRule | GCTile | GCStipple | + GCTileStipXOrigin | GCTileStipYOrigin | GCFont | + GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | + GCClipYOrigin | GCClipMask | GCDashOffset | GCDashList | + GCArcMode) != Success) + { + (void)FreeGC(pDst, (GContext)0); + + return NULL; + } + + return pDst; +} + diff --git a/xorg-server/hw/xprint/ps/PsImageUtil.c b/xorg-server/hw/xprint/ps/PsImageUtil.c new file mode 100644 index 000000000..668a23f65 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsImageUtil.c @@ -0,0 +1,329 @@ + +/* +Copyright (c) 2005 Roland Mainz <roland.mainz@nrubsig.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the copyright holders shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from said +copyright holders. +*/ + +/* Please do not beat me for this ugly code - most of it has been stolen from + * xc/lib/X11/ImUtil.c */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "servermd.h" +#include "attributes.h" + +static unsigned char const _reverse_byte[0x100] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +static +int XReverse_Bytes( + register unsigned char *bpt, + register int nb) +{ + do { + *bpt = _reverse_byte[*bpt]; + bpt++; + } while (--nb > 0); + return 0; +} + +/* + * Data structure for "image" data, used by image manipulation routines. + */ +typedef struct { + int width, height; /* size of image */ + int xoffset; /* number of pixels offset in X direction */ + int format; /* XYBitmap, XYPixmap, ZPixmap */ + char *data; /* pointer to image data */ + int byte_order; /* data byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* quant. of scanline 8, 16, 32 */ + int bitmap_bit_order; /* LSBFirst, MSBFirst */ + int depth; /* depth of image */ + int bytes_per_line; /* accelarator to next line */ + int bits_per_pixel; /* bits per pixel (ZPixmap) */ +} TmpImage; + + +static void xynormalizeimagebits ( + register unsigned char *bp, + register TmpImage *img) +{ + register unsigned char c; + + if (img->byte_order != img->bitmap_bit_order) { + switch (img->bitmap_unit) { + + case 16: + c = *bp; + *bp = *(bp + 1); + *(bp + 1) = c; + break; + + case 32: + c = *(bp + 3); + *(bp + 3) = *bp; + *bp = c; + c = *(bp + 2); + *(bp + 2) = *(bp + 1); + *(bp + 1) = c; + break; + } + } + if (img->bitmap_bit_order == MSBFirst) + XReverse_Bytes (bp, img->bitmap_unit >> 3); +} + +static void znormalizeimagebits ( + register unsigned char *bp, + register TmpImage *img) +{ + register unsigned char c; + switch (img->bits_per_pixel) { + + case 4: + *bp = ((*bp >> 4) & 0xF) | ((*bp << 4) & ~0xF); + break; + + case 16: + c = *bp; + *bp = *(bp + 1); + *(bp + 1) = c; + break; + + case 24: + c = *(bp + 2); + *(bp + 2) = *bp; + *bp = c; + break; + + case 32: + c = *(bp + 3); + *(bp + 3) = *bp; + *bp = c; + c = *(bp + 2); + *(bp + 2) = *(bp + 1); + *(bp + 1) = c; + break; + } +} + +/* + * Macros + * + * The ROUNDUP macro rounds up a quantity to the specified boundary, + * then truncates to bytes. + * + * The XYNORMALIZE macro determines whether XY format data requires + * normalization and calls a routine to do so if needed. The logic in + * this module is designed for LSBFirst byte and bit order, so + * normalization is done as required to present the data in this order. + * + * The ZNORMALIZE macro performs byte and nibble order normalization if + * required for Z format data. + * + * The XYINDEX macro computes the index to the starting byte (char) boundary + * for a bitmap_unit containing a pixel with coordinates x and y for image + * data in XY format. + * + * The ZINDEX macro computes the index to the starting byte (char) boundary + * for a pixel with coordinates x and y for image data in ZPixmap format. + * + */ + +#if defined(Lynx) && defined(ROUNDUP) +#undef ROUNDUP +#endif + +#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3)) + +#define XYNORMALIZE(bp, img) \ + if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \ + xynormalizeimagebits((unsigned char *)(bp), img) + +#define ZNORMALIZE(bp, img) \ + if (img->byte_order == MSBFirst) \ + znormalizeimagebits((unsigned char *)(bp), img) + +#define XYINDEX(x, y, img) \ + ((y) * img->bytes_per_line) + \ + (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3) + +#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \ + (((x) * img->bits_per_pixel) >> 3) + +/* + * GetPixel + * + * Returns the specified pixel. The X and Y coordinates are relative to + * the origin (upper left [0,0]) of the image. The pixel value is returned + * in normalized format, i.e. the LSB of the long is the LSB of the pixel. + * The algorithm used is: + * + * copy the source bitmap_unit or Zpixel into temp + * normalize temp if needed + * extract the pixel bits into return value + * + */ + +static unsigned long const low_bits_table[] = { + 0x00000000, 0x00000001, 0x00000003, 0x00000007, + 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, + 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, + 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, + 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, + 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, + 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, + 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, + 0xffffffff +}; + +static unsigned long XGetPixel (TmpImage *ximage, int x, int y) +{ + unsigned long pixel, px; + register char *src; + register char *dst; + register int i, j; + int bits, nbytes; + long plane; + + if ((ximage->bits_per_pixel | ximage->depth) == 1) { + src = &ximage->data[XYINDEX(x, y, ximage)]; + dst = (char *)&pixel; + pixel = 0; + for (i = ximage->bitmap_unit >> 3; --i >= 0; ) *dst++ = *src++; + XYNORMALIZE(&pixel, ximage); + bits = (x + ximage->xoffset) % ximage->bitmap_unit; + pixel = ((((char *)&pixel)[bits>>3])>>(bits&7)) & 1; + } else if (ximage->format == XYPixmap) { + pixel = 0; + plane = 0; + nbytes = ximage->bitmap_unit >> 3; + for (i = ximage->depth; --i >= 0; ) { + src = &ximage->data[XYINDEX(x, y, ximage)+ plane]; + dst = (char *)&px; + px = 0; + for (j = nbytes; --j >= 0; ) *dst++ = *src++; + XYNORMALIZE(&px, ximage); + bits = (x + ximage->xoffset) % ximage->bitmap_unit; + pixel = (pixel << 1) | + (((((char *)&px)[bits>>3])>>(bits&7)) & 1); + plane = plane + (ximage->bytes_per_line * ximage->height); + } + } else if (ximage->format == ZPixmap) { + src = &ximage->data[ZINDEX(x, y, ximage)]; + dst = (char *)&px; + px = 0; + for (i = (ximage->bits_per_pixel + 7) >> 3; --i >= 0; ) + *dst++ = *src++; + ZNORMALIZE(&px, ximage); + pixel = 0; + for (i=sizeof(unsigned long); --i >= 0; ) + pixel = (pixel << 8) | ((unsigned char *)&px)[i]; + if (ximage->bits_per_pixel == 4) { + if (x & 1) + pixel >>= 4; + else + pixel &= 0xf; + } + } else { + return 0; /* bad image */ + } + if (ximage->bits_per_pixel == ximage->depth) + return pixel; + else + return (pixel & low_bits_table[ximage->depth]); +} + +unsigned long +PsGetImagePixel(char *pImage, int depth, int w, int h, int leftPad, int format, + int px, int py) +{ + TmpImage xi = {0}; + + xi.width = w; + xi.height = h; + xi.xoffset = 0/*leftPad*/; + xi.format = format; + xi.data = pImage; + xi.byte_order = IMAGE_BYTE_ORDER; + xi.bitmap_bit_order = BITMAP_BIT_ORDER; + xi.bitmap_unit = ((depth > 16)?(32): + ((depth > 8)?(16): + ((depth > 1)? (8): + (1)))); + xi.depth = depth; + xi.bits_per_pixel = xi.bitmap_unit; + + /* + * compute per line accelerator. + */ + if (format == ZPixmap) + xi.bytes_per_line = + ROUNDUP((xi.bits_per_pixel * xi.width), 32); + else + xi.bytes_per_line = + ROUNDUP((xi.width + xi.xoffset), 32); + + return XGetPixel(&xi, px, py); +} + + + diff --git a/xorg-server/hw/xprint/ps/PsInit.c b/xorg-server/hw/xprint/ps/PsInit.c new file mode 100644 index 000000000..72bd7bd7c --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsInit.c @@ -0,0 +1,648 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsInit.c +** * +** * Contents: Initialization code of Ps driver for the print server. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> + +#include "Ps.h" +#include "mi.h" +#include "micmap.h" +#include "AttrValid.h" +#include "fb.h" + +#include "windowstr.h" +#include "DiPrint.h" + +static void AllocatePsPrivates(ScreenPtr pScreen); +static int PsInitContext(XpContextPtr pCon); +static int PsDestroyContext(XpContextPtr pCon); + +DevPrivateKey PsScreenPrivateKey = &PsScreenPrivateKey; +DevPrivateKey PsContextPrivateKey = &PsContextPrivateKey; +DevPrivateKey PsPixmapPrivateKey = &PsPixmapPrivateKey; +DevPrivateKey PsWindowPrivateKey = &PsWindowPrivateKey; + +#ifdef GLXEXT +extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); +#endif /* GLXEXT */ + +Bool +InitializePsDriver(ndx, pScreen, argc, argv) + int ndx; + ScreenPtr pScreen; + int argc; + char **argv; +{ +#if 0 + int maxXres, maxYres, maxWidth, maxHeight; + int maxRes, maxDim, numBytes; + PsScreenPrivPtr pPriv; +#endif + int nv, /* total number of visuals */ + nv_1bit, /* number of 8bit visuals */ + nv_8bit, /* number of 8bit visuals */ + nv_12bit, /* number of 12bit visuals */ + nv_14bit, /* number of 14bit visuals */ + nv_16bit, /* number of 16bit visuals */ + nv_24bit, /* number of 24bit visuals*/ + nv_30bit; /* number of 30bit visuals*/ + int nd; /* number of depths */ + int defaultVisualIndex = -1; + VisualID *vids_1bit, + *vids_8bit, + *vids_12bit, + *vids_14bit, + *vids_16bit, + *vids_24bit, + *vids_30bit; + VisualPtr visuals; + DepthPtr depths; + VisualID defaultVisual; + int rootDepth; + +/* + * Register this driver's InitContext function with the print + * extension. + */ + XpRegisterInitFunc(pScreen, "XP-POSTSCRIPT", PsInitContext); + +/* + * Create and fill in the devPrivate for the PS driver. + */ + AllocatePsPrivates(pScreen); + +#if 0 + pPriv = (PsScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey); + pPriv->resDB = rmdb; +#endif + + pScreen->defColormap = (Colormap) FakeClientID(0); + pScreen->blackPixel = 1; + pScreen->whitePixel = 0; + pScreen->QueryBestSize = (QueryBestSizeProcPtr)PsQueryBestSize; + pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop; + pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop; + pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop; + pScreen->CreateWindow = PsCreateWindow; + pScreen->DestroyWindow = PsDestroyWindow; + pScreen->PositionWindow = PsPositionWindow; + pScreen->ChangeWindowAttributes = PsChangeWindowAttributes; + pScreen->RealizeWindow = PsMapWindow; + pScreen->UnrealizeWindow = PsUnmapWindow; + pScreen->CloseScreen = PsCloseScreen; + pScreen->CopyWindow = PsCopyWindow; + /* XXX Hard routine to write! */ + +/* + * These two are going to be VERY different... + */ + pScreen->CreatePixmap = PsCreatePixmap; + pScreen->DestroyPixmap = PsDestroyPixmap; + pScreen->RealizeFont = PsRealizeFont; + pScreen->UnrealizeFont = PsUnrealizeFont; + pScreen->CreateGC = PsCreateGC; + pScreen->CreateColormap = PsCreateColormap; + pScreen->DestroyColormap = PsDestroyColormap; + pScreen->InstallColormap = PsInstallColormap; + pScreen->UninstallColormap = PsUninstallColormap; + pScreen->ListInstalledColormaps = PsListInstalledColormaps; + pScreen->StoreColors = PsStoreColors; + pScreen->ResolveColor = PsResolveColor; + /* Will BitmapToRegion make any difference at all? */ + pScreen->BitmapToRegion = fbPixmapToRegion; + + visuals = (VisualPtr) xalloc(16*sizeof(VisualRec)); + depths = (DepthPtr) xalloc(16*sizeof(DepthRec)); + vids_1bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_8bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_12bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_14bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_16bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_24bit = (VisualID *)xalloc(16*sizeof(VisualID)); + vids_30bit = (VisualID *)xalloc(16*sizeof(VisualID)); + + nv = nv_1bit = nv_8bit = nv_12bit = nv_14bit = nv_16bit = nv_24bit = nv_30bit = nd = 0; + +#ifdef PSOUT_USE_DEEPCOLOR +/* gisburn: 30bit TrueColor has been disabled for now since it causes problems + * with GLX - see https://bugs.freedesktop.org/show_bug.cgi?id=2868 ("Mesa + * seems to be unable to handle 30bit TrueColor visuals") for details... + */ +#ifdef DISABLED_FOR_NOW + /* TrueColor, 30bit, 10bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = TrueColor; + visuals[nv].bitsPerRGBValue = 10; + visuals[nv].ColormapEntries = 1024; + visuals[nv].nplanes = 30; + visuals[nv].redMask = 0X3FF00000; + visuals[nv].greenMask = 0X000FFC00; + visuals[nv].blueMask = 0X000003FF; + visuals[nv].offsetRed = 20; + visuals[nv].offsetGreen = 10; + visuals[nv].offsetBlue = 0; + vids_30bit[nv_30bit] = visuals[nv].vid; + nv++; nv_30bit++; +#endif /* DISABLED_FOR_NOW */ +#endif /* PSOUT_USE_DEEPCOLOR */ + + /* TrueColor, 24bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = TrueColor; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 24; + visuals[nv].redMask = 0X00FF0000; + visuals[nv].greenMask = 0X0000FF00; + visuals[nv].blueMask = 0X000000FF; + visuals[nv].offsetRed = 16; + visuals[nv].offsetGreen = 8; + visuals[nv].offsetBlue = 0; + vids_24bit[nv_24bit] = visuals[nv].vid; + nv++; nv_24bit++; + + /* TrueColor, 16bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = TrueColor; + visuals[nv].bitsPerRGBValue = 6; + visuals[nv].ColormapEntries = 64; + visuals[nv].nplanes = 16; + visuals[nv].redMask = 0x0000f800; + visuals[nv].greenMask = 0x000007e0; + visuals[nv].blueMask = 0x0000001f; + visuals[nv].offsetRed = 11; + visuals[nv].offsetGreen = 5; + visuals[nv].offsetBlue = 0; + vids_16bit[nv_16bit] = visuals[nv].vid; + nv++; nv_16bit++; + +#ifdef PSOUT_USE_DEEPCOLOR + /* PostScript Level 2 and above, colors can have 12 bits per component + * (36 bit for RGB) */ + + /* PseudoColor, 14bit (15bit won't work as |ColormapEntries==32768| + * is too large for a |signed short|... xx@@!!!... ;-( ) */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = PseudoColor; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 16384; + visuals[nv].nplanes = 14; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_14bit[nv_14bit] = visuals[nv].vid; + nv++; nv_14bit++; + + /* PseudoColor, 12bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = PseudoColor; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 4096; + visuals[nv].nplanes = 12; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_12bit[nv_12bit] = visuals[nv].vid; + defaultVisualIndex = nv; + nv++; nv_12bit++; + + /* GrayScale, 12bit, 12bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = GrayScale; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 4096; + visuals[nv].nplanes = 12; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_12bit[nv_12bit] = visuals[nv].vid; + nv++; nv_12bit++; + + /* StaticGray, 12bit, 12bit per R-,G-,B-gun */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 12; + visuals[nv].ColormapEntries = 4096; + visuals[nv].nplanes = 12; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_12bit[nv_12bit] = visuals[nv].vid; + nv++; nv_12bit++; +#endif /* PSOUT_USE_DEEPCOLOR */ + + /* PseudoColor, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = PseudoColor; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; +#ifndef PSOUT_USE_DEEPCOLOR + defaultVisualIndex = nv; +#endif /* !PSOUT_USE_DEEPCOLOR */ + nv++; nv_8bit++; + + /* GrayScale, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = GrayScale; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; + nv++; nv_8bit++; + + /* StaticGray, 8bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 8; + visuals[nv].ColormapEntries = 256; + visuals[nv].nplanes = 8; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_8bit[nv_8bit] = visuals[nv].vid; + nv++; nv_8bit++; + + /* StaticGray, 1bit */ + visuals[nv].vid = FakeClientID(0); + visuals[nv].class = StaticGray; + visuals[nv].bitsPerRGBValue = 1; + visuals[nv].ColormapEntries = 2; + visuals[nv].nplanes = 1; + visuals[nv].redMask = 0x0; + visuals[nv].greenMask = 0x0; + visuals[nv].blueMask = 0x0; + visuals[nv].offsetRed = 0x0; + visuals[nv].offsetGreen = 0x0; + visuals[nv].offsetBlue = 0x0; + vids_1bit[nv_1bit] = visuals[nv].vid; + nv++; nv_1bit++; + + if( nv_30bit > 0 ) + { + depths[nd].depth = 30; + depths[nd].numVids = nv_30bit; + depths[nd].vids = vids_30bit; + nd++; + } + + if( nv_24bit > 0 ) + { + depths[nd].depth = 24; + depths[nd].numVids = nv_24bit; + depths[nd].vids = vids_24bit; + nd++; + } + + if( nv_16bit > 0 ) + { + depths[nd].depth = 16; + depths[nd].numVids = nv_16bit; + depths[nd].vids = vids_16bit; + nd++; + } + + if( nv_14bit > 0 ) + { + depths[nd].depth = 14; + depths[nd].numVids = nv_14bit; + depths[nd].vids = vids_14bit; + nd++; + } + + if( nv_12bit > 0 ) + { + depths[nd].depth = 12; + depths[nd].numVids = nv_12bit; + depths[nd].vids = vids_12bit; + nd++; + } + + if( nv_8bit > 0 ) + { + depths[nd].depth = 8; + depths[nd].numVids = nv_8bit; + depths[nd].vids = vids_8bit; + nd++; + } + + if( nv_1bit > 0 ) + { + depths[nd].depth = 1; + depths[nd].numVids = nv_1bit; + depths[nd].vids = vids_1bit; + nd++; + } + + /* Defaul visual is 12bit PseudoColor */ + defaultVisual = visuals[defaultVisualIndex].vid; + rootDepth = visuals[defaultVisualIndex].nplanes; + +#ifdef GLXEXT + { + miInitVisualsProcPtr proc = NULL; + + GlxWrapInitVisuals(&proc); + /* GlxInitVisuals ignores the last three arguments. */ + proc(&visuals, &depths, &nv, &nd, + &rootDepth, &defaultVisual, 0, 0, 0); + } +#endif /* GLXEXT */ + + miScreenInit(pScreen, (pointer)0, + pScreen->width, pScreen->height, + (int) (pScreen->width / (pScreen->mmWidth / 25.40)), + (int) (pScreen->height / (pScreen->mmHeight / 25.40)), + 0, rootDepth, nd, + depths, defaultVisual, nv, visuals); + + if( miCreateDefColormap(pScreen)==FALSE ) return FALSE; + +/*scalingScreenInit(pScreen);*/ + + return TRUE; +} + +static void +AllocatePsPrivates(ScreenPtr pScreen) +{ + dixRequestPrivate(PsWindowPrivateKey, sizeof(PsWindowPrivRec)); + dixRequestPrivate(PsContextPrivateKey, sizeof(PsContextPrivRec)); + dixRequestPrivate(PsPixmapPrivateKey, sizeof(PsPixmapPrivRec)); + + dixSetPrivate(&pScreen->devPrivates, PsScreenPrivateKey, + xalloc(sizeof(PsScreenPrivRec))); +} + +/* + * PsInitContext + * + * Establish the appropriate values for a PrintContext used with the PS + * driver. + */ + +static char DOC_ATT_SUPP[]="document-attributes-supported"; +static char DOC_ATT_VAL[]="document-format xp-listfonts-modes"; +static char JOB_ATT_SUPP[]="job-attributes-supported"; +static char JOB_ATT_VAL[]=""; +static char PAGE_ATT_SUPP[]="xp-page-attributes-supported"; +static char PAGE_ATT_VAL[]="content-orientation default-printer-resolution \ +default-input-tray default-medium plex xp-listfonts-modes"; + +static int +PsInitContext(pCon) + XpContextPtr pCon; +{ + XpDriverFuncsPtr pFuncs; + PsContextPrivPtr pConPriv; + char *server, *attrStr; + + /* + * Initialize the attribute store for this printer. + */ + XpInitAttributes(pCon); + + /* + * Initialize the function pointers + */ + pFuncs = &(pCon->funcs); + pFuncs->StartJob = PsStartJob; + pFuncs->EndJob = PsEndJob; + pFuncs->StartDoc = PsStartDoc; + pFuncs->EndDoc = PsEndDoc; + pFuncs->StartPage = PsStartPage; + pFuncs->EndPage = PsEndPage; + pFuncs->PutDocumentData = PsDocumentData; + pFuncs->GetDocumentData = PsGetDocumentData; + pFuncs->GetAttributes = PsGetAttributes; + pFuncs->SetAttributes = PsSetAttributes; + pFuncs->AugmentAttributes = PsAugmentAttributes; + pFuncs->GetOneAttribute = PsGetOneAttribute; + pFuncs->DestroyContext = PsDestroyContext; + pFuncs->GetMediumDimensions = PsGetMediumDimensions; + pFuncs->GetReproducibleArea = PsGetReproducibleArea; + pFuncs->SetImageResolution = PsSetImageResolution; + + /* + * Set up the context privates + */ + pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + pConPriv->jobFileName = (char *)NULL; + pConPriv->pJobFile = (FILE *)NULL; + pConPriv->dash = (unsigned char *)NULL; + pConPriv->validGC = 0; + pConPriv->getDocClient = (ClientPtr)NULL; + pConPriv->getDocBufSize = 0; + pConPriv->pPsOut = NULL; + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; + + /* + * document-attributes-supported + */ + server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP ); + if ((attrStr = (char *) xalloc(strlen(server) + + strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL) + + strlen(PAGE_ATT_VAL) + 8)) == NULL) + { + return BadAlloc; + } + sprintf(attrStr, "*%s:\t%s %s %s", + DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL); + XpAugmentAttributes( pCon, XPPrinterAttr, attrStr); + xfree(attrStr); + + /* + * job-attributes-supported + */ + server = XpGetOneAttribute( pCon, XPServerAttr, JOB_ATT_SUPP ); + if ((attrStr = (char *) xalloc(strlen(server) + strlen(JOB_ATT_SUPP) + + strlen(JOB_ATT_VAL) + 8)) == NULL) + { + return BadAlloc; + } + sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL); + XpAugmentAttributes(pCon, XPPrinterAttr, attrStr); + xfree(attrStr); + + /* + * xp-page-attributes-supported + */ + server = XpGetOneAttribute( pCon, XPServerAttr, PAGE_ATT_SUPP ); + if ((attrStr = (char *) xalloc(strlen(server) + strlen(PAGE_ATT_SUPP) + + strlen(PAGE_ATT_VAL) + 8)) == NULL) + { + return BadAlloc; + } + sprintf(attrStr, "*%s:\t%s %s", PAGE_ATT_SUPP, server, PAGE_ATT_VAL); + XpAugmentAttributes(pCon, XPPrinterAttr, attrStr); + xfree(attrStr); + + /* + * Validate the attribute pools + */ + XpValidateAttributePool(pCon, XPPrinterAttr, &PsValidatePoolsRec); + XpValidateAttributePool(pCon, XPDocAttr, &PsValidatePoolsRec); + XpValidateAttributePool(pCon, XPJobAttr, &PsValidatePoolsRec); + XpValidateAttributePool(pCon, XPPageAttr, &PsValidatePoolsRec); + + return Success; +} + +static Bool +PsDestroyContext(pCon) + XpContextPtr pCon; +{ + PsContextPrivPtr pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + if( pConPriv->pJobFile!=(FILE *)NULL ) + { + fclose(pConPriv->pJobFile); + pConPriv->pJobFile = NULL; + } + if( pConPriv->jobFileName!=(char *)NULL ) + { + unlink(pConPriv->jobFileName); + xfree(pConPriv->jobFileName); + pConPriv->jobFileName = (char *)NULL; + } + + PsFreeFontInfoRecords(pConPriv); + + /* Reset context to make sure we do not use any stale/invalid/obsolete data */ + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + +/*### free up visuals/depths ###*/ + + return Success; +} + +XpContextPtr +PsGetContextFromWindow(win) + WindowPtr win; +{ + PsWindowPrivPtr pPriv; + + while( win ) + { + pPriv = (PsWindowPrivPtr) + dixLookupPrivate(&win->devPrivates, PsWindowPrivateKey); + if( pPriv->validContext ) return pPriv->context; + win = win->parent; + } + + return NULL; +} diff --git a/xorg-server/hw/xprint/ps/PsLine.c b/xorg-server/hw/xprint/ps/PsLine.c new file mode 100644 index 000000000..aca186642 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsLine.c @@ -0,0 +1,191 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsLine.c +** * +** * Contents: Line drawing routines for the PS driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" + +void +PsPolyLine( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int nPoints, + xPoint *pPoints) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyLineCmd; + elm->gc = gc; + elm->c.polyPts.mode = mode; + elm->c.polyPts.nPoints = nPoints; + elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint)); + memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + PsPointPtr pts; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + PsLineAttrs(psOut, pGC, cMap); + pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints); + if( mode==CoordModeOrigin ) + { + for( i=0 ; i<nPoints ; i++ ) + { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; } + } + else + { + pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y; + for( i=1 ; i<nPoints ; i++ ) + { + pts[i].x = pts[i-1].x+pPoints[i].x; + pts[i].y = pts[i-1].y+pPoints[i].y; + } + } + PsOut_Lines(psOut, nPoints, pts); + xfree(pts); + } +} + +void +PsPolySegment( + DrawablePtr pDrawable, + GCPtr pGC, + int nSegments, + xSegment *pSegments) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolySegmentCmd; + elm->gc = gc; + elm->c.segments.nSegments = nSegments; + elm->c.segments.pSegments = (xSegment *)xalloc(nSegments*sizeof(xSegment)); + memcpy(elm->c.segments.pSegments, pSegments, nSegments*sizeof(xSegment)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + PsPointRec pts[2]; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + PsLineAttrs(psOut, pGC, cMap); + for( i=0 ; i<nSegments ; i++ ) + { + pts[0].x = pSegments[i].x1; + pts[0].y = pSegments[i].y1; + pts[1].x = pSegments[i].x2; + pts[1].y = pSegments[i].y2; + PsOut_Lines(psOut, 2, pts); + } + } +} diff --git a/xorg-server/hw/xprint/ps/PsMisc.c b/xorg-server/hw/xprint/ps/PsMisc.c new file mode 100644 index 000000000..8d5005f91 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsMisc.c @@ -0,0 +1,320 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsMisc.c +** * +** * Contents: Miscellaneous code for Ps driver. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */ +#include <stdio.h> +#include "Ps.h" + +#include "cursor.h" +#include "resource.h" + +#include "windowstr.h" +#include "propertyst.h" + + +/*ARGSUSED*/ +void +PsQueryBestSize( + int type, + short *pwidth, + short *pheight, + ScreenPtr pScreen) +{ + unsigned width, highBit; + + switch(type) + { + case CursorShape: + *pwidth = 0; + *pheight = 0; + break; + case TileShape: + case StippleShape: + width = *pwidth; + if (!width) break; + /* Return the nearest power of two >= what they gave us */ + highBit = 0x80000000; + /* Find the highest 1 bit in the given width */ + while(!(highBit & width)) + highBit >>= 1; + /* If greater than that then return the next power of two */ + if((highBit - 1) & width) + highBit <<= 1; + *pwidth = highBit; + /* height is a don't-care */ + break; + } +} + +/* + * PsGetMediumDimensions is installed in the GetMediumDimensions field + * of each Ps-initialized context. + */ +int +PsGetMediumDimensions(XpContextPtr pCon, CARD16 *width, CARD16 *height) +{ + XpGetMediumDimensions(pCon, width, height); + return Success; +} + +/* + * PsGetReproducibleArea is installed in the GetReproducibleArea field + * of each Ps-initialized context. + */ +int +PsGetReproducibleArea(XpContextPtr pCon, xRectangle *pRect) +{ + XpGetReproductionArea(pCon, pRect); + return Success; +} + +/* + * PsSetImageResolution is installed in the SetImageResolution field + * of each Ps-initialized context. + */ +int +PsSetImageResolution(XpContextPtr pCon, int imageRes, Bool *status) +{ + pCon->imageRes = imageRes; + *status = True; + return Success; +} + +/* + * GetPropString searches the window heirarchy from pWin up looking for + * a property by the name of propName. If found, returns the property's + * value. If not, it returns NULL. + */ +/* +char * +GetPropString( + WindowPtr pWin, + char *propName) +{ + Atom atom; + PropertyPtr pProp = (PropertyPtr)NULL; + char *retVal; + + atom = MakeAtom(propName, strlen(propName), FALSE); + if(atom != BAD_RESOURCE) + { + WindowPtr pPropWin; + int rc, n; +*/ + + /* + * The atom has been defined, but it might only exist as a + * property on an unrelated window. + */ +/* + for(pPropWin = pWin; pPropWin != (WindowPtr)NULL; + pPropWin = pPropWin->parent) + { + rc = dixLookupProperty(&pProp, pPropWin, atom, + serverClient, DixReadAccess); + if (rc == Success) + break; + else + pProp = NULL; + } + if(pProp == (PropertyPtr)NULL) + return (char *)NULL; + + n = (pProp->format/8) * pProp->size; *//* size (bytes) of prop */ +/* + retVal = (char *)xalloc(n + 1); + (void)memcpy((void *)retVal, (void *)pProp->data, n); + retVal[n] = '\0'; + + return retVal; + } + + return (char *)NULL; +} + +#include <signal.h> + +*/ +/* ARGSUSED */ +/* +static void SigchldHndlr (int dummy) +{ + int status, w; + struct sigaction act; + sigfillset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = SigchldHndlr; + + w = wait (&status); + +*/ + /* + * Is this really necessary? + */ +/* + sigaction(SIGCHLD, &act, (struct sigaction *)NULL); +} +*/ + +/* + * SystemCmd provides a wrapper for the 'system' library call. The call + * appears to be sensitive to the handling of SIGCHLD, so this wrapper + * sets the status to SIG_DFL, and then resets the established handler + * after system returns. + */ +/* +int +SystemCmd(char *cmdStr) +{ + int status; + struct sigaction newAct, oldAct; + sigfillset(&newAct.sa_mask); + newAct.sa_flags = 0; + newAct.sa_handler = SIG_DFL; + sigfillset(&oldAct.sa_mask); + oldAct.sa_flags = 0; + oldAct.sa_handler = SigchldHndlr; + +*/ + /* + * get the old handler, and set the action to IGN + */ +/* + sigaction(SIGCHLD, &newAct, &oldAct); + + status = system (cmdStr); + + sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL); + return status; +} +*/ + +Bool +PsCloseScreen( + int index, + ScreenPtr pScreen) +{ + return TRUE; +} + +void +PsLineAttrs( + PsOutPtr psOut, + GCPtr pGC, + ColormapPtr cMap) +{ + int i; + int nDsh; + int dshOff; + int *dsh; + PsCapEnum cap; + PsJoinEnum join; + + switch(pGC->capStyle) { + case CapButt: cap = PsCButt; break; + case CapRound: cap = PsCRound; break; + case CapProjecting: cap = PsCSquare; break; + default: cap = PsCButt; break; } + switch(pGC->joinStyle) { + case JoinMiter: join = PsJMiter; break; + case JoinRound: join = PsJRound; break; + case JoinBevel: join = PsJBevel; break; + default: join = PsJBevel; break; } + if( pGC->lineStyle==LineSolid ) { nDsh = dshOff = 0; dsh = (int *)0; } + else + { + nDsh = pGC->numInDashList; + dshOff = pGC->dashOffset; + if( !nDsh ) dsh = (int *)0; + else + { + dsh = (int *)xalloc(sizeof(int)*nDsh); + for( i=0 ; i<nDsh ; i++ ) dsh[i] = (int)pGC->dash[i]&0xFF; + } + } + + if( pGC->lineStyle!=LineDoubleDash ) + PsOut_LineAttrs(psOut, (int)pGC->lineWidth, + cap, join, nDsh, dsh, dshOff, -1); + else + PsOut_LineAttrs(psOut, (int)pGC->lineWidth, + cap, join, nDsh, dsh, dshOff, + PsGetPixelColor(cMap, pGC->bgPixel)); + if( nDsh && dsh ) xfree(dsh); +} diff --git a/xorg-server/hw/xprint/ps/PsPixel.c b/xorg-server/hw/xprint/ps/PsPixel.c new file mode 100644 index 000000000..d51cb6ecf --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsPixel.c @@ -0,0 +1,156 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsPixel.c +** * +** * Contents: Pixel-drawing code for the PS DDX driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1995 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> + +#include "windowstr.h" +#include "gcstruct.h" + +#include "Ps.h" + +void +PsPolyPoint( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int nPoints, + xPoint *pPoints) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyPointCmd; + elm->gc = gc; + elm->c.polyPts.mode = mode; + elm->c.polyPts.nPoints = nPoints; + elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint)); + memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + PsPointPtr pts; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints); + if( mode==CoordModeOrigin ) + { + for( i=0 ; i<nPoints ; i++ ) + { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; } + } + else + { + pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y; + for( i=1 ; i<nPoints ; i++ ) + { + pts[i].x = pts[i-1].x+pPoints[i].x; + pts[i].y = pts[i-1].y+pPoints[i].y; + } + } + PsOut_Points(psOut, nPoints, pts); + xfree(pts); + } +} + +void +PsPushPixels( + GCPtr pGC, + PixmapPtr pBitmap, + DrawablePtr pDrawable, + int width, + int height, + int x, + int y) +{ +} diff --git a/xorg-server/hw/xprint/ps/PsPixmap.c b/xorg-server/hw/xprint/ps/PsPixmap.c new file mode 100644 index 000000000..a588f4276 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsPixmap.c @@ -0,0 +1,623 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsPixmap.c +** * +** * Contents: Pixmap functions for the PS DDX driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1995 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "windowstr.h" +#include "gcstruct.h" +#include "privates.h" + +#include "Ps.h" + +#define _BitsPerPixel(d) (\ + (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ + (PixmapWidthPaddingInfo[d].padRoundUp+1)) + +PixmapPtr +PsCreatePixmap( + ScreenPtr pScreen, + int width, + int height, + int depth, + unsigned usage_hint) +{ + PixmapPtr pPixmap; + + pPixmap = (PixmapPtr)xcalloc(1, sizeof(PixmapRec)); + if( !pPixmap) return NullPixmap; + pPixmap->drawable.type = DRAWABLE_PIXMAP; + pPixmap->drawable.class = 0; + pPixmap->drawable.pScreen = pScreen; + pPixmap->drawable.depth = depth; + pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth); + pPixmap->drawable.id = 0; + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pPixmap->drawable.x = 0; + pPixmap->drawable.y = 0; + pPixmap->drawable.width = width; + pPixmap->drawable.height = height; + pPixmap->devKind = 0; + pPixmap->refcnt = 1; + pPixmap->devPrivates = NULL; + + pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec)); + if( !pPixmap->devPrivate.ptr ) + { xfree(pPixmap); return NullPixmap; } + return pPixmap; +} + +/* PsScrubPixmap: Remove all content from a pixmap (used by + * |PsPolyFillRect()| when the "solid fill" operation covers + * the whole pixmap) */ +void +PsScrubPixmap(PixmapPtr pPixmap) +{ + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pPixmap->devPrivate.ptr; + DisplayListPtr disp = priv->dispList; + + while( disp ) + { + int i; + DisplayListPtr oldDisp = disp; + disp = disp->next; + for( i=0 ; i<oldDisp->nelms ; i++ ) + { + DisplayElmPtr elm = &oldDisp->elms[i]; + + switch(elm->type) + { + case PolyPointCmd: + case PolyLineCmd: + if( elm->c.polyPts.pPoints ) xfree(elm->c.polyPts.pPoints); + break; + case PolySegmentCmd: + if( elm->c.segments.pSegments ) xfree(elm->c.segments.pSegments); + break; + case PolyRectangleCmd: + if( elm->c.rects.pRects ) xfree(elm->c.rects.pRects); + break; + case FillPolygonCmd: + if( elm->c.polyPts.pPoints ) xfree(elm->c.polyPts.pPoints); + break; + case PolyFillRectCmd: + if( elm->c.rects.pRects ) xfree(elm->c.rects.pRects); + break; + case PolyArcCmd: + if( elm->c.arcs.pArcs ) xfree(elm->c.arcs.pArcs); + break; + case PolyFillArcCmd: + if( elm->c.arcs.pArcs ) xfree(elm->c.arcs.pArcs); + break; + case Text8Cmd: + case TextI8Cmd: + if( elm->c.text8.string ) xfree(elm->c.text8.string); + break; + case Text16Cmd: + case TextI16Cmd: + if( elm->c.text16.string ) xfree(elm->c.text16.string); + break; + case PutImageCmd: + if( elm->c.image.pData ) xfree(elm->c.image.pData); + break; + case BeginFrameCmd: + break; + case EndFrameCmd: + break; + } + + if (elm->type != BeginFrameCmd && elm->type != EndFrameCmd) { + (void) FreeGC(elm->gc, (GContext) 0); + } + } + xfree(oldDisp); + } + + priv->dispList = NULL; +} + +Bool +PsDestroyPixmap(PixmapPtr pPixmap) +{ + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pPixmap->devPrivate.ptr; + + if( --pPixmap->refcnt ) return TRUE; + + PsScrubPixmap(pPixmap); + + xfree(priv); + dixFreePrivates(pPixmap->devPrivates); + xfree(pPixmap); + return TRUE; +} + +DisplayListPtr +PsGetFreeDisplayBlock(PsPixmapPrivPtr priv) +{ + DisplayListPtr disp = priv->dispList; + + for(; disp ; disp=disp->next ) + { + if( disp->nelms>=DPY_BLOCKSIZE && disp->next ) continue; + if( disp->nelms<DPY_BLOCKSIZE ) return(disp); + disp->next = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec)); + disp->next->next = (DisplayListPtr)0; + disp->next->nelms = 0; + } + disp = (DisplayListPtr)xcalloc(1, sizeof(DisplayListRec)); + disp->next = (DisplayListPtr)0; + disp->nelms = 0; + priv->dispList = disp; + return(disp); +} + +void +PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable) +{ + switch(elm->type) + { + case PolyPointCmd: + PsPolyPoint(pDrawable, elm->gc, elm->c.polyPts.mode, + elm->c.polyPts.nPoints, elm->c.polyPts.pPoints); + break; + case PolyLineCmd: + PsPolyLine(pDrawable, elm->gc, elm->c.polyPts.mode, + elm->c.polyPts.nPoints, elm->c.polyPts.pPoints); + break; + case PolySegmentCmd: + PsPolySegment(pDrawable, elm->gc, elm->c.segments.nSegments, + elm->c.segments.pSegments); + break; + case PolyRectangleCmd: + PsPolyRectangle(pDrawable, elm->gc, elm->c.rects.nRects, + elm->c.rects.pRects); + break; + case FillPolygonCmd: + PsFillPolygon(pDrawable, elm->gc, 0, elm->c.polyPts.mode, + elm->c.polyPts.nPoints, elm->c.polyPts.pPoints); + break; + case PolyFillRectCmd: + PsPolyFillRect(pDrawable, elm->gc, elm->c.rects.nRects, + elm->c.rects.pRects); + break; + case PolyArcCmd: + PsPolyArc(pDrawable, elm->gc, elm->c.arcs.nArcs, elm->c.arcs.pArcs); + break; + case PolyFillArcCmd: + PsPolyFillArc(pDrawable, elm->gc, elm->c.arcs.nArcs, elm->c.arcs.pArcs); + break; + case Text8Cmd: + PsPolyText8(pDrawable, elm->gc, elm->c.text8.x, elm->c.text8.y, + elm->c.text8.count, elm->c.text8.string); + break; + case Text16Cmd: + PsPolyText16(pDrawable, elm->gc, elm->c.text16.x, elm->c.text16.y, + elm->c.text16.count, elm->c.text16.string); + break; + case TextI8Cmd: + PsImageText8(pDrawable, elm->gc, elm->c.text8.x, elm->c.text8.y, + elm->c.text8.count, elm->c.text8.string); + break; + case TextI16Cmd: + PsImageText16(pDrawable, elm->gc, elm->c.text16.x, elm->c.text16.y, + elm->c.text16.count, elm->c.text16.string); + break; + case PutImageCmd: + PsPutScaledImage(pDrawable, elm->gc, elm->c.image.depth, + elm->c.image.x, elm->c.image.y, + elm->c.image.w, elm->c.image.h, elm->c.image.leftPad, + elm->c.image.format, elm->c.image.res, + elm->c.image.pData); + break; + case BeginFrameCmd: + { + PsOutPtr psOut; + ColormapPtr cMap; + if( PsUpdateDrawableGC(NULL, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_BeginFrame(psOut, 0, 0, elm->c.frame.x, elm->c.frame.y, + elm->c.frame.w, elm->c.frame.h); + } + break; + case EndFrameCmd: + { + PsOutPtr psOut; + ColormapPtr cMap; + if( PsUpdateDrawableGC(NULL, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_EndFrame(psOut); + } + break; + } +} + +void +PsReplayPixmap(PixmapPtr pix, DrawablePtr pDrawable) +{ + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp = priv->dispList; + DisplayElmPtr elm; + + for(; disp ; disp=disp->next ) + { + int i; + for( i=0,elm=disp->elms ; i<disp->nelms ; i++,elm++ ) + PsReplay(elm, pDrawable); + } +} + +int +PsCloneDisplayElm(PixmapPtr dst, DisplayElmPtr elm, DisplayElmPtr newElm, + int xoff, int yoff) +{ + int i; + int size; + int status = 0; + + *newElm = *elm; + + /* I think this is the correct return value */ + if ((newElm->gc = PsCreateAndCopyGC(&dst->drawable, elm->gc)) == NULL) { + return 1; + } + + switch(elm->type) + { + case PolyPointCmd: + case PolyLineCmd: + newElm->c.polyPts.pPoints = + (xPoint *)xalloc(elm->c.polyPts.nPoints*sizeof(xPoint)); + for( i=0 ; i<elm->c.polyPts.nPoints ; i++ ) + { + newElm->c.polyPts.pPoints[i].x = elm->c.polyPts.pPoints[i].x+xoff; + newElm->c.polyPts.pPoints[i].y = elm->c.polyPts.pPoints[i].y+yoff; + } + break; + case PolySegmentCmd: + newElm->c.segments.pSegments = + (xSegment *)xalloc(elm->c.segments.nSegments*sizeof(xSegment)); + for( i=0 ; i<elm->c.segments.nSegments ; i++ ) + { + newElm->c.segments.pSegments[i].x1 = + elm->c.segments.pSegments[i].x1+xoff; + newElm->c.segments.pSegments[i].y1 = + elm->c.segments.pSegments[i].y1+yoff; + newElm->c.segments.pSegments[i].x2 = + elm->c.segments.pSegments[i].x2+xoff; + newElm->c.segments.pSegments[i].y2 = + elm->c.segments.pSegments[i].y2+yoff; + } + break; + case PolyRectangleCmd: + newElm->c.rects.pRects = + (xRectangle *)xalloc(elm->c.rects.nRects*sizeof(xRectangle)); + for( i=0 ; i<elm->c.rects.nRects ; i++ ) + { + newElm->c.rects.pRects[i].x = elm->c.rects.pRects[i].x+xoff; + newElm->c.rects.pRects[i].y = elm->c.rects.pRects[i].y+yoff; + newElm->c.rects.pRects[i].width = elm->c.rects.pRects[i].width; + newElm->c.rects.pRects[i].height = elm->c.rects.pRects[i].height; + } + break; + case FillPolygonCmd: + newElm->c.polyPts.pPoints = + (xPoint *)xalloc(elm->c.polyPts.nPoints*sizeof(xPoint)); + for( i=0 ; i<elm->c.polyPts.nPoints ; i++ ) + { + newElm->c.polyPts.pPoints[i].x = elm->c.polyPts.pPoints[i].x+xoff; + newElm->c.polyPts.pPoints[i].y = elm->c.polyPts.pPoints[i].y+yoff; + } + break; + case PolyFillRectCmd: + newElm->c.rects.pRects = + (xRectangle *)xalloc(elm->c.rects.nRects*sizeof(xRectangle)); + for( i=0 ; i<elm->c.rects.nRects ; i++ ) + { + newElm->c.rects.pRects[i].x = elm->c.rects.pRects[i].x+xoff; + newElm->c.rects.pRects[i].y = elm->c.rects.pRects[i].y+yoff; + newElm->c.rects.pRects[i].width = elm->c.rects.pRects[i].width; + newElm->c.rects.pRects[i].height = elm->c.rects.pRects[i].height; + } + break; + case PolyArcCmd: + newElm->c.arcs.pArcs = + (xArc *)xalloc(elm->c.arcs.nArcs*sizeof(xArc)); + for( i=0 ; i<elm->c.arcs.nArcs ; i++ ) + { + newElm->c.arcs.pArcs[i].x = elm->c.arcs.pArcs[i].x+xoff; + newElm->c.arcs.pArcs[i].y = elm->c.arcs.pArcs[i].y+yoff; + newElm->c.arcs.pArcs[i].width = elm->c.arcs.pArcs[i].width; + newElm->c.arcs.pArcs[i].height = elm->c.arcs.pArcs[i].height; + newElm->c.arcs.pArcs[i].angle1 = elm->c.arcs.pArcs[i].angle1; + newElm->c.arcs.pArcs[i].angle2 = elm->c.arcs.pArcs[i].angle2; + } + break; + case PolyFillArcCmd: + newElm->c.arcs.pArcs = + (xArc *)xalloc(elm->c.arcs.nArcs*sizeof(xArc)); + for( i=0 ; i<elm->c.arcs.nArcs ; i++ ) + { + newElm->c.arcs.pArcs[i].x = elm->c.arcs.pArcs[i].x+xoff; + newElm->c.arcs.pArcs[i].y = elm->c.arcs.pArcs[i].y+yoff; + newElm->c.arcs.pArcs[i].width = elm->c.arcs.pArcs[i].width; + newElm->c.arcs.pArcs[i].height = elm->c.arcs.pArcs[i].height; + newElm->c.arcs.pArcs[i].angle1 = elm->c.arcs.pArcs[i].angle1; + newElm->c.arcs.pArcs[i].angle2 = elm->c.arcs.pArcs[i].angle2; + } + break; + case Text8Cmd: + case TextI8Cmd: + newElm->c.text8.string = (char *)xalloc(elm->c.text8.count); + memcpy(newElm->c.text8.string, elm->c.text8.string, elm->c.text8.count); + newElm->c.text8.x += xoff; + newElm->c.text8.y += yoff; + break; + case Text16Cmd: + case TextI16Cmd: + newElm->c.text16.string = + (unsigned short *)xalloc(elm->c.text16.count*sizeof(unsigned short)); + memcpy(newElm->c.text16.string, elm->c.text16.string, + elm->c.text16.count*sizeof(unsigned short)); + newElm->c.text16.x += xoff; + newElm->c.text16.y += yoff; + break; + case PutImageCmd: + size = PixmapBytePad(elm->c.image.w, elm->c.image.depth)*elm->c.image.h; + newElm->c.image.pData = (char *)xalloc(size); + memcpy(newElm->c.image.pData, elm->c.image.pData, size); + newElm->c.image.x += xoff; + newElm->c.image.y += yoff; + break; + case BeginFrameCmd: + case EndFrameCmd: + status = 1; + break; + } + return(status); +} + +void +PsCopyDisplayList(PixmapPtr src, PixmapPtr dst, int xoff, int yoff, + int x, int y, int w, int h) +{ + PsPixmapPrivPtr sPriv = (PsPixmapPrivPtr)src->devPrivate.ptr; + PsPixmapPrivPtr dPriv = (PsPixmapPrivPtr)dst->devPrivate.ptr; + DisplayListPtr sDisp; + DisplayListPtr dDisp = PsGetFreeDisplayBlock(dPriv); + DisplayElmPtr elm = &dDisp->elms[dDisp->nelms]; + + elm->type = BeginFrameCmd; + elm->c.frame.x = x; + elm->c.frame.y = y; + elm->c.frame.w = w; + elm->c.frame.h = h; + dDisp->nelms += 1; + + sDisp = sPriv->dispList; + for(; sDisp ; sDisp=sDisp->next ) + { + int i; + for( i=0,elm=sDisp->elms ; i<sDisp->nelms ; i++,elm++ ) + { + dDisp = PsGetFreeDisplayBlock(dPriv); + if (PsCloneDisplayElm(dst, elm, &dDisp->elms[dDisp->nelms], + xoff, yoff)==0) + { + dDisp->nelms += 1; + } + } + } + + dDisp = PsGetFreeDisplayBlock(dPriv); + elm = &dDisp->elms[dDisp->nelms]; + elm->type = EndFrameCmd; + dDisp->nelms += 1; +} + +PsElmPtr +PsCreateFillElementList(PixmapPtr pix, int *nElms) +{ + PsElmPtr elms = (PsElmPtr)0; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp = priv->dispList; + PsArcEnum styl; + + *nElms = 0; + for(; disp ; disp=disp->next ) + { + int i; + DisplayElmPtr elm = disp->elms; + + for( i=0 ; i<disp->nelms ; i++,elm++ ) + { + if( !elm->gc ) continue; /* workaround for https://freedesktop.org/bugzilla/show_bug.cgi?id=1416 */ + if( !elm->gc->fgPixel ) continue; + switch(elm->type) + { + case FillPolygonCmd: + *nElms += 1; + break; + case PolyFillRectCmd: + *nElms += elm->c.rects.nRects; + break; + case PolyFillArcCmd: + *nElms += elm->c.arcs.nArcs; + break; + default: /* keep the compiler happy with unhandled enums */ + break; + } + } + } + + if( (*nElms) ) + { + elms = (PsElmPtr)xcalloc(1, (*nElms)*sizeof(PsElmRec)); + if( elms ) + { + disp = priv->dispList; + *nElms = 0; + for(; disp ; disp=disp->next ) + { + int i, k; + DisplayElmPtr elm = disp->elms; + + for( i=0 ; i<disp->nelms ; i++,elm++ ) + { + if( !elm->gc->fgPixel ) continue; + switch(elm->type) + { + case FillPolygonCmd: + elms[*nElms].type = PSOUT_POINTS; + elms[*nElms].nPoints = elm->c.polyPts.nPoints; + elms[*nElms].c.points = + (PsPointPtr)xalloc(elms[*nElms].nPoints*sizeof(PsPointRec)); + for( k=0 ; k<elms[*nElms].nPoints ; k++ ) + { + elms[*nElms].c.points[k].x = elm->c.polyPts.pPoints[k].x; + elms[*nElms].c.points[k].y = elm->c.polyPts.pPoints[k].y; + } + *nElms += 1; + break; + case PolyFillRectCmd: + for( k=0 ; k<elm->c.rects.nRects ; k++ ) + { + elms[*nElms].type = PSOUT_RECT; + elms[*nElms].nPoints = 0; + elms[*nElms].c.rect.x = elm->c.rects.pRects[k].x; + elms[*nElms].c.rect.y = elm->c.rects.pRects[k].y; + elms[*nElms].c.rect.w = elm->c.rects.pRects[k].width; + elms[*nElms].c.rect.h = elm->c.rects.pRects[k].height; + *nElms += 1; + } + break; + case PolyFillArcCmd: + if( elm->gc->arcMode==ArcChord ) styl = PsChord; + else styl = PsPieSlice; + for( k=0 ; k<elm->c.rects.nRects ; k++ ) + { + elms[*nElms].type = PSOUT_ARC; + elms[*nElms].nPoints = 0; + elms[*nElms].c.arc.x = elm->c.arcs.pArcs[k].x; + elms[*nElms].c.arc.y = elm->c.arcs.pArcs[k].y; + elms[*nElms].c.arc.w = elm->c.arcs.pArcs[k].width; + elms[*nElms].c.arc.h = elm->c.arcs.pArcs[k].height; + elms[*nElms].c.arc.a1 = elm->c.arcs.pArcs[k].angle1; + elms[*nElms].c.arc.a2 = elm->c.arcs.pArcs[k].angle2; + elms[*nElms].c.arc.style = styl; + *nElms += 1; + } + break; + default: /* keep the compiler happy with unhandled enums */ + break; + } + } + } + } + } + return(elms); +} + +PsElmPtr +PsCloneFillElementList(int nElms, PsElmPtr elms) +{ + int i; + PsElmPtr newElms; + + newElms = (PsElmPtr)xcalloc(1, nElms*sizeof(PsElmRec)); + if( !newElms ) return(newElms); + for( i=0 ; i<nElms ; i++ ) + { + newElms[i] = elms[i]; + + if( elms[i].type==PSOUT_POINTS ) + { + newElms[i].c.points = + (PsPointPtr)xalloc(elms[i].nPoints*sizeof(PsElmRec)); + memcpy(newElms[i].c.points, elms[i].c.points, + elms[i].nPoints*sizeof(PsPointRec)); + } + } + return(newElms); +} + +void +PsDestroyFillElementList(int nElms, PsElmPtr elms) +{ + int i; + + for( i=0 ; i<nElms ; i++ ) + { if( elms[i].type==PSOUT_POINTS ) xfree(elms[i].c.points); } + + xfree(elms); +} diff --git a/xorg-server/hw/xprint/ps/PsPolygon.c b/xorg-server/hw/xprint/ps/PsPolygon.c new file mode 100644 index 000000000..fe4626085 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsPolygon.c @@ -0,0 +1,259 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsPolygon.c +** * +** * Contents: Draws Polygons and Rectangles for the PS DDX +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" + +void +PsPolyRectangle( + DrawablePtr pDrawable, + GCPtr pGC, + int nRects, + xRectangle *pRects) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyRectangleCmd; + elm->gc = gc; + elm->c.rects.nRects = nRects; + elm->c.rects.pRects = (xRectangle *)xalloc(nRects*sizeof(xRectangle)); + memcpy(elm->c.rects.pRects, pRects, nRects*sizeof(xRectangle)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + PsLineAttrs(psOut, pGC, cMap); + for( i=0 ; i<nRects ; i++ ) + { + PsOut_DrawRect(psOut, (int)pRects[i].x, (int)pRects[i].y, + (int)pRects[i].width, (int)pRects[i].height); + } + } +} + +void +PsFillPolygon( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int nPoints, + DDXPointPtr pPoints) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = FillPolygonCmd; + elm->gc = gc; + elm->c.polyPts.mode = mode; + elm->c.polyPts.nPoints = nPoints; + elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint)); + memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + PsPointPtr pts; + PsRuleEnum rule; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsSetFillColor(pDrawable, pGC, psOut, cMap); + if( pGC->fillRule==EvenOddRule ) rule = PsEvenOdd; + else rule = PsNZWinding; + PsOut_FillRule(psOut, rule); + pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints); + if( mode==CoordModeOrigin ) + { + for( i=0 ; i<nPoints ; i++ ) + { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; } + } + else + { + i = 0; + pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y; + for( i=1 ; i<nPoints ; i++ ) + { + pts[i].x = pts[i-1].x+pPoints[i].x; + pts[i].y = pts[i-1].y+pPoints[i].y; + } + } + PsOut_Polygon(psOut, nPoints, pts); + xfree(pts); + } +} + +void +PsPolyFillRect( + DrawablePtr pDrawable, + GCPtr pGC, + int nRects, + xRectangle *pRects) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + +#ifdef DBE + /* Remove previous pixmap content if we render one single rect which + * covers the whole pixmap surface (this optimisation was added for + * the double-buffer extension ("DBE") which uses |PolyFillRect()| + * to clear the buffer - but it makes sense in other cases, too). + */ + if (nRects == 1) + { + if ( (pRects[0].x==0) && (pRects[0].y==0) && + (pRects[0].width==pDrawable->width) && (pRects[0].height==pDrawable->height) && + (pGC->fillStyle == FillSolid) && + (noDbeExtension == False)) + { +#ifdef DEBUG_gismobile + ErrorF("PsPolyFillRect: scrubbing pixmap...\n"); +#endif /* DEBUG_gismobile */ + /* Remove all content from the pixmap as it would be covered + * by the whole rect anyway */ + PsScrubPixmap((PixmapPtr)pDrawable); + } + } +#endif /* DBE */ + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = PolyFillRectCmd; + elm->gc = gc; + elm->c.rects.nRects = nRects; + elm->c.rects.pRects = (xRectangle *)xalloc(nRects*sizeof(xRectangle)); + memcpy(elm->c.rects.pRects, pRects, nRects*sizeof(xRectangle)); + disp->nelms += 1; + } + else + { + int i; + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsSetFillColor(pDrawable, pGC, psOut, cMap); + for( i=0 ; i<nRects ; i++ ) + { + PsOut_FillRect(psOut, (int)pRects[i].x, (int)pRects[i].y, + (int)pRects[i].width, (int)pRects[i].height); + } + } +} diff --git a/xorg-server/hw/xprint/ps/PsPrint.c b/xorg-server/hw/xprint/ps/PsPrint.c new file mode 100644 index 000000000..386646858 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsPrint.c @@ -0,0 +1,459 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All rights reserved. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsPrint.c +** * +** * Contents: Print extension code of Ps driver +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> +#include <unistd.h> +#include <errno.h> +#include <X11/Xprotostr.h> + +#define NEED_EVENTS +#include <X11/Xproto.h> +#undef NEED_EVENTS + +#include "Ps.h" + +#include "windowstr.h" +#include "attributes.h" +#include "Oid.h" + +/* static utility function to get document/page attributes */ +static void +S_GetPageAttributes(XpContextPtr pCon,int *iorient,int *icount, int *iplex, + int *ires, unsigned short *iwd, unsigned short *iht) +{ + char *count; + XpOid orient, plex; + /* + * Get the orientation + */ + orient = XpGetContentOrientation(pCon); + switch (orient) { + case xpoid_val_content_orientation_landscape: + *iorient = 1; + break; + case xpoid_val_content_orientation_reverse_portrait: + *iorient = 2; + break; + case xpoid_val_content_orientation_reverse_landscape: + *iorient = 3; + break; + case xpoid_val_content_orientation_portrait: + default: + *iorient = 0; + break; + } + + /* + * Get the count + */ + count = XpGetOneAttribute(pCon, XPDocAttr, "copy-count"); + if( count ) + { + int ii = sscanf(count, "%d", icount); + if( ii!=1 ) *icount = 1; + } + else *icount = 1; + + /* + * Get the plex + */ + plex = XpGetPlex(pCon); + switch(plex) + { + case xpoid_val_plex_duplex: + *iplex = 1; + break; + case xpoid_val_plex_tumble: + *iplex = 2; + break; + default: + *iplex = 0; + break; + } + + /* + * Get the resolution and media size + */ + *ires = XpGetResolution(pCon); + XpGetMediumDimensions(pCon, iwd, iht); +} + + +int +PsStartJob( + XpContextPtr pCon, + Bool sendClientData, + ClientPtr client) +{ + PsContextPrivPtr pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + /* + * Create a temporary file to store the printer output. + */ + if (!XpOpenTmpFile("w", &pConPriv->jobFileName, &pConPriv->pJobFile)) + return BadAlloc; + + return Success; +} + + + +/* I thought about making this following code into a set of routines + or using a goto, or something, but in the end decided not to, + because the plain old listing here makes the logic clearer. */ +int +PsEndJob( + XpContextPtr pCon, + Bool cancel) +{ + int r; + struct stat buffer; + int error; + + PsContextPrivPtr priv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + if (cancel == True) { + if (priv->getDocClient != (ClientPtr) NULL) { + (void) XpFinishDocData( priv->getDocClient ); + + priv->getDocClient = NULL; + priv->getDocBufSize = 0; + } + + /* job is cancelled - do we really care if we're out of space? */ + (void) fclose(priv->pJobFile); + priv->pJobFile = NULL; + + unlink(priv->jobFileName); + xfree(priv->jobFileName); + priv->jobFileName = (char *)NULL; + + PsFreeFontInfoRecords(priv); + + return Success; + } + + /* + * Append any trailing information here + */ + PsOut_EndFile(priv->pPsOut, 0); + priv->pPsOut = NULL; + + /* this is where we find out if we're out of space */ + error = (fclose(priv->pJobFile) == EOF); + priv->pJobFile = NULL; + + /* status to the client if we have ran out of space on the disk or + some other resource problem with the temporary file... */ + if (error) { + if (priv->getDocClient != (ClientPtr) NULL) { + (void) XpFinishDocData( priv->getDocClient ); + + priv->getDocClient = NULL; + priv->getDocBufSize = 0; + } + + unlink(priv->jobFileName); + xfree(priv->jobFileName); + priv->jobFileName = (char *)NULL; + + PsFreeFontInfoRecords(priv); + + return BadAlloc; + } + + /* we have finished without incident & no cancel */ + + if (priv->getDocClient != NULL && priv->getDocBufSize > 0) { + FILE *file; + + file = fopen(priv->jobFileName, "r"); + if (!file || (fstat(fileno(file), &buffer) < 0)) + r = BadAlloc; + else + r = XpSendDocumentData(priv->getDocClient, file, buffer.st_size, + priv->getDocBufSize); + if (file) + fclose(file); + + (void) XpFinishDocData(priv->getDocClient); + + priv->getDocClient = NULL; + priv->getDocBufSize = 0; + } + else { + XpSubmitJob(priv->jobFileName, pCon); + + r = Success; + } + + unlink(priv->jobFileName); + xfree(priv->jobFileName); + priv->jobFileName = (char *)NULL; + + PsFreeFontInfoRecords(priv); + +#ifdef BM_CACHE + PsBmClearImageCache(); +#endif + + return r; +} + +/* StartPage + */ +int +PsStartPage( + XpContextPtr pCon, + WindowPtr pWin) +{ + int iorient, iplex, icount, ires; + unsigned short iwd, iht; + PsContextPrivPtr pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr) + dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey); + +/* + * Put a pointer to the context in the window private structure + */ + pWinPriv->validContext = 1; + pWinPriv->context = pCon; + + /* get page level attributes */ + S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht); + /* + * Start the page + */ + if (pConPriv->pPsOut == NULL) { + char *title; + + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + + pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, False); + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; + } + PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires, + (int)iwd, (int)iht); + + return Success; +} + + +/* + * EndPage: + * + * Write page trailer to page file + * Write page file to job file + */ +int +PsEndPage( + XpContextPtr pCon, + WindowPtr pWin) +{ + PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr) + dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey); + PsContextPrivPtr pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + PsOut_EndPage(pConPriv->pPsOut); + + pWinPriv->validContext = 0; + pWinPriv->context = NULL; + + /* status to the client if we have ran out of space on the disk or + some other resource problem with the temporary file... */ +/* if (ferror(pConPriv->pJobFile)) return BadAlloc; */ + + return Success; +} + +/* + * The PsStartDoc() and PsEndDoc() functions serve basically as NOOP + * placeholders. This driver doesn't deal with the notion of multiple + * documents per page. + */ + +int +PsStartDoc(XpContextPtr pCon, XPDocumentType type) +{ + int iorient, iplex, icount, ires; + unsigned short iwd, iht; + char *title; + PsContextPrivPtr pConPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + + /* get document level attributes */ + S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht); + + pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, (Bool)(type == XPDocRaw)); + + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; + + return Success; +} + +int +PsEndDoc( + XpContextPtr pCon, + Bool cancel) +{ + return Success; +} + +/* + * PsDocumentData() + * + * Hand any pre-generated PDL down to the spool files, formatting it + * as necessary to fit the given window. + */ + +int +PsDocumentData( + XpContextPtr pCon, + DrawablePtr pDraw, + char *pData, + int len_data, + char *pFmt, + int len_fmt, + char *pOpt, + int len_opt, + ClientPtr client) +{ + PsContextPrivPtr cPriv; + PsOutPtr psOut; + + if (len_fmt != 12 || + strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 || + len_opt) + return BadValue; + + cPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + psOut = cPriv->pPsOut; + + if (pDraw) + PsOut_BeginFrame(psOut, 0, 0, pDraw->x, pDraw->y, + pDraw->width, pDraw->height); + PsOut_RawData(psOut, pData, len_data); + if (pDraw) + PsOut_EndFrame(psOut); + + return Success; +} + +/* + * + * PsGetDocumentData() + * + * This function allows the driver to send the generated PS back to + * the client. + */ + +int +PsGetDocumentData( + XpContextPtr pCon, + ClientPtr client, + int maxBufferSize) +{ + PsContextPrivPtr pPriv = (PsContextPrivPtr) + dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey); + + pPriv->getDocClient = client; + pPriv->getDocBufSize = maxBufferSize; + + return Success; +} + diff --git a/xorg-server/hw/xprint/ps/PsSpans.c b/xorg-server/hw/xprint/ps/PsSpans.c new file mode 100644 index 000000000..c0e66ee7a --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsSpans.c @@ -0,0 +1,164 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsSpans.c +** * +** * Contents: Code to set and fill spans in the PS DDX +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" + +void +PsFillSpans( + DrawablePtr pDrawable, + GCPtr pGC, + int nSpans, + DDXPointPtr pPoints, + int *pWidths, + int fSorted) +{ + PsOutPtr psOut; + int xoffset, yoffset; + xRectangle *rects, *r; + RegionPtr fillRegion, region = 0; + int i; + int nbox; + BoxPtr pbox; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + + /* + * Build a region out of the spans + */ + rects = (xRectangle *)xalloc(nSpans*sizeof(xRectangle)); + xoffset = pDrawable->x; + yoffset = pDrawable->y; + + for( i = 0, r = rects; i < nSpans; i++, r++ ) + { + r->x = pPoints[i].x + xoffset; + r->y = pPoints[i].y + yoffset; + r->width = pWidths[i]; + r->height = 1; + } + fillRegion = RECTS_TO_REGION(pGC->pScreen, nSpans, rects, + (fSorted)?CT_YSORTED:CT_UNSORTED); + + /* + * Intersect this region with the clip region. Whatever's left, + * should be filled. + */ +/*REGION_INTERSECT(pGC->pScreen, region, fillRegion, pGC->clientClip);*/ + + pbox = REGION_RECTS(region); + nbox = REGION_NUM_RECTS(region); + + /* Enter HP-GL/2 */ + /*###SEND_PCL( outFile, "\27%0B" );*/ + + while( nbox ) + { +/*### + sprintf( t, "PU%d,%d;RR%d,%d;", pbox->x1, pbox->y1, pbox->x2, pbox->y2); + SEND_PCL( outFile, t ); +*/ + nbox--; + pbox++; + } + + /* Go back to PCL */ + /*###SEND_PCL( outFile, "\27%0A" );*/ + + /* + * Clean up the temporary regions + */ + REGION_DESTROY(pGC->pScreen, fillRegion); + REGION_DESTROY(pGC->pScreen, region); + xfree(rects); +} + +void +PsSetSpans( + DrawablePtr pDrawable, + GCPtr pGC, + char *pSrc, + DDXPointPtr pPoints, + int *pWidths, + int nSpans, + int fSorted) +{ +} diff --git a/xorg-server/hw/xprint/ps/PsText.c b/xorg-server/hw/xprint/ps/PsText.c new file mode 100644 index 000000000..872c0f427 --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsText.c @@ -0,0 +1,581 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsText.c +** * +** * Contents: Character-drawing routines for the PS DDX +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" +#include <X11/fonts/fntfil.h> +#include <X11/fonts/fntfilst.h> +#include <limits.h> + +int +PsPolyText8( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + char *string) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return x; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = Text8Cmd; + elm->gc = gc; + elm->c.text8.x = x; + elm->c.text8.y = y; + elm->c.text8.count = count; + elm->c.text8.string = (char *)xalloc(count); + memcpy(elm->c.text8.string, string, count); + disp->nelms += 1; + + return x; + } + else + { + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + firec->ftir->download_ps_name, pGC->font, 0); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count); + + return x; + } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadType1(psOut, "PsPolyText8", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; + + GetGlyphs(pGC->font, (unsigned long)count, + (unsigned char *)string, Linear8Bit, &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, + charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } + } + return x; +} + +int +PsPolyText16( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *string) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return x; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = Text16Cmd; + elm->gc = gc; + elm->c.text16.x = x; + elm->c.text16.y = y; + elm->c.text16.count = count; + elm->c.text16.string = + (unsigned short *)xalloc(count*sizeof(unsigned short)); + memcpy(elm->c.text16.string, string, count*sizeof(unsigned short)); + disp->nelms += 1; + + return x; + } + else + { + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + int i; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + /* Scan the string we want to render and download all neccesary parts + * of the font (one part(="font page") has 256 glyphs) + */ + for( i = 0 ; i < count ; i++ ) + { + c = string[i]; +#if IMAGE_BYTE_ORDER == LSBFirst + c_hiByte = c & 0x00FF; + c_lowByte = (c >> 8) & 0x00FF; +#elif IMAGE_BYTE_ORDER == MSBFirst + c_hiByte = (c >> 8) & 0x00FF; + c_lowByte = c & 0x00FF; +#else +#error Unsupported byte order +#endif + fontPage = c_hiByte; + + if (firec->ftir->alreadyDownloaded[fontPage] == False) + { + char buffer[256]; + const char *ps_name; + + if (fontPage > 0) + { + sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage); + ps_name = buffer; + } + else + { + ps_name = firec->ftir->download_ps_name; + } + + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */ + + firec->ftir->alreadyDownloaded[fontPage] = True; + } + } + + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count); + + return x; + } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short fontPage; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + PsOut_DownloadType1(psOut, "PsPolyText16", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[fontPage] = True; + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text16(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ + + GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } + } + return x; +} + +void +PsImageText8( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + char *string) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = TextI8Cmd; + elm->gc = gc; + elm->c.text8.x = x; + elm->c.text8.y = y; + elm->c.text8.count = count; + elm->c.text8.string = (char *)xalloc(count); + memcpy(elm->c.text8.string, string, count); + disp->nelms += 1; + } + else + { + int iso; + int siz; + float mtx[4]; + char *fnam; + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + fnam = PsGetPSFontName(pGC->font); + if( !fnam ) fnam = "Times-Roman"; + siz = PsGetFontSize(pGC->font, mtx); + iso = PsIsISOLatin1Encoding(pGC->font); + if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso); + else PsOut_TextAttrs(psOut, fnam, siz, iso); + PsOut_Text(psOut, x, y, string, count, PsGetPixelColor(cMap, pGC->bgPixel)); + } +} + +void +PsImageText16( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *string) +{ + if( pDrawable->type==DRAWABLE_PIXMAP ) + { + DisplayElmPtr elm; + PixmapPtr pix = (PixmapPtr)pDrawable; + PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; + DisplayListPtr disp; + GCPtr gc; + + if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; + + disp = PsGetFreeDisplayBlock(priv); + + elm = &disp->elms[disp->nelms]; + elm->type = TextI16Cmd; + elm->gc = gc; + elm->c.text16.x = x; + elm->c.text16.y = y; + elm->c.text16.count = count; + elm->c.text16.string = + (unsigned short *)xalloc(count*sizeof(unsigned short)); + memcpy(elm->c.text16.string, string, count*sizeof(unsigned short)); + disp->nelms += 1; + } + else + { + int i; + char *str; + if( !count ) return; + str = (char *)xalloc(count); + for( i=0 ; i<count ; i++ ) str[i] = string[i]; + PsImageText8(pDrawable, pGC, x, y, count, str); + free(str); + } +} + +void +PsImageGlyphBlt( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nGlyphs, + CharInfoPtr *pCharInfo, + pointer pGlyphBase) +{ + /* NOT TO BE IMPLEMENTED */ +} + +void +PsPolyGlyphBlt( + DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nGlyphs, + CharInfoPtr *pCharInfo, + pointer pGlyphBase) +{ + int width, height; + PixmapPtr pPixmap; + int nbyLine; /* bytes per line of padded pixmap */ + FontPtr pfont; + GCPtr pGCtmp; + register int i; + register int j; + unsigned char *pbits; /* buffer for PutImage */ + register unsigned char *pb; /* temp pointer into buffer */ + register CharInfoPtr pci; /* currect char info */ + register unsigned char *pglyph; /* pointer bits in glyph */ + int gWidth, gHeight; /* width and height of glyph */ + register int nbyGlyphWidth; /* bytes per scanline of glyph */ + int nbyPadGlyph; /* server padded line of glyph */ + int w, tmpx; + XID gcvals[3]; + + pfont = pGC->font; + width = FONTMAXBOUNDS(pfont,rightSideBearing) - + FONTMINBOUNDS(pfont,leftSideBearing); + height = FONTMAXBOUNDS(pfont,ascent) + + FONTMAXBOUNDS(pfont,descent); + + if ((width == 0) || (height == 0) ) + return; + { + int i; + w = 0; + for (i=0; i < nGlyphs; i++) w += pCharInfo[i]->metrics.characterWidth; + } + pGCtmp = GetScratchGC(1, pDrawable->pScreen); + if (!pGCtmp) + { + (*pDrawable->pScreen->DestroyPixmap)(pPixmap); + return; + } + + gcvals[0] = GXcopy; + gcvals[1] = pGC->fgPixel; + gcvals[2] = pGC->bgPixel; + + DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0); + + + nbyLine = BitmapBytePad(width); + pbits = (unsigned char *)xalloc(height*nbyLine); + if (!pbits){ + PsDestroyPixmap(pPixmap); + return; + } + tmpx = 0; + while(nGlyphs--) + { + pci = *pCharInfo++; + pglyph = FONTGLYPHBITS(pGlyphBase, pci); + gWidth = GLYPHWIDTHPIXELS(pci); + gHeight = GLYPHHEIGHTPIXELS(pci); + if (gWidth && gHeight) + { + nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci); + nbyPadGlyph = BitmapBytePad(gWidth); + + if (nbyGlyphWidth == nbyPadGlyph +#if GLYPHPADBYTES != 4 + && (((int) pglyph) & 3) == 0 +#endif + ) + { + pb = pglyph; + } + else + { + for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph)) + for (j = 0; j < nbyGlyphWidth; j++) + *pb++ = *pglyph++; + pb = pbits; + } + + PsPutImageMask((DrawablePtr)pDrawable, pGCtmp, + 1, x + pci->metrics.leftSideBearing, + y - pci->metrics.ascent, gWidth, gHeight, + 0, XYBitmap, (char *)pb); + } + + x += pci->metrics.characterWidth; + } + xfree(pbits); + FreeScratchGC(pGCtmp); +} diff --git a/xorg-server/hw/xprint/ps/PsWindow.c b/xorg-server/hw/xprint/ps/PsWindow.c new file mode 100644 index 000000000..8bfde4b0d --- /dev/null +++ b/xorg-server/hw/xprint/ps/PsWindow.c @@ -0,0 +1,222 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: PsWindow.c +** * +** * Contents: Window code for PS driver. +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> +#include <string.h> +#include <sys/wait.h> + +#include "mistruct.h" +#include "regionstr.h" +#include "windowstr.h" +#include "gcstruct.h" + +#include "Ps.h" + +/* + * The following list of strings defines the properties which will be + * placed on the screen's root window if the property was defined in + * the start-up configuration resource database. + */ +#if 0 +static char *propStrings[] = { + DT_PRINT_JOB_HEADER, + DT_PRINT_JOB_TRAILER, + DT_PRINT_JOB_COMMAND, + DT_PRINT_JOB_EXEC_COMMAND, + DT_PRINT_JOB_EXEC_OPTIONS, + DT_PRINT_PAGE_HEADER, + DT_PRINT_PAGE_TRAILER, + DT_PRINT_PAGE_COMMAND, + (char *)NULL +}; +#endif + +/* + * PsCreateWindow - watch for the creation of the root window. + * When it's created, register the screen with the print extension, + * and put the default command/header properties on it. + */ +/*ARGSUSED*/ + +Bool +PsCreateWindow(WindowPtr pWin) +{ + PsWindowPrivPtr pPriv; + +#if 0 + Bool status = Success; + ScreenPtr pScreen = pWin->drawable.pScreen; + PsScreenPrivPtr pScreenPriv = (PsScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey); + PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr) + dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey); + + /* + * Initialize this window's private struct. + */ + pWinPriv->jobFileName = (char *)NULL; + pWinPriv->pJobFile = (FILE *)NULL; + pWinPriv->pageFileName = (char *)NULL; + pWinPriv->pPageFile = (FILE *)NULL; + + if(pWin->parent == (WindowPtr)NULL) /* root window? */ + { + Atom propName; /* type = XA_STRING */ + char *propVal; + int i; + XrmDatabase rmdb = pScreenPriv->resDB; + + /* + * Put the defaults spec'd in the config files in properties on this + * screen's root window. + */ + for(i = 0; propStrings[i] != (char *)NULL; i++) + { + if((propVal = _DtPrintGetPrinterResource(pWin, rmdb, + propStrings[i])) != + (char *)NULL) + { + propName = MakeAtom(propStrings[i], strlen(propStrings[i]), + TRUE); + dixChangeWindowProperty(serverClient, pWin, propName, XA_STRING, + 8, PropModeReplace, strlen(propVal), + (pointer)propVal, FALSE); + xfree(propVal); + } + } + } + + return status; +#endif + + pPriv = (PsWindowPrivPtr) + dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey); + pPriv->validContext = 0; + + return TRUE; +} + + +/*ARGSUSED*/ +Bool PsMapWindow(WindowPtr pWindow) +{ + return TRUE; +} + +/*ARGSUSED*/ +Bool +PsPositionWindow( + WindowPtr pWin, + int x, + int y) +{ + return TRUE; +} + +/*ARGSUSED*/ +Bool +PsUnmapWindow(WindowPtr pWindow) +{ + return TRUE; +} + +/*ARGSUSED*/ +void +PsCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc) +{ +} + +/*ARGSUSED*/ +Bool +PsChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask) +{ + return TRUE; +} + +/*ARGSUSED*/ +Bool +PsDestroyWindow(WindowPtr pWin) +{ + return TRUE; +} diff --git a/xorg-server/hw/xprint/ps/psout.c b/xorg-server/hw/xprint/ps/psout.c new file mode 100644 index 000000000..c24f88b3d --- /dev/null +++ b/xorg-server/hw/xprint/ps/psout.c @@ -0,0 +1,1789 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996, 2000 Sun Microsystems, Inc. All Rights Reserved. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: psout.c +** * +** * Contents: Code to output PostScript to file +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "Ps.h" +#include "psout.h" +#ifdef XP_USE_FREETYPE +#include <ft2build.h> +#include FT_FREETYPE_H +#endif /* XP_USE_FREETYPE */ +/* For VENDOR_STRING and VENDOR_RELEASE */ +#include "site.h" + +/* + * Standard definitions + */ + +static char *S_StandardDefs = "\ +/d{def}bind def\ +/b{bind}bind d\ +/bd{b d}b d\ +/x{exch}bd\ +/xd{x d}bd\ +/dp{dup}bd\ +/t{true}bd\ +/f{false}bd\ +/p{pop}bd\ +/r{roll}bd\ +/c{copy}bd\ +/i{index}bd\ +/rp{repeat}bd\ +/n{newpath}bd\ +/w{setlinewidth}bd\ +/lc{setlinecap}bd\ +/lj{setlinejoin}bd\ +/sml{setmiterlimit}bd\ +/ds{setdash}bd\ +/ie{ifelse}bd\ +/len{length}bd\ +/m{moveto}bd\ +/rm{rmoveto}bd\ +/l{lineto}bd\ +/rl{rlineto}bd\ +/a{arc}bd\ +/an{arcn}bd\ +/st{stroke}bd\ +/fl{fill}bd\ +/ef{eofill}bd\ +/sp{showpage}bd\ +/cp{closepath}bd\ +/clp{clippath}bd\ +/cl{clip}bd\ +/pb{pathbbox}bd\ +/tr{translate}bd\ +/rt{rotate}bd\ +/dv{div}bd\ +/ml{mul}bd\ +/ad{add}bd\ +/ng{neg}bd\ +/scl{scale}bd\ +/sc{setrgbcolor}bd\ +/g{setgray}bd\ +/gs{gsave}bd\ +/gr{grestore}bd\ +/sv{save}bd\ +/rs{restore}bd\ +/mx{matrix}bd\ +/cm{currentmatrix}bd\ +/sm{setmatrix}bd\ +/ccm{concatmatrix}bd\ +/cc{concat}bd\ +/ff{findfont}bd\ +/mf{makefont}bd\ +/sf{setfont}bd\ +/cft{currentfont}bd\ +/fd{FontDirectory}bd\ +/sh{show}bd\ +/stw{stringwidth}bd\ +/ci{colorimage}bd\ +/ig{image}bd\ +/im{imagemask}bd\ +/cf{currentfile}bd\ +/rh{readhexstring}bd\ +/str{string}bd\ +/al{aload}bd\ +/wh{where}bd\ +/kn{known}bd\ +/stp{stopped}bd\ +/bg{begin}bd\ +/ed{end}bd\ +/fa{forall}bd\ +/pi{putinterval}bd\ +/mk{mark}bd\ +/ctm{cleartomark}bd\ +/df{definefont}bd\ +/cd{currentdict}bd\ +/db{20 dict dp bg}bd\ +/de{ed}bd\ +/languagelevel wh{p languagelevel}{1}ie\ + 1 eq{/makepattern{p}bd/setpattern{p}bd/setpagedevice{p}bd}if\ +/mp{makepattern}bd\ +/spt{setpattern}bd\ +/spd{setpagedevice}bd\ +" +#ifdef XP_USE_FREETYPE +"/trmoveto{currentfont /FontMatrix get transform rm}d" +#endif /* XP_USE_FREETYPE */ +; + +/* + * Composite definitions + * + * + * XYr - Return X/Y dpi for device + * + * XYr <xdpi> <ydpi> + * + * Cs - Coordinate setup (for origin upper left) + * + * <orient(0,1,2,3)> Cs + * + * P - Draw a point + * + * <x> <y> P + * + * R - Add rectangle to path + * + * <x> <y> <w> <h> R + * + * Ac - Add arc to path + * + * <x> <y> <w> <h> <ang1> <ang2> Ac + * + * An - Add arc to path (counterclockwise) + * + * <x> <y> <w> <h> <ang1> <ang2> An + * + * Tf - Set font + * + * <font_name> <size> <iso> Tf + * + * Tfm - Set font with matrix + * + * <font_name> <matrix> <iso> Tfm + * + * T - Draw text + * + * <text> <x> <y> T + * + * Tb - Draw text with background color + * + * <text> <x> <y> <bg_red> <bg_green> <bg_blue> Tb + * + * Im1 - Image 1 bit monochrome imagemask + * + * <x> <y> <w> <h> <sw> <sh> Im1 + * + * Im24 - Image 24 bit RGB color + * + * <x> <y> <w> <h> <sw> <sh> Im24 + * + * Im1t - Image 1 bit monochrome imagemask (in tile) + * + * <data> <x> <y> <w> <h> <sw> <sh> Im1t + * + * Im24t - Image 24 bit RGB color (in tile) + * + * <data> <x> <y> <w> <h> <sw> <sh> Im24t + */ + +static char *S_CompositeDefs = "\ +/XYr{/currentpagedevice wh\ + {p currentpagedevice dp /HWResolution kn\ + {/HWResolution get al p}{p 300 300}ie}{300 300}ie}bd\ +/Cs{dp 0 eq{0 pHt tr XYr -1 x dv 72 ml x 1 x dv 72 ml x scl}if\ + dp 1 eq{90 rt XYr -1 x dv 72 ml x 1 x dv 72 ml x scl}if\ + dp 2 eq{pWd 0 tr XYr 1 x dv 72 ml x -1 x dv 72 ml x scl}if\ + 3 eq{pHt pWd tr 90 rt XYr 1 x dv 72 ml x -1 x dv 72 ml x scl}if}bd\ +/P{gs 1 w [] 0 ds 2 c m .1 ad x .1 ad x l st gr}bd\ +/R{4 2 r m 1 i 0 rl 0 x rl ng 0 rl cp}bd\ +/Ac{mx_ cm p 6 -2 r tr 4 2 r ng scl 0 0 .5 5 3 r a mx_ sm}bd\ +/An{mx_ cm p 6 -2 r tr 4 2 r ng scl 0 0 .5 5 3 r an mx_ sm}bd\ +/ISO{dp len dict bg{1 i/FID ne{d}{p p}ie}fa\ + /Encoding ISOLatin1Encoding d cd ed df}bd\ +/iN{dp len str cvs dp len x 1 i 3 ad str 2 c c p x p dp 3 -1 r(ISO)pi}bd\ +/Tp{{x dp iN dp fd x kn{x p dp/f_ x d ff}{dp/f_ x d x ff ISO}ie x}\ + {x dp/f_ x d ff x}ie}bd\ +/Tf{Tp[x 0 0 2 i ng 0 0] dp/fm_ x d mf sf}bd\ +/Tfm{Tp 1 -1 tm1_ scl tm2_ ccm dp/fm_ x d mf sf}bd\ +/T{m sh}bd\ +/Tb{gs sc f_ ff sf cft/FontMatrix get 3 get\ + cft/FontBBox get dp 1 get x 3 get 2 i ml 3 1 r ml\ + 0 0 m 4 i stw p 4 i 4 i m fm_ cc\ + 0 2 i rl dp 0 rl 0 2 i ng rl 0 3 i rl ng 0 rl cp fl p p\ + gr T}bd\ +/Im1{6 4 r tr scl t [3 i 0 0 5 i 0 0]{cf str1 rh p} im}bd\ +/Im1rev{6 4 r tr scl f [3 i 0 0 5 i 0 0]{cf str1 rh p} im}bd\ +/Im24{gs 6 4 r tr scl 8 [3 i 0 0 5 i 0 0]{cf str3 rh p} f 3 ci}bd\ +/Im1t{6 4 r tr scl t [3 i 0 0 5 i 0 0]{} im}bd\ +/Im24t{gs 6 4 r tr scl 8 [3 i 0 0 5 i 0 0]{} f 3 ci}bd\ +/ck2{/currentpagedevice wh \ +{p dp currentpagedevice dp 3 -1 r kn \ +{x get al p 3 -1 r eq 3 1 r eq and } \ +{p p p p t}ie} \ +{p p p t}ie}bd \ +/ck1{/currentpagedevice wh \ +{p dp currentpagedevice dp 3 -1 r kn \ +{x get eq} {p p p t}ie} \ +{p p t}ie}bd \ +/mtx{scl t [3 i 0 0 5 i 0 0]}bd \ +"; + +char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"}; +/* + * Setup definitions + */ + +static char *S_SetupDefs = "\ + /mx_ mx d\ + /im_ mx d\ + /tm1_ mx d\ + /tm2_ mx d\ + /str3 3 str d\ + /str1 1 str d\ +"; + +/******************************************************************* + * PRIVATE FUNCTIONS * + *******************************************************************/ + +void +S_Flush(PsOutPtr self) +{ + int len; + + if( self->Buf[0] == '\0' ) + return; + + len = strlen(self->Buf); + + /* Append a newline char ('\n') if there isn't one there already */ + if( self->Buf[len-1] != '\n' ) + { + self->Buf[len++] = '\n'; + self->Buf[len] = '\0'; + } + + (void)fwrite(self->Buf, len, 1, self->Fp); + + self->Buf[0] = '\0'; +} + +static void +S_Comment(PsOutPtr self, char *comment) +{ + S_Flush(self); + strcpy(self->Buf, comment); + S_Flush(self); +} + +static void +S_OutDefs(PsOutPtr self, char *defs) +{ + int i, k=0; + S_Flush(self); + memset(self->Buf, 0, sizeof(self->Buf)); + for( i=0 ; defs[i]!='\0' ;) + { + if( k>70 && (i==0 || (i && defs[i-1]!='/')) && + (defs[i]==' ' || defs[i]=='/' || defs[i]=='{') ) + { + S_Flush(self); + k = 0; + memset(self->Buf, 0, sizeof(self->Buf)); + } + if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; } + self->Buf[k] = defs[i]; + k++; i++; + } + S_Flush(self); +} + +void +S_OutNum(PsOutPtr self, float num) +{ + int i; + char buf[64]; + int len; + + sprintf(buf, "%.3f", num); + + /* Remove any zeros at the end */ + for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0'; + /* Remove '.' if it is the last character */ + i = strlen(buf)-1; if( buf[i]=='.' ) buf[i] = '\0'; + + len = strlen(self->Buf); + if( len > 0 ) + { + self->Buf[len++] = ' '; + self->Buf[len] = '\0'; + } + strcpy(&self->Buf[len], buf); + if( (len+i)>70 ) S_Flush(self); +} + +static void +S_OutStr(PsOutPtr self, char *txt, int txtl) +{ + int i, k; + char buf[1024]; + for( i=0,k=0 ; i<txtl ; i++ ) + { + if( (txt[i]>=' ' && txt[i]<='~') && + txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' ) + { buf[k] = txt[i]; k++; continue; } + buf[k] = '\\'; k++; + sprintf(&buf[k], "%03o", txt[i]&0xFF); + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; + } + strcat(self->Buf, "("); + i = strlen(self->Buf); + memcpy(&self->Buf[i], buf, k); + self->Buf[i+k] = '\0'; + strcat(self->Buf, ")"); + if( strlen(self->Buf)>70 ) S_Flush(self); +} + +/* Same as S_OutStr() but takes |short *| instead of |char *| */ +static void +S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl) +{ + int i, k; + char buf[2048]; + for( i=0,k=0 ; i<txtl ; i++ ) + { + if( (txt[i]>=' ' && txt[i]<='~') && + txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' ) + { buf[k] = txt[i]; k++; continue; } + buf[k] = '\\'; k++; + sprintf(&buf[k], "%03o", txt[i]&0xFFFF); + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; + } + strcat(self->Buf, "("); + i = strlen(self->Buf); + memcpy(&self->Buf[i], buf, k); + self->Buf[i+k] = '\0'; + strcat(self->Buf, ")"); + if( strlen(self->Buf)>70 ) S_Flush(self); +} + +void +S_OutTok(PsOutPtr self, char *tok, int cr) +{ + int len = strlen(self->Buf); + if( len > 0 ) + { + self->Buf[len++] = ' '; + self->Buf[len] = '\0'; + } + strcpy(&self->Buf[len], tok); + if( cr ) S_Flush(self); +} + +static void +S_Color(PsOutPtr self, PsOutColor clr) +{ + int ir, ig, ib; + ir = PSOUTCOLOR_TO_REDBITS(clr); + ig = PSOUTCOLOR_TO_GREENBITS(clr); + ib = PSOUTCOLOR_TO_BLUEBITS(clr); + if( ir==ig && ig==ib ) + { S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); S_OutTok(self, "g", 1); } + else + { + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); + S_OutTok(self, "sc", 1); + } +} + +static void +S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res, + int wd, int ht, int isPage) +{ + float fwd = ((float)wd/(float)res)*72.; + float fht = ((float)ht/(float)res)*72.; + +#define USE_WORKAROUND_COPY_COUNT_BUG 1 + +#ifdef USE_WORKAROUND_COPY_COUNT_BUG + /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 - + * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies + * instead of n copies. + * The problem is that we use both /NumCopies here but pass the + * %copy-count% to the spooler, too. + * But we only have to use _one_ way... + * + * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 - + * "PS DDX creates n^2 copies of a job instead of n copies") will back this + * workaround out and replace it with a better solution. + * (see mozilla.org bug 140030 + * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number + * of copies causes too many copies to print") for the initial report for + * this issue...) + */ + count = 1; +#endif /* USE_WORKAROUND_COPY_COUNT_BUG */ + + S_OutTok(self, "/pWd", 0); + S_OutNum(self, fwd); + S_OutTok(self, "d /pHt", 0); + S_OutNum(self, fht); + S_OutTok(self, "d", 1); + + /* + * if these are page attributes, have PostScript check to see if they + * have changed. If not, don't do setpagedevice, since it will cause + * a page flush and screw up duplex printing. Having PostScript check + * means we don't have to keep track ourselves. + */ + if(isPage) { + S_OutNum(self, (float) orient); + S_OutTok(self, "/Orientation ck1", 0); + S_OutTok(self, "pWd pHt /PageSize ck2 and not {", 1); + } + S_OutTok(self, "{db", 0); + + S_OutTok(self, "/Orientation", 0); + S_OutNum(self, (float) orient); + S_OutTok(self, " d ", 0); + S_OutTok(self, "/PageSize [pWd pHt] d", 0); + + S_OutTok(self, " de spd", 0); + /* + * save a flag to show if we failed to set orientation... determined + * by both/either Orientation and/or PageSize, use this + * later to set/not set orientation using Cs command. + */ + S_OutTok(self,"}stp /orientationFailed x d", 1); + /* + * if these are page attributes, have PostScript check to see if they + * have changed. If not, don't do setpagedevice, since it will cause + * a page flush and screw up duplex printing. Having PostScript check + * means we don't have to keep track ourselves. + */ + if(isPage) + { + S_OutTok(self,"}if",1); + + S_OutTok(self, (plex==0)?"f":"t", 0); + S_OutTok(self, "/Duplex ck1 ", 0); + + S_OutTok(self, (plex==2)?"t":"f", 0); + S_OutTok(self, "/Tumble ck1 and ", 0); + + + S_OutNum(self, (float)res); + S_OutNum(self, (float)res); + S_OutTok(self, " /HWResolution ck2 and", 0); + + if( count>1 ) + { + S_OutNum(self, (float)count); + S_OutTok(self, " /NumCopies", 0); + S_OutTok(self, " ck1 and ", 0); + } + S_OutTok(self," not {",1); + } + S_OutTok(self, "{db", 0); + + S_OutTok(self, "/Duplex ", 0); + S_OutTok(self, (plex==0)?"f":"t", 0); + S_OutTok(self, " d ", 0); + + S_OutTok(self, "/Tumble ", 0); + S_OutTok(self, (plex==2)?"t":"f", 0); + S_OutTok(self, " d ", 0); + + S_OutTok(self, " /HWResolution [", 0); + S_OutNum(self, (float)res); + S_OutNum(self, (float)res); + S_OutTok(self, "] d ", 0); + + if( count>1 ) + { + S_OutTok(self, " /NumCopies", 0); + S_OutNum(self, (float)count); + S_OutTok(self, " d ", 0); + } + S_OutTok(self, " de spd}stp p", 1); + + if(isPage) + { + S_OutTok(self, "}if", 1); + } +} + +/******************************************************************* + * PUBLIC FUNCTIONS * + *******************************************************************/ + +FILE * +PsOut_ChangeFile(PsOutPtr self, FILE *fp) +{ + FILE *nfp; + + nfp = self->Fp; + + self->Fp = fp; + + return nfp; +} + +PsOutPtr +PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res, + int wd, int ht, Bool raw) +{ + int i; + char buffer[256+32]; /* enougth space for a title with 256 chars... */ +/* + * Get ready to output PostScript header + */ + PsOutPtr psout; + psout = (PsOutPtr)xalloc(sizeof(PsOutRec)); + memset(psout, 0, sizeof(PsOutRec)); + psout->Fp = fp; + psout->isRaw = raw; + psout->pagenum = 0; + + if (!raw) { +/* + * Output PostScript header + */ + /* GhostScript will rant about the missing BoundingBox if we use + * "%!PS-Adobe-3.0 EPSF-3.0" here... */ + S_Comment(psout, "%!PS-Adobe-3.0"); +#ifdef XP_USE_FREETYPE + { + FT_Int ftmajor = 0, + ftminor = 0, + ftpatch = 0; + extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */ + + FT_Library_Version(ftypeLibrary, &ftmajor, &ftminor, &ftpatch); + sprintf(buffer, + "%%%%Creator: The X Print Server's PostScript DDX " + "(%s, release %d, FreeType version %d.%d.%d)", + VENDOR_STRING, VENDOR_RELEASE, + (int)ftmajor, (int)ftminor, (int)ftpatch); + } +#else + sprintf(buffer, + "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)", + VENDOR_STRING, VENDOR_RELEASE); +#endif /* XP_USE_FREETYPE */ + S_Comment(psout, buffer); + + if (title) + { + sprintf(buffer, "%%%%Title: %.256s", title); + S_Comment(psout, buffer); + } + S_Comment(psout, "%%EndComments"); + S_Comment(psout, "%%BeginProlog"); + S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions"); + S_OutDefs(psout, S_StandardDefs); + S_OutDefs(psout, S_CompositeDefs); + S_Comment(psout, "%%EndProcSet"); + S_Comment(psout, "%%EndProlog"); + S_Comment(psout, "%%BeginSetup"); + /* set document level page attributes */ + S_SetPageDevice(psout, orient, count, plex, res, wd, ht, 0); + S_Comment(psout, "%%Pages: atend"); + S_OutDefs(psout, S_SetupDefs); + S_Comment(psout, "%%EndSetup"); + } +/* + * Initialize the structure + */ + psout->CurColor = PSOUTCOLOR_NOCOLOR; + psout->LineWidth = 1; + psout->LineCap = PsCButt; + psout->LineJoin = PsJMiter; + psout->NDashes = 0; + psout->Dashes = (int *)0; + psout->FontName = (char *)0; + psout->FontSize = 0; + psout->start_image = 0; + for( i=0 ; i<4 ; i++ ) psout->FontMtx[i] = 0.; + psout->ImageFormat = 0; + return(psout); +} + +void +PsOut_EndFile(PsOutPtr self, int closeFile) +{ + char coms[50]; + + if (!self) + return; + + if (!self->isRaw) { + S_Comment(self,"%%Trailer"); + sprintf(coms,"%%%%Pages: %d", self->pagenum); + S_Comment(self, coms); + S_Comment(self, "%%EOF"); + } + if( self->NDashes && self->Dashes ) xfree(self->Dashes); + if( self->FontName ) xfree(self->FontName); + if( self->Patterns ) xfree(self->Patterns); + if( self->Clip.rects ) xfree(self->Clip.rects); + if( closeFile ) fclose(self->Fp); + xfree(self); +} + +void +PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res, + int wd, int ht) +{ + char coms[50]; + +/*** comment for pagenumbers *****/ + + S_Comment(self,"%%PageHeader"); + self->pagenum++; + sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum); + S_Comment(self, coms); + sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]); + S_Comment(self, coms); + +/*** end comment *****************/ + + /* set page level page attributes */ + S_SetPageDevice(self, orient, count, plex, res, wd, ht, 1); + + S_OutTok(self, "gs ", 0); + /* + * check to see if we set orientation already; if it wasn't set, + * use Cs to set orientation here. + */ + S_OutNum(self, (float)orient); + S_OutTok(self, "orientationFailed { ", 0); + S_OutNum(self, (float)orient); + S_OutTok(self, " } { 0 }ie Cs 100 sml gs", 1); +} + +void +PsOut_EndPage(PsOutPtr self) +{ + S_OutTok(self, "gr gr sp", 1); + + /* did grestore: mark attributes 'dirty' so they will be re-sent */ + PsOut_DirtyAttributes(self); + +/*** comment for pagenumbers *****/ + + S_Comment(self,"%%PageTrailer"); + +/*** end comment *****************/ +} + +void +PsOut_DirtyAttributes(PsOutPtr self) +{ + int i; + self->CurColor = PSOUTCOLOR_NOCOLOR; + self->LineWidth = -1; + self->LineCap = (PsCapEnum)-1; + self->LineJoin = (PsJoinEnum)-1; + self->NDashes = -1; + self->FontSize = -1; + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; + if( self->Dashes ) { xfree(self->Dashes); self->Dashes = (int *)0; } + if( self->FontName ) { xfree(self->FontName); self->FontName = (char *)0; } +} + +void +PsOut_Comment(PsOutPtr self, char *comment) +{ + S_Comment(self, comment); +} + +void +PsOut_Offset(PsOutPtr self, int x, int y) +{ + self->XOff = x; + self->YOff = y; +} + +void +PsOut_Clip(PsOutPtr self, int clpTyp, PsClipPtr clpinf) +{ + int i, k; + int changed = 0; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InTile ) return; + if( self->InFrame ) xo = yo = 0; + if( clpTyp!=self->ClipType ) changed = 1; + else + { + if( clpinf->nRects!=self->Clip.nRects ) changed = 1; + else + { + if( clpinf->nOutterClips!=self->Clip.nOutterClips ) changed = 1; + else + { + for( i=0 ; i<clpinf->nOutterClips ; i++ ) + { + if( memcmp(&clpinf->outterClips[i], &self->Clip.outterClips[i], + sizeof(PsRectRec))!=0 ) break; + } + if( i<clpinf->nOutterClips ) changed = 1; + else + { + for( i=0 ; i<clpinf->nRects ; i++ ) + { + if( memcmp(&clpinf->rects[i], &self->Clip.rects[i], + sizeof(PsRectRec))!=0 ) { changed = 1; break; } + } + } + } + } + if( clpinf->nElms!=self->Clip.nElms ) changed = 1; + else + { + for( i=0 ; i<clpinf->nElms ; i++ ) + { + if( clpinf->elms[i].type!=PSOUT_POINTS ) + { + if( memcmp(&clpinf->elms[i], &self->Clip.elms[i], + sizeof(PsElmRec))!=0 ) { changed = 1; break; } + } + else + { + if( clpinf->elms[i].type!=self->Clip.elms[i].type || + clpinf->elms[i].nPoints!=self->Clip.elms[i].nPoints ) + { changed = 1; break; } + else + { + for( k=0 ; k<clpinf->elms[i].nPoints ; k++ ) + { + if( memcmp(&clpinf->elms[i].c.points[k], + &self->Clip.elms[i].c.points[k], sizeof(PsPointRec)) ) + { changed = 1; break; } + } + if( changed ) break; + } + } + } + } + } + + if( self->Clip.rects ) xfree(self->Clip.rects); + if( self->Clip.outterClips ) xfree(self->Clip.outterClips); + if( self->Clip.elms ) + PsDestroyFillElementList(self->Clip.nElms, self->Clip.elms); + self->ClipType = clpTyp; + self->Clip.nRects = clpinf->nRects; + self->Clip.nElms = clpinf->nElms; + self->Clip.nOutterClips = clpinf->nOutterClips; + if( clpinf->nRects ) + { + self->Clip.rects = (PsRectPtr)xalloc(clpinf->nRects*sizeof(PsRectRec)); + memcpy(self->Clip.rects, clpinf->rects, clpinf->nRects*sizeof(PsRectRec)); + } + else self->Clip.rects = 0; + if( clpinf->nOutterClips ) + { + self->Clip.outterClips = (PsRectPtr)xalloc(clpinf->nOutterClips* + sizeof(PsRectRec)); + memcpy(self->Clip.outterClips, clpinf->outterClips, + clpinf->nOutterClips*sizeof(PsRectRec)); + } + else self->Clip.outterClips = 0; + if( clpinf->nElms ) + self->Clip.elms = PsCloneFillElementList(clpinf->nElms, clpinf->elms); + else self->Clip.elms = 0; + + PsOut_DirtyAttributes(self); + S_OutTok(self, "gr gs", 1); + if( self->Clip.nOutterClips ) + { + for( i=0 ; i<self->Clip.nOutterClips ; i++ ) + { + S_OutNum(self, (float)(self->Clip.outterClips[i].x)); + S_OutNum(self, (float)(self->Clip.outterClips[i].y)); + S_OutNum(self, (float)self->Clip.outterClips[i].w); + S_OutNum(self, (float)self->Clip.outterClips[i].h); + S_OutTok(self, "R", 1); + } + S_OutTok(self, "cl n", 1); + } + if( self->Clip.nRects ) + { + for( i=0 ; i<self->Clip.nRects ; i++ ) + { + S_OutNum(self, (float)(self->Clip.rects[i].x+xo)); + S_OutNum(self, (float)(self->Clip.rects[i].y+yo)); + S_OutNum(self, (float)self->Clip.rects[i].w); + S_OutNum(self, (float)self->Clip.rects[i].h); + S_OutTok(self, "R", 1); + } + S_OutTok(self, "cl n", 1); + } + if( self->Clip.nElms ) + { + PsElmPtr elm = self->Clip.elms; + for( i=0 ; i<self->Clip.nElms ; i++,elm++ ) + { + switch(elm->type) + { + case PSOUT_POINTS: + for( k=0 ; k<elm->nPoints ; k++ ) + { + S_OutNum(self, (float)elm->c.points[k].x+xo); + S_OutNum(self, (float)elm->c.points[k].y+yo); + if( k==0 ) S_OutTok(self, "m", 0); + else S_OutTok(self, "l", 0); + } + S_OutTok(self, "cp", 1); + break; + case PSOUT_RECT: + S_OutNum(self, (float)elm->c.rect.x+xo); + S_OutNum(self, (float)elm->c.rect.y+yo); + S_OutNum(self, (float)elm->c.rect.w); + S_OutNum(self, (float)elm->c.rect.h); + S_OutTok(self, "R", 1); + break; + case PSOUT_ARC: + if( elm->c.arc.style==PsPieSlice ) + { + S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.); + S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.); + S_OutTok(self, "m", 0); + } + S_OutNum(self, (float)elm->c.arc.x+xo+(float)elm->c.arc.w/2.); + S_OutNum(self, (float)elm->c.arc.y+yo+(float)elm->c.arc.h/2.); + S_OutNum(self, (float)elm->c.arc.w); + S_OutNum(self, (float)elm->c.arc.h); + S_OutNum(self, (float)elm->c.arc.a1/64.); + S_OutNum(self, (float)elm->c.arc.a1/64.+(float)elm->c.arc.a2/64.); + if( elm->c.arc.a2<0 ) S_OutTok(self, "An cp", 1); + else S_OutTok(self, "Ac cp", 1); + break; + } + } + S_OutTok(self, "cl n", 1); + } +} + +void +PsOut_Color(PsOutPtr self, PsOutColor clr) +{ + if( clr==self->CurColor || self->InTile>=PsStip ) return; + self->CurColor = clr; + S_Color(self, clr); +} + +void +PsOut_FillRule(PsOutPtr self, PsRuleEnum rule) +{ + self->FillRule = rule; +} + +void +PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap, PsJoinEnum join, + int nDsh, int *dsh, int dshOff, PsOutColor bclr) +{ + int i; + int same = 1; + + if( wd!=self->LineWidth && wd>=0 ) + { + if( wd==0 ) wd = 1; + self->LineWidth = wd; + S_OutNum(self, (float)wd); S_OutTok(self, "w", 1); + } + if( cap!=self->LineCap ) + { + self->LineCap = cap; + S_OutNum(self, (float)cap); S_OutTok(self, "lc", 1); + } + if( join!=self->LineJoin ) + { + self->LineJoin = join; + S_OutNum(self, (float)join); S_OutTok(self, "lj", 1); + } + if( nDsh!=self->NDashes ) same = 0; + else if( dshOff!=self->DashOffset ) same = 0; + else if( nDsh ) + { + for( i=0 ; i<nDsh ; i++ ) + { if( dsh[i]!=self->Dashes[i] ) break; } + if( i<nDsh ) same = 0; + } + if( !same ) + { + if( self->NDashes && self->Dashes ) + { xfree(self->Dashes); self->Dashes = (int *)0; } + self->NDashes = nDsh; + self->DashOffset = dshOff; + if( nDsh ) self->Dashes = (int *)xalloc(sizeof(int)*nDsh); + S_OutTok(self, "[", 0); + for( i=0 ; i<nDsh ; i++ ) + { + self->Dashes[i] = dsh[i]; + S_OutNum(self, (float)dsh[i]); + } + S_OutTok(self, "]", 0); + S_OutNum(self, (float)dshOff); + S_OutTok(self, "ds", 1); + } + + if( nDsh ) + self->LineBClr = bclr; + else + bclr = PSOUTCOLOR_NOCOLOR; +} + +void +PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso) +{ + int i; + char buf[256]; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + siz==self->FontSize ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + self->FontSize = siz; + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; + strcpy(buf, "/"); strcat(buf, fnam); + S_OutTok(self, buf, 0); + S_OutNum(self, (float)siz); + if( iso ) S_OutTok(self, "t", 0); + else S_OutTok(self, "f", 0); + S_OutTok(self, "Tf", 1); +} + +void +PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso) +{ + int i; + char buf[256]; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && + mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = mtx[i]; + self->FontSize = -1; + strcpy(buf, "/"); strcat(buf, fnam); strcat(buf, " ["); + S_OutTok(self, buf, 0); + for( i=0 ; i<4 ; i++ ) S_OutNum(self, mtx[i]); + S_OutTok(self, "0 0]", 0); + if( iso ) S_OutTok(self, "t", 0); + else S_OutTok(self, "f", 0); + S_OutTok(self, "Tfm", 1); +} + +void +PsOut_Polygon(PsOutPtr self, int nPts, PsPointPtr pts) +{ + int i; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + if( nPts<=2 ) return; + for( i=0 ; i<nPts ; i++ ) + { + S_OutNum(self, (float)(pts[i].x+xo)); + S_OutNum(self, (float)(pts[i].y+yo)); + if( i==0 ) S_OutTok(self, "m", 0); + else S_OutTok(self, "l", 0); + } + if( self->FillRule==PsEvenOdd ) S_OutTok(self, "cp ef", 1); + else S_OutTok(self, "cp fl", 1); +} + +void +PsOut_FillRect(PsOutPtr self, int x, int y, int w, int h) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutTok(self, "R fl", 1); +} + +void +PsOut_FillArc(PsOutPtr self, int x, int y, int w, int h, + float ang1, float ang2, PsArcEnum style) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + if( style==PsPieSlice ) + { + S_OutNum(self, (float)x+(float)w/2.); + S_OutNum(self, (float)y+(float)h/2.); + S_OutTok(self, "m", 0); + } + S_OutNum(self, (float)x+(float)w/2.); + S_OutNum(self, (float)y+(float)h/2.); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutNum(self, ang1); + S_OutNum(self, ang1+ang2); + if( ang2<0 ) S_OutTok(self, "An cp fl", 1); + else S_OutTok(self, "Ac cp fl", 1); +} + +void +PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts) +{ + int i; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + if( nPts<1 ) return; + for( i=0 ; i<nPts ; i++ ) + { + S_OutNum(self, (float)(pts[i].x+xo)); + S_OutNum(self, (float)(pts[i].y+yo)); + if( i==0 ) S_OutTok(self, "m", 0); + else S_OutTok(self, "l", 0); + } + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) + { + S_OutTok(self, "gs", 0); + S_Color(self, self->LineBClr); + S_OutTok(self, "[] 0 ds st gr", 0); + } + S_OutTok(self, "st", 1); +} + +void +PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts) +{ + int i; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + if( nPts<1 ) return; + for( i=0 ; i<nPts ; i++ ) + { + S_OutNum(self, (float)(pts[i].x+xo)); + S_OutNum(self, (float)(pts[i].y+yo)); + S_OutTok(self, "P", 1); + } +} + +void +PsOut_DrawRect(PsOutPtr self, int x, int y, int w, int h) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutTok(self, "R", 0); + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) + { + S_OutTok(self, "gs", 0); + S_Color(self, self->LineBClr); + S_OutTok(self, "[] 0 ds st gr", 0); + } + S_OutTok(self, "st", 1); +} + +void +PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h, + float ang1, float ang2) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutNum(self, (float)x+(float)w/2.); + S_OutNum(self, (float)y+(float)h/2.); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutNum(self, ang1); + S_OutNum(self, ang1+ang2); + if( ang2<0 ) S_OutTok(self, "An", 0); + else S_OutTok(self, "Ac", 0); + if( self->LineBClr != PSOUTCOLOR_NOCOLOR ) + { + S_OutTok(self, "gs", 0); + S_Color(self, self->LineBClr); + S_OutTok(self, "[] 0 ds st gr", 0); + } + S_OutTok(self, "st", 1); +} + +void +PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, PsOutColor bclr) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutStr(self, text, textl); + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + if( bclr == PSOUTCOLOR_NOCOLOR ) + S_OutTok(self, "T", 1); + else + { + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); + S_OutTok(self, "Tb", 1); + } +} + +void +PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutStr16(self, text, textl); + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + if( bclr == PSOUTCOLOR_NOCOLOR ) + S_OutTok(self, "T", 1); + else + { + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ig)); + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ib)); + S_OutTok(self, "Tb", 1); + } +} + +#ifdef BM_CACHE +void /* new */ +PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, PsOutColor bclr, PsOutColor fclr) +{ + char cacheID[10]; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + sprintf(cacheID, "c%di", cache_id); + + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + + if( fclr==PSOUTCOLOR_WHITE ) + { + int ir = PSOUTCOLOR_TO_REDBITS(bclr); + int ig = PSOUTCOLOR_TO_GREENBITS(bclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(bclr); + + if( ir==ig && ig==ib ) + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + else + S_OutNum(self, (float)0); + self->RevImage = 1; + } + else + { + int ir = PSOUTCOLOR_TO_REDBITS(fclr); + int ig = PSOUTCOLOR_TO_GREENBITS(fclr); + int ib = PSOUTCOLOR_TO_BLUEBITS(fclr); + + if( ir==ig && ig==ib ) + S_OutNum(self, PSOUTCOLOR_BITS_TO_PSFLOAT(ir)); + else + S_OutNum(self, (float)0); + } + + S_OutTok(self, cacheID, 1); +} /* new */ + +void /* new */ +PsOut_BeginImageCache(PsOutPtr self, long cache_id) +{ + char cacheID[10]; + + sprintf(cacheID, "/c%di {", cache_id); + + S_OutTok(self, cacheID, 0); +} /* new */ + +void /* new */ +PsOut_EndImageCache(PsOutPtr self) +{ + S_OutTok(self, "}bd", 1); +} /* new */ +#endif + +void +PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, + int w, int h, int sw, int sh, int format) +{ + PsOutColor savClr = self->CurColor; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + if( self->InTile ) + { + if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; } + self->ImgBClr = bclr; self->ImgFClr = fclr; + self->ImgX = x; self->ImgY = y; + self->ImgW = w; self->ImgH = h; + self->SclW = sw; self->SclH = sh; + S_OutTok(self, "<", 0); + self->ImageFormat = format; + self->RevImage = 0; + if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE ) + self->RevImage = 1; + return; + } + + self->RevImage = 0; + if( format==1 ) + { + S_OutTok(self, "gs", 0); + if( fclr==PSOUTCOLOR_WHITE ) + { + PsOut_Color(self, fclr); + PsOut_FillRect(self, x, y, sw, sh); + PsOut_Color(self, bclr); + self->RevImage = 1; + } + else + { + PsOut_Color(self, bclr); + PsOut_FillRect(self, x, y, sw, sh); + PsOut_Color(self, fclr); + } + } + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutNum(self, (float)sw); + S_OutNum(self, (float)sh); + if( format==1 ) { + if(self->RevImage) + S_OutTok(self, "Im1rev", 1); + else + S_OutTok(self, "Im1", 1); + } + else S_OutTok(self, "Im24", 1); + self->ImageFormat = format; + self->CurColor = savClr; +} + +void +PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, + int w, int h, int sw, int sh, int format) +{ + PsOutColor savClr = self->CurColor; + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + if( self->InTile ) + { + if( self->InTile>=PsStip && format!=1 ) { self->ImgSkip = 1; return; } + self->ImgBClr = bclr; self->ImgFClr = fclr; + self->ImgX = x; self->ImgY = y; + self->ImgW = w; self->ImgH = h; + self->SclW = sw; self->SclH = sh; + S_OutTok(self, "<", 0); + self->ImageFormat = format; + self->RevImage = 0; + if( self->InTile==PsTile && format==1 && fclr==PSOUTCOLOR_WHITE ) + self->RevImage = 1; + return; + } + + self->RevImage = 0; + if( format==1 ) + { + S_OutTok(self, "gs", 0); +#ifdef BM_CACHE + S_OutTok(self, "g", 1); +#else + if( fclr==PSOUTCOLOR_WHITE ) + { + PsOut_Color(self, bclr); + self->RevImage = 1; + } + else + { + PsOut_Color(self, fclr); + } +#endif + } + +#ifdef BM_CACHE + S_OutTok(self, "tr", 0); /* new */ +#else + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); +#endif + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutNum(self, (float)sw); + S_OutNum(self, (float)sh); +#ifdef BM_CACHE + S_OutTok(self, "mtx", 1); /* new */ + S_OutTok(self, "<", 0); /* new */ + self->start_image = 1; +#else + if( format==1 ){ + if(self->RevImage) + S_OutTok(self, "Im1rev", 1); + else + S_OutTok(self, "Im1", 1); + } + else S_OutTok(self, "Im24", 1); +#endif + self->ImageFormat = format; + self->CurColor = savClr; +} + +void +PsOut_EndImage(PsOutPtr self) +{ + if( self->ImgSkip ) { self->ImgSkip = 0; return; } + if( self->InTile ) + { + S_OutTok(self, ">", 1); + if( self->ImageFormat==1 && self->InTile==PsTile ) + { + if( self->ImgFClr==PSOUTCOLOR_WHITE ) + { + PsOut_Color(self, self->ImgFClr); + PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH); + PsOut_Color(self, self->ImgBClr); + } + else + { + PsOut_Color(self, self->ImgBClr); + PsOut_FillRect(self, self->ImgX, self->ImgY, self->SclW, self->SclH); + PsOut_Color(self, self->ImgFClr); + } + } + S_OutNum(self, (float)self->ImgX); + S_OutNum(self, (float)self->ImgY); + S_OutNum(self, (float)self->ImgW); + S_OutNum(self, (float)self->ImgH); + S_OutNum(self, (float)self->SclW); + S_OutNum(self, (float)self->SclH); + if( self->ImageFormat==1 ) S_OutTok(self, "Im1t", 1); + else S_OutTok(self, "Im24t", 1); + self->ImageFormat = 0; + self->RevImage = 0; + return; + } + /* + * Bug 4639307: Move flush before "> im" to get all of bitmap into ps file. + */ + S_Flush(self); +#ifdef BM_CACHE + if(self->start_image) + S_OutTok(self, "> im", 1); /* new */ +#endif + self->ImageFormat = 0; + self->RevImage = 0; +#ifdef BM_CACHE + if(self->start_image) + { + self->start_image = 0; + S_OutTok(self, "gr", 0); + } + else + S_OutTok(self, "gr", 1); +#else + S_OutTok(self, "gr", 1); +#endif +} + +void +PsOut_OutImageBytes(PsOutPtr self, int nBytes, char *bytes) +{ + int i; + int b; + int len; + const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + + if( (!self->ImageFormat) || self->ImgSkip ) return; + + len = strlen(self->Buf); + + for( i=0 ; i<nBytes ; i++ ) + { + if( self->RevImage ) b = (int)((bytes[i]^0xFF)&0xFF); + else b = (int)(bytes[i]&0xFF); + + self->Buf[len++] = hex[(b&0xF0) >> 4]; + self->Buf[len++] = hex[(b&0x0F)]; + self->Buf[len] = '\0'; + + if( len>70 ) + { + S_Flush(self); + len = 0; + } + } +} + +void +PsOut_BeginFrame(PsOutPtr self, int xoff, int yoff, int x, int y, + int w, int h) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame ) xo = yo = 0; + S_OutTok(self, "gs", 0); + S_OutNum(self, (float)(x+xo)); + S_OutNum(self, (float)(y+yo)); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutTok(self, "R cl n", 0); + xoff += xo; yoff += yo; + if( xoff || yoff ) + { + S_OutNum(self, (float)xoff); + S_OutNum(self, (float)yoff); + S_OutTok(self, "tr", 0); + } + S_OutTok(self, "gs", 1); + self->InFrame += 1; +} + +void +PsOut_EndFrame(PsOutPtr self) +{ + self->InFrame -= 1; + if( self->InFrame<0 ) self->InFrame = 0; + S_OutTok(self, "gr gr", 1); + PsOut_DirtyAttributes(self); +} + +int +PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type, + PsOutColor bclr, PsOutColor fclr) +{ + int i; + char key[64]; + + for( i=0 ; i<self->NPatterns ; i++ ) + { if( self->Patterns[i].tag==tag && self->Patterns[i].type==type ) break; } + if( i<self->NPatterns ) return(1); + if( (self->NPatterns+1)>self->MxPatterns ) + { + if( self->Patterns ) + { + self->MxPatterns *= 2; + self->Patterns = + (PsPatPtr)xrealloc(self->Patterns, sizeof(PsPatRec)*self->MxPatterns); + } + else + { + self->MxPatterns = 64; + self->Patterns = (PsPatPtr)xalloc(sizeof(PsPatRec)*self->MxPatterns); + } + } + self->Patterns[self->NPatterns].tag = tag; + self->Patterns[self->NPatterns].type = type; + sprintf(key, "/ %d", (int)tag); + switch(type) { + case PsTile: key[1] = 't'; break; + case PsStip: key[1] = 's'; break; + case PsOpStip: key[1] = 'o'; break; + default: break; } + S_OutTok(self, key, 0); + S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0); + S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutTok(self, "]d/XStep", 0); + S_OutNum(self, (float)w); + S_OutTok(self, "d/YStep", 0); + S_OutNum(self, (float)h); + S_OutTok(self, "d/PaintProc{bg sv", 1); + if( type==PsOpStip ) + { + S_Color(self, bclr); + S_OutTok(self, "0 0", 0); + S_OutNum(self, (float)w); + S_OutNum(self, (float)h); + S_OutTok(self, "R fl", 1); + } + if( type!=PsTile ) S_Color(self, fclr); + self->NPatterns += 1; + self->InTile = type; + return(0); +} + +void +PsOut_EndPattern(PsOutPtr self) +{ + self->InTile = PsSolid; + S_OutTok(self, "rs ed}d de im_ mp d", 1); +} + +void +PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type) +{ + int i; + char key[64]; + + for( i=0 ; i<self->NPatterns ; i++ ) + { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; } + if( i>=self->NPatterns ) return; + sprintf(key, " %d", (int)tag); + switch(type) { + case PsTile: key[0] = 't'; break; + case PsStip: key[0] = 's'; break; + case PsOpStip: key[0] = 'o'; break; + default: break; } + S_OutTok(self, key, 0); + S_OutTok(self, "spt", 1); + self->CurColor = PSOUTCOLOR_NOCOLOR; +} + +void +PsOut_RawData(PsOutPtr self, char *data, int len) +{ + S_Flush(self); + if (!ferror(self->Fp)) { + (void) fwrite(data, 1, len, self->Fp); + } +} + +typedef enum PsDownfontFontType_ +{ + PsDFT_Type1PFA=0, + PsDFT_Type1PFB, + PsDFT_TrueType /* not implemented yet */ +} PsDownfontFontType; + +/* Download a PS Type1 font */ +int +PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname) +{ + int stt; + char buf[256]; + FILE *fp; + PsDownfontFontType type; + + fp = fopen(fname, "r"); + if( !fp ) + return 0; + +#ifdef DEBUG_gisburn + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname); +#endif /* DEBUG_gisburn */ + + fread(buf, 32, 1, fp); + fseek(fp, (long)0, 0); + + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 ) + { + type = PsDFT_Type1PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (!strncmp(buf, "%!PS-AdobeFont", 14)) + { + type = PsDFT_Type1PFA; + } + else + { + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname); + return 0; + } + + S_Flush(self); + sprintf(buf, "%%%%BeginFont: %s", name); + S_Comment(self, buf); + + if( type == PsDFT_Type1PFB ) + { + char *buf, + *pt; + int len, + ch, + stype; + + ch = fgetc(fp); + /* Strip out the binary headers and de-binary it */ + while( (ch&0xFF) == 0x80 ) + { + stype = fgetc(fp); + if( stype==3 ) /* eof mark */ + break; + len = fgetc(fp); + len |= fgetc(fp)<<8; + len |= fgetc(fp)<<16; + len |= fgetc(fp)<<24; + buf = (char *)xalloc(len+1); + if( stype==1 ) + { + /* Process ASCII section */ + len = fread(buf, 1, len, fp); + /* convert any lone CRs (ie Mac eol) to LFs */ + for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ ) + { + if ( pt[1]!='\n' ) + *pt = '\n'; + } + fwrite(buf, 1, len, self->Fp); + } + else if( stype==2 ) + { + int i; + + /* Process binary section */ + len = fread(buf, 1, len, fp); + for( i=0 ; i<len ; i++ ) + { + ch = buf[i]; + if( ((ch>>4)&0xf) <= 9 ) + fputc('0'+((ch>>4)&0xf), self->Fp); + else + fputc('A'-10+((ch>>4)&0xf), self->Fp); + + if( (ch&0xf) <= 9 ) + fputc('0'+(ch&0xf), self->Fp); + else + fputc('A'-10+(ch&0xf), self->Fp); + + if( (i&0x1f)==0x1f ) + fputc('\n', self->Fp); + } + } + xfree(buf); + + /* Next block... */ + ch = fgetc(fp); + } + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (type == PsDFT_Type1PFA) + { + for(;;) + { + stt = fread(buf, 1, 256, fp); + if( stt<=0 ) break; + if (!ferror(self->Fp)) { + (void) fwrite(buf, 1, stt, self->Fp); + } + if( stt<256 ) + break; + } + } + fclose(fp); + S_Flush(self); + S_Comment(self, "%%EndFont"); + + /* Success... */ + return 1; +} + + + + + + diff --git a/xorg-server/hw/xprint/ps/psout.h b/xorg-server/hw/xprint/ps/psout.h new file mode 100644 index 000000000..1138e4afe --- /dev/null +++ b/xorg-server/hw/xprint/ps/psout.h @@ -0,0 +1,335 @@ +/* + +Copyright 1996, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* + * (c) Copyright 1996 Hewlett-Packard Company + * (c) Copyright 1996 International Business Machines Corp. + * (c) Copyright 1996 Sun Microsystems, Inc. + * (c) Copyright 1996 Novell, Inc. + * (c) Copyright 1996 Digital Equipment Corp. + * (c) Copyright 1996 Fujitsu Limited + * (c) Copyright 1996 Hitachi, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the names of the copyright holders + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from said copyright holders. + */ + +/******************************************************************* +** +** ********************************************************* +** * +** * File: psout.h +** * +** * Contents: Include file for psout.c +** * +** * Created By: Roger Helmendach (Liberty Systems) +** * +** * Copyright: Copyright 1996 The Open Group, Inc. +** * +** ********************************************************* +** +********************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef _psout_ +#define _psout_ + +#include <stdio.h> + +typedef enum PsCapEnum_ { PsCButt=0, PsCRound, PsCSquare } PsCapEnum; +typedef enum PsJoinEnum_ { PsJMiter=0, PsJRound, PsJBevel } PsJoinEnum; +typedef enum PsArcEnum_ { PsChord, PsPieSlice } PsArcEnum; +typedef enum PsRuleEnum_ { PsEvenOdd, PsNZWinding } PsRuleEnum; +typedef enum PsFillEnum_ { PsSolid=0, PsTile, PsStip, PsOpStip } PsFillEnum; + +typedef struct PsPointRec_ +{ + int x; + int y; +} PsPointRec; + +typedef PsPointRec *PsPointPtr; + +typedef struct PsRectRec_ +{ + int x; + int y; + int w; + int h; +} PsRectRec; + +typedef PsRectRec *PsRectPtr; + +typedef struct PsArcRec_ +{ + int x; + int y; + int w; + int h; + int a1; + int a2; + PsArcEnum style; +} PsArcRec; + +typedef PsArcRec *PsArcPtr; + +#define PSOUT_RECT 0 +#define PSOUT_ARC 1 +#define PSOUT_POINTS 2 + +typedef struct PsElmRec_ +{ + int type; + int nPoints; + union + { + PsRectRec rect; + PsArcRec arc; + PsPointPtr points; + } c; +} PsElmRec; + +typedef PsElmRec *PsElmPtr; + +typedef struct PsClipRec_ +{ + int nRects; + PsRectPtr rects; + int nElms; + PsElmPtr elms; + int nOutterClips; + PsRectPtr outterClips; +} PsClipRec; + +typedef PsClipRec *PsClipPtr; + +typedef enum PsFTDownloadFontType_ +{ + PsFontBitmap=0, + PsFontType1, + PsFontType3 +} PsFTDownloadFontType; + +/* Define |PsOutColor| color type which can hold one RGB value + * (note: this needs to be |signed| long/long long to represent + * special values such as |PSOUTCOLOR_NOCOLOR|) + */ +#ifdef PSOUT_USE_DEEPCOLOR +/* 64bit |PsOutColor| which can hold 16bit R-,G-,B-values */ +#ifdef WIN32 +typedef signed __int64 PsOutColor; +#else +# if defined(__alpha__) || defined(__alpha) || \ + defined(ia64) || defined(__ia64__) || \ + defined(__sparc64__) || defined(_LP64) || \ + defined(__s390x__) || \ + defined(amd64) || defined (__amd64__) || defined(__x86_64__) || \ + defined (__powerpc64__) || \ + (defined(sgi) && (_MIPS_SZLONG == 64)) +typedef signed long PsOutColor; +# else +typedef signed long long PsOutColor; +# endif /* native 64bit platform */ +#endif /* WIN32 */ + +#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 32) +#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 16) & 0xFFFF) +#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFFFF) +#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 65535.) +#define PSOUTCOLOR_WHITE (0xFFFFFFFFFFFFLL) +#define PSOUTCOLOR_NOCOLOR (-1LL) +#define PSOUTCOLOR_TO_RGB24BIT(clr) (((PSOUTCOLOR_TO_REDBITS(clr) >> 8) << 16) | \ + ((PSOUTCOLOR_TO_GREENBITS(clr) >> 8) << 8) | \ + ((PSOUTCOLOR_TO_BLUEBITS(clr) >> 8) << 0)) +#else +/* 32bit |PsOutColor| which can hold 8bit R-,G-,B-values */ +typedef signed long PsOutColor; +#define PSOUTCOLOR_TO_REDBITS(clr) ((clr) >> 16) +#define PSOUTCOLOR_TO_GREENBITS(clr) (((clr) >> 8) & 0xFF) +#define PSOUTCOLOR_TO_BLUEBITS(clr) ((clr) & 0xFF) +#define PSOUTCOLOR_BITS_TO_PSFLOAT(b) ((float)(b) / 255.) +#define PSOUTCOLOR_WHITE (0xFFFFFF) +#define PSOUTCOLOR_NOCOLOR (-1) +#define PSOUTCOLOR_TO_RGB24BIT(clr) ((PSOUTCOLOR_TO_REDBITS(clr) << 16) | \ + (PSOUTCOLOR_TO_GREENBITS(clr) << 8) | \ + (PSOUTCOLOR_TO_BLUEBITS(clr) << 0)) +#endif /* PSOUT_USE_DEEPCOLOR */ + +#ifdef USE_PSOUT_PRIVATE +typedef void *voidPtr; + +typedef struct PsPatRec_ +{ + PsFillEnum type; + voidPtr tag; +} PsPatRec; + +typedef PsPatRec *PsPatPtr; + +typedef struct PsOutRec_ +{ + FILE *Fp; + char Buf[16384]; + PsOutColor CurColor; + int LineWidth; + PsCapEnum LineCap; + PsJoinEnum LineJoin; + int NDashes; + int *Dashes; + int DashOffset; + PsOutColor LineBClr; + PsRuleEnum FillRule; + char *FontName; + int FontSize; + float FontMtx[4]; + int ImageFormat; + int RevImage; + int NPatterns; + int MxPatterns; + PsPatPtr Patterns; + int ClipType; + PsClipRec Clip; + int InFrame; + int XOff; + int YOff; + + PsFillEnum InTile; + int ImgSkip; + PsOutColor ImgBClr; + PsOutColor ImgFClr; + int ImgX; + int ImgY; + int ImgW; + int ImgH; + int SclW; + int SclH; + + Bool isRaw; + + int pagenum; + + int start_image; +} PsOutRec; + +typedef struct PsOutRec_ *PsOutPtr; + +extern void S_Flush(PsOutPtr self); +extern void S_OutNum(PsOutPtr self, float num); +extern void S_OutTok(PsOutPtr self, char *tok, int cr); +#else +typedef struct PsOutRec_ *PsOutPtr; +#endif /* USE_PSOUT_PRIVATE */ + +extern FILE * PsOut_ChangeFile(PsOutPtr self, FILE *fp); +extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, + int res, int wd, int ht, Bool raw); +extern void PsOut_EndFile(PsOutPtr self, int closeFile); +extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, + int res, int wd, int ht); +extern void PsOut_EndPage(PsOutPtr self); +extern void PsOut_DirtyAttributes(PsOutPtr self); +extern void PsOut_Comment(PsOutPtr self, char *comment); +extern void PsOut_Offset(PsOutPtr self, int x, int y); + +extern void PsOut_Clip(PsOutPtr self, int clpTyp, PsClipPtr clpinf); + +extern void PsOut_Color(PsOutPtr self, PsOutColor clr); +extern void PsOut_FillRule(PsOutPtr self, PsRuleEnum rule); +extern void PsOut_LineAttrs(PsOutPtr self, int wd, PsCapEnum cap, + PsJoinEnum join, int nDsh, int *dsh, int dshOff, + PsOutColor bclr); +extern void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso); +extern void PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso); + +extern void PsOut_Polygon(PsOutPtr self, int nPts, PsPointPtr pts); +extern void PsOut_FillRect(PsOutPtr self, int x, int y, int w, int h); +extern void PsOut_FillArc(PsOutPtr self, int x, int y, int w, int h, + float ang1, float ang2, PsArcEnum style); + +extern void PsOut_Lines(PsOutPtr self, int nPts, PsPointPtr pts); +extern void PsOut_Points(PsOutPtr self, int nPts, PsPointPtr pts); +extern void PsOut_DrawRect(PsOutPtr self, int x, int y, int w, int h); +extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h, + float ang1, float ang2); + +extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, + PsOutColor bclr); +extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, PsOutColor bclr); + +extern void PsOut_BeginImage(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, + int w, int h, int sw, int sh, int format); +extern void PsOut_BeginImageIM(PsOutPtr self, PsOutColor bclr, PsOutColor fclr, int x, int y, + int w, int h, int sw, int sh, int format); +extern void PsOut_EndImage(PsOutPtr self); +extern void PsOut_OutImageBytes(PsOutPtr self, int nBytes, char *bytes); + +extern void PsOut_BeginFrame(PsOutPtr self, int xoff, int yoff, int x, int y, + int w, int h); +extern void PsOut_EndFrame(PsOutPtr self); + +extern int PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, + PsFillEnum type, PsOutColor bclr, PsOutColor fclr); +extern void PsOut_EndPattern(PsOutPtr self); +extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type); + +extern void PsOut_RawData(PsOutPtr self, char *data, int len); + +extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname); + +extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); +extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); + +extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset); +extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex); +extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl); +extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl); + +extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso); +extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso); +#endif diff --git a/xorg-server/hw/xprint/ps/psout_ft.c b/xorg-server/hw/xprint/ps/psout_ft.c new file mode 100644 index 000000000..30939f972 --- /dev/null +++ b/xorg-server/hw/xprint/ps/psout_ft.c @@ -0,0 +1,337 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H + +#include <X11/Xproto.h> +#include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#include <X11/fonts/fntfilst.h> +#include <X11/fonts/fontutil.h> +#include <X11/fonts/fontenc.h> +#include <X11/fonts/ft.h> +#define NOT_IN_FTFUNCS +#include <X11/fonts/ftfuncs.h> +#include "servermd.h" /* needed for endian test (IMAGE_BYTE_ORDER) */ + +#define USE_FT_PS_NAMES 1 + +#ifdef USE_FT_PS_NAMES +void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex) +{ + FTFontPtr tf = (FTFontPtr)pFont->fontPrivate; + FT_Face ttface = tf->instance->face->face; + FT_Error error; + char buf[256]; + unsigned long ftindex; + + /* Remap X11 font index to FreeType font index */ + ftindex = FTRemap(ttface, &tf->mapping, x11fontindex); + + if( FT_Has_PS_Glyph_Names(ttface) ) + { + error = FT_Get_Glyph_Name(ttface, ftindex, buf, 64); + } + else + { + error = 1; + } + + if( error ) + { + /* Check for unicode mapping + * See Adobe document "Unicode and Glyph Names" + * (http://partners.adobe.com/asn/tech/type/unicodegn.jsp) + */ + if( (tf->mapping.mapping->type == FONT_ENCODING_UNICODE) && + (ftindex < 0xFFFE) ) + { + sprintf(buf, "uni%04lx", ftindex); + } + else + { + sprintf(buf, "ch%02lx", ftindex); + } + } + + strcpy(destbuf, buf); +} +#endif /* USE_FT_PS_NAMES */ + +int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset) +{ + switch(downloadfonttype) + { + case PsFontType3: + return PsOut_DownloadFreeType3(self, psfontname, pFont, block_offset); + case PsFontType1: + return PsOut_DownloadFreeType1(self, psfontname, pFont, block_offset); + default: + FatalError("PS DDX: PsOut_DownloadFreeType(downloadfonttype='%d' not implemented\n", + (int)downloadfonttype); + return 0; /* NO-OP, FatalError() will call |exit()| */ + } +} + +/* cloned from |PsOut_TextAttrs16| */ +void +PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso) +{ + int i; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + siz==self->FontSize ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + self->FontSize = siz; + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; +} + +/* cloned from |PsOut_TextAttrsMtx16| */ +void +PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso) +{ + int i; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && + mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = mtx[i]; + self->FontSize = -1; +} + +static +int FT_Get_CharcellMetricsCharacterHeight(FontPtr pFont) +{ + FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate; + + return ftfont->instance->charcellMetrics->ascent + + ftfont->instance->charcellMetrics->descent; +} + +static +int FT_Get_CharcellMetricsCharacterWidth(FontPtr pFont) +{ + FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate; + + if( ftfont->instance->spacing != FT_PROPORTIONAL ) + { + int width = ftfont->instance->charcellMetrics->characterWidth; + + /* If the font uses a matrix make sure we transform the |characterWidth| + * back to it's original value since we download the untransformed font + * and use a PostScript transformation matrix to transform the font when + * rendering the text + */ + if( ftfont->instance->transformation.nonIdentity ) + { + FT_Vector v; + + FT_Matrix m = ftfont->instance->transformation.matrix; + (void)FT_Matrix_Invert(&m); /* FixMe: We should check the return code */ + v.x = width; + v.y = FT_Get_CharcellMetricsCharacterHeight(pFont); + FT_Vector_Transform(&v, &m); + width = v.x; + } + + return width; + } + + return 0; +} + +void +PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl) +{ + int i; + int xo = self->XOff, + yo = self->YOff; + char buf[256]; + int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont); + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutTok(self, "moveto", 1); + + S_OutTok(self, "[ ", 0); + + for( i = 0 ; i < textl ; i++ ) + { +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + unsigned int ch = text[i]&0xFF; + unsigned long block_offset = 0; + PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset); + + sprintf(buf, "/%s ", namebuf); +#else + sprintf(buf, "/ch%02x ", text[i]&0xFF); +#endif /* USE_FT_PS_NAMES */ + S_OutTok(self, buf, 0); + } + + /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */ + if( cwidth != 0 ) + { + /* If the we use a matrix to render the font (instead of using |self->FontSize|) + * we must apply the matrix to the "rmoveto" which is used to force the exact + * character width. The "trmoveto" macro will do that for us... + */ + if( self->FontSize == -1 ) + { + sprintf(buf, "]{gs glyphshow gr %d 0 trmoveto}fa", cwidth); + } + else + { + sprintf(buf, "]{gs glyphshow gr %d 0 rm}fa", cwidth); + } + } + else + { + sprintf(buf, "]{glyphshow}fa"); + } + S_OutTok(self, buf, 0); +} + +/* XXX: |PsOut_FreeType_Text16| should be rewritten - currently it uses lame, + * slow hacks and makes some risky assumtions about how |PsOut_Text16| + * allocates memory */ +void +PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl) +{ + int i; + int xo = self->XOff, + yo = self->YOff; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + long lastFontPage = -1; + char baseFontName[256]; + char buf[256]; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + + strcpy(baseFontName, self->FontName); + + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutTok(self, "moveto", 1); + + for( i = 0 ; i < textl ; i++ ) + { + c = text[i]; +#if IMAGE_BYTE_ORDER == LSBFirst + c_hiByte = c & 0x00FF; + c_lowByte = (c >> 8) & 0x00FF; +#elif IMAGE_BYTE_ORDER == MSBFirst + c_hiByte = (c >> 8) & 0x00FF; + c_lowByte = c & 0x00FF; +#else +#error Unsupported byte order +#endif + fontPage = c_hiByte; + + if( fontPage != lastFontPage ) + { + if( fontPage > 0 ) + { + sprintf(buf, "%s_%x", baseFontName, fontPage); + } + else + { + sprintf(buf, "%s", baseFontName); + xfree(self->FontName); + self->FontName = NULL; + } + + if( self->FontSize == -1 ) + { + PsOut_TextAttrsMtx(self, buf, self->FontMtx, FALSE); + } + else + { + PsOut_TextAttrs(self, buf, self->FontSize, FALSE); + } + lastFontPage = fontPage; + } + +#ifdef USE_FT_PS_NAMES + { + char namebuf[256]; + unsigned int ch = c_lowByte; + unsigned long block_offset = c_hiByte * 0x100 /* same as c_hiByte << 8 */; + int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont); + PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset); + + /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */ + if( cwidth != 0 ) + { + /* If the we use a matrix to render the font (instead of using |self->FontSize|) + * we must apply the matrix to the "rmoveto" which is used to force the exact + * character width. The "trmoveto" macro will do that for us... + */ + if( self->FontSize == -1 ) + { + sprintf(buf, "gs /%s glyphshow gr %d 0 trmoveto", namebuf, cwidth); + } + else + { + sprintf(buf, "gs /%s glyphshow gr %d 0 rm", namebuf, cwidth); + } + } + else + { + sprintf(buf, "/%s glyphshow", namebuf); + } + } +#else + sprintf(buf, "/ch%02x glyphshow", c_lowByte); +#endif /* USE_FT_PS_NAMES */ + S_OutTok(self, buf, 1); + } + + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(baseFontName)+1); + strcpy(self->FontName, baseFontName); +} + diff --git a/xorg-server/hw/xprint/ps/psout_ftpstype1.c b/xorg-server/hw/xprint/ps/psout_ftpstype1.c new file mode 100644 index 000000000..572e13601 --- /dev/null +++ b/xorg-server/hw/xprint/ps/psout_ftpstype1.c @@ -0,0 +1,185 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <sys/wait.h> + +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include <X11/Xproto.h> +#include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#include <X11/fonts/fntfilst.h> +#include <X11/fonts/fontutil.h> +#include <X11/fonts/fontenc.h> +#include <X11/fonts/ft.h> +#define NOT_IN_FTFUNCS +#include <X11/fonts/ftfuncs.h> + +int do_debug_ft2pt1 = FALSE; +int do_enable_ft2pt1_optimizer = FALSE; + +/* Defined in ttf2pt1.c */ +int ft2pt1_main(int argc, char **argv, + FTFontPtr tf, const char *download_psfontname, unsigned long download_font_block_offset); + +/* Download FreeType outlines as PS Type1 font */ +int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset) +{ + FTFontPtr tf; + FT_Face face; + int ft2pt1_numargs = 0; + char *ft2pt1_args[40]; + char *pstype1filename_prefix; + char pstype1filename[PATH_MAX+1]; + int ft2pt1_main_retval; + pid_t childpid; + + tf = (FTFontPtr)pFont->fontPrivate; + face = tf->instance->face->face; + + /* Set debugging flags */ + do_debug_ft2pt1 = (getenv("XPRT_PSDDX_DO_DEBUG_FT2PT1") != NULL); + do_enable_ft2pt1_optimizer = (getenv("XPRT_PSDDX_DO_ENABLE_FT2PT1_OPTIMIZER") != NULL); + + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "# Converting FT2 font to PS Type1 filename='%s', ttface=%lx\n", tf->instance->face->filename, (long)face); + } + + pstype1filename_prefix = tempnam(NULL, "Xprt_"); + + ft2pt1_args[ft2pt1_numargs] = "ft2pt1"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Ob"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-e"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-a"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Ga"; ft2pt1_numargs++; + if( do_enable_ft2pt1_optimizer ) + { + /* Scale fonts to a 1000x1000 matrix */ + ft2pt1_args[ft2pt1_numargs] = "-Ot"; ft2pt1_numargs++; + } + else + { + /* Disable the ttf2pt1 optimisations */ + ft2pt1_args[ft2pt1_numargs] = "-Ou"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Oo"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Os"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Oh"; ft2pt1_numargs++; + } + + if( !do_debug_ft2pt1 ) + { + ft2pt1_args[ft2pt1_numargs] = "-W 0"; ft2pt1_numargs++; + } + ft2pt1_args[ft2pt1_numargs] = tf->instance->face->filename; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = pstype1filename_prefix; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = NULL; + +/* XXX: ttf2pt1 has lots of leaks and global vars which are not cleaned-up + * As long this problem exists we will simply fork() and call the converter + * from the child process (all resources are free'ed when the child process + * exists) as a workaround. + */ +#define FT2PT1_NEEDS_SEPERATE_PROCESS 1 + +#ifdef FT2PT1_NEEDS_SEPERATE_PROCESS + /* Flush internal buffer and then the stdio stream before fork()! */ + S_Flush(self); + fflush(self->Fp); + + childpid = fork(); + switch(childpid) + { + case -1: + FatalError("PS DDX internal error: Cannot fork() converter child process, %s\n", strerror(errno)); + break; + case 0: /* child */ + fclose(self->Fp); + self->Fp = NULL; + + ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval); + } + exit(ft2pt1_main_retval); + break; + default: /* parent */ + waitpid(childpid, &ft2pt1_main_retval, 0); + break; + } + + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (parent)\n", ft2pt1_main_retval); + } +#else + S_Flush(self); + + ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval); + } +#endif /* FT2PT1_NEEDS_SEPERATE_PROCESS */ + + if( ft2pt1_main_retval != EXIT_SUCCESS ) + { + FatalError("PS DDX internal error while converting FreeType font '%s' to PS Type1, error=%d\n", + tf->instance->face->filename, ft2pt1_main_retval); + } + + sprintf(pstype1filename, "%s.pfa", pstype1filename_prefix); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "# Downloading converted FT2/PS Type1 filename='%s'\n", pstype1filename); + } + + PsOut_DownloadType1(self, "PsOut_DownloadFreeType1", psfontname, pstype1filename); + + if( !do_debug_ft2pt1 ) + { + unlink(pstype1filename); + } + + free(pstype1filename_prefix); + + S_Flush(self); + + return 0; +} + + diff --git a/xorg-server/hw/xprint/ps/psout_ftpstype3.c b/xorg-server/hw/xprint/ps/psout_ftpstype3.c new file mode 100644 index 000000000..733b5386b --- /dev/null +++ b/xorg-server/hw/xprint/ps/psout_ftpstype3.c @@ -0,0 +1,439 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TRUETYPE_TABLES_H +#include FT_BBOX_H +#include FT_GLYPH_H + +#include FT_CONFIG_CONFIG_H +#include FT_CONFIG_OPTIONS_H +#include FT_ERRORS_H +#include FT_SYSTEM_H +#include FT_IMAGE_H +#include FT_TYPES_H +#include FT_OUTLINE_H +#include FT_MODULE_H +#include FT_RENDER_H +#include FT_TYPE1_TABLES_H +#include FT_TRUETYPE_IDS_H +#include FT_TRUETYPE_TAGS_H +#include FT_CACHE_H +#include FT_CACHE_IMAGE_H +#include FT_CACHE_SMALL_BITMAPS_H +#include FT_MULTIPLE_MASTERS_H +#include FT_SFNT_NAMES_H + +#include <X11/Xproto.h> +#include <X11/fonts/font.h> +#include <X11/fonts/fontstruct.h> +#include <X11/fonts/fntfilst.h> +#include <X11/fonts/fontutil.h> +#include <X11/fonts/fontenc.h> +#include <X11/fonts/ft.h> +#define NOT_IN_FTFUNCS +#include <X11/fonts/ftfuncs.h> + +struct ft2info +{ + FontPtr pFont; + FTFontPtr tf; + FT_Face ttface; + struct + { + char *full_name; + char *copyright; + char *family; + char *subfamily; + char *version; + } nameid; + TT_Postscript *ttpostscript; + TT_Header *ttheader; +}; + +/* Local prototypes */ +static FT_Error PSType3_createOutlineGlyphs(FILE *out, struct ft2info *ti, unsigned long unicode, const char *psglyphname); +static int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset); + +extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */ + +#define USE_FT_PS_NAMES 1 + +static +FT_Error PSType3_createOutlineGlyphs( FILE *out, struct ft2info *ti, unsigned long x11fontindex, const char *psglyphname ) +{ + unsigned long ftindex; + FT_BBox bbox; + FT_Error error; + FT_Outline outline; + + /* Remap X11 font index to FreeType font index */ + ftindex = FTRemap(ti->ttface, &ti->tf->mapping, x11fontindex); + + error = FT_Load_Glyph(ti->ttface, ftindex, (FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING)); + if( error ) + { + fprintf(stderr, "PSType3_createOutlineGlyphs: FT_Load_Glyph() failure, error=%d\n", (int)error); + return error; + } + + outline = ti->ttface->glyph->outline; + + FT_Outline_Get_CBox(&outline, &bbox); + + fprintf(out, "/%s {\n", psglyphname); + fprintf(out, "%ld 0 %ld %ld %ld %ld setcachedevice\n", + (signed long)ti->ttface->glyph->metrics.horiAdvance, + (long)bbox.xMin, + (long)bbox.yMin, + (long)bbox.xMax, + (long)bbox.yMax); + + if( outline.n_contours > 0 ) + { + long i, + j, + k, k1, + cs, ce, + nguide, + contour_start, + contour_end, + last_point; + Bool first; + FT_Vector *vec; + + contour_start = ce = 0; + + vec = outline.points; + last_point = outline.n_points; + + i = j = k = 0; + first = TRUE; + + while( i <= outline.contours[outline.n_contours - 1] ) + { + contour_end = outline.contours[j]; + + if( first ) + { + fprintf(out, "%ld %ld moveto\n", vec[i].x, vec[i].y); + contour_start = i; + first = FALSE; + } + else if( outline.tags[i] & FT_CURVE_TAG_ON ) + { + fprintf(out, "%ld %ld lineto\n", vec[i].x, vec[i].y); + } + else + { + Bool finished = FALSE; + + cs = i-1; + nguide = 0; + while( !finished ) + { + if( i == contour_end+1 ) + { + ce = contour_start; + finished = TRUE; + } + else if( outline.tags[i] & FT_CURVE_TAG_ON ) + { + ce = i; + finished = TRUE; + } + else + { + i++; + nguide++; + } + } + + switch( nguide ) + { + case 0: + fprintf(out, "%ld %ld lineto\n", vec[ce].x, vec[ce].y); + break; + + case 1: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (2*vec[cs+1].x+vec[ce].x)/3, + (2*vec[cs+1].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + case 2: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (-vec[cs].x+4*vec[cs+1].x)/3, + (-vec[cs].y+4*vec[cs+1].y)/3, + (4*vec[cs+2].x-vec[ce].x)/3, + (4*vec[cs+2].y-vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + case 3: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (5*vec[cs+1].x+vec[cs+2].x)/6, + (5*vec[cs+1].y+vec[cs+2].y)/6, + (vec[cs+1].x+vec[cs+2].x)/2, + (vec[cs+1].y+vec[cs+2].y)/2); + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs+1].x+5*vec[cs+2].x)/6, + (vec[cs+1].y+5*vec[cs+2].y)/6, + (5*vec[cs+2].x+vec[cs+3].x)/6, + (5*vec[cs+2].y+vec[cs+3].y)/6, + (vec[cs+3].x+vec[cs+2].x)/2, + (vec[cs+3].y+vec[cs+2].y)/2); + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs+2].x+5*vec[cs+3].x)/6, + (vec[cs+2].y+5*vec[cs+3].y)/6, + (2*vec[cs+3].x+vec[ce].x)/3, + (2*vec[cs+3].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + default: /* anything |nguide > 3| */ + k1 = cs + nguide; + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (5*vec[cs+1].x+vec[cs+2].x)/6, + (5*vec[cs+1].y+vec[cs+2].y)/6, + (vec[cs+1].x+vec[cs+2].x)/2, + (vec[cs+1].y+vec[cs+2].y)/2); + + for( k = cs+2 ; k <= k1-1 ; k++ ) + { + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[k-1].x+5*vec[k].x)/6, + (vec[k-1].y+5*vec[k].y)/6, + (5*vec[k].x+vec[k+1].x)/6, + (5*vec[k].y+vec[k+1].y)/6, + (vec[k].x+vec[k+1].x)/2, + (vec[k].y+vec[k+1].y)/2); + } + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[k1-1].x+5*vec[k1].x)/6, + (vec[k1-1].y+5*vec[k1].y)/6, + (2*vec[k1].x+vec[ce].x)/3, + (2*vec[k1].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + } + } + + if( i >= contour_end ) + { + fprintf(out, "closepath\n"); + first = TRUE; + i = contour_end + 1; + j++; + } + else + { + i++; + } + } + } + + fprintf(out, "fill } bind def\n"); + + return 0; +} + +static +int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset) +{ + long i; + double scaler; + const int numchars = 256; +#ifdef USE_FT_PS_NAMES + int linewidth = 0; +#endif /* USE_FT_PS_NAMES */ + + fprintf(out, "%%%%BeginFont: %s\n", psfontname); + fprintf(out, "22 dict begin\n"); + fprintf(out, "/FontType 3 def\n"); + fprintf(out, "/StrokeWidth 0 def\n"); + fprintf(out, "/PaintType 0 def\n"); + fprintf(out, "/FontName (%s) def\n", psfontname); + fprintf(out, "/FontInfo 9 dict dup begin\n"); + fprintf(out, " /FullName (%s) def\n", ti->nameid.full_name?ti->nameid.full_name:psfontname); + fprintf(out, " /Notice (%s) def\n", ti->nameid.copyright?ti->nameid.copyright:"nothing here"); + fprintf(out, " /FamilyName (%s) def\n", ti->nameid.family?ti->nameid.family:psfontname); + fprintf(out, " /Weight (%s) def\n", ti->nameid.subfamily?ti->nameid.subfamily:"Regular"); + fprintf(out, " /version (%s) def\n", ti->nameid.version?ti->nameid.version:"0.1"); + + if( ti->ttpostscript ) + { + fprintf(out, " /italicAngle %.9g def\n", (double)ti->ttpostscript->italicAngle); + fprintf(out, " /underlineThickness %d def\n", (int)ti->ttpostscript->underlineThickness); + fprintf(out, " /underlinePosition %d def\n", (int)ti->ttpostscript->underlinePosition); + fprintf(out, " /isFixedPitch %s def\n", ((ti->ttpostscript->isFixedPitch)?("true"):("false"))); + } + else + { + fprintf(out, " /italicAngle %.9g def\n", 0.0); + fprintf(out, " /underlineThickness %d def\n", 100); + fprintf(out, " /underlinePosition %d def\n", 0); + fprintf(out, " /isFixedPitch false def\n"); + } + + fprintf(out, "end def\n"); + + scaler = (1000.0 / (double)ti->ttface->units_per_EM) / 1000.0; + fprintf(out, "/FontMatrix [%.9g 0 0 %.9g 0 0] def\n", scaler, scaler); + + if( ti->ttheader ) + { + fprintf(out, "/FontBBox [%d %d %d %d] def\n", + (int)ti->ttheader->xMin, + (int)ti->ttheader->yMin, + (int)ti->ttheader->xMax, + (int)ti->ttheader->yMax); + } + else + { + fprintf(out, "/FontBBox [%ld %ld %ld %ld] def\n", + ti->ttface->bbox.xMin, + ti->ttface->bbox.yMin, + ti->ttface->bbox.xMax, + ti->ttface->bbox.yMax); + + } + + fprintf(out, "/Encoding [\n"); + for( i = 0 ; i < 256 ; i++ ) + { +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset); + linewidth += strlen(namebuf) + 2; + fprintf(out, "/%s%s", namebuf, (linewidth > 70)?(linewidth = 0, "\n"):(" ")); +#else + fprintf(out, "/ch%02x%s", i, (((i % 10) == 9)?("\n"):(" "))); +#endif /* USE_FT_PS_NAMES */ + } + fprintf(out, "] def\n"); + + fprintf(out, "/CharProcs %d dict def CharProcs begin\n", (int)(numchars + 1)); + fprintf(out, "/.notdef {\n" + "1000 0 0 0 0 0 setcachedevice\n" + "fill } bind def\n"); + for( i = 0 ; i < numchars ; i++ ) + { + char buf[32]; +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset); + sprintf(buf, "%s ", namebuf); +#else + sprintf(buf, "ch%02lx ", i); +#endif /* USE_FT_PS_NAMES */ + PSType3_createOutlineGlyphs(out, ti, i+block_offset, buf); + } + fprintf(out, "end\n" + "/BuildGlyph {\n" + " exch /CharProcs get exch\n" + " 2 copy known not {pop /.notdef} if get exec } bind def\n" + "/BuildChar { 1 index /Encoding get exch get\n" + " 1 index /Encoding get exec } bind def\n"); + fprintf(out, "currentdict end /%s exch definefont pop\n", psfontname); + fprintf(out, "%%EndFont\n"); + + return 0; +} + +static +char *FT_Get_TT_NAME_ID(FT_Face ttface, int index) +{ + FT_SfntName name; + char *s; + + if( index >= FT_Get_Sfnt_Name_Count(ttface) ) + return NULL; + + FT_Get_Sfnt_Name(ttface, index, &name); + s = (char *)malloc(name.string_len+2); + if( !s ) + return NULL; + memcpy(s, (char *)name.string, name.string_len); + s[name.string_len] = '\0'; + return s; +} + +int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset) +{ + struct ft2info cft2info = { 0 }; + struct ft2info *ti = &cft2info; + + S_Flush(self); + + ti->tf = (FTFontPtr)pFont->fontPrivate; + ti->ttface = ti->tf->instance->face->face; + ti->pFont = pFont; +#ifdef DEBUG_gisburn + fprintf(stderr, "# Downloading FT2 font filename='%s', ttface=%lx\n", ti->tf->instance->face->filename, (long)ti->ttface); +#endif /* DEBUG_gisburn */ + + ti->nameid.full_name = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FULL_NAME); + ti->nameid.copyright = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_COPYRIGHT); + ti->nameid.family = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_FAMILY); + ti->nameid.subfamily = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_SUBFAMILY); + ti->nameid.version = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_VERSION_STRING); + + ti->ttheader = (TT_Header *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_head); + ti->ttpostscript = (TT_Postscript *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_post); + + PSType3_generateOutlineFont(self->Fp, psfontname, ti, block_offset); + + free(ti->nameid.full_name); + free(ti->nameid.copyright); + free(ti->nameid.family); + free(ti->nameid.subfamily); + free(ti->nameid.version); + + S_Flush(self); + + return 0; +} + diff --git a/xorg-server/hw/xprint/ps/ttf2pt1wrap.c b/xorg-server/hw/xprint/ps/ttf2pt1wrap.c new file mode 100644 index 000000000..57bb777d2 --- /dev/null +++ b/xorg-server/hw/xprint/ps/ttf2pt1wrap.c @@ -0,0 +1,14 @@ +/* + * Wrapper to add missing symbol to externally supplied code + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifdef Lynx +extern int optind; +extern char *optarg; +#endif + +#include "ttf2pt1.c" |