aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/Xprint/pcl
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/Xprint/pcl')
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Imakefile76
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Pcl.h625
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclArc.c270
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclArea.c486
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c207
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c87
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclColor.c851
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c115
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclDef.h68
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c74
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclGC.c1046
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclInit.c631
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclLine.c316
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c306
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c159
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c85
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c353
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c711
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c429
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h116
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c139
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclText.c936
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c452
-rw-r--r--nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h213
24 files changed, 8751 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Imakefile b/nx-X11/programs/Xserver/Xprint/pcl/Imakefile
new file mode 100644
index 000000000..310ae9e20
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Imakefile
@@ -0,0 +1,76 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:07 cpqbld Exp $
+
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/Xprint/pcl/Imakefile,v 1.7 2001/08/01 00:44:45 tsi Exp $
+
+#include <Server.tmpl>
+
+#ifndef PixelSize
+#define PixelSize 8
+#endif
+
+#ifdef PclDriver
+PCL_DRIVER = PclDriver
+#else
+PCL_DRIVER = -DXP_PCL_COLOR
+#endif
+
+SRCS1 = PclInit.c PclMisc.c PclWindow.c PclFonts.c PclPrint.c \
+ PclArea.c PclArc.c PclGC.c PclLine.c PclPixel.c PclPolygon.c \
+ PclSpans.c PclText.c PclCursor.c PclAttr.c PclPixmap.c PclSFonts.c \
+ PclColor.c PclAttVal.c
+
+OBJS1 = PclInit.o PclMisc.o PclWindow.o PclFonts.o PclPrint.o \
+ PclArea.o PclArc.o PclGC.o PclLine.o PclPixel.o PclPolygon.o \
+ PclSpans.o PclText.o PclCursor.o PclAttr.o PclPixmap.o PclSFonts.o \
+ PclColor.o PclAttVal.o
+
+SRCS = $(SRCS1)
+
+OBJS = $(OBJS1)
+
+DEFINES = -DPSZ=PixelSize $(PCL_DRIVER) -UXFree86LOADER -D_XP_PRINT_SERVER_
+
+ INCLUDES = -I. -I$(XINCLUDESRC) -I.. -I$(LIBSRC) \
+ -I../../include -I$(TOP)/include \
+ -I$(TOP)/include/extensions -I$(TOP)/include/fonts \
+ -I../../mi -I../../mfb -I../../cfb
+
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../../mfb/llib-lmfb.ln ../../mi/llib-lmi.ln \
+ ../../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(pcl,$(OBJS))
+NormalLintTarget($(SRCS1) $(SRCS2))
+#ifdef LinkDirectory
+LinkSourceFile(Pcl.h,LinkDirectory)
+LinkSourceFile(Pclmap.h,LinkDirectory)
+LinkSourceFile(PclDef.h,LinkDirectory)
+LinkSourceFile(PclSFonts.h,LinkDirectory)
+
+LinkSourceFile(PclArc.c,LinkDirectory)
+LinkSourceFile(PclArea.c,LinkDirectory)
+LinkSourceFile(PclAttr.c,LinkDirectory)
+LinkSourceFile(PclAttVal.c,LinkDirectory)
+LinkSourceFile(PclColor.c,LinkDirectory)
+LinkSourceFile(PclCursor.c,LinkDirectory)
+LinkSourceFile(PclFonts.c,LinkDirectory)
+LinkSourceFile(PclGC.c,LinkDirectory)
+LinkSourceFile(PclInit.c,LinkDirectory)
+LinkSourceFile(PclLine.c,LinkDirectory)
+LinkSourceFile(PclMisc.c,LinkDirectory)
+LinkSourceFile(PclPixel.c,LinkDirectory)
+LinkSourceFile(PclPixmap.c,LinkDirectory)
+LinkSourceFile(PclPolygon.c,LinkDirectory)
+LinkSourceFile(PclPrint.c,LinkDirectory)
+LinkSourceFile(PclSFonts.c,LinkDirectory)
+LinkSourceFile(PclSpans.c,LinkDirectory)
+LinkSourceFile(PclText.c,LinkDirectory)
+LinkSourceFile(PclWindow.c,LinkDirectory)
+#endif
+
+DependTarget()
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h b/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h
new file mode 100644
index 000000000..bb1f52b2c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Pcl.h
@@ -0,0 +1,625 @@
+/* $Xorg: Pcl.h,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: Pcl.h
+** *
+** * Contents: defines and includes for the Pcl driver
+** * for a printing X server.
+** *
+** * Created: 1/30/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/Pcl.h,v 1.12 2001/12/21 21:02:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCL_H_
+#define _PCL_H_
+
+#include <stdio.h>
+#include "scrnintstr.h"
+
+#include "PclDef.h"
+#include "Pclmap.h"
+#include "PclSFonts.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;
+#endif
+#define Status int
+#define True 1
+#define False 0
+#include "misc.h"
+#include <X11/Xfuncproto.h>
+#include <X11/Xresource.h>
+#include "attributes.h"
+
+/******
+ * externally visible variables from PclInit.c
+ ******/
+extern int PclScreenPrivateIndex, PclWindowPrivateIndex;
+extern int PclContextPrivateIndex;
+extern int PclPixmapPrivateIndex;
+extern int PclGCPrivateIndex;
+
+/******
+ * externally visible variables from PclAttVal.c
+ ******/
+extern XpValidatePoolsRec PclValidatePoolsRec;
+
+/*
+ * This structure defines a mapping from an X colormap ID to a list of
+ * print contexts which use the colormap.
+ */
+typedef struct _pclcontextlist {
+ XpContextPtr context;
+ struct _pclcontextlist *next;
+} PclContextList, *PclContextListPtr;
+
+typedef struct _pclcmaptocontexts {
+ long colormapId;
+ PclContextListPtr contexts;
+ struct _pclcmaptocontexts *next;
+} PclCmapToContexts;
+
+typedef struct {
+ PclCmapToContexts *colormaps;
+ CloseScreenProcPtr CloseScreen;
+} PclScreenPrivRec, *PclScreenPrivPtr;
+
+/*
+ * This structure defines a mapping from an X colormap ID to a PCL
+ * palette ID.
+ */
+typedef struct _palettemap {
+ long colormapId;
+ int paletteId;
+ int downloaded;
+ struct _palettemap *next;
+} PclPaletteMap, *PclPaletteMapPtr;
+
+typedef struct {
+ char *jobFileName;
+ FILE *pJobFile;
+ char *pageFileName;
+ FILE *pPageFile;
+ GC lastGC;
+ unsigned char *dash;
+ int validGC;
+ ClientPtr getDocClient;
+ int getDocBufSize;
+ PclSoftFontInfoPtr pSoftFontInfo;
+ PclPaletteMapPtr palettes;
+ int currentPalette;
+ int nextPaletteId;
+ PclPaletteMap staticGrayPalette;
+ PclPaletteMap trueColorPalette;
+ PclPaletteMap specialTrueColorPalette;
+ unsigned char *ctbl;
+ int ctbldim;
+ int isRaw;
+#ifdef XP_PCL_LJ3
+ unsigned int fcount;
+ unsigned int fcount_max;
+ char *figures;
+#endif /* XP_PCL_LJ3 */
+} PclContextPrivRec, *PclContextPrivPtr;
+
+typedef struct {
+ int validContext;
+ XpContextPtr context;
+} PclWindowPrivRec, *PclWindowPrivPtr;
+
+typedef struct {
+ unsigned long stippleFg, stippleBg;
+} PclGCPrivRec, *PclGCPrivPtr;
+
+typedef struct {
+ XpContextPtr context;
+ char *tempFileName;
+ FILE *tempFile;
+ GC lastGC;
+ int validGC;
+} PclPixmapPrivRec, *PclPixmapPrivPtr;
+
+/******
+ * Defined functions
+ ******/
+#define SEND_PCL(f,c) fwrite( c, sizeof( char ), strlen( c ), f )
+#define SEND_PCL_COUNT(f,c,n) fwrite( c, sizeof( char ), n, f )
+
+#ifndef XP_PCL_LJ3
+#define SAVE_PCL(f,p,c) SEND_PCL(f,c)
+#define SAVE_PCL_COUNT(f,p,c,n) SEND_PCL_COUNT(f,c,n)
+#define MACRO_START(f,p) SEND_PCL(f, "\033&f1Y\033&f0X")
+#define MACRO_END(f) SEND_PCL(f, "\033&f1X")
+#else
+#define SAVE_PCL(f,p,c) PclSpoolFigs(p, c, strlen(c))
+#define SAVE_PCL_COUNT(f,p,c,n) PclSpoolFigs(p, c, n)
+#define MACRO_START(f,p) p->fcount = 0
+#define MACRO_END(f) /* do nothing */
+#endif /* XP_PCL_LJ3 */
+
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#ifndef MAX
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/******
+ * Functions in PclArc.c
+ ******/
+extern void PclPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs);
+extern void PclPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs);
+
+/******
+ * Functions in PclArea.c
+ ******/
+extern void PclPutImage(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage);
+extern RegionPtr PclCopyArea(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty);
+RegionPtr PclCopyPlane(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long plane);
+
+
+/******
+ * Functions in PclAttr.c
+ ******/
+extern char *PclGetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool );
+extern char *PclGetOneAttribute(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attr );
+extern int PclAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs );
+extern int PclSetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs );
+
+/******
+ * Functions in PclColor.c
+ ******/
+extern Bool PclCreateDefColormap(ScreenPtr pScreen);
+extern Bool PclCreateColormap(ColormapPtr pColor);
+extern void PclDestroyColormap(ColormapPtr pColor);
+extern void PclInstallColormap(ColormapPtr pColor);
+extern void PclUninstallColormap(ColormapPtr pColor);
+extern int PclListInstalledColormaps(ScreenPtr pScreen,
+ XID *pCmapList);
+extern void PclStoreColors(ColormapPtr pColor,
+ int ndef,
+ xColorItem *pdefs);
+extern void PclResolveColor(unsigned short *pRed,
+ unsigned short *pGreen,
+ unsigned short *pBlue,
+ VisualPtr pVisual);
+extern int PclUpdateColormap(DrawablePtr pDrawable,
+ XpContextPtr pCon,
+ GCPtr gc,
+ FILE *outFile);
+extern void PclLookUp(ColormapPtr cmap,
+ PclContextPrivPtr cPriv,
+ unsigned short *r,
+ unsigned short *g,
+ unsigned short *b);
+extern PclPaletteMapPtr PclFindPaletteMap(PclContextPrivPtr cPriv,
+ ColormapPtr cmap,
+ GCPtr gc);
+extern unsigned char *PclReadMap(char *, int *);
+
+
+/******
+ * Functions in PclCursor.c
+ ******/
+extern void PclConstrainCursor(
+ ScreenPtr pScreen,
+ BoxPtr pBox);
+extern void PclCursorLimits(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftbox);
+extern Bool PclDisplayCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern Bool PclRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern Bool PclUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor);
+extern void PclRecolorCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed);
+extern Bool PclSetCursorPosition(
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent);
+
+/******
+ * Functions in PclSFonts.c
+ ******/
+extern void
+PclDownloadSoftFont8(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead8Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char *code);
+extern void PclDownloadSoftFont16(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead16Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char row,
+ unsigned char col);
+extern PclSoftFontInfoPtr PclCreateSoftFontInfo(void);
+extern void PclDestroySoftFontInfo(
+ PclSoftFontInfoPtr pSoftFontInfo );
+
+/******
+ * Functions in PclGC.c
+ ******/
+extern Bool PclCreateGC(GCPtr pGC);
+extern void PclDestroyGC(GCPtr pGC);
+extern int PclUpdateDrawableGC(
+ GCPtr pGC,
+ DrawablePtr pDrawable,
+ FILE **outFile);
+extern void PclValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable);
+extern void PclSetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC gc );
+extern int PclGetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC *gc,
+ unsigned long *valid,
+ FILE **file );
+extern void PclSetDrawablePrivateGC(
+ DrawablePtr pDrawable,
+ GC gc);
+extern void PclComputeCompositeClip(
+ GCPtr pGC,
+ DrawablePtr pDrawable);
+
+/******
+ * Functions in PclInit.c
+ ******/
+extern Bool PclCloseScreen(
+ int index,
+ ScreenPtr pScreen);
+extern Bool InitializeColorPclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern Bool InitializeMonoPclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern Bool InitializeLj3PclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv);
+extern XpContextPtr PclGetContextFromWindow( WindowPtr win );
+
+/******
+ * Functions in PclLine.c
+ ******/
+extern void PclPolyLine(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints);
+extern void PclPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSegments,
+ xSegment *pSegments);
+
+/******
+ * Functions in PclMisc.c
+ ******/
+extern void PclQueryBestSize(
+ int class,
+ short *pwidth,
+ short *pheight,
+ ScreenPtr pScreen);
+extern char *GetPropString(WindowPtr pWin, char *propName);
+extern int SystemCmd(char *cmdStr);
+extern int PclGetMediumDimensions(
+ XpContextPtr pCon,
+ CARD16 *pWidth,
+ CARD16 *pHeight);
+extern int PclGetReproducibleArea(
+ XpContextPtr pCon,
+ xRectangle *pRect);
+extern void PclSendData(
+ FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ BoxPtr pbox,
+ int nbox,
+ double ratio);
+
+/******
+ * Functions in PclPixel.c
+ ******/
+extern void PclPolyPoint(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints);
+extern void PclPushPixels(
+ GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int width,
+ int height,
+ int x,
+ int y);
+
+/******
+ * Functions in PclPixmap.c
+ ******/
+extern PixmapPtr PclCreatePixmap(
+ ScreenPtr pScreen,
+ int width,
+ int height,
+ int depth);
+extern Bool PclDestroyPixmap(PixmapPtr pPixmap);
+
+/******
+ * Functions in PclPolygon.c
+ ******/
+extern void PclPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects);
+extern void PclFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nPoints,
+ DDXPointPtr pPoints);
+extern void PclPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects);
+
+/******
+ * Functions in PclSpans.c
+ ******/
+extern void PclFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted);
+extern void PclSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ int fSorted);
+
+/******
+ * Functions in PclText.c
+ ******/
+extern int PclPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string);
+extern int PclPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string);
+extern void PclImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string);
+extern void PclImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string);
+extern void PclImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+extern void PclPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase);
+
+/******
+ * Functions in PclWindow.c
+ ******/
+extern Bool PclCreateWindow(register WindowPtr pWin);
+extern Bool PclDestroyWindow(WindowPtr pWin);
+extern Bool PclMapWindow(WindowPtr pWindow);
+extern Bool PclPositionWindow(
+ register WindowPtr pWin,
+ int x,
+ int y);
+extern Bool PclUnmapWindow(WindowPtr pWindow);
+extern void PclCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
+extern Bool PclChangeWindowAttributes(
+ register WindowPtr pWin,
+ register unsigned long mask);
+extern void PclPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what);
+
+/******
+ * Functions in PclFonts.c
+ ******/
+extern Bool PclRealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont);
+extern Bool PclUnrealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont);
+
+/******
+ * Functions in PclPrint.c
+ ******/
+extern int PclStartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client);
+extern int PclEndJob(
+ XpContextPtr pCon,
+ Bool cancel);
+extern int PclStartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+extern int PclEndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin);
+extern int PclStartDoc(XpContextPtr pCon,
+ XPDocumentType type);
+extern int PclEndDoc(
+ XpContextPtr pCon,
+ Bool cancel);
+extern int PclDocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pFmt,
+ int len_fmt,
+ char *pOpt,
+ int len_opt,
+ ClientPtr client);
+extern int PclGetDocumentData(
+ XpContextPtr pCon,
+ ClientPtr client,
+ int maxBufferSize);
+
+
+#endif /* _PCL_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c b/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c
new file mode 100644
index 000000000..d675e1699
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclArc.c
@@ -0,0 +1,270 @@
+/* $Xorg: PclArc.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclArc.c
+** *
+** * Contents:
+** * Arc-drawing code for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclArc.c,v 1.4 1999/12/13 02:12:53 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <errno.h>
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "attributes.h"
+
+static void
+PclDoArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs,
+ void (*DoIt)(FILE *, PclContextPrivPtr, double, double, xArc))
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ BoxRec r;
+ RegionPtr drawRegion, region, transClip;
+ short fudge;
+ int xoffset, yoffset;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ xRectangle repro;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ fudge = 3 * pGC->lineWidth;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ XpGetReproductionArea( pCon, &repro );
+
+ /*
+ * Generate the PCL code to draw the collection of arcs, by
+ * defining it as a macro which uses the HP-GL/2 arc drawing
+ * function.
+ */
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0; i < nArcs; i++ )
+ {
+ xArc Arc = pArcs[i];
+ double b, X, Y, ratio;
+ double angle1;
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ /* Calculate the start of the arc */
+ if( ( Arc.angle1 / 64 ) % 360 == 90 )
+ {
+ X = 0;
+ Y = -Arc.height / 2.0;
+ }
+ else if( ( Arc.angle1 / 64 ) % 360 == 270 )
+ {
+ X = 0;
+ Y = Arc.height / 2.0;
+ }
+ else
+ {
+ /* Convert the angle to radians */
+ angle1 = ( Arc.angle1 / 64.0 ) * 3.141592654 / 180.0;
+
+ b = (Arc.height / 2.0);
+ X = b * cos( angle1 );
+ Y = -b * sin( angle1 );
+ }
+
+ /* Change the coordinate system to scale the ellipse */
+ ratio = (double)Arc.height / (double)Arc.width;
+
+ sprintf( t, "SC%.2f,%.2f,%d,%d;",
+ (repro.x - Arc.width / 2 - xoffset - Arc.x) * ratio,
+ (repro.x - Arc.width / 2 - xoffset - Arc.x +
+ repro.width) * ratio,
+ repro.y - Arc.height / 2 - yoffset - Arc.y + repro.height,
+ repro.y - Arc.height / 2 - yoffset - Arc.y);
+ SAVE_PCL( outFile, pConPriv, t );
+
+ DoIt( outFile, pConPriv, X, Y, Arc );
+
+ /* Build the bounding box */
+ r.x1 = -Arc.width / 2 - fudge;
+ r.y1 = -Arc.height / 2 - fudge;
+ r.x2 = Arc.width / 2 + fudge;
+ r.y2 = Arc.height / 2 + fudge;
+ drawRegion = REGION_CREATE( pGC->pScreen, &r, 0 );
+
+ SAVE_PCL( outFile, pConPriv, "\033%0A" );
+ MACRO_END( outFile );
+
+ /*
+ * Intersect the bounding box with the clip region.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ transClip = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ REGION_COPY( pGC->pScreen, transClip, pGC->pCompositeClip );
+ REGION_TRANSLATE( pGC->pScreen, transClip,
+ -(xoffset + Arc.x + Arc.width / 2),
+ -(yoffset + Arc.y + Arc.height / 2) );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, transClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the collection of arcs to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, ratio);
+
+ /*
+ * Restore the coordinate system
+ */
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x,
+ repro.x + repro.width, repro.y + repro.height,
+ repro.y );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ REGION_DESTROY( pGC->pScreen, transClip );
+ }
+}
+
+/*
+ * Draw a simple non-filled arc, centered on the origin and starting
+ * at the given point.
+ */
+static void
+DrawArc(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU%d,%d;PD;AA0,0,%.2f;", (int)X, (int)Y,
+ (float)A.angle2 / -64.0 );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+void
+PclPolyArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DrawArc );
+}
+
+/*
+ * Draw a filled wedge, from the origin, to the given point, through
+ * the appropriate angle, and back to the origin.
+ */
+static void
+DoWedge(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU0,0;WG%.2f,%.2f,%.2f;", sqrt( X * X + Y * Y ),
+ (float)A.angle1 / -64.0,
+ (float)A.angle2 / -64.0 );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+static void
+DoChord(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ double X,
+ double Y,
+ xArc A)
+{
+ char t[80];
+
+ sprintf( t, "PU%d,%d;PM0;AA0,0,%.2f;PA%d,%d;PM2;FP;", (int)X, (int)Y,
+ (float)A.angle2 / -64.0 , (int)X, (int)Y );
+ SAVE_PCL(outFile, pConPriv, t);
+}
+
+
+void
+PclPolyFillArc(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nArcs,
+ xArc *pArcs)
+{
+ switch( pGC->arcMode )
+ {
+ case ArcChord:
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DoChord );
+ break;
+ case ArcPieSlice:
+ PclDoArc( pDrawable, pGC, nArcs, pArcs, DoWedge );
+ break;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c b/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c
new file mode 100644
index 000000000..cfed7c866
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclArea.c
@@ -0,0 +1,486 @@
+/* $Xorg: PclArea.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclArea.c
+** *
+** * Contents:
+** * Image and Area functions for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclArea.c,v 1.8 2001/01/17 22:36:30 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Pcl.h"
+#include "pixmapstr.h"
+#include "region.h"
+
+#include "cfb.h"
+#if 1
+#include "cfb32.h"
+#endif
+
+void
+PclPutImage(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int depth,
+ int x,
+ int y,
+ int w,
+ int h,
+ int leftPad,
+ int format,
+ char *pImage)
+{
+ PixmapPtr pPixmap;
+ unsigned long oldFg, oldBg;
+ XID gcv[3];
+ unsigned long oldPlanemask;
+ unsigned long i;
+ long bytesPer;
+
+ if( ( w == 0 ) || ( h == 0 ) )
+ return;
+
+ if( format != XYPixmap )
+ {
+ pPixmap = GetScratchPixmapHeader( pDrawable->pScreen,
+ w+leftPad, h, depth,
+ BitsPerPixel( depth ),
+ PixmapBytePad( w + leftPad,
+ depth ), (pointer)pImage );
+ if( !pPixmap )
+ return;
+
+ if( format == ZPixmap )
+ (void)(*pGC->ops->CopyArea)( (DrawablePtr)pPixmap, pDrawable, pGC,
+ leftPad, 0, w, h, x, y );
+ else
+ (void)(*pGC->ops->CopyPlane)( (DrawablePtr)pPixmap, pDrawable, pGC,
+ leftPad, 0, w, h, x, y, 1 );
+ FreeScratchPixmapHeader( pPixmap );
+ }
+ else
+ {
+ pPixmap = GetScratchPixmapHeader( pDrawable->pScreen,
+ w+leftPad, h, depth,
+ BitsPerPixel( depth ),
+ PixmapBytePad( w + leftPad,
+ depth ), (pointer)pImage );
+
+ if( !pPixmap )
+ return;
+
+ depth = pGC->depth;
+ oldPlanemask = pGC->planemask;
+ oldFg = pGC->fgPixel;
+ oldBg = pGC->bgPixel;
+ gcv[0] = ~0L;
+ gcv[1] = 0;
+ DoChangeGC( pGC, GCForeground | GCBackground, gcv, 0 );
+ bytesPer = (long)h * BitmapBytePad( w + leftPad );
+
+ for( i = 1 << (depth-1); i != 0; i >>= 1, pImage += bytesPer )
+ {
+ if( i & oldPlanemask )
+ {
+ gcv[0] = i;
+ DoChangeGC( pGC, GCPlaneMask, gcv, 0 );
+ ValidateGC( pDrawable, pGC );
+ if (pPixmap->drawable.depth <= 8 )
+ cfbPutImage( (DrawablePtr)pPixmap, pGC, 1, x, y, w, h,
+ leftPad, XYBitmap, pImage );
+ else if (pPixmap->drawable.depth <= 32 )
+ cfb32PutImage( (DrawablePtr)pPixmap, pGC, 1, x, y, w, h,
+ leftPad, XYBitmap, pImage );
+ }
+ }
+ gcv[0] = oldPlanemask;
+ gcv[1] = oldFg;
+ gcv[2] = oldBg;
+ DoChangeGC( pGC, GCPlaneMask | GCForeground | GCBackground,
+ gcv, 0 );
+
+ PclCopyArea( (DrawablePtr)pPixmap, pDrawable, pGC, leftPad,
+ 0, w, h, x, y );
+ FreeScratchPixmapHeader( pPixmap );
+ }
+}
+
+/*
+ * PclMonoPixmapFragment()
+ *
+ * Given a 1-bit-deep pixmap, send the appropriate part of it to the
+ * output file as a PCL raster graphics command.
+ */
+static void
+PclMonoPixmapFragment(FILE *outFile,
+ PixmapPtr pix,
+ short x1,
+ short y1,
+ short x2,
+ short y2,
+ short dstx,
+ short dsty)
+{
+ char *bits, t[80], *row;
+ int h, w, i;
+
+ /*
+ * Create a storage area large enough to hold the entire pixmap,
+ * then use mfbGetImage to get the appropriate bits.
+ */
+ h = y2 - y1;
+ w = BitmapBytePad( x2 - x1 );
+
+ bits = (char *)xalloc( h * w );
+ mfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ XYPixmap, ~0, bits );
+
+ /*
+ * Move the cursor to the appropriate place on the page. We have
+ * to jump into HP-GL/2 to do this correctly, then go back to PCL
+ * for the actual drawing.
+ */
+ sprintf( t, "\033%%0BPU%d,%d;\033%%1A", dstx, dsty );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Now, wrap the raster in the appropriate PCL code. Right now,
+ * it's going to go down the wire without any compression. That
+ * will have to be good enough for the sample implementation.
+ */
+ sprintf( t, "\033*t300R\033*r%dT\033*r%dS\033*r1A\033*b0M",
+ h, x2 - x1 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "\033*b%dW", w );
+ for( row = bits, i = 0; i <= h; i++, row += w )
+ {
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, row, w );
+ }
+
+ SEND_PCL( outFile, "\033*rC" );
+
+ /*
+ * Clean things up a bit
+ */
+ xfree( bits );
+}
+
+static void
+PclColorPixmapFragment(FILE *outFile,
+ PixmapPtr pix,
+ short x1,
+ short y1,
+ short x2,
+ short y2,
+ short dstx,
+ short dsty)
+{
+ char *bits, t[80], *row;
+ int h, w, i;
+
+ /*
+ * Create a storage area large enough to hold the entire pixmap,
+ * then use cfbGetImage to get the appropriate bits.
+ */
+ h = y2 - y1;
+ w = PixmapBytePad( x2 - x1, pix->drawable.depth );
+
+ bits = (char *)xalloc( h * w );
+ if (pix->drawable.depth <= 8)
+ cfbGetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ ZPixmap, ~0, bits );
+ else if (pix->drawable.depth <= 32)
+ cfb32GetImage( (DrawablePtr)pix, x1, y1, x2 - x1, h,
+ ZPixmap, ~0, bits );
+
+ /*
+ * Move the cursor to the appropriate place on the page. We have
+ * to jump into HP-GL/2 to do this correctly, then go back to PCL
+ * for the actual drawing.
+ */
+ sprintf( t, "\033%%0BPU%d,%d;\033%%1A", dstx, dsty );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Now, wrap the raster in the appropriate PCL code. Right now,
+ * it's going to go down the wire without any compression. That
+ * will have to be good enough for the sample implementation.
+ */
+ sprintf( t, "\033*t300R\033*r%dt%ds1A\033*b0M",
+ h, x2 - x1 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "\033*b%dW", w );
+ for( row = bits, i = 0; i < h; i++, row += w )
+ {
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, row, w );
+ }
+
+ SEND_PCL( outFile, "\033*rC" );
+
+ /*
+ * Clean things up a bit
+ */
+ xfree( bits );
+}
+
+RegionPtr
+PclCopyArea(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty)
+{
+ PixmapPtr pixSrc = (PixmapPtr)pSrc;
+/*
+ FILE *srcFile;
+ GC srcGC;
+*/
+ FILE *dstFile;
+ GC dstGC;
+ unsigned long valid;
+ RegionPtr drawRegion, region, whole, ret;
+ BoxRec box;
+ BoxPtr prect;
+ int nrect;
+ void (*doFragment)(FILE *, PixmapPtr, short, short, short, short,
+ short, short );
+
+ /*
+ * Since we don't store any information on a per-window basis, we
+ * can't copy from a window.
+ */
+ if( pSrc->type == DRAWABLE_WINDOW )
+ return NULL;
+
+ /*
+ * If we're copying from a pixmap to a pixmap, we just use the
+ * mfb/cfb code to do the work.
+ */
+ if( pDst->type == DRAWABLE_PIXMAP )
+ {
+ if( pSrc->depth == 1 )
+ return mfbCopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ else if( pSrc->depth <= 8 )
+ return cfbCopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ else if( pSrc->depth <= 32 )
+ return cfb32CopyArea( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty );
+ }
+
+/*
+ PclGetDrawablePrivateStuff( pSrc, &srcGC, &valid, &srcFile );
+*/
+ PclGetDrawablePrivateStuff( pDst, &dstGC, &valid, &dstFile );
+
+ /*
+ * If we're copying to a window, we have to do some actual
+ * drawing, instead of just handing it off to mfb or cfb. Start
+ * by determining the region that will be drawn.
+ */
+ box.x1 = srcx;
+ box.y1 = srcy;
+ box.x2 = srcx + width;
+ box.y2 = srcy + height;
+ drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, dstx, dsty );
+
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * Now select the operation to be performed on each box in the
+ * region.
+ */
+ if( pSrc->depth == 1 )
+ doFragment = PclMonoPixmapFragment;
+ else
+ doFragment = PclColorPixmapFragment;
+
+ /*
+ * Actually draw each section of the bitmap.
+ */
+ nrect = REGION_NUM_RECTS( region );
+ prect = REGION_RECTS( region );
+
+ while( nrect )
+ {
+ (*doFragment)( dstFile, (PixmapPtr)pSrc, prect->x1 - dstx,
+ prect->y1 - dsty, prect->x2 - dstx,
+ prect->y2 - dsty, prect->x1, prect->y1 );
+
+ nrect--;
+ prect++;
+ }
+
+ /*
+ * Update the destination's GC to the source's GC.
+ */
+/*
+ PclSetDrawablePrivateGC( pDst, srcGC );
+*/
+
+ /*
+ * Determine the region that needs to be returned. This is the
+ * region of the source that falls outside the boundary of the
+ * pixmap.
+ */
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pixSrc->drawable.width;
+ box.y2 = pixSrc->drawable.height;
+ whole = REGION_CREATE( pGC->pScreen, &box, 0 );
+ ret = REGION_CREATE( pGC->pScreen, NULL, 0 );
+
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, -dstx, -dsty );
+ REGION_SUBTRACT( pGC->pScreen, ret, drawRegion, whole );
+
+ /*
+ * Clean up the regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ REGION_DESTROY( pGC->pScreen, whole );
+
+ if( REGION_NOTEMPTY( pGC->pScreen, ret ) )
+ return ret;
+ else
+ {
+ REGION_DESTROY( pGC->pScreen, ret );
+ return NULL;
+ }
+}
+
+RegionPtr
+PclCopyPlane(DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long plane)
+{
+ RegionPtr reg;
+ GCPtr scratchGC;
+ PixmapPtr scratchPix;
+
+ /*
+ * Since we don't store PCL on a per-window basis, there's no good
+ * way to copy from a window.
+ */
+ if( pSrc->type == DRAWABLE_WINDOW )
+ return NULL;
+
+ /*
+ * Copying from a pixmap to a pixmap is already implemented by
+ * mfb/cfb.
+ */
+ if( pSrc->type == DRAWABLE_PIXMAP &&
+ pDst->type == DRAWABLE_PIXMAP )
+ {
+ if( pDst->depth == 1 )
+ return mfbCopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ else if( pDst->depth <= 8 )
+ return cfbCopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ else if( pDst->depth <= 32 )
+ return cfb32CopyPlane( pSrc, pDst, pGC, srcx, srcy, width,
+ height, dstx, dsty, plane );
+ }
+
+ /*
+ * We can use the mfb/cfbCopyPlane function to do the work of grabbing
+ * the plane and converting it to the desired visual. Once that's
+ * done, we already know how to do a CopyArea.
+ */
+ scratchPix = (*pDst->pScreen->CreatePixmap)( pDst->pScreen, width,
+ height, pDst->depth );
+
+ scratchGC = GetScratchGC( pDst->depth, pDst->pScreen );
+ CopyGC( pGC, scratchGC, ~0L );
+
+ if( pDst->depth == 1 )
+ {
+ mfbValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ mfbCopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+ else if( pDst->depth <= 8 )
+ {
+ cfbValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ cfbCopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+ else if( pDst->depth <= 32 )
+ {
+ cfb32ValidateGC( scratchGC, ~0L, (DrawablePtr)scratchPix );
+ cfb32CopyPlane( pSrc, (DrawablePtr)scratchPix, scratchGC,
+ srcx, srcy, width, height, 0, 0, plane );
+ }
+
+ reg = PclCopyArea( (DrawablePtr)scratchPix, pDst, pGC, 0, 0, width,
+ height, dstx, dsty );
+
+ FreeScratchGC( scratchGC );
+
+ (*pDst->pScreen->DestroyPixmap)( scratchPix );
+
+ return reg;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c b/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c
new file mode 100644
index 000000000..adbd197fd
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c
@@ -0,0 +1,207 @@
+/*
+ * $Xorg: PclAttVal.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $
+ */
+/*
+(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 "Pcl.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[] = {
+ 300
+};
+static XpOidCardList ValidPrinterResolutions = {
+ ValidPrinterResolutionsCards, XpNumber(ValidPrinterResolutionsCards)
+};
+
+static unsigned long DefaultPrinterResolutionsCards[] = {
+ 300
+};
+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[] = {
+ { "PCL", "5", NULL },
+};
+static XpOidDocFmtList ValidDocFormatsSupported = {
+ ValidDocFormatsSupportedFmts, XpNumber(ValidDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultDocFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL }
+};
+static XpOidDocFmtList DefaultDocFormatsSupported = {
+ DefaultDocFormatsSupportedFmts, XpNumber(DefaultDocFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidEmbeddedFormatsSupportedFmts[] = {
+ { "HPGL", "2", NULL },
+};
+static XpOidDocFmtList ValidEmbeddedFormatsSupported = {
+ ValidEmbeddedFormatsSupportedFmts, XpNumber(ValidEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultEmbeddedFormatsSupportedFmts[] = {
+ { "HPGL", "2", NULL }
+};
+static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
+ DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts)
+};
+
+static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
+ { "PCL", "5", NULL },
+ { "Postscript", "2", NULL },
+ { "ASCII", NULL, NULL }
+
+};
+static XpOidDocFmtList ValidRawFormatsSupported = {
+ ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
+};
+
+static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
+ { "PCL", "5", 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_a3,
+ xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_na_letter,
+ xpoid_val_medium_size_na_legal,
+ xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_designated_long,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_jis_b5,
+};
+static XpOidList ValidMediumSizes = {
+ ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
+};
+
+static XpOidDocFmt DefaultDocumentFormat = {
+ "PCL", "5", NULL
+};
+
+
+/*
+ * init struct for XpValidate*Pool
+ */
+XpValidatePoolsRec PclValidatePoolsRec = {
+ &ValidContentOrientations, &DefaultContentOrientations,
+ &ValidDocFormatsSupported, &DefaultDocFormatsSupported,
+ &ValidInputTrays, &ValidMediumSizes,
+ &ValidPlexes, &DefaultPlexes,
+ &ValidPrinterResolutions, &DefaultPrinterResolutions,
+ &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
+ &ValidListfontsModes, &DefaultListfontsModes,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
+ &ValidSetupProviso,
+ &DefaultDocumentFormat
+};
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c b/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c
new file mode 100644
index 000000000..3cde053f1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c
@@ -0,0 +1,87 @@
+/* $Xorg: PclAttr.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclAttr.c
+** *
+** * Contents:
+** * Attribute-handling functions for the PCL driver
+** *
+** * Created: 2/2/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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 "Pcl.h"
+#include "attributes.h"
+
+char *
+PclGetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool )
+{
+ return XpGetAttributes( pCon, pool );
+}
+
+char *
+PclGetOneAttribute(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attr )
+{
+ return XpGetOneAttribute( pCon, pool, attr );
+}
+int
+PclAugmentAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs )
+{
+ return XpAugmentAttributes( pCon, pool, attrs );
+}
+
+int
+PclSetAttributes(
+ XpContextPtr pCon,
+ XPAttributes pool,
+ char *attrs )
+{
+ return XpSetAttributes( pCon, pool, attrs );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c b/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c
new file mode 100644
index 000000000..72c7e3f99
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclColor.c
@@ -0,0 +1,851 @@
+/* $Xorg: PclColor.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclColorInit.c
+** *
+** * Contents:
+** * Colormap handing code of Pcl driver for the
+** * print server.
+** *
+** * Created: 4/8/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclColor.c,v 1.9tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <math.h>
+
+#include "colormapst.h"
+#include "windowstr.h"
+#include "resource.h"
+
+#include "Pcl.h"
+#include "cfb.h"
+
+static void lookup(unsigned char *src,
+ unsigned char *dst,
+ int num,
+ unsigned char *map,
+ int dim);
+static void trilinear(unsigned char *p,
+ unsigned char *out,
+ unsigned char *d,
+ int dim,
+ unsigned char def);
+
+
+/*
+ * This seems to be (and is) a duplication of effort; one would think
+ * that cfbCreateDefColormap would be sufficient. It almost is. The
+ * only change made in this function is that the black and white pixels
+ * are allocated with three separate variables for red, green and blue
+ * values, instead of the single variable in cfbCreateDefColormap. The
+ * single variable leads to the one value being corrected by
+ * ResolveColor three times, which leads to incorrect colors.
+ */
+
+Bool
+PclCreateDefColormap(ScreenPtr pScreen)
+{
+ unsigned short wp_red = ~0, wp_green = ~0, wp_blue = ~0;
+ unsigned short bp_red = 0, bp_green = 0, bp_blue = 0;
+ VisualPtr pVisual;
+ ColormapPtr cmap;
+ Pixel wp, bp;
+
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual;
+ pVisual++)
+ ;
+
+ if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0)
+ != Success)
+ return FALSE;
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+ if ((AllocColor(cmap, &wp_red, &wp_green, &wp_blue, &wp, 0) !=
+ Success) ||
+ (AllocColor(cmap, &bp_red, &bp_green, &bp_blue, &bp, 0) !=
+ Success))
+ return FALSE;
+
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+
+ (*pScreen->InstallColormap)(cmap);
+ return TRUE;
+}
+
+/*
+ * Add colormap to list of colormaps on screen
+ */
+Bool
+PclCreateColormap(ColormapPtr pColor)
+{
+ PclCmapToContexts *new;
+ PclScreenPrivPtr sPriv;
+
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+
+ /*
+ * Use existing code to initialize the values in the colormap
+ */
+ cfbInitializeColormap( pColor );
+
+ /*
+ * Set up the mapping between the color map and the context
+ */
+ new = (PclCmapToContexts *)xalloc( sizeof( PclCmapToContexts ) );
+
+ if( new )
+ {
+ new->colormapId = pColor->mid;
+ new->contexts = NULL;
+ new->next = sPriv->colormaps;
+ sPriv->colormaps = new;
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+void
+PclDestroyColormap(ColormapPtr pColor)
+{
+ PclScreenPrivPtr sPriv;
+ PclCmapToContexts *pCmap, *tCmap = 0;
+ PclContextListPtr con, tCon;
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pPal;
+ char t[80];
+
+ /*
+ * At DestroyContext time, colormaps may be destroyed twice, so if the
+ * pointer is NULL, just crash out.
+ */
+ if( !pColor )
+ return;
+
+ /*
+ * Find the colormap <-> contexts mapping
+ */
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap )
+ {
+ if( pCmap->colormapId == pColor->mid )
+ break;
+ tCmap = pCmap;
+ pCmap = pCmap->next;
+ }
+
+ /*
+ * For each context, delete the palette in the printer and
+ * free the mapping.
+ */
+ if( pCmap )
+ {
+ con = pCmap->contexts;
+ while( con )
+ {
+ cPriv = con->context->devPrivates[PclContextPrivateIndex].ptr;
+
+ pPal = cPriv->palettes;
+ while( pPal )
+ {
+ if( pPal->colormapId == pColor->mid )
+ break;
+ pPal = pPal->next;
+ }
+
+ if( cPriv->pPageFile )
+ {
+ sprintf( t, "\033&p%dI\033*p2C", pPal->paletteId );
+ SEND_PCL( cPriv->pPageFile, t );
+ }
+
+ tCon = con;
+ con = con->next;
+ xfree( tCon );
+ }
+
+ /*
+ * Delete the colormap<->contexts mapping
+ */
+ if( sPriv->colormaps == pCmap )
+ /* Delete from the front */
+ sPriv->colormaps = pCmap->next;
+ else
+ /* Delete from the middle */
+ tCmap->next = pCmap->next;
+ free( pCmap );
+ }
+}
+
+void
+PclInstallColormap(ColormapPtr pColor)
+{
+}
+
+void
+PclUninstallColormap(ColormapPtr pColor)
+{
+}
+
+int
+PclListInstalledColormaps(ScreenPtr pScreen,
+ XID *pCmapList)
+{
+ return 0;
+}
+
+void
+PclStoreColors(ColormapPtr pColor,
+ int ndef,
+ xColorItem *pdefs)
+{
+ PclCmapToContexts *p;
+ PclScreenPrivPtr sPriv;
+ PclContextListPtr con;
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pMap;
+ char t[80];
+ int i;
+
+ sPriv = (PclScreenPrivPtr)pColor->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ p = sPriv->colormaps;
+ while( p )
+ {
+ if( p->colormapId == pColor->mid )
+ break;
+ p = p->next;
+ }
+
+ if( p )
+ {
+ con = p->contexts;
+ while( con )
+ {
+ /*
+ * For each context, get the palette ID and update the
+ * appropriate palette.
+ */
+ cPriv = con->context
+ ->devPrivates[PclContextPrivateIndex].ptr;
+ pMap = PclFindPaletteMap( cPriv, pColor, NULL );
+
+ /*
+ * Update the palette
+ */
+ sprintf( t, "\033&p%dS", pMap->paletteId );
+ SEND_PCL( cPriv->pPageFile, t );
+
+ if( pColor->class == PseudoColor )
+ {
+ unsigned short r, g, b;
+ unsigned int pID;
+ for( i = 0; i < ndef; i++ )
+ {
+ pID = pdefs[i].pixel;
+ if ( pColor->red[i].fShared )
+ {
+ r = pColor->red[pID].co.shco.red->color;
+ g = pColor->red[pID].co.shco.green->color;
+ b = pColor->red[pID].co.shco.blue->color;
+ }
+ else
+ {
+ r = pColor->red[pID].co.local.red;
+ g = pColor->red[pID].co.local.green;
+ b = pColor->red[pID].co.local.blue;
+ }
+
+ if( pdefs[i].flags & DoRed )
+ r = pdefs[i].red;
+ if( pdefs[i].flags & DoGreen )
+ g = pdefs[i].green;
+ if( pdefs[i].flags & DoBlue )
+ b = pdefs[i].blue;
+ PclLookUp(pColor, cPriv, &r, &g, &b);
+ sprintf( t, "\033*v%ua%ub%uc%dI", r, g, b, pID);
+ SEND_PCL( cPriv->pPageFile, t );
+ }
+ }
+
+ sprintf( t, "\033&p%dS", cPriv->currentPalette );
+ SEND_PCL( cPriv->pPageFile, t );
+
+ con = con->next;
+ }
+ }
+}
+
+void
+PclResolveColor(unsigned short *pRed,
+ unsigned short *pGreen,
+ unsigned short *pBlue,
+ VisualPtr pVisual)
+{
+ /*
+ * We need to map the X color range of [0,65535] to the PCL color
+ * range of [0,32767].
+ */
+ *pRed >>= 1;
+ *pGreen >>= 1;
+ *pBlue >>= 1;
+}
+
+PclPaletteMapPtr
+PclFindPaletteMap(PclContextPrivPtr cPriv,
+ ColormapPtr cmap,
+ GCPtr gc)
+{
+ PclPaletteMapPtr p = cPriv->palettes, new;
+
+ /*
+ * If the colormap is static, grab one of the special palettes. If we come
+ * into this from StoreColors, there will be no GC, but by definition we're
+ * looking at a dynamic color map, so the special colors will not be
+ * needed.
+ */
+ if( gc )
+ {
+ if( cmap->pVisual->class == StaticGray )
+ return &( cPriv->staticGrayPalette );
+ else if( cmap->pVisual->class == TrueColor )
+ {
+ if( gc->fillStyle == FillTiled && !( gc->tileIsPixel ) )
+ return &( cPriv->specialTrueColorPalette );
+ else
+ return &( cPriv->trueColorPalette );
+ }
+ }
+
+
+ /* Look for the colormap ID <-> palette ID mapping */
+ while( p )
+ {
+ if( p->colormapId == cmap->mid )
+ return p;
+ p = p->next;
+ }
+
+ /* If the colormap isn't already there, make an entry for it */
+ new = (PclPaletteMapPtr)xalloc( sizeof( PclPaletteMap ) );
+ new->colormapId = cmap->mid;
+ new->paletteId = cPriv->nextPaletteId++;
+ new->downloaded = 0;
+ new->next = cPriv->palettes;
+ cPriv->palettes = new;
+ return new;
+}
+
+int
+PclUpdateColormap(DrawablePtr pDrawable,
+ XpContextPtr pCon,
+ GCPtr gc,
+ FILE *outFile)
+{
+ PclScreenPrivPtr sPriv;
+
+ PclContextPrivPtr cPriv;
+ PclPaletteMapPtr pMap;
+ PclCmapToContexts *pCmap;
+ PclContextListPtr new;
+ char t[80];
+ Colormap c;
+ ColormapPtr cmap;
+ WindowPtr win = (WindowPtr)pDrawable;
+ unsigned short r, g, b, rr, gg, bb;
+ int i;
+
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ c = wColormap( win );
+ cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
+ pMap = PclFindPaletteMap( cPriv, cmap, gc );
+
+ if( cPriv->currentPalette == pMap->paletteId )
+ /*
+ * If the requested colormap is already active, nothing needs to
+ * be done.
+ */
+ return FALSE;
+
+ /*
+ * Now we activate the palette in the printer
+ */
+ sprintf( t, "\033&p%dS", pMap->paletteId );
+ SEND_PCL( outFile, t );
+ cPriv->currentPalette = pMap->paletteId;
+
+ if( pMap->downloaded == 0 )
+ /*
+ * If the requested colormap has not been downloaded to the
+ * printer, we need to do that before activating it.
+ */
+ {
+ /*
+ * Add the colormap to the screen-level colormap<->context mapping.
+ */
+ sPriv = (PclScreenPrivPtr)cmap->pScreen
+ ->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap && ( pCmap->colormapId != cmap->mid ) )
+ pCmap = pCmap->next;
+ new = (PclContextListPtr)xalloc( sizeof( PclContextList ) );
+ new->context = pCon;
+ new->next = pCmap->contexts;
+ pCmap->contexts = new;
+
+ /*
+ * XXX Download the colormap
+ */
+ if( cmap->class == StaticGray )
+ {
+#ifdef XP_PCL_COLOR
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1, 1, 1, 1, 1 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c", 0x7f, 0xff, 0x7f, 0xff,
+ 0x7f, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now program the two colors */
+ sprintf( t, "\033*v0a0b0c%ldI", (long) cmap->pScreen->blackPixel );
+ SEND_PCL( cPriv->pPageFile, t );
+ sprintf( t, "\033*v32767a32767b32767c%ldI",
+ (long) cmap->pScreen->whitePixel );
+ SEND_PCL( cPriv->pPageFile, t );
+#endif /* XP_PCL_COLOR */
+ }
+ else if( cmap->class == PseudoColor )
+ {
+ sprintf( t,
+ "\033*v18W%c%c%c%c%c%c",
+ 0, 1, cmap->pVisual->nplanes, 16, 16, 16 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ if ( cPriv->ctbl != NULL )
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xff );
+ else
+ sprintf( t, "%c%c%c%c%c%c", 0x7f, 0xff, 0x7f, 0xff,
+ 0x7f, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ for(i = 0; i < cmap->pVisual->ColormapEntries; i++ )
+ {
+ if( cmap->red[i].fShared )
+ {
+ r = cmap->red[i].co.shco.red->color;
+ g = cmap->red[i].co.shco.green->color;
+ b = cmap->red[i].co.shco.blue->color;
+ }
+ else
+ {
+ r = cmap->red[i].co.local.red;
+ g = cmap->red[i].co.local.green;
+ b = cmap->red[i].co.local.blue;
+ }
+ PclLookUp(cmap, cPriv, &r, &g, &b);
+ sprintf( t, "\033*v%ua%ub%uc%dI", r, g, b, i );
+ SEND_PCL( outFile, t );
+ }
+ }
+ else if( cmap->class == TrueColor )
+ {
+ unsigned short lim;
+
+ if( gc->fillStyle == FillTiled && !( gc->tileIsPixel ) )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1,
+ 8,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0xff,
+ 0x00, 0xff,
+ 0x00, 0xff );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now send the color entries, RRRGGGBB */
+ i=0;
+ for( r = 0; r < 8; r++ )
+ for( g = 0; g < 8; g ++ )
+ for( b = 0; b < 4; b++ )
+ {
+ rr = (r * 0xff)/7;
+ gg = (g * 0xff)/7;
+ bb = (b * 0xff)/3;
+ PclLookUp(cmap, cPriv, &rr, &gg, &bb);
+ sprintf( t, "\033*v%ua%ub%uc%dI",
+ rr, gg, bb, i );
+ SEND_PCL( outFile, t );
+ i++;
+ }
+ }
+ else
+ {
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 1,
+ 8,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x07,
+ 0x00, 0x07,
+ 0x00, 0x03 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c",
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* Now send the color entries, RRRGGGBB */
+ i=0;
+ for( r = 0; r < 8; r++ )
+ for( g = 0; g < 8; g ++ )
+ for( b = 0; b < 4; b++ )
+ {
+ sprintf( t, "\033*v%ua%ub%uc%dI",
+ r, g, b, i );
+ SEND_PCL( outFile, t );
+ i++;
+ }
+ }
+
+ }
+ else
+ {
+ lim = (1 << cmap->pVisual->bitsPerRGBValue) - 1;
+
+ /* Send the "special" colormap for 24-bit fills */
+ sprintf( t, "\033*v18W%c%c%c%c%c%c", 0, 3,
+ cmap->pVisual->nplanes,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue,
+ cmap->pVisual->bitsPerRGBValue );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 12 );
+
+ /* Send the white reference point... */
+ sprintf( t, "%c%c%c%c%c%c",
+ (lim >> 8) & 0xff, lim & 0xff,
+ (lim >> 8) & 0xff, lim & 0xff,
+ (lim >> 8) & 0xff, lim & 0xff);
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+
+ /* ... and the black reference point */
+ sprintf( t, "%c%c%c%c%c%c", 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 );
+ SEND_PCL_COUNT( cPriv->pPageFile, t, 6 );
+ }
+
+ }
+ pMap->downloaded = 1;
+ }
+ return TRUE;
+
+}
+
+void PclLookUp(
+ ColormapPtr cmap,
+ PclContextPrivPtr cPriv,
+ unsigned short *r,
+ unsigned short *g,
+ unsigned short *b
+)
+{
+ unsigned char cdata[3];
+
+ if( cmap->class == PseudoColor )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ cdata[0] = *r >> 8;
+ cdata[1] = *g >> 8;
+ cdata[2] = *b >> 8;
+ lookup(cdata, cdata, 1, cPriv->ctbl, cPriv->ctbldim);
+ *r = cdata[0];
+ *g = cdata[1];
+ *b = cdata[2];
+ }
+ else
+ {
+ *r >>= 1;
+ *g >>= 1;
+ *b >>= 1;
+ }
+ }
+ else if( cmap->class == TrueColor )
+ {
+ if( cPriv->ctbl != NULL )
+ {
+ cdata[0] = *r;
+ cdata[1] = *g;
+ cdata[2] = *b;
+ lookup(cdata, cdata, 1, cPriv->ctbl, cPriv->ctbldim);
+ *r = cdata[0];
+ *g = cdata[1];
+ *b = cdata[2];
+ }
+ }
+ return;
+}
+
+unsigned char *PclReadMap(char *name, int *dim)
+{
+ FILE *fp;
+ unsigned char *data;
+ long size;
+
+ if ((fp=fopen(name, "r")) == NULL) {
+ return(NULL);
+ }
+
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+
+ /* Could do this with a lookup table, if the constraint is that the
+ 3 map dimensions must be equal. */
+ switch (size) {
+ case 8*8*8*3:
+ *dim = 8;
+ break;
+ case 16*16*16*3:
+ *dim = 16;
+ break;
+ case 17*17*17*3:
+ *dim = 17;
+ break;
+ case 65*65*65*3:
+ *dim = 65;
+ break;
+ default:
+ fclose(fp);
+ return(NULL);
+ }
+
+ if ((data = (unsigned char *) xalloc(sizeof(char) * size)) == NULL) {
+ fclose(fp);
+ return(NULL);
+ }
+
+ fseek(fp, 0, SEEK_SET);
+
+ if (fread(data, sizeof(char), size, fp) != (unsigned) size) {
+ fclose(fp);
+ free(data);
+ return(NULL);
+ }
+
+ fclose(fp);
+ return(data);
+}
+
+/************************************************************************
+ *
+ * Here is the mapper.
+ *
+ ************************************************************************/
+
+#define SCL(x) ((x)*(dim-1)/255)
+/* Interleaved-map lookup */
+static void lookup(unsigned char *src, unsigned char *dst, int num, unsigned char *map, int dim)
+{
+ int i;
+
+#define _INTERPOLATE
+#ifndef _INTERPOLATE
+ unsigned char *p1, *p2, *p3;
+
+ for (i=0; i<num; i++) {
+ p1 = map + (SCL(src[0])*dim*dim + SCL(src[1])*dim + SCL(src[2])) * 3;
+ *dst++ = *p1++;
+ *dst++ = *p1++;
+ *dst++ = *p1++;
+ src += 3;
+ }
+#else
+ for (i=0; i<num; i++) {
+ trilinear(src, dst, map, dim, 128);
+ src += 3;
+ dst += 3;
+ }
+#endif
+}
+
+/*
+ * C code from the article
+ * "Tri-linear Interpolation"
+ * by Steve Hill, sah@ukc.ac.uk
+ * in "Graphics Gems IV", Academic Press, 1994
+ *
+ * Fri Feb 16 14:12:43 PST 1996
+ * Modified to use for 8-bit color mapping -- A. Fitzhugh,
+ * HP Labs, Printing Technology Department
+ */
+
+/* linear interpolation from l (when a=0) to h (when a=1)*/
+/* (equal to (a*h)+((1-a)*l) */
+#define LERP(a,l,h) ((l)+((((h)-(l))*(a))>>8))
+
+static void trilinear(unsigned char *p, unsigned char *out, unsigned char *d, int dim, unsigned char def)
+{
+#define DENS(X, Y, Z, ch) d[((X*dim+Y)*dim+Z)*3+ch]
+
+ int x0, y0, z0,
+ x1, y1, z1,
+ i;
+ unsigned char *dp,
+ fx, fy, fz,
+ d000, d001, d010, d011,
+ d100, d101, d110, d111,
+ dx00, dx01, dx10, dx11,
+ dxy0, dxy1;
+ float scale;
+
+ scale = 255.0 / (dim-1);
+
+ x0 = p[0] / scale;
+ y0 = p[1] / scale;
+ z0 = p[2] / scale;
+
+ /* Fractions should range from 0-1.0 (fixed point 8-256) */
+ fx = (((int) (p[0] - x0 * scale)) << 8) / 255;
+ fy = (((int) (p[1] - y0 * scale)) << 8) / 255;
+ fz = (((int) (p[2] - z0 * scale)) << 8) / 255;
+
+ x1 = x0 + 1;
+ y1 = y0 + 1;
+ z1 = z0 + 1;
+
+ for (i=0; i<3; i++) {
+
+ if (x0 >= 0 && x1 < dim &&
+ y0 >= 0 && y1 < dim &&
+ z0 >= 0 && z1 < dim) {
+ dp = &DENS(x0, y0, z0, i);
+ d000 = dp[0];
+ d100 = dp[3];
+ dp += dim*3;
+ d010 = dp[0];
+ d110 = dp[3];
+ dp += dim*dim*3;
+ d011 = dp[0];
+ d111 = dp[3];
+ dp -= dim*3;
+ d001 = dp[0];
+ d101 = dp[3];
+ } else {
+# define INRANGE(X, Y, Z) \
+ ((X) >= 0 && (X) < dim && \
+ (Y) >= 0 && (Y) < dim && \
+ (Z) >= 0 && (Z) < dim)
+
+ d000 = INRANGE(x0, y0, z0) ? DENS(x0, y0, z0, i) : def;
+ d001 = INRANGE(x0, y0, z1) ? DENS(x0, y0, z1, i) : def;
+ d010 = INRANGE(x0, y1, z0) ? DENS(x0, y1, z0, i) : def;
+ d011 = INRANGE(x0, y1, z1) ? DENS(x0, y1, z1, i) : def;
+
+ d100 = INRANGE(x1, y0, z0) ? DENS(x1, y0, z0, i) : def;
+ d101 = INRANGE(x1, y0, z1) ? DENS(x1, y0, z1, i) : def;
+ d110 = INRANGE(x1, y1, z0) ? DENS(x1, y1, z0, i) : def;
+ d111 = INRANGE(x1, y1, z1) ? DENS(x1, y1, z1, i) : def;
+ }
+
+ dx00 = LERP(fx, d000, d100);
+ dx01 = LERP(fx, d001, d101);
+ dx10 = LERP(fx, d010, d110);
+ dx11 = LERP(fx, d011, d111);
+
+ dxy0 = LERP(fy, dx00, dx10);
+ dxy1 = LERP(fy, dx01, dx11);
+
+ out[i] = LERP(fz, dxy0, dxy1);
+ }
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c b/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c
new file mode 100644
index 000000000..f50c355e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c
@@ -0,0 +1,115 @@
+/* $Xorg: PclCursor.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclCursor.c
+** *
+** * Contents:
+** * Cursor-handling code for the PCL DDX driver
+** *
+** * Created: 1/18/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclCursor.c,v 1.3 1999/12/16 02:26:27 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclConstrainCursor(
+ ScreenPtr pScreen,
+ BoxPtr pBox)
+{
+}
+
+void
+PclCursorLimits(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ BoxPtr pHotBox,
+ BoxPtr pTopLeftBox)
+{
+}
+
+Bool
+PclDisplayCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+Bool
+PclRealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+Bool
+PclUnrealizeCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ return True;
+}
+
+void
+PclRecolorCursor(
+ ScreenPtr pScreen,
+ CursorPtr pCursor,
+ Bool displayed)
+{
+}
+
+Bool
+PclSetCursorPosition(
+ ScreenPtr pScreen,
+ int x,
+ int y,
+ Bool generateEvent)
+{
+ return True;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h b/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h
new file mode 100644
index 000000000..275bd63ec
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclDef.h
@@ -0,0 +1,68 @@
+/* $Xorg: PclDef.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclDef.h
+** *
+** * Contents: extran defines and includes for the Pcl driver
+** * for a printing X server.
+** *
+** * Created: 7/31/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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
+
+#ifndef _PCLDEF_H_
+#define _PCLDEF_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 /* _PCLDEF_H_ */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c b/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c
new file mode 100644
index 000000000..591435faa
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c
@@ -0,0 +1,74 @@
+/* $Xorg: PclFonts.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclFonts.c
+** *
+** * Contents:
+** * Font code for Pcl driver.
+** *
+** * Created: 2/03/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/* $XFree86$ */
+/*
+(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 "regionstr.h"
+#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+
+#include "Pcl.h"
+
+Bool
+PclRealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
+
+Bool
+PclUnrealizeFont(
+ ScreenPtr pscr,
+ FontPtr pFont)
+{
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c b/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c
new file mode 100644
index 000000000..83ebb47e1
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclGC.c
@@ -0,0 +1,1046 @@
+/* $Xorg: PclGC.c,v 1.4 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclGC.c
+** *
+** * Contents:
+** * Graphics Context handling for the PCL driver
+** *
+** * Created: 10/11/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclGC.c,v 1.9 2001/01/19 18:34:28 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "gcstruct.h"
+
+#include "Pcl.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#include "cfb.h"
+#include "cfb32.h"
+#include "migc.h"
+#include "scrnintstr.h"
+#include "resource.h"
+
+static GCOps PclGCOps =
+{
+ PclFillSpans,
+ PclSetSpans,
+ PclPutImage,
+ PclCopyArea,
+ PclCopyPlane,
+ PclPolyPoint,
+ PclPolyLine,
+ PclPolySegment,
+ PclPolyRectangle,
+ PclPolyArc,
+ PclFillPolygon,
+ PclPolyFillRect,
+ PclPolyFillArc,
+ PclPolyText8,
+ PclPolyText16,
+ PclImageText8,
+ PclImageText16,
+ PclImageGlyphBlt,
+ PclPolyGlyphBlt,
+ PclPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+}
+;
+
+
+static GCFuncs PclGCFuncs =
+{
+ PclValidateGC,
+ miChangeGC,
+ miCopyGC,
+ PclDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+}
+;
+
+Bool
+PclCreateGC(GCPtr pGC)
+{
+ if( pGC->depth == 1 )
+ {
+ if( mfbCreateGC( pGC ) == FALSE )
+ return FALSE;
+ }
+ else if( pGC->depth <= 32 )
+ {
+#if PSZ == 8
+ if( cfbCreateGC( pGC ) == FALSE )
+#else
+ if( cfb32CreateGC( pGC ) == FALSE )
+#endif
+ return FALSE;
+ }
+ else
+ return FALSE;
+
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ pGC->ops = &PclGCOps;
+ pGC->funcs = &PclGCFuncs;
+
+ return TRUE;
+}
+
+void
+PclDestroyGC(GCPtr pGC)
+{
+ /* Handle the mfb and cfb, which share a GC private struct */
+ miDestroyGC( pGC );
+}
+
+
+int
+PclGetDrawablePrivateStuff(
+ DrawablePtr pDrawable,
+ GC *gc,
+ unsigned long *valid,
+ FILE **file)
+{
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+
+ switch( pDrawable->type )
+ {
+ case DRAWABLE_PIXMAP:
+ /*
+ * If we ever get here, something is wrong.
+ */
+ return FALSE;
+
+ case DRAWABLE_WINDOW:
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+
+ if( pCon == NULL )
+ return FALSE;
+ else
+ {
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ *gc = cPriv->lastGC;
+ *valid = cPriv->validGC;
+ *file = cPriv->pPageFile;
+ return TRUE;
+ }
+
+ default:
+ return FALSE;
+ }
+}
+
+void
+PclSetDrawablePrivateGC(
+ DrawablePtr pDrawable,
+ GC gc)
+{
+ PixmapPtr pix;
+ XpContextPtr pCon;
+ PclPixmapPrivPtr pixPriv;
+ PclContextPrivPtr pPriv;
+ int i;
+
+ switch( pDrawable->type )
+ {
+ case DRAWABLE_PIXMAP:
+ pix = (PixmapPtr)pDrawable;
+ pixPriv = pix->devPrivates[PclPixmapPrivateIndex].ptr;
+
+ pixPriv->lastGC = gc;
+ pixPriv->validGC = 1;
+ break;
+
+ case DRAWABLE_WINDOW:
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pPriv = ((PclContextPrivPtr)
+ (pCon->devPrivates[PclContextPrivateIndex].ptr));
+
+ pPriv->validGC = 1;
+ pPriv->lastGC = gc;
+
+ /*
+ * Store the dash list separately, to avoid having it freed
+ * out from under us.
+ */
+ if( pPriv->dash != NULL )
+ xfree( pPriv->dash );
+ if( gc.numInDashList != 0 )
+ {
+ pPriv->dash = (unsigned char *)xalloc( sizeof( unsigned char )
+ * gc.numInDashList );
+ for( i = 0; i < gc.numInDashList; i++ )
+ pPriv->dash[i] = gc.dash[i];
+ }
+ else
+ pPriv->dash = NULL;
+
+
+ /*
+ * Store the dash list separately, to avoid having it freed
+ * out from under us.
+ */
+ if( pPriv->dash != NULL )
+ xfree( pPriv->dash );
+ if( gc.numInDashList != 0 )
+ {
+ pPriv->dash = (unsigned char *)xalloc( sizeof( unsigned char )
+ * gc.numInDashList );
+ for( i = 0; i < gc.numInDashList; i++ )
+ pPriv->dash[i] = gc.dash[i];
+ }
+ else
+ pPriv->dash = NULL;
+
+ break;
+ }
+}
+
+static void
+PclSendPattern(char *bits,
+ int sz,
+ int depth,
+ int h,
+ int w,
+ int patNum,
+ FILE *outFile)
+{
+ char t[80], *row, *mod;
+ int w2;
+ int i, j;
+
+ SEND_PCL( outFile, "\033%0A" );
+
+ if( depth == 1 )
+ {
+ /* Each row must be word-aligned */
+ w2 = ( w / 8 ) + ( ( w%8 ) ? 1 : 0 );
+/*
+ if( w2 % 2 )
+ w2++;
+*/
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 0, 0, 1, 0, h>>8, h&0xff, w>>8,
+ w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++, row += BitmapBytePad( w ) )
+ SEND_PCL_COUNT( outFile, row, w2 );
+ }
+ else if( depth == 8 )
+ {
+ w2 = ( w % 2 ) ? w + 1 : w;
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 1, 0, 8, 0, h>>8, h&0xff,
+ w>>8, w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++,
+ row += PixmapBytePad( w, 8 ) )
+ SEND_PCL_COUNT( outFile, row, w2 );
+ }
+ else
+ {
+ w2 = ( w % 2 ) ? w + 1 : w;
+
+ sprintf( t, "\033*c%dg%dW", patNum, h * w2 + 8 );
+ SEND_PCL( outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 1, 0, 8, 0, h>>8, h&0xff,
+ w>>8, w&0xff );
+ SEND_PCL_COUNT( outFile, t, 8 );
+
+ mod = (char *)xalloc( w2 );
+
+ for( row = bits, i = 0; i < h; i++,
+ row += PixmapBytePad( w, 24 ) )
+ {
+ char r, g, b;
+ for( j = 0; j < w2; j++ ) {
+ r = ((row[j*4+1] >> 5) & 0x7) << 5;
+ g = ((row[j*4+2] >> 5) & 0x7) << 2;
+ b = ((row[j*4+3] >> 6) & 0x3);
+ mod[j] = r | g | b;
+ }
+ SEND_PCL_COUNT( outFile, mod, w2 );
+ }
+
+ xfree( mod );
+ }
+
+ SEND_PCL( outFile, "\033%0B" );
+}
+
+int
+PclUpdateDrawableGC(
+ GCPtr pGC,
+ DrawablePtr pDrawable,
+ FILE **outFile)
+{
+ Mask changeMask = 0;
+ GC dGC;
+ unsigned long valid;
+ int i;
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+ PclGCPrivPtr gcPriv = (PclGCPrivPtr)
+ (pGC->devPrivates[PclGCPrivateIndex].ptr);
+
+ if( !PclGetDrawablePrivateStuff( pDrawable, &dGC, &valid, outFile ) )
+ return FALSE;
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Here's where we update the colormap. Since there can be
+ * different colormaps installed on each window, we need to check
+ * before each drawing request that the correct palette is active in
+ * the printer. This is as good a place as any.
+ */
+ if( !PclUpdateColormap( pDrawable, pCon, pGC, *outFile ) )
+ return FALSE;
+
+ /*
+ * If the drawable's last GC is NULL, this means that this is
+ * the first time the drawable is being used. Therefore, we need
+ * to emit PCL for all the GC fields.
+ */
+ if( valid == 0 )
+ changeMask = ~0;
+
+ /*
+ * If we have two different GC structures, there is no alternative
+ * but to scan through them both to determine the changeMask.
+ */
+ else
+ {
+ if( dGC.alu != pGC->alu )
+ changeMask |= GCFunction;
+ if( dGC.fgPixel != pGC->fgPixel )
+ changeMask |= GCForeground;
+ if( dGC.bgPixel != pGC->bgPixel )
+ changeMask |= GCBackground;
+ if( dGC.lineWidth != pGC->lineWidth )
+ changeMask |= GCLineWidth;
+ if( dGC.lineStyle != pGC->lineStyle )
+ changeMask |= GCLineStyle;
+ if( dGC.capStyle != pGC->capStyle )
+ changeMask |= GCCapStyle;
+ if( dGC.joinStyle != pGC->joinStyle )
+ changeMask |= GCJoinStyle;
+ if( dGC.fillStyle != pGC->fillStyle )
+ changeMask |= GCFillStyle;
+ if( dGC.tile.pixmap != pGC->tile.pixmap )
+ changeMask |= GCTile;
+ if( dGC.stipple != pGC->stipple )
+ changeMask |= GCStipple;
+ if( dGC.patOrg.x != pGC->patOrg.x )
+ changeMask |= GCTileStipXOrigin;
+ if( dGC.patOrg.y != pGC->patOrg.y )
+ changeMask |= GCTileStipYOrigin;
+
+ if( dGC.numInDashList == pGC->numInDashList )
+ {
+ for( i = 0; i < dGC.numInDashList; i++ )
+ if( cPriv->dash[i] != pGC->dash[i] )
+ {
+ changeMask |= GCDashList;
+ break;
+ }
+ }
+ else
+ changeMask |= GCDashList;
+ }
+
+ /*
+ * Once the changeMask has been determined, we scan it and emit
+ * the appropriate PCL code to set the drawing attributes.
+ */
+
+ /* Must be in HP-GL/2 mode to set attributes */
+ SEND_PCL( *outFile, "\033%0B" );
+
+ if( changeMask & GCFunction )
+ {
+#ifdef XP_PCL_COLOR
+
+ if( pGC->alu == GXclear )
+ SEND_PCL( *outFile, "SP0;" );
+ else
+ SEND_PCL( *outFile, "SP1;" );
+#else
+ if( pGC->alu == GXclear )
+ SEND_PCL( *outFile, "SP0;" );
+ else
+ SEND_PCL( *outFile, "SP1;" );
+#endif /* XP_PCL_COLOR */
+ }
+
+#if 0
+ if( changeMask & GCFunction )
+ {
+ int rop = -1;
+ char t[10];
+
+ switch( pGC->alu )
+ {
+ case GXclear:
+ rop = 1;
+ break;
+ case GXand:
+ rop = 136;
+ break;
+ case GXandReverse:
+ rop = 68;
+ break;
+ case GXcopy:
+ rop = 204;
+ break;
+ case GXandInverted:
+ rop = 34;
+ break;
+ case GXnoop:
+ rop = 170;
+ break;
+ case GXxor:
+ rop = 238;
+ break;
+ case GXor:
+ rop = 238;
+ break;
+ case GXnor:
+ rop = 17;
+ break;
+ case GXequiv:
+ rop = 153;
+ break;
+ case GXinvert:
+ rop = 85;
+ break;
+ case GXorReverse:
+ rop = 221;
+ break;
+ case GXcopyInverted:
+ rop = 51;
+ break;
+ case GXorInverted:
+ rop = 187;
+ break;
+ case GXnand:
+ rop = 119;
+ break;
+ case GXset:
+ rop = 0;
+ break;
+ }
+ if( rop != -1 )
+ {
+ sprintf( t, "MC1,%d;", rop );
+ SEND_PCL( *outFile, t );
+#endif
+
+ if( changeMask & GCForeground )
+ switch( pGC->fgPixel )
+ {
+ case 1:
+ SEND_PCL( *outFile, "SP1;" );
+ break;
+ default:
+ SEND_PCL( *outFile, "SP0;" );
+ break;
+ }
+
+ if( changeMask & GCForeground )
+ {
+#ifdef XP_PCL_COLOR
+ ColormapPtr cmap;
+ Colormap c;
+ char t[40];
+
+ c = wColormap( ((WindowPtr)pDrawable) );
+ cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
+
+ if( cmap->class == TrueColor )
+ {
+ if( pGC->fillStyle != FillTiled || pGC->tileIsPixel ) {
+ unsigned short r, g, b;
+
+ r = (pGC->fgPixel & cmap->pVisual->redMask)
+ >> (cmap->pVisual->offsetRed );
+ g = (pGC->fgPixel & cmap->pVisual->greenMask)
+ >> (cmap->pVisual->offsetGreen);
+ b = (pGC->fgPixel & cmap->pVisual->blueMask)
+ >> (cmap->pVisual->offsetBlue);
+
+ PclLookUp(cmap, cPriv, &r, &g, &b);
+ sprintf( t, "\033%%0A\033*v%ua%ub%uc0I\033%%0B", r, g, b);
+ SEND_PCL( *outFile, t );
+ }
+ }
+ else /* PseudoColor or StaticGray */
+ {
+ sprintf( t, "SP%ld;", (long) pGC->fgPixel );
+ SEND_PCL( *outFile, t );
+ }
+#else
+ ScreenPtr screen;
+ screen = pDrawable->pScreen;
+ if ( pGC->fgPixel == screen->whitePixel )
+ SEND_PCL( *outFile, "SP0;");
+ else
+ SEND_PCL( *outFile, "SP1;");
+#endif /* XP_PCL_COLOR */
+ }
+
+ if( changeMask & GCJoinStyle )
+ switch( pGC->joinStyle )
+ {
+ case JoinMiter:
+ SEND_PCL( *outFile, "LA2,1;" );
+ break;
+ case JoinRound:
+ SEND_PCL( *outFile, "LA2,4;" );
+ break;
+ case JoinBevel:
+ SEND_PCL( *outFile, "LA2,5;" );
+ break;
+ }
+
+ if( changeMask & GCCapStyle )
+ switch( pGC->capStyle )
+ {
+ case CapNotLast:
+ case CapButt:
+ SEND_PCL( *outFile, "LA1,1;" );
+ break;
+ case CapRound:
+ SEND_PCL( *outFile, "LA1,4;" );
+ break;
+ case CapProjecting:
+ SEND_PCL( *outFile, "LA1,2;" );
+ break;
+ }
+
+ if( changeMask & GCLineWidth )
+ {
+ float penWidth, pixelsPerMM;
+ ScreenPtr screen;
+ char temp[30];
+
+ if( pGC->lineWidth == 0 || pGC->lineWidth == 1 )
+ /* A pen width of 0.0 mm gives a one-pixel-wide line */
+ penWidth = 0.0;
+ else
+ {
+ screen = pDrawable->pScreen;
+ pixelsPerMM = (float)screen->width / (float)screen->mmWidth;
+
+ penWidth = pGC->lineWidth / pixelsPerMM;
+ }
+ sprintf( temp, "PW%g;", penWidth );
+ SEND_PCL( *outFile, temp );
+ }
+
+ if( changeMask & GCLineStyle )
+ {
+ int i, num = pGC->numInDashList;
+ double total;
+ char t[30];
+
+ switch( pGC->lineStyle )
+ {
+ case LineSolid:
+ SEND_PCL( *outFile, "LT;" );
+ break;
+ case LineOnOffDash:
+ /*
+ * Calculate the pattern length of the dashes, in pixels,
+ * then convert to mm
+ */
+ for( i = 0, total = 0.0; i < 20 && i < num; i++ )
+ total += pGC->dash[i];
+ if( num % 2 )
+ for( i = num; i < 20 && i < num + num; i++ )
+ total += pGC->dash[i-num];
+
+ total *= ( (double)pDrawable->pScreen->mmWidth /
+ (double)pDrawable->pScreen->width );
+
+ sprintf( t, "LT8,%f,1;", total );
+ SEND_PCL( *outFile, t );
+ break;
+ }
+ }
+
+
+ if( changeMask & GCFillStyle )
+ switch( pGC->fillStyle )
+ {
+ case FillSolid:
+ SEND_PCL( *outFile, "FT1;TR0;CF;" );
+ break;
+ case FillTiled:
+ SEND_PCL( *outFile, "FT22,100;TR0;CF2,0;" );
+ break;
+ case FillOpaqueStippled:
+ SEND_PCL( *outFile, "FT22,101;TR0;CF2,0;" );
+ if( pGC->fgPixel != gcPriv->stippleFg ||
+ pGC->bgPixel != gcPriv->stippleBg )
+ changeMask |= GCStipple;
+ break;
+ case FillStippled:
+ SEND_PCL( *outFile, "FT22,102;TR1;CF2,0;" );
+ break;
+ }
+
+ if( changeMask & GCTile && !pGC->tileIsPixel )
+ {
+ char *bits;
+ int h, w, sz;
+
+ h = pGC->tile.pixmap->drawable.height;
+ w = pGC->tile.pixmap->drawable.width;
+
+ if( pGC->tile.pixmap->drawable.depth == 1 )
+ {
+ sz = h * BitmapBytePad( w );
+
+ bits = (char *)xalloc( sz );
+ mfbGetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, XYPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 1, h, w, 100, *outFile );
+ xfree( bits );
+ }
+ else if( pGC->tile.pixmap->drawable.depth == 8 )
+ {
+ sz = h * PixmapBytePad( w, 8 );
+ bits = (char *)xalloc( sz );
+ cfbGetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, ZPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 8, h, w, 100, *outFile );
+ xfree( bits );
+ }
+#if PSZ == 32
+ else
+ {
+ sz = h * PixmapBytePad( w, 24 );
+
+ bits = (char *)xalloc( sz );
+ cfb32GetImage(&(pGC->tile.pixmap->drawable), 0, 0, w, h, ZPixmap, ~0, bits);
+ PclSendPattern( bits, sz, 24, h, w, 100, *outFile );
+ xfree( bits );
+ }
+#endif
+ }
+
+ if( changeMask & ( GCTileStipXOrigin | GCTileStipYOrigin ) )
+ {
+ char t[30];
+
+ sprintf( t, "AC%d,%d;", pGC->patOrg.x, pGC->patOrg.y );
+ SEND_PCL( *outFile, t );
+ }
+
+ /*
+ * We have to resend the stipple pattern either when the stipple itself
+ * changes, or if we're in FillOpaqueStippled mode and either the
+ * foreground or the background color changes.
+ */
+ if( changeMask & GCStipple ||
+ ( pGC->fillStyle == FillOpaqueStippled &&
+ ( pGC->fgPixel != gcPriv->stippleFg ||
+ pGC->bgPixel != gcPriv->stippleBg ) ) )
+ {
+ int h, w, i, sz, w2;
+ char *bits, *row, t[30];
+ PixmapPtr scratchPix;
+ GCPtr scratchGC;
+
+ if( pGC->stipple != NULL )
+ {
+ SEND_PCL( *outFile, "\033%0A" );
+
+ h = pGC->stipple->drawable.height;
+ w = pGC->stipple->drawable.width;
+ sz = h * BitmapBytePad( w );
+
+ bits = (char *)xalloc( sz );
+ mfbGetImage( &(pGC->stipple->drawable), 0, 0, w, h, XYPixmap, ~0, bits );
+
+ w2 = ( w / 8 ) + ( ( w%8 ) ? 1 : 0 );
+ /*
+ * XXX The PCL docs say that I need to word-align each
+ * XXX row, but I get garbage when I do...
+ */
+ /*
+ if( w2 % 2 )
+ w2++;
+ */
+
+ sprintf( t, "\033*c102g%dW", h * w2 + 8 );
+ SEND_PCL( *outFile, t );
+
+ sprintf( t, "%c%c%c%c%c%c%c%c", 0, 0, 1, 0, h>>8, h&0xff, w>>8,
+ w&0xff );
+ SEND_PCL_COUNT( *outFile, t, 8 );
+
+ for( row = bits, i = 0; i < h; i++, row += BitmapBytePad( w ) )
+ SEND_PCL_COUNT( *outFile, row, w2 );
+
+ SEND_PCL( *outFile, "\033%0B" );
+
+ xfree( bits );
+
+ /*
+ * Also do the opaque stipple, as a tile
+ */
+ if( pGC->depth != 1 )
+ sz = h * PixmapBytePad( w, pGC->depth );
+ bits = (char *)xalloc( sz );
+
+ scratchPix =
+ (*pGC->pScreen->CreatePixmap)( pGC->pScreen,
+ w, h, pGC->depth );
+ scratchGC = GetScratchGC( pGC->depth, pGC->pScreen );
+ CopyGC( pGC, scratchGC, ~0L );
+
+ if( pGC->depth == 1 )
+ {
+ mfbValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ mfbCopyPlane( &(pGC->stipple->drawable),
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ mfbGetImage( &(scratchPix->drawable), 0, 0, w, h, XYPixmap, ~0,
+ bits );
+ }
+ else if( pGC->depth <= 32 )
+ {
+#if PSZ == 8
+ cfbValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ cfbCopyPlane( &(pGC->stipple->drawable),
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ cfbGetImage( &(scratchPix->drawable), 0, 0, w, h, ZPixmap, ~0,
+ bits );
+#else
+ cfb32ValidateGC( scratchGC, ~0L,
+ (DrawablePtr)scratchPix );
+ cfb32CopyPlane( pGC->stipple,
+ (DrawablePtr)scratchPix, scratchGC, 0,
+ 0, w, h, 0, 0, 1 );
+ cfb32GetImage( scratchPix, 0, 0, w, h, ZPixmap, ~0,
+ bits );
+#endif
+ }
+ PclSendPattern( bits, sz, pGC->depth, h, w, 101, *outFile );
+ FreeScratchGC( scratchGC );
+ (*pGC->pScreen->DestroyPixmap)( scratchPix );
+ xfree( bits );
+ }
+ }
+
+ if( changeMask & ( GCTileStipXOrigin | GCTileStipYOrigin ) )
+ {
+ char t[30];
+
+ sprintf( t, "AC%d,%d;", pGC->patOrg.x, pGC->patOrg.y );
+ SEND_PCL( *outFile, t );
+ }
+
+ if( changeMask & GCDashList )
+ {
+ int num = pGC->numInDashList;
+ double total;
+ char dashes[20];
+ char t[100], t2[20];
+
+ /* Make up the doubled dash list, if necessary */
+ for( i = 0; i < 20 && i < num; i++ )
+ dashes[i] = pGC->dash[i];
+
+ if( num % 2 )
+ {
+ for( i = num; i < 20 && i < num + num; i++ )
+ dashes[i] = dashes[i-num];
+ if( ( num *= 2 ) > 20 )
+ num = 20;
+ }
+
+ /* Add up dash lengths to get percentage */
+ for( i = 0, total = 0; i < num; i++ )
+ total += dashes[i];
+
+ /* Build up the HP-GL/2 for the dash list */
+ strcpy( t, "UL8" );
+ for( i = 0; i < num; i++ )
+ {
+ sprintf( t2, ",%d",
+ (int)( ( (double)dashes[i] / total * 100.0 ) + 0.5 ) );
+ strcat( t, t2 );
+ }
+ strcat( t, ";" );
+ SEND_PCL( *outFile, t );
+ }
+
+
+ /* Go back to PCL mode */
+ SEND_PCL( *outFile, "\033%0A" );
+
+ /*
+ * Update the drawable's private information, which includes
+ * erasing the drawable's private changeMask, since all the
+ * changes have been made.
+ */
+ if( changeMask )
+ PclSetDrawablePrivateGC( pDrawable, *pGC );
+
+ return TRUE;
+}
+
+/*
+ * PclComputeCompositeClip()
+ *
+ * I'd like to use the miComputeCompositeClip function, but it sticks
+ * things into the mi GC privates, where the PCL driver can't get at
+ * it. So, rather than mess around with the mi code, I ripped it out
+ * and made the appropriate changes here.
+ */
+
+
+void
+PclComputeCompositeClip(
+ GCPtr pGC,
+ DrawablePtr pDrawable)
+{
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else
+ {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = pGC->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping the
+ * pointer we got, and remembering whether or not should destroy (or
+ * maybe re-use) it later. this way, we avoid unnecessary copying of
+ * regions. (this wins especially if many clients clip by children
+ * and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE)
+ {
+ if (freeCompClip)
+ REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+ pGC->pCompositeClip = pregWin;
+ pGC->freeCompClip = freeTmpClip;
+ }
+ else
+ {
+ /*
+ * we need one 'real' region to put into the composite clip. if
+ * pregWin the current composite clip are real, we can get rid of
+ * one. if pregWin is real and the current composite clip isn't,
+ * use pregWin for the composite clip. if the current composite
+ * clip is real and pregWin isn't, use the current composite
+ * clip. if neither is real, create a new region.
+ */
+
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ if (freeTmpClip)
+ REGION_DESTROY(pGC->pScreen, pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ REGION_INTERSECT(pGC->pScreen, pregWin, pregWin,
+ pGC->clientClip);
+ pGC->pCompositeClip = pregWin;
+ }
+ else
+ {
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ pGC->freeCompClip = TRUE;
+ REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+ }
+ } /* end of composite clip for a window */
+ else
+ {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ pixbounds.x1 = 0;
+ pixbounds.y1 = 0;
+ pixbounds.x2 = pDrawable->width;
+ pixbounds.y2 = pDrawable->height;
+
+ if (pGC->freeCompClip)
+ {
+ REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
+ }
+ else
+ {
+ pGC->freeCompClip = TRUE;
+ pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION)
+ {
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip,
+ -pGC->clipOrg.x, -pGC->clipOrg.y);
+ REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+ pGC->pCompositeClip, pGC->clientClip);
+ REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip,
+ pGC->clipOrg.x, pGC->clipOrg.y);
+ }
+ } /* end of composite clip for pixmap */
+}
+
+/*
+ * PclValidateGC()
+ *
+ * Unlike many screen GCValidate routines, this function should not need
+ * to mess with setting the drawing functions. Different drawing
+ * functions are usually needed to optimize such things as drawing
+ * wide or dashed lines; this functionality will be handled primarily
+ * by the printer itself, while the necessary PCL code to set the
+ * attributes will be done in PclUpdateDrawableGC().
+ */
+
+/*ARGSUSED*/
+void
+PclValidateGC(
+ GCPtr pGC,
+ unsigned long changes,
+ DrawablePtr pDrawable)
+{
+ /*
+ * Pixmaps should be handled by their respective validation
+ * functions.
+ */
+ if( pDrawable->type == DRAWABLE_PIXMAP )
+ {
+ if( pDrawable->depth == 1 )
+ {
+ mfbValidateGC( pGC, ~0, pDrawable );
+ }
+ else if( pDrawable->depth <= 32 )
+ {
+#if PSZ == 8
+ cfbValidateGC( pGC, ~0, pDrawable );
+#else
+ cfb32ValidateGC( pGC, ~0, pDrawable );
+#endif
+ }
+ return;
+ }
+
+ /*
+ * Reset the drawing operations
+ */
+ pGC->ops = &PclGCOps;
+
+ /*
+ * Validate the information, and correct it if necessary.
+ */
+
+ /*
+ * If necessary, compute the composite clip region. (Code ripped
+ * from migc.c)
+ */
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ PclComputeCompositeClip(pGC, pDrawable);
+ }
+
+ /*
+ * PCL does not directly support the DoubleDash line style, nor is
+ * there an easy way to simulate it, so we'll just change it to a
+ * LineOnOffDash, which is supported by PCL.
+ */
+ if( ( changes & GCLineStyle ) && ( pGC->lineStyle == LineDoubleDash ) )
+ pGC->lineStyle = LineOnOffDash;
+
+ /*
+ * Update the drawable's changeMask to reflect the changes made to the GC.
+ */
+/*
+ PclSetDrawablePrivateGC( pDrawable, *pGC, changes );
+*/
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c b/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c
new file mode 100644
index 000000000..8bedee7c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclInit.c
@@ -0,0 +1,631 @@
+/* $Xorg: PclInit.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclInit.c
+** *
+** * Contents:
+** * Initialization code of Pcl driver for the print server.
+** *
+** * Created: 1/30/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclInit.c,v 1.11 2001/12/21 21:02:05 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "Pcl.h"
+
+#include "cfb.h"
+#include <X11/Xos.h> /* for unlink() */
+
+#include "attributes.h"
+#include "DiPrint.h"
+
+#define MODELDIRNAME "/models"
+
+static void AllocatePclPrivates(ScreenPtr pScreen);
+static int PclInitContext(XpContextPtr pCon);
+static Bool PclDestroyContext(XpContextPtr pCon);
+
+int PclScreenPrivateIndex;
+int PclContextPrivateIndex;
+int PclPixmapPrivateIndex;
+int PclWindowPrivateIndex;
+int PclGCPrivateIndex;
+
+#ifdef XP_PCL_COLOR
+/*
+ * The supported visuals on this screen
+ */
+static VisualRec Visuals[] =
+{
+ { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0 },
+ { 2, PseudoColor, 8, 256, 8, 0, 0, 0, 0, 0, 0 },
+ { 3, TrueColor, 8, 256, 24, 0xFF0000, 0xFF00, 0xFF, 16, 8, 0 }
+};
+
+/*
+ * The supported depths on this screen
+ */
+static DepthRec Depths[] =
+{
+ { 1, 1, NULL },
+ { 8, 1, NULL },
+ { 24, 1, NULL }
+};
+#else
+/*
+ * The supported visuals on this screen
+ */
+static VisualRec Visuals[] =
+{
+ { 1, StaticGray, 1, 2, 1, 0, 0, 0, 0, 0, 0}
+};
+
+/*
+ * The supported depths on this screen
+ */
+static DepthRec Depths[] =
+{
+ { 1, 1, NULL }
+};
+#endif /* XP_PCL_COLOR */
+
+
+#define NUM_VISUALS(visuals) (sizeof(visuals) / sizeof(VisualRec))
+#define NUM_DEPTHS(depths) (sizeof(depths) / sizeof(DepthRec))
+
+Bool
+PclCloseScreen(int index,
+ ScreenPtr pScreen)
+{
+ PclScreenPrivPtr pPriv = pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+
+ pScreen->CloseScreen = pPriv->CloseScreen;
+ xfree( pPriv );
+
+ return (*pScreen->CloseScreen)(index, pScreen);
+}
+
+Bool
+InitializePclDriver(
+ int ndx,
+ ScreenPtr pScreen,
+ int argc,
+ char **argv)
+{
+ int maxRes, xRes, yRes, maxDim;
+ unsigned i;
+ PclScreenPrivPtr pPriv;
+
+ /*
+ * Register this driver's InitContext function with the print
+ * extension. This is a bit sleazy, as the extension hasn't yet
+ * been initialized, but the extensionneeds to know this, and this
+ * seems the best time to provide the information.
+ */
+#ifdef XP_PCL_COLOR
+ XpRegisterInitFunc( pScreen, "XP-PCL-COLOR", PclInitContext );
+#elif XP_PCL_MONO
+ XpRegisterInitFunc( pScreen, "XP-PCL-MONO", PclInitContext );
+#else
+ XpRegisterInitFunc( pScreen, "XP-PCL-LJ3", PclInitContext );
+#endif /* XP_PCL_MONO */
+
+ /*
+ * Create and fill in the devPrivate for the PCL driver.
+ */
+ AllocatePclPrivates(pScreen);
+
+ pPriv =
+ (PclScreenPrivPtr)pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+
+ maxDim = MAX( pScreen->height, pScreen->width );
+ xRes = pScreen->width / ( pScreen->mmWidth / 25.4 );
+ yRes = pScreen->height / ( pScreen->mmHeight / 25.4 );
+ maxRes = MAX( xRes, yRes );
+
+#ifdef XP_PCL_COLOR
+ cfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
+ maxRes );
+ /*
+ * Clean up the fields that we stomp (code taken from cfbCloseScreen)
+ */
+ for( i = 0; (int) i < pScreen->numDepths; i++ )
+ xfree( pScreen->allowedDepths[i].vids );
+ xfree( pScreen->allowedDepths );
+ xfree( pScreen->visuals );
+#else
+ mfbScreenInit( pScreen, NULL, maxDim, maxDim, maxRes, maxRes,
+ maxRes );
+#endif /* XP_PCL_COLOR */
+
+ miInitializeBackingStore ( pScreen );
+
+ pScreen->defColormap = FakeClientID(0);
+ pScreen->blackPixel = 1;
+ pScreen->whitePixel = 0;
+
+ pPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = PclCloseScreen;
+
+ pScreen->QueryBestSize = (QueryBestSizeProcPtr)PclQueryBestSize;
+ pScreen->SaveScreen = (SaveScreenProcPtr)_XpBoolNoop;
+ pScreen->GetImage = (GetImageProcPtr)_XpVoidNoop;
+ pScreen->GetSpans = (GetSpansProcPtr)_XpVoidNoop;
+ pScreen->CreateWindow = PclCreateWindow;
+ pScreen->DestroyWindow = PclDestroyWindow;
+/*
+ pScreen->PositionWindow = PclPositionWindow;
+*/
+ pScreen->ChangeWindowAttributes = PclChangeWindowAttributes;
+/*
+ pScreen->RealizeWindow = PclMapWindow;
+ pScreen->UnrealizeWindow = PclUnmapWindow;
+*/
+ pScreen->PaintWindowBackground = PclPaintWindow;
+ pScreen->PaintWindowBorder = PclPaintWindow;
+ pScreen->CopyWindow = PclCopyWindow; /* XXX Hard routine to write! */
+
+ pScreen->CreatePixmap = PclCreatePixmap;
+ pScreen->DestroyPixmap = PclDestroyPixmap;
+ pScreen->RealizeFont = PclRealizeFont;
+ pScreen->UnrealizeFont = PclUnrealizeFont;
+ pScreen->CreateGC = PclCreateGC;
+
+ pScreen->CreateColormap = PclCreateColormap;
+ pScreen->DestroyColormap = PclDestroyColormap;
+ pScreen->InstallColormap = (InstallColormapProcPtr)NoopDDA;
+ pScreen->UninstallColormap = (UninstallColormapProcPtr)NoopDDA;
+ pScreen->ListInstalledColormaps = PclListInstalledColormaps;
+ pScreen->StoreColors = PclStoreColors;
+/*
+ pScreen->ResolveColor = PclResolveColor;
+*/
+
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+ pScreen->ConstrainCursor = PclConstrainCursor;
+ pScreen->CursorLimits = PclCursorLimits;
+ pScreen->DisplayCursor = PclDisplayCursor;
+ pScreen->RealizeCursor = PclRealizeCursor;
+ pScreen->UnrealizeCursor = PclUnrealizeCursor;
+ pScreen->RecolorCursor = PclRecolorCursor;
+ pScreen->SetCursorPosition = PclSetCursorPosition;
+
+ pScreen->visuals = Visuals;
+ pScreen->numVisuals = NUM_VISUALS( Visuals );
+ pScreen->allowedDepths = Depths;
+ pScreen->numDepths = NUM_DEPTHS( Depths );
+
+ for( i = 0; i < NUM_DEPTHS( Depths ); i++ )
+ {
+ pScreen->allowedDepths[i].vids =
+ (VisualID *)xalloc( sizeof(VisualID ) );
+ pScreen->allowedDepths[i].vids[0] = i + 1;
+ }
+
+#ifdef XP_PCL_COLOR
+ pScreen->rootVisual = 2;
+ pScreen->rootDepth = 8;
+#else
+ pScreen->rootVisual = 1;
+ pScreen->rootDepth = 1;
+#endif /* XP_PCL_COLOR */
+
+ pPriv->colormaps = NULL;
+ PclCreateDefColormap( pScreen );
+
+ return TRUE;
+}
+
+static void
+AllocatePclPrivates(ScreenPtr pScreen)
+{
+ static unsigned long PclGeneration = 0;
+
+ if((unsigned long) PclGeneration != serverGeneration)
+ {
+ PclScreenPrivateIndex = AllocateScreenPrivateIndex();
+
+ PclWindowPrivateIndex = AllocateWindowPrivateIndex();
+ AllocateWindowPrivate( pScreen, PclWindowPrivateIndex,
+ sizeof( PclWindowPrivRec ) );
+
+ PclContextPrivateIndex = XpAllocateContextPrivateIndex();
+ XpAllocateContextPrivate( PclContextPrivateIndex,
+ sizeof( PclContextPrivRec ) );
+
+ PclGCPrivateIndex = AllocateGCPrivateIndex();
+ AllocateGCPrivate( pScreen, PclGCPrivateIndex,
+ sizeof( PclGCPrivRec ) );
+
+ PclPixmapPrivateIndex = AllocatePixmapPrivateIndex();
+ AllocatePixmapPrivate( pScreen, PclPixmapPrivateIndex,
+ sizeof( PclPixmapPrivRec ) );
+
+ PclGeneration = serverGeneration;
+ }
+
+ pScreen->devPrivates[PclScreenPrivateIndex].ptr = (pointer)xalloc(
+ sizeof(PclScreenPrivRec));
+}
+
+/*
+ * PclInitContext
+ *
+ * Establish the appropriate values for a PrintContext used with the PCL
+ * 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
+PclInitContext(XpContextPtr pCon)
+{
+ XpDriverFuncsPtr pFuncs;
+ PclContextPrivPtr pConPriv;
+ char *server, *attrStr;
+ char *modelID;
+ char *configDir;
+ char *pathName;
+ int i, j;
+ float width, height;
+ XpOidMediumDiscreteSizeList* ds_list;
+ XpOidArea* repro;
+ XpOid page_size;
+ XpOidMediumSS* m;
+
+ /*
+ * Initialize the attribute store for this printer.
+ */
+ XpInitAttributes( pCon );
+
+ /*
+ * Initialize the function pointers
+ */
+ pFuncs = &( pCon->funcs );
+ pFuncs->StartJob = PclStartJob;
+ pFuncs->EndJob = PclEndJob;
+ pFuncs->StartDoc = PclStartDoc;
+ pFuncs->EndDoc = PclEndDoc;
+ pFuncs->StartPage = PclStartPage;
+ pFuncs->EndPage = PclEndPage;
+ pFuncs->PutDocumentData = PclDocumentData;
+ pFuncs->GetDocumentData = PclGetDocumentData;
+ pFuncs->GetAttributes = PclGetAttributes;
+ pFuncs->SetAttributes = PclSetAttributes;
+ pFuncs->AugmentAttributes = PclAugmentAttributes;
+ pFuncs->GetOneAttribute = PclGetOneAttribute;
+ pFuncs->DestroyContext = PclDestroyContext;
+ pFuncs->GetMediumDimensions = PclGetMediumDimensions;
+ pFuncs->GetReproducibleArea = PclGetReproducibleArea;
+
+
+ /*
+ * Set up the context privates
+ */
+ pConPriv =
+ (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pageFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->pPageFile = (FILE *)NULL;
+ pConPriv->dash = NULL;
+ pConPriv->validGC = 0;
+
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ modelID = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-model-identifier");
+ if ( (configDir = XpGetConfigDir(False)) != (char *) NULL ) {
+ pathName = (char *)xalloc(strlen(configDir) + strlen(MODELDIRNAME) +
+ strlen(modelID) + strlen("color.map") + 4);
+ if (pathName) {
+ sprintf(pathName, "%s/%s/%s/%s", configDir, MODELDIRNAME, modelID,
+ "color.map");
+ pConPriv->ctbl = PclReadMap(pathName, &pConPriv->ctbldim);
+ xfree(pathName);
+
+ } else
+ pConPriv->ctbl = NULL;
+ } else
+ pConPriv->ctbl = NULL;
+
+#ifdef XP_PCL_LJ3
+ /*
+ * Initialize the spooling buffer for saving the figures temporary
+ * (LaserJet IIIs printers don't support the macro function which
+ * includes some HP-GL/2 commands.)
+ */
+ pConPriv->fcount = 0;
+ if ( !(pConPriv->figures = (char *)xalloc(1024)) )
+ pConPriv->fcount_max = 0;
+ else
+ pConPriv->fcount_max = 1024;
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * 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 ) )
+ == (char *)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 ) )
+ == (char *)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 ) )
+ == (char *)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, &PclValidatePoolsRec );
+
+ /*
+ * Munge the reproducible areas to reflect the fact that PCL will not let
+ * me move the right or left margins closer than .25" to the edge of the
+ * paper.
+ */
+ m = XpGetMediumSSAttr( pCon, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported,
+ (const XpOidList*) NULL,
+ (const XpOidList*) NULL );
+ for( i = 0; i < XpOidMediumSSCount( m ); i++ )
+ {
+ if( XpOidMediumSS_DISCRETE == (m->mss)[i].mstag )
+ {
+ ds_list = (m->mss)[i].ms.discrete;
+ for( j = 0; j < ds_list->count; j++ )
+ {
+ repro = &(ds_list->list)[j].assured_reproduction_area;
+ page_size = (ds_list->list)[j].page_size;
+ XpGetMediumMillimeters( page_size, &width, &height );
+
+ if( repro->minimum_x < 6.35 )
+ repro->minimum_x = 6.35;
+ if( width - repro->maximum_x < 6.35 )
+ repro->maximum_x = width - 6.35;
+ }
+ }
+ }
+ XpPutMediumSSAttr( pCon, XPPrinterAttr,
+ xpoid_att_medium_source_sizes_supported, m );
+ XpOidMediumSSDelete( m );
+
+ /*
+ * Finish validating the attribute pools
+ */
+
+ XpValidateAttributePool( pCon, XPDocAttr, &PclValidatePoolsRec );
+ XpValidateAttributePool( pCon, XPJobAttr, &PclValidatePoolsRec );
+ XpValidateAttributePool( pCon, XPPageAttr, &PclValidatePoolsRec );
+
+ /*
+ * Clear out the colormap storage
+ */
+ pConPriv->palettes = NULL;
+
+ return Success;
+}
+
+static Bool
+PclDestroyContext(XpContextPtr pCon)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclPaletteMapPtr p, t;
+ PclCmapToContexts *pCmap;
+ ScreenPtr screen;
+ PclScreenPrivPtr sPriv;
+ PclContextListPtr con, prevCon, temp;
+
+
+ /*
+ * Clean up the temporary files
+ */
+ if( pConPriv->pPageFile != (FILE *)NULL )
+ {
+ fclose( pConPriv->pPageFile );
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if( pConPriv->pageFileName != (char *)NULL )
+ {
+ unlink( pConPriv->pageFileName );
+ xfree( pConPriv->pageFileName );
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ 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;
+ }
+
+ xfree( pConPriv->dash );
+ xfree(pConPriv->ctbl);
+ pConPriv->ctbl = NULL;
+#ifdef XP_PCL_LJ3
+ xfree( pConPriv->figures );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Destroy the colormap<->palette mappings
+ */
+ p = pConPriv->palettes;
+ while( p )
+ {
+ t = p;
+ p = p->next;
+ xfree( t );
+ }
+ pConPriv->palettes = NULL;
+
+ /*
+ * Remove the context from the screen-level colormap<->contexts mappings
+ */
+ screen = screenInfo.screens[pCon->screenNum];
+ sPriv = (PclScreenPrivPtr)screen->devPrivates[PclScreenPrivateIndex].ptr;
+ pCmap = sPriv->colormaps;
+ while( pCmap )
+ {
+ con = pCmap->contexts;
+ prevCon = NULL;
+
+ while( con )
+ {
+ if( con->context->contextID == pCon->contextID )
+ {
+ if( prevCon )
+ {
+ temp = con;
+ prevCon->next = con = con->next;
+ }
+ else
+ {
+ temp = pCmap->contexts;
+ pCmap->contexts = con = con->next;
+ }
+ xfree( temp );
+ }
+ else
+ con = con->next;
+ }
+
+ pCmap = pCmap->next;
+ }
+
+ XpDestroyAttributes(pCon);
+
+ return Success;
+}
+
+XpContextPtr
+PclGetContextFromWindow(WindowPtr win)
+{
+ PclWindowPrivPtr pPriv;
+
+ while( win )
+ {
+ pPriv =
+ (PclWindowPrivPtr)win->devPrivates[PclWindowPrivateIndex].ptr;
+ if( pPriv->validContext )
+ return pPriv->context;
+
+ win = win->parent;
+ }
+
+ return NULL;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c b/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c
new file mode 100644
index 000000000..f2b564df8
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclLine.c
@@ -0,0 +1,316 @@
+/* $Xorg: PclLine.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclLine.c
+** *
+** * Contents:
+** * Line drawing routines for the PCL driver
+** *
+** * Created: 10/11/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclLine.c,v 1.6 1999/12/13 02:12:55 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+/*
+ * PclPolyLine()
+ * PclPolySegment()
+ *
+ * Generates PCL code to draw a polyline, or a collection of distinct
+ * line segments, clipped by the current clip region. Since PCL
+ * supports clipping to a rectangle, and the clip region is
+ * represented as a collection of visible rectangles, we can draw and
+ * clip the line by repeatedly drawing the complete line, clipped to
+ * each rectangle in the clip region.
+ *
+ * Since each box in the clipping region generates approximately 30
+ * bytes of PCL code, we have to have a way to avoid having a large
+ * number of boxes. The worst problem the case where the clipping
+ * region is a collection of one-pixel-high boxes, perhaps arising
+ * from a bitmap clip mask, or a region defined by a non-rectangular
+ * polygon.
+ *
+ * To alleviate this problem, we create a second clipping region,
+ * which consists of the union of the bounding boxes of each line
+ * segment. (Each bounding box is also increased by some amount
+ * related to the current line width to allow for non-zero-width
+ * lines, and for the various end and join styles.) This region is
+ * intersected with the "real" clipping region to get the region used
+ * to actually clip the polyline. This should result in a significant
+ * reduction in the number of clip rectangles, as the region-handling
+ * code should consolidate many of the fragments of one-pixel-high
+ * rectangles into larger rectangles.
+ */
+
+void
+PclPolyLine(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int nPoints,
+ xPoint *pPoints)
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset = 0, yoffset = 0;
+ int nbox;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ int i;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)
+ xalloc( ( nPoints - 1 ) * sizeof( xRectangle ) );
+
+ /*
+ * Calculate the "fudge factor" based on the line width.
+ * Multiplying by three seems to be a good first guess.
+ * XXX I need to think of a way to test this.
+ */
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the polyline, by defining it as a
+ * macro which uses the HP-GL/2 line drawing function.
+ */
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ sprintf( t, "PU%d,%dPD\n", pPoints[0].x + pDrawable->x,
+ pPoints[0].y + pDrawable->y );
+ SAVE_PCL( outFile, pConPriv, t ); /* Move to the start of the polyline */
+
+ switch( mode )
+ {
+ case CoordModeOrigin:
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+ SAVE_PCL( outFile, pConPriv, "PA" );
+ break;
+ case CoordModePrevious:
+ xoffset = yoffset = 0;
+ SAVE_PCL( outFile, pConPriv, "PR" );
+ break;
+ }
+
+ /*
+ * Build the "drawing region" as we build the PCL to draw the
+ * line.
+ */
+ for(i = 1, r = drawRects; i < nPoints; i++, r++ )
+ {
+ if( i != 1 )
+ SAVE_PCL( outFile, pConPriv, "," );
+
+ sprintf( t, "%d,%d", pPoints[i].x + xoffset,
+ pPoints[i].y + yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ r->x = MIN( pPoints[i-1].x, pPoints[i].x ) + xoffset - fudge;
+ r->y = MIN( pPoints[i-1].y, pPoints[i].y ) + yoffset - fudge;
+ r->width = abs( pPoints[i-1].x - pPoints[i].x ) + 2 * fudge;
+ r->height = abs( pPoints[i-1].y - pPoints[i].y ) + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nPoints - 1,
+ drawRects, CT_UNSORTED );
+ if( mode == CoordModePrevious )
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
+
+void
+PclPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSegments,
+ xSegment *pSegments)
+{
+ FILE *outFile, *dummy;
+ char t[80];
+ int xoffset, yoffset;
+ int nbox, i;
+ unsigned long valid;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ GC cacheGC;
+
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage for the temporary regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)
+ xalloc( nSegments * sizeof( xRectangle ) );
+
+ /*
+ * Calculate the fudge factor, based on the line width
+ */
+ fudge = pGC->lineWidth * 3 + 1;
+
+ /*
+ * Turn off line joining.
+ */
+ SEND_PCL( outFile, "\033%0BLA2,6;\033%0A" );
+
+ /*
+ * Generate the PCL code to draw the segments, by defining them as
+ * a macro which uses the HP-GL/2 line drawing function.
+ *
+ * XXX I wonder if this should be implemented using the Encoded
+ * XXX Polyline function. Since I'm only sending it once, it's not
+ * XXX necessarily too important.
+ */
+
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nSegments; i++, r++ )
+ {
+ r->x = MIN( pSegments[i].x1, pSegments[i].x2 ) + xoffset;
+ r->y = MIN( pSegments[i].y1, pSegments[i].y2 ) + yoffset;
+ r->width = abs( pSegments[i].x1 - pSegments[i].x2 );
+ r->height = abs( pSegments[i].y1 - pSegments[i].y2 );
+
+ sprintf( t, "PU%d,%d;PD%d,%d;", pSegments[i].x1 + xoffset,
+ pSegments[i].y1 + yoffset, pSegments[i].x2 +
+ xoffset, pSegments[i].y2 + yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ r->x -= fudge;
+ r->y -= fudge;
+ r->width += 2 * fudge;
+ r->height += 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, "\033%0A" );
+ MACRO_END ( outFile );
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nSegments,
+ drawRects, CT_UNSORTED );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire set of segments to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Now we need to reset the line join mode to whatever it was at before.
+ * The easiest way is to force the cached GC's joinstyle to be different
+ * from the current GC's joinstyle, then re-update the GC. This way, we
+ * don't have to duplicate code unnecessarily.
+ */
+ PclGetDrawablePrivateStuff( pDrawable, &cacheGC, &valid, &dummy );
+ cacheGC.joinStyle = !cacheGC.joinStyle;
+ PclSetDrawablePrivateGC( pDrawable, cacheGC );
+ PclUpdateDrawableGC( pGC, pDrawable, &outFile );
+
+ /*
+ * Clean up
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c b/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c
new file mode 100644
index 000000000..3a958e783
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c
@@ -0,0 +1,306 @@
+/* $Xorg: PclMisc.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclMisc.c
+** *
+** * Contents:
+** * Miscellaneous code for Pcl driver.
+** *
+** * Created: 2/01/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclMisc.c,v 1.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
+#include "Pcl.h"
+
+#include "cursor.h"
+#include "resource.h"
+
+#include "windowstr.h"
+#include "propertyst.h"
+#include "attributes.h"
+
+
+/*ARGSUSED*/
+void
+PclQueryBestSize(
+ 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;
+ }
+}
+
+/*
+ * 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 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)
+ {
+ for(pProp = (PropertyPtr)(wUserProps(pPropWin));
+ pProp != (PropertyPtr)NULL;
+ pProp = pProp->next)
+ {
+ if (pProp->propertyName == atom)
+ break;
+ }
+ if(pProp != (PropertyPtr)NULL)
+ break;
+ }
+ 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>
+#include <errno.h>
+
+/* ARGSUSED */
+static void SigchldHndlr (
+ int dummy)
+{
+ int status;
+ int olderrno = errno;
+ struct sigaction act;
+ sigfillset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = SigchldHndlr;
+
+ (void) wait (&status);
+
+ /*
+ * Is this really necessary?
+ */
+ sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
+ errno = olderrno;
+}
+
+/*
+ * 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;
+}
+
+
+/*
+ * PclGetMediumDimensions is installed in the GetMediumDimensions field
+ * of each Pcl-initialized context.
+ */
+int
+PclGetMediumDimensions(XpContextPtr pCon,
+ CARD16 *width,
+ CARD16 *height)
+{
+ XpGetMediumDimensions(pCon, width, height);
+ return Success;
+}
+
+/*
+ * PclGetReproducibleArea is installed in the GetReproducibleArea field
+ * of each Pcl-initialized context.
+ */
+int
+PclGetReproducibleArea(XpContextPtr pCon,
+ xRectangle *pRect)
+{
+ XpGetReproductionArea(pCon, pRect);
+ return Success;
+}
+
+#ifdef XP_PCL_LJ3
+/*
+ * PclSpoolFigs spooled the rendering PCL/HP-GL2 commands into the
+ * temporary buffer pointed by figures pointer in pcl private context.
+ * LaserJet IIIs printers don't support the macro function which
+ * includes some HP-GL/2 commands.
+ */
+void
+PclSpoolFigs(PclContextPrivPtr pConPriv, char *t, int n)
+{
+char *ptr;
+
+ ptr = pConPriv->figures;
+ while ( ( pConPriv->fcount + n) > pConPriv->fcount_max ) {
+ ptr = (char *)xrealloc(ptr, 1024 + pConPriv->fcount_max);
+ if ( !ptr )
+ return;
+ pConPriv->figures = ptr;
+ pConPriv->fcount_max += 1024;
+ }
+ ptr += pConPriv->fcount;
+ pConPriv->fcount += n;
+ memcpy(ptr, t, n);
+}
+#endif /* XP_PCL_LJ3 */
+
+/*
+ * PclSendData:
+ * For XP-PCL-COLOR/XP-PCL-MONO, it executes the macro stored before
+ * in the clipped area.
+ * For XP-PCL-LJ3, it draws the spooled figures in the clipped area.
+ */
+void
+PclSendData(
+ FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ BoxPtr pbox,
+ int nbox,
+ double ratio
+)
+{
+char *ptr;
+int n;
+char t[80];
+
+#ifdef XP_PCL_LJ3
+ ptr = pConPriv->figures;
+ n = pConPriv->fcount;
+#else
+ ptr = "\033&f3X";
+ n = 5;
+#endif /* XP_PCL_LJ3 */
+
+ while( nbox )
+ {
+ /*
+ * Set the HP-GL/2 input window to the current
+ * rectangle in the clip region, then send the code to
+ * execute the macro defined above.
+ */
+ if (ratio == 1.0)
+ sprintf( t, "\033%%0BIW%d,%d,%d,%d;\033%%0A",
+ pbox->x1, pbox->y1,
+ pbox->x2, pbox->y2 );
+ else
+ sprintf( t, "\033%%0BIW%g,%d,%g,%d;\033%%0A",
+ ratio * pbox->x1, pbox->y1,
+ ratio * pbox->x2, pbox->y2 );
+
+ SEND_PCL( outFile, t );
+ SEND_PCL_COUNT( outFile, ptr, n);
+
+ nbox--;
+ pbox++;
+ }
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c
new file mode 100644
index 000000000..bfad618ed
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c
@@ -0,0 +1,159 @@
+/* $Xorg: PclPixel.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPixel.c
+** *
+** * Contents:
+** * Pixel-drawing code for the PCL DDX driver
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPixel.c,v 1.6tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Pcl.h"
+
+void
+PclPolyPoint( pDrawable, pGC, mode, nPoints, pPoints )
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int nPoints;
+ xPoint *pPoints;
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset, yoffset;
+ BoxRec box;
+ int xloc, yloc, i;
+#if 0
+ XpContextPtr pCon;
+ PclContextPrivPtr cPriv;
+ PclPixmapPrivPtr pPriv;
+#endif
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ /*
+ * Enter HP-GL/2 and change the line style to one in which only
+ * the vertices of the specified polyline are drawn. We must also
+ * temporarily change the line width so that only a single pixel
+ * is drawn. Then move to the first possible location.
+ */
+ xloc = pPoints[0].x + pDrawable->x;
+ yloc = pPoints[0].y + pDrawable->y;
+
+ sprintf( t, "\27%%0BPW0,0;LT0;PU;PA%d,%d", xloc, yloc );
+ SEND_PCL( outFile, t );
+
+ /*
+ * Check each point against the clip region. If it is outside the
+ * region, don't send the PCL to the printer.
+ */
+
+ for( i = 0; i < nPoints; i++ )
+ {
+ if( POINT_IN_REGION( pGC->pScreen, pGC->clientClip, xloc, yloc, &box ) )
+ {
+ sprintf( t, ",%d,%d", xloc, yloc );
+ SEND_PCL( outFile, t );
+ }
+
+ if( mode == CoordModeOrigin )
+ {
+ xloc = pPoints[i+1].x + xoffset;
+ yloc = pPoints[i+1].y + yoffset;
+ }
+ else
+ {
+ xloc += pPoints[i+1].x;
+ yloc += pPoints[i+1].y;
+ }
+ }
+
+#if 0
+ /*
+ * Change the line style and width back to what they were before
+ * this routine was called. No, this isn't pretty...
+ */
+ if( pDrawable->type == DRAWABLE_WINDOW )
+ {
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv->changeMask = GCLineWidth | GCLineStyle;
+ }
+ else
+ {
+ pPriv =
+ ((PixmapPtr)pDrawable)->devPrivates[PclPixmapPrivateIndex].ptr;
+ pPriv->changeMask = GCLineWidth | GCLineStyle;
+ }
+#endif
+
+ PclUpdateDrawableGC( pGC, pDrawable, &outFile );
+
+ /*
+ * Go back to PCL
+ */
+ SEND_PCL( outFile, "\27%0A" );
+}
+
+void
+PclPushPixels( pGC, pBitmap, pDrawable, width, height, x, y )
+ GCPtr pGC;
+ PixmapPtr pBitmap;
+ DrawablePtr pDrawable;
+ int width;
+ int height;
+ int x;
+ int y;
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c
new file mode 100644
index 000000000..9449dfdd6
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c
@@ -0,0 +1,85 @@
+/* $Xorg: PclPixmap.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPixmap.c
+** *
+** * Contents:
+** * Pixmap handling code for the PCL DDX driver
+** *
+** * Created: 2/19/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPixmap.c,v 1.3 1999/12/16 02:26:27 robin Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "cfb.h"
+#include "cfb32.h"
+#include "mfb.h"
+#include "pixmapstr.h"
+
+PixmapPtr
+PclCreatePixmap(ScreenPtr pScreen,
+ int width,
+ int height,
+ int depth)
+{
+ if( depth == 1 )
+ return mfbCreatePixmap( pScreen, width, height, depth );
+ else if( depth <= 8 )
+ return cfbCreatePixmap( pScreen, width, height, depth );
+ else if( depth <= 32 )
+ return cfb32CreatePixmap( pScreen, width, height, depth );
+ return 0;
+}
+
+
+Bool
+PclDestroyPixmap(PixmapPtr pPixmap)
+{
+ if( pPixmap->drawable.depth == 1 )
+ return mfbDestroyPixmap( pPixmap );
+ else if( pPixmap->drawable.depth <= 8 )
+ return cfbDestroyPixmap( pPixmap );
+ else if( pPixmap->drawable.depth <= 32 )
+ return cfb32DestroyPixmap( pPixmap );
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c
new file mode 100644
index 000000000..41ba4b1c0
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c
@@ -0,0 +1,353 @@
+/* $Xorg: PclPolygon.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPolygon.c
+** *
+** * Contents:
+** * Draws Polygons and Rectangles for the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPolygon.c,v 1.6 1999/12/13 02:12:56 robin Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclPolyRectangle(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ short fudge;
+ int xoffset, yoffset;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
+
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the rectangles, by defining them
+ * as a macro which uses the HP-GL/2 rectangle drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nRects; i++, r++ )
+ {
+ xRectangle rect = pRects[i];
+
+ /* Draw the rectangle */
+ sprintf( t, "PU%d,%d;ER%d,%d;", rect.x + xoffset,
+ rect.y + yoffset, rect.width, rect.height );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Build the bounding box */
+ r->x = MIN( rect.x, rect.x + rect.width ) + xoffset -
+ fudge;
+ r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
+ fudge;
+ r->width = rect.width + 2 * fudge;
+ r->height = rect.height + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles to a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
+ drawRects, CT_UNSORTED );
+
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the set of rectangles to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
+
+void
+PclFillPolygon(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int nPoints,
+ DDXPointPtr pPoints)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ BoxRec box;
+ RegionPtr drawRegion, region;
+ int xoffset, yoffset;
+ int xtop, xbottom, yleft, yright;
+ int fillRule;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+ char *command;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Generate the PCL code to draw the filled polygon, by defining
+ * it as a macro which uses the HP-GL/2 polygon drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ if( mode == CoordModeOrigin )
+ {
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+ command = "PA";
+ }
+ else
+ {
+ xoffset = yoffset = 0;
+ command = "PR";
+ }
+
+ /* Begin the polygon */
+ sprintf( t, "PU%d,%d;PM0;%s", pPoints[0].x + xoffset, pPoints[0].y
+ + yoffset, command );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Seed the bounding box */
+ xtop = xbottom = pPoints[0].x + xoffset;
+ yleft = yright = pPoints[0].y + yoffset;
+
+ /* Add the rest of the points to the polygon */
+ for( i = 1; i < nPoints; i++ )
+ {
+ if( i != 1 )
+ SAVE_PCL( outFile, pConPriv, "," );
+
+ sprintf( t, "%d,%d", pPoints[i].x + xoffset, pPoints[i].y +
+ yoffset );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Update the bounding box */
+ xtop = MIN( xtop, pPoints[i].x + xoffset );
+ xbottom = MAX( xbottom, pPoints[i].x + xoffset );
+ yleft = MIN( yleft, pPoints[i].y + yoffset );
+ yright = MAX( yright, pPoints[i].y + yoffset );
+ }
+
+ /* Close the polygon and the macro */
+
+ if( pGC->fillRule == EvenOddRule )
+ fillRule = 0;
+ else
+ fillRule = 1;
+
+ sprintf( t, ";PM2;FP%d;\033%%0A", fillRule );
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END ( outFile );
+
+ /*
+ * Build the bounding region from the bounding box of the polygon
+ */
+ box.x1 = xtop;
+ box.y1 = yleft;
+ box.x2 = xbottom;
+ box.y2 = yright;
+ drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
+
+ if( mode == CoordModePrevious )
+ REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y );
+
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the polygon to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+}
+
+void
+PclPolyFillRect(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRects,
+ xRectangle *pRects)
+{
+ char t[80];
+ FILE *outFile;
+ int nbox, i;
+ BoxPtr pbox;
+ xRectangle *drawRects, *r;
+ RegionPtr drawRegion, region;
+ int xoffset, yoffset;
+ short fudge;
+ XpContextPtr pCon;
+ PclContextPrivPtr pConPriv;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return;
+
+ pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ /*
+ * Allocate the storage required to deal with the clipping
+ * regions.
+ */
+ region = REGION_CREATE( pGC->pScreen, NULL, 0 );
+ drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
+
+
+ fudge = 3 * pGC->lineWidth + 1;
+
+ /*
+ * Generate the PCL code to draw the filled rectangles, by
+ * defining them as a macro which uses the HP-GL/2 rectangle
+ * drawing function.
+ */
+ MACRO_START( outFile, pConPriv );
+ SAVE_PCL( outFile, pConPriv, "\033%0B" );
+
+ xoffset = pDrawable->x;
+ yoffset = pDrawable->y;
+
+ for( i = 0, r = drawRects; i < nRects; i++, r++ )
+ {
+ xRectangle rect = pRects[i];
+
+ /* Draw the rectangle */
+ sprintf( t, "PU%d,%d;RR%d,%d;", rect.x + xoffset, rect.y +
+ yoffset, rect.width, rect.height );
+ SAVE_PCL( outFile, pConPriv, t );
+
+ /* Build the bounding box */
+ r->x = MIN( rect.x, rect.x + rect.width ) + xoffset - fudge;
+ r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
+ fudge;
+ r->width = rect.width + 2 * fudge;
+ r->height = rect.height + 2 * fudge;
+ }
+ SAVE_PCL( outFile, pConPriv, ";\033%0A" ); /* End the macro */
+ MACRO_END( outFile );
+
+ /*
+ * Convert the collection of rectangles to a proper region, then
+ * intersect it with the clip region.
+ */
+ drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
+ drawRects, CT_UNSORTED );
+ REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the set of rectangles to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+ xfree( drawRects );
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c b/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c
new file mode 100644
index 000000000..701710253
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c
@@ -0,0 +1,711 @@
+/* $Xorg: PclPrint.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclPrint.c
+** *
+** * Contents: Print extension code of Pcl driver
+** *
+** * Created: 2/03/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclPrint.c,v 1.7tsi Exp $ */
+
+#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 <X11/Xprotostr.h>
+
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#undef NEED_EVENTS
+
+#include "Pcl.h"
+
+#include "windowstr.h"
+#include "attributes.h"
+#include "AttrValid.h"
+#include "Oid.h"
+
+int
+PclStartJob(
+ XpContextPtr pCon,
+ Bool sendClientData,
+ ClientPtr client)
+{
+ PclContextPrivPtr pConPriv =
+ (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclPaletteMap *pal;
+
+ /*
+ * Check for existing page file, and delete it if it exists.
+ */
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ unlink(pConPriv->pageFileName);
+ xfree(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ /*
+ * Create a temporary file to store the printer output.
+ */
+ if (!XpOpenTmpFile("w+", &pConPriv->jobFileName, &pConPriv->pJobFile))
+ return BadAlloc;
+
+ /*
+ * Create/Initialize the SoftFontInfo structure
+ */
+ pConPriv->pSoftFontInfo = PclCreateSoftFontInfo();
+
+ /*
+ * Set up the colormap handling
+ */
+ pConPriv->palettes = NULL;
+ pConPriv->nextPaletteId = 4;
+ pConPriv->currentPalette = 0;
+
+ pal = &( pConPriv->staticGrayPalette );
+ pal->paletteId = 1;
+ pal->downloaded = 0;
+
+ pal = &( pConPriv->trueColorPalette );
+ pal->paletteId = 2;
+ pal->downloaded = 0;
+
+ pal = &( pConPriv->specialTrueColorPalette );
+ pal->paletteId = 3;
+ pal->downloaded = 0;
+
+ return Success;
+}
+
+int
+PclEndJob(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ PclContextPrivPtr priv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+#ifdef CCP_DEBUG
+ FILE *xpoutput;
+#endif
+ FILE *fp;
+ int retVal;
+ char *fileName, *trailer;
+ struct stat statBuf;
+ PclPaletteMapPtr p;
+
+ trailer = "\033%-12345X@PJL RESET\n";
+
+ if( cancel == True )
+ {
+ if( priv->getDocClient != (ClientPtr)NULL ) {
+ XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ return Success;
+ }
+
+ if( priv->getDocClient != (ClientPtr)NULL && priv->getDocBufSize > 0 )
+ {
+ /*
+ * We need to stash the trailer information somewhere...
+ */
+ if (!XpOpenTmpFile("w+", &fileName, &fp))
+ return BadAlloc;
+
+#ifndef XP_PCL_LJ3
+ SEND_PCL( fp, trailer );
+ rewind( fp );
+
+ retVal = XpSendDocumentData( priv->getDocClient, fp,
+ strlen( trailer ),
+ priv->getDocBufSize );
+#endif /* XP_PCL_LJ3 */
+
+ fclose( fp );
+ unlink( fileName );
+ xfree( fileName );
+
+ if( priv->getDocClient != (ClientPtr)NULL ) {
+ XpFinishDocData( priv->getDocClient );
+
+ priv->getDocClient = NULL;
+ priv->getDocBufSize = 0;
+ }
+
+ return retVal;
+ }
+
+#ifndef XP_PCL_LJ3
+ SEND_PCL( priv->pJobFile, trailer );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Submit the job to the spooler
+ */
+ fflush( priv->pJobFile );
+
+ /*
+ * Dump the job file to another output file, for testing
+ * purposes.
+ */
+ rewind( priv->pJobFile );
+ stat( priv->jobFileName, &statBuf );
+
+#ifdef CCP_DEBUG
+ unlink( "/users/prince/XpOutput" );
+ xpoutput = fopen( "/users/prince/XpOutput", "w" );
+
+ rewind( priv->pJobFile );
+ TransferBytes( priv->pJobFile, xpoutput,
+ (int)statBuf.st_size );
+ fclose( xpoutput );
+#endif
+
+ XpSubmitJob( priv->jobFileName, pCon );
+ fclose( priv->pJobFile );
+ unlink( priv->jobFileName );
+ xfree( priv->jobFileName );
+ priv->jobFileName = NULL;
+
+ PclDestroySoftFontInfo(priv->pSoftFontInfo);
+ priv->pSoftFontInfo = (PclSoftFontInfoPtr) NULL;
+
+ /*
+ * Clear out the colormap cache
+ */
+ p = priv->palettes;
+ while( p )
+ {
+ p->downloaded = 0;
+ p = p->next;
+ }
+
+ return Success;
+}
+
+/* StartPage
+ *
+ * If page file exists
+ * close page file
+ * set page file pointer = NULL
+ * unlink page file
+ * Create a new page file
+ * Send the page header information to the page file
+ * ClearArea the window and all descendant windows
+ */
+int
+PclStartPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclWindowPrivPtr pWinPriv =
+ (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ xRectangle repro;
+ char t[80];
+ XpOid orient, plex, tray, medium;
+ int dir, plexNum, num;
+
+ /*
+ * Put a pointer to the context in the window private structure
+ */
+ pWinPriv->validContext = 1;
+ pWinPriv->context = pCon;
+
+ /*
+ * Clear out the old page file, if necessary
+ */
+ if(pConPriv->pPageFile != (FILE *)NULL)
+ {
+ fclose(pConPriv->pPageFile);
+ pConPriv->pPageFile = (FILE *)NULL;
+ }
+ if(pConPriv->pageFileName != (char *)NULL)
+ {
+ unlink(pConPriv->pageFileName);
+ pConPriv->pageFileName = (char *)NULL;
+ }
+
+ /*
+ * Make up a new page file.
+ */
+ if (!XpOpenTmpFile("w+", &pConPriv->pageFileName, &pConPriv->pPageFile))
+ return BadAlloc;
+
+ /*
+ * Reset the GC cached in the context private struct.
+ */
+ pConPriv->validGC = 0;
+
+ /*
+ * Set the page orientation
+ */
+ orient = XpGetContentOrientation( pCon );
+ switch( orient )
+ {
+ case xpoid_val_content_orientation_landscape:
+ dir = 1;
+ break;
+ case xpoid_val_content_orientation_reverse_portrait:
+ dir = 2;
+ break;
+ case xpoid_val_content_orientation_reverse_landscape:
+ dir = 3;
+ break;
+ case xpoid_val_content_orientation_portrait:
+ default:
+ dir = 0;
+ break;
+ }
+ sprintf( t, "\033&l%dO", dir );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ /*
+ * Set the duplexing method. Since PCL wants to think of it in
+ * terms of the "binding edge," and the attribute store thinks in
+ * "duplex/tumble," this is a little complicated.
+ *
+ * Actually, this has no bearing on the output, since the HP1600C
+ * will only print on one side of the paper, and ignore all
+ * requests to enable duplexing. But, in an attempt to keep this
+ * driver somewhat generic, we'll enable it anyway.
+ */
+ plex = XpGetPlex( pCon );
+
+ if( plex == xpoid_val_plex_duplex )
+ {
+ if( dir == 0 || dir == 2 )
+ plexNum = 1;
+ else
+ plexNum = 2;
+ }
+ else if( plex == xpoid_val_plex_tumble )
+ {
+ if( dir == 0 || dir == 2 )
+ plexNum = 2;
+ else
+ plexNum = 1;
+ }
+ else
+ plexNum = 0;
+ sprintf( t, "\033&l%dS", plexNum );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ /*
+ * Set the input tray or medium. If XpGetPageSize gives us a valid medium,
+ * we can just send that to the printer, and let the printer handle the
+ * details. Otherwise, we select the tray returned from XpGetPageSize,
+ * which will be either a tray that should contain the correct medium
+ * (possibly with operator intervention), or the default tray from the
+ * config files.
+ */
+ medium = XpGetPageSize( pCon, &tray, NULL );
+ if( medium != xpoid_none )
+ {
+ switch( medium )
+ {
+ case xpoid_val_medium_size_na_legal:
+ num = 3;
+ break;
+ case xpoid_val_medium_size_iso_a3:
+ num = 27;
+ break;
+ case xpoid_val_medium_size_iso_a4:
+ num = 26;
+ break;
+ case xpoid_val_medium_size_executive:
+ num = 1;
+ break;
+ case xpoid_val_medium_size_ledger:
+ num = 6;
+ break;
+ case xpoid_val_medium_size_monarch_envelope:
+ num = 80;
+ break;
+ case xpoid_val_medium_size_na_number_10_envelope:
+ num = 81;
+ break;
+ case xpoid_val_medium_size_iso_designated_long:
+ num = 90;
+ break;
+ case xpoid_val_medium_size_iso_c5:
+ num = 91;
+ break;
+ case xpoid_val_medium_size_iso_b5:
+ num = 100;
+ break;
+ case xpoid_val_medium_size_jis_b5:
+ num = 45;
+ break;
+ case xpoid_val_medium_size_na_letter:
+ default:
+ num = 2;
+ break;
+ }
+ sprintf( t, "\033&l%dA", num );
+ SEND_PCL( pConPriv->pPageFile, t );
+ }
+ else
+ {
+ switch( tray )
+ {
+ case xpoid_val_input_tray_manual:
+ num = 2;
+ break;
+ case xpoid_val_input_tray_envelope:
+ num = 3;
+ break;
+ case xpoid_val_input_tray_large_capacity:
+ num = 5;
+ break;
+ case xpoid_val_input_tray_bottom:
+ num = 4;
+ break;
+ case xpoid_val_input_tray_main:
+ default:
+ num = 1;
+ break;
+ }
+ sprintf( t, "\033&l%dH", num );
+ SEND_PCL( pConPriv->pPageFile, t );
+ }
+
+ /*
+ * Set the scaling factors so that the HP-GL/2 coordinate system
+ * matches the X coordinate system, both in axis orientation and
+ * in unit<->pixel conversion.
+ */
+ XpGetReproductionArea( pCon, &repro );
+
+ sprintf( t, "\033&l0E\033*p%dx%dY", repro.x - 75, repro.y );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*c0T", (int)(repro.width / 300.0 * 720.0),
+ (int)(repro.height / 300.0 * 720.0) );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x, repro.x +
+ repro.width, repro.y + repro.height, repro.y );
+ SEND_PCL( pConPriv->pPageFile, t );
+
+ return Success;
+}
+
+/*
+ * When sending the generated PCL code back to the client, we send everything
+ * that we have generated so far for the job. After sending the data, we clean
+ * out the job file, to avoid repeatedly sending the same data.
+ */
+
+static int
+SendDocData( PclContextPrivPtr pPriv )
+{
+ struct stat statBuf;
+ int ret;
+
+ rewind( pPriv->pJobFile );
+ if( stat( pPriv->jobFileName, &statBuf ) < 0 )
+ return BadAlloc;
+
+ ret = XpSendDocumentData( pPriv->getDocClient, pPriv->pJobFile,
+ (int)statBuf.st_size, pPriv->getDocBufSize );
+
+ /*
+ * Clean out the job file
+ */
+ fclose( pPriv->pJobFile );
+ unlink( pPriv->jobFileName );
+
+ xfree(pPriv->jobFileName);
+
+ if (!XpOpenTmpFile("w+", &pPriv->jobFileName, &pPriv->pJobFile))
+ return BadAlloc;
+
+ return ret;
+}
+
+/*
+ * EndPage:
+ *
+ * Write page trailer to page file
+ * Write page file to job file
+ */
+int
+PclEndPage(
+ XpContextPtr pCon,
+ WindowPtr pWin)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ struct stat statBuf;
+
+ /*
+ * Send the page trailer to the page file.
+ */
+ SEND_PCL( pConPriv->pPageFile, "\014" );
+ fflush( pConPriv->pPageFile );
+
+ /*
+ * Write the page file contents to the job file, or to the
+ * whatever client has called GetDocumentData.
+ *
+ * pWinPriv->pPageFile must first be set to the start of the page file.
+ */
+ rewind(pConPriv->pPageFile);
+ if(stat(pConPriv->pageFileName, &statBuf) < 0)
+ return BadAlloc;
+
+ if(TransferBytes(pConPriv->pPageFile, pConPriv->pJobFile,
+ (int)statBuf.st_size) != (int)statBuf.st_size)
+ return BadAlloc;
+
+ if( pConPriv->getDocClient != (ClientPtr)NULL &&
+ pConPriv->getDocBufSize > 0 )
+ {
+ return SendDocData( pConPriv );
+ }
+
+ return Success;
+}
+
+/*
+ * The PclStartDoc() and PclEndDoc() functions serve basically as NOOP
+ * placeholders. This driver doesn't deal with the notion of multiple
+ * documents per page.
+ */
+
+int
+PclStartDoc(XpContextPtr pCon,
+ XPDocumentType type)
+{
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+#ifndef XP_PCL_LJ3
+ /*
+ * Set the printer resolution for the page. Since we can only
+ * render color at 300dpi, we just hard-code this.
+ */
+ SEND_PCL( pConPriv->pJobFile,
+ "\033%-12345X@PJL SET RESOLUTION = 300\r\n" );
+#endif /* XP_PCL_LJ3 */
+
+ /*
+ * Initialize HP-GL/2
+ */
+ SEND_PCL( pConPriv->pJobFile, "\033E\033%0BIN,SP1,TR0;\033%0A" );
+
+ /*
+ * Stash the type of the document (used by PutDocumentData operation)
+ */
+ pConPriv->isRaw = (type == XPDocRaw);
+
+ return Success;
+}
+
+int
+PclEndDoc(
+ XpContextPtr pCon,
+ Bool cancel)
+{
+ /*
+ * XXX What should I do if I get cancel == TRUE?
+ */
+ return Success;
+}
+
+/*
+ * PclDocumentData()
+ *
+ * Hand any pre-generated PDL down to the spool files, formatting it
+ * as necessary to fit the given window.
+ *
+ */
+
+#define DOC_PCL 1
+#define DOC_HPGL 2
+
+int
+PclDocumentData(
+ XpContextPtr pCon,
+ DrawablePtr pDraw,
+ char *pData,
+ int len_data,
+ char *pFmt,
+ int len_fmt,
+ char *pOpt,
+ int len_opt,
+ ClientPtr client)
+{
+ int type = 0;
+ PclContextPrivPtr pPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ XpOidDocFmtList *formats;
+ XpOidDocFmt *f;
+ char t[80];
+ xRectangle repro;
+
+ /*
+ * Verify the input format
+ */
+ formats = XpGetDocFmtListAttr( pCon, XPPrinterAttr,
+ (pPriv->isRaw) ?
+ xpoid_att_xp_raw_formats_supported :
+ xpoid_att_xp_embedded_formats_supported,
+ NULL );
+ f = XpOidDocFmtNew( pFmt );
+ if( !XpOidDocFmtListHasFmt( formats, f ) )
+ {
+ XpOidDocFmtListDelete( formats );
+ XpOidDocFmtDelete( f );
+ return BadMatch;
+ }
+ XpOidDocFmtListDelete( formats );
+
+ if( !(pPriv->isRaw) )
+ {
+ if( !strcmp( f->format, "PCL" ) )
+ type = DOC_PCL;
+ else if( !strcmp( f->format, "HPGL" ) )
+ type = DOC_HPGL;
+ else
+ {
+ XpOidDocFmtDelete( f );
+ return BadMatch;
+ }
+
+ switch( type )
+ {
+ case DOC_HPGL:
+ /*
+ * Move the picture frame to the appropriate place on the page,
+ * then assume that the embedded code will scale it properly.
+ */
+ sprintf( t, "\033&l0E\033*p%dx%dY",
+ pDraw->x - 75,
+ pDraw->y );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*coT",
+ (int)( pDraw->width / 300.0 * 720.0 ),
+ (int)( pDraw->height / 300.0 * 720.0 ) );
+ SEND_PCL( pPriv->pPageFile, t );
+ break;
+ }
+ }
+
+
+ /*
+ * Send the data down the pipe
+ */
+ SEND_PCL_COUNT( pPriv->pPageFile, pData, len_data );
+
+ /*
+ * If it's not a raw document, clean up the embedding
+ */
+ if( !(pPriv->isRaw) )
+ switch( type )
+ {
+ case DOC_HPGL:
+ /*
+ * Reset the picture frame
+ */
+ XpGetReproductionArea( pCon, &repro );
+
+ sprintf( t, "\033&l0E\033*p%dx%dY", repro.x - 75, repro.y );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033*c%dx%dY\033*c0T",
+ (int)(repro.width / 300.0 * 720.0),
+ (int)(repro.height / 300.0 * 720.0) );
+ SEND_PCL( pPriv->pPageFile, t );
+
+ sprintf( t, "\033%%0BSC%d,%d,%d,%d;\033%%0A", repro.x, repro.x +
+ repro.width, repro.y + repro.height, repro.y );
+ SEND_PCL( pPriv->pPageFile, t );
+ break;
+ }
+
+ XpOidDocFmtDelete( f );
+ return Success;
+}
+
+/*
+ *
+ * PclGetDocumentData()
+ *
+ * This function allows the driver to send the generated PCL back to
+ * the client.
+ *
+ * XXX This function is barely spec'ed, much less implemented!
+ */
+
+int
+PclGetDocumentData(
+ XpContextPtr pCon,
+ ClientPtr client,
+ int maxBufferSize)
+{
+ PclContextPrivPtr pPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+
+ pPriv->getDocClient = client;
+ pPriv->getDocBufSize = maxBufferSize;
+
+ return Success;
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c
new file mode 100644
index 000000000..287c5c14f
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c
@@ -0,0 +1,429 @@
+/* $Xorg: PclSFonts.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclSFonts.c
+** *
+** * Contents:
+** * Send Soft Font Download data to the specified
+** * file pointer.
+** *
+** * Created: 3/4/96
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclSFonts.c,v 1.7tsi Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include "Pcl.h"
+
+static char tmp1;
+static short tmp2;
+#define Put1byte(fp, x) tmp1=x; fwrite((char *)&tmp1, 1, 1, fp)
+#define Put2bytes(fp, x) tmp2=x; fwrite((char *)&tmp2, 2, 1, fp)
+
+#define ESC 0x1b
+#define SYMBOL_SET 277
+
+static unsigned int PclDownloadChar(FILE *,PclCharDataPtr,unsigned short,unsigned char);
+static unsigned int PclDownloadHeader(FILE *, PclFontDescPtr, unsigned short);
+
+#ifdef PCL_FONT_COMPRESS
+static unsigned char *compress_bitmap_data(PclCharDataPtr, unsigned int *);
+#endif /* PCL_FONT_COMPRESS */
+
+/* -*- PclDownloadSoftFont8 -*-
+ * Send the Character Definition Command for 8-bit font
+ * **************************************************************************/
+void
+PclDownloadSoftFont8(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead8Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char *code
+)
+{
+ /*
+ * Check whether the font header has already been downloaded.
+ * If not, download it.
+ */
+
+ if ( !pfh->fid ) {
+ pfh->fid = pSoftFontInfo->cur_max_fid++;
+ PclDownloadHeader(fp, &(pfh->fd), pfh->fid);
+ }
+ pfh->index[*code] = *code;
+ PclDownloadChar(fp, pcd, pfh->fid, pfh->index[*code]);
+
+}
+
+/* -*- PclDownloadSoftFont16 -*-
+ * Send the Character Definition Command for 16 bit font
+ * **************************************************************************/
+void
+PclDownloadSoftFont16(
+ FILE *fp,
+ PclSoftFontInfoPtr pSoftFontInfo,
+ PclFontHead16Ptr pfh,
+ PclCharDataPtr pcd,
+ unsigned char row,
+ unsigned char col
+)
+{
+ /*
+ * Check whether the font header is already downloaded.
+ * If not, download it.
+ */
+
+ if ( !pfh->cur_cindex ) {
+ pfh->cur_fid = pSoftFontInfo->cur_max_fid++;
+ PclDownloadHeader(fp, &(pfh->fd), pfh->cur_fid);
+ }
+ pfh->index[row][col].fid = pfh->cur_fid;
+ pfh->index[row][col].cindex = pfh->cur_cindex++;
+
+ PclDownloadChar(fp, pcd, pfh->index[row][col].fid, pfh->index[row][col].cindex);
+}
+
+/* -*- PclCreateSoftFontInfo -*-
+ * Create and Initialize the structure for storing the information
+ * of the downloaded soft font.
+ * **************************************************************************/
+PclSoftFontInfoPtr
+PclCreateSoftFontInfo(void)
+{
+PclSoftFontInfoPtr pSoftFontInfo;
+
+ pSoftFontInfo = (PclSoftFontInfoPtr)xalloc(sizeof(PclSoftFontInfoRec));
+ if ( pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclSoftFontInfoPtr) NULL;
+ pSoftFontInfo->phead8 = (PclFontHead8Ptr)NULL;
+ pSoftFontInfo->phead16 = (PclFontHead16Ptr)NULL;
+ pSoftFontInfo->pinfont = (PclInternalFontPtr)NULL;
+ pSoftFontInfo->cur_max_fid = 1;
+ return pSoftFontInfo;
+}
+
+/* -*- PclDestroySoftFontInfo -*-
+ * Destroy the soft font information structure
+ * **************************************************************************/
+void
+PclDestroySoftFontInfo( PclSoftFontInfoPtr pSoftFontInfo )
+{
+PclFontHead8Ptr pfh8, pfh8_next;
+PclFontHead16Ptr pfh16, pfh16_next;
+PclInternalFontPtr pin, pin_next;
+unsigned char nindex_row;
+int i;
+
+ if ( pSoftFontInfo == (PclSoftFontInfoPtr) NULL )
+ return;
+
+ pfh8 = pSoftFontInfo->phead8;
+ while (pfh8 != (PclFontHead8Ptr) NULL) {
+ xfree(pfh8->fontname);
+ xfree(pfh8->index);
+ pfh8_next = pfh8->next;
+ xfree(pfh8);
+ pfh8 = pfh8_next;
+ }
+
+ pfh16 = pSoftFontInfo->phead16;
+ while (pfh16 != (PclFontHead16Ptr) NULL) {
+ xfree(pfh16->fontname);
+ nindex_row = pfh16->lastRow - pfh16->firstRow + 1;
+ for (i=0; i<nindex_row; i++)
+ xfree(pfh16->index[i]);
+ xfree(pfh16->index);
+ pfh16_next = pfh16->next;
+ xfree(pfh16);
+ pfh16 = pfh16_next;
+ }
+
+ pin = pSoftFontInfo->pinfont;
+ while (pin != (PclInternalFontPtr) NULL) {
+ xfree(pin->fontname);
+ pin_next = pin->next;
+ xfree(pin);
+ pin = pin_next;
+ }
+
+ xfree(pSoftFontInfo);
+}
+
+/* -*- PclDownloadHeader -*-
+ * Send the Font Header Commnad.
+ * Format 0 : Font Header for Pcl Bitmapped Fonts
+ * Format 20 : Font Header for Resolution Specified Bitmapped Fonts
+ * **************************************************************************/
+static unsigned int
+PclDownloadHeader(
+ FILE *fp,
+ PclFontDescPtr fd,
+ unsigned short fid
+)
+{
+int nbytes;
+
+#ifdef XP_PCL_LJ3
+ nbytes = 64;
+#else
+ nbytes = 68;
+#endif /* XP_PCL_LJ3 */
+ /*
+ * Font ID Command : Esc *c#D
+ * (Default = 0, Range = 0 - 32767)
+ */
+ fprintf(fp, "%c*c%dD", ESC, fid);
+
+ /*
+ * Font Header Commnad : Esc )s#W[font header data]
+ * (Default = 0, Range = 0 - 32767)
+ */
+ fprintf(fp, "%c)s%dW", ESC, nbytes);
+
+ Put2bytes(fp, nbytes); /* Font Description Size */
+#ifdef XP_PCL_LJ3
+ Put1byte(fp, 0); /* Header Format */
+#else
+ Put1byte(fp, 20); /* Header Format */
+#endif /* XP_PCL_LJ3 */
+ Put1byte(fp, 2); /* Font Type */
+ Put2bytes(fp, 0); /* Style MSB */
+ Put2bytes(fp, fd->ascent); /* BaseLine Position */
+ Put2bytes(fp, fd->cellwidth); /* Cell Width */
+ Put2bytes(fp, fd->cellheight); /* Cell Height */
+ Put1byte(fp, 0); /* Orienation */
+ Put1byte(fp, fd->spacing); /* Spacing */
+ Put2bytes(fp, SYMBOL_SET); /* Symbol Set */
+ Put2bytes(fp, fd->pitch*4); /* font pitch */
+ Put2bytes(fp, fd->cellheight * 4); /* Height */
+ Put2bytes(fp, 0); /* x-Height */
+ Put1byte(fp, 0); /* width type (normal) */
+ Put1byte(fp, 0); /* Style LSB */
+ Put1byte(fp, 0); /* Stroke Weight */
+ Put1byte(fp, 5); /* Typeface LSB */
+ Put1byte(fp, 0); /* Typeface MSB */
+ Put1byte(fp, 0); /* Serif Style */
+ Put1byte(fp, 0); /* Quality */
+ Put1byte(fp, 0); /* Placement */
+ Put1byte(fp, 0); /* Underline Position */
+ Put1byte(fp, 0); /* Underline Thickness */
+ Put2bytes(fp, fd->cellheight*1.2); /* Text Height */
+ Put2bytes(fp, fd->cellwidth * 4); /* Text Width */
+ Put2bytes(fp, 0); /* First Code */
+ Put2bytes(fp, 255); /* Last Code */
+ Put1byte(fp, 0); /* Pitch Extend */
+ Put1byte(fp, 0); /* Height Extend */
+ Put2bytes(fp, 0); /* Cap Height */
+ Put2bytes(fp, 0); /* Font Number 1 */
+ Put2bytes(fp, 0); /* Font Number 2 */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+ Put2bytes(fp, 0); /* Font Name */
+
+#ifdef XP_PCL_LJ3
+ return 64;
+#else
+ Put2bytes(fp, 300); /* X Resolution */
+ Put2bytes(fp, 300); /* Y Resolution */
+ return 68;
+#endif /* XP_PCL_LJ3 */
+
+}
+
+/* -*- PclDownloadCharacter -*-
+ * Send the Character Definition Command.
+ * **************************************************************************/
+static unsigned int
+PclDownloadChar(
+ FILE *fp,
+ PclCharDataPtr cd,
+ unsigned short fid,
+ unsigned char code
+)
+{
+unsigned int nbytes, n;
+unsigned char *raster;
+
+ /*
+ * Font ID Command : Esc *c#D
+ * (Default = 0, Range = 0 - 32767)
+ * Character Code Command : Esc *c#E
+ * (Default = 0, Range = 0 - 65535)
+ */
+ fprintf(fp, "%c*c%dd%dE", ESC, fid, code);
+
+ /*
+ * Character Definition Command : Esc (s#W[character descriptor and data]
+ * (Default = N/A, Range = 0 - 32767)
+ */
+
+ nbytes = n = cd->height * ((cd->width + 7) / 8);
+#ifdef PCL_FONT_COMPRESS
+ raster = compress_bitmap_data(cd, &nbytes);
+#else
+ raster = (unsigned char *)NULL;
+#endif /* PCL_FONT_COMPRESS */
+ fprintf(fp, "%c(s%dW", ESC, nbytes + 16);
+
+ Put1byte(fp, 4); /* Format */
+ Put1byte(fp, 0); /* Continuation */
+ Put1byte(fp, 14); /* Descriptor Size */
+ if (raster) { /* Class */
+ Put1byte(fp, 2);
+ } else {
+ Put1byte(fp, 1); /* Class */
+ }
+ Put2bytes(fp, 0); /* Orientation */
+ Put2bytes(fp, cd->h_offset); /* left offset */
+ Put2bytes(fp, cd->v_offset); /* top offset */
+ Put2bytes(fp, cd->width); /* character width */
+ Put2bytes(fp, cd->height); /* character height */
+ Put2bytes(fp, cd->font_pitch*4); /* delta X */
+
+ /*
+ * Raster Character Data
+ */
+ if (raster) {
+ fwrite(raster, nbytes, 1, fp);
+ xfree(raster);
+ } else
+ fwrite(cd->raster_top, nbytes, 1, fp);
+
+ return n + 16;
+}
+
+
+#ifdef PCL_FONT_COMPRESS
+/* -*- compress_bitmap_data -*-
+ * Compress Bitmap data
+ * **************************************************************************/
+static unsigned char *
+compress_bitmap_data(
+ PclCharDataPtr cd,
+ unsigned int *nbytes
+)
+{
+unsigned int byte_width;
+unsigned char *raster, *rptr_s, *rptr_e, *rptr_end;
+unsigned char *tmp_s, *tmp_ptr;
+unsigned char *p;
+unsigned char cur, pixel;
+unsigned int num;
+
+int i, j, k, w;
+
+ byte_width = (cd->width + 7) / 8;
+ *nbytes = cd->height * byte_width;
+
+ /* Create buffer for storing compress bitmap glyph */
+ raster = (unsigned char *)xalloc(*nbytes);
+ rptr_s = raster;
+ rptr_e = raster;
+ rptr_end = raster + *nbytes;
+
+ tmp_s = (unsigned char *)xalloc(cd->width * 8 + 2);
+
+ p = cd->raster_top;
+ for (i=0; i<cd->height; i++) {
+ tmp_ptr = tmp_s;
+ *tmp_ptr++ = 0;
+ if ( (*p>>7)&0x1 == 1 ) {
+ *tmp_ptr++ = 0;
+ cur = 1;
+ } else {
+ cur = 0;
+ }
+ num = 0;
+ for (j=0, w=0; j<byte_width; j++, p++) {
+ for (k=0; k<8 && w<cd->width; k++, w++) {
+ pixel = (*p>>(7-k))&0x1;
+ if ( pixel == cur ) {
+ num++;
+ } else {
+ cur = pixel;
+ while (num > 255) {
+ *tmp_ptr++ = 255;
+ *tmp_ptr++ = 0;
+ num -= 255;
+ }
+ *tmp_ptr++ = num;
+ num = 1;
+ }
+ }
+ }
+ if ( pixel == cur ) {
+ while (num > 255) {
+ *tmp_ptr++ = 255;
+ *tmp_ptr++ = 0;
+ num -= 255;
+ }
+ *tmp_ptr++ = num&0xff;
+ } else
+ *tmp_ptr++ = num;
+
+ if ( ((rptr_e - rptr_s) == (tmp_ptr - tmp_s)) &&
+ !memcmp(rptr_s+1, tmp_s+1, (tmp_ptr - tmp_s) - 1) )
+ *rptr_s += 1;
+ else {
+ if ( rptr_e + (tmp_ptr - tmp_s) > rptr_end ) {
+ xfree(raster);
+ xfree(tmp_s);
+ return (unsigned char *)NULL;
+ }
+ memcpy (rptr_e, tmp_s, tmp_ptr - tmp_s);
+ rptr_s = rptr_e;
+ rptr_e = rptr_s + (tmp_ptr - tmp_s);
+ }
+ }
+ xfree(tmp_s);
+ *nbytes = rptr_e - raster;
+
+ return raster;
+}
+#endif /* PCL_FONT_COMPRESS */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h
new file mode 100644
index 000000000..fdd62f651
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h
@@ -0,0 +1,116 @@
+/* $Xorg: PclSFonts.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCLFONTS_H
+#define _PCLFONTS_H
+
+/* -*-H-*-
+******************************************************************************
+******************************************************************************
+*
+* File: PclFonts.h
+* Description: Send Soft Font Download data to the specified file pointer.
+*
+*
+******************************************************************************
+******************************************************************************
+*/
+/*
+(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.
+*/
+
+
+typedef struct {
+ unsigned char fid; /* sfont font ID */
+ unsigned char cindex; /* character indext */
+} PclFontMapRec, PclFontMapPtr;
+
+typedef struct {
+ int h_offset;
+ int v_offset;
+ unsigned int width;
+ unsigned int height;
+ int font_pitch;
+ unsigned char *raster_top;
+} PclCharDataRec, *PclCharDataPtr;
+
+typedef struct {
+ unsigned char spacing;
+ unsigned int pitch;
+ unsigned int cellheight;
+ unsigned int cellwidth;
+ int ascent;
+ int descent;
+} PclFontDescRec, *PclFontDescPtr;
+
+typedef struct _PclFontHead8Rec {
+ char *fontname;
+ PclFontDescRec fd;
+ unsigned short fid;
+ unsigned char *index;
+ struct _PclFontHead8Rec *next;
+} PclFontHead8Rec, *PclFontHead8Ptr;
+
+typedef struct _PclFontHead16Rec {
+ char *fontname;
+ PclFontDescRec fd;
+ unsigned short cur_fid;
+ unsigned char cur_cindex;
+ PclFontMapRec **index;
+ unsigned short firstCol;
+ unsigned short lastCol;
+ unsigned short firstRow;
+ unsigned short lastRow;
+ struct _PclFontHead16Rec *next;
+} PclFontHead16Rec, *PclFontHead16Ptr;
+
+typedef struct _PclInternalFontRec {
+ char *fontname;
+ float pitch;
+ float height;
+ char *pcl_font_name;
+ char *spacing;
+ struct _PclInternalFontRec *next;
+} PclInternalFontRec, *PclInternalFontPtr;
+
+typedef struct {
+ PclFontHead8Ptr phead8;
+ PclFontHead16Ptr phead16;
+ PclInternalFontPtr pinfont;
+ unsigned char cur_max_fid;
+} PclSoftFontInfoRec, *PclSoftFontInfoPtr;
+
+#define MONOSPACE 0
+#define PROPSPACE 1
+
+#endif /* _PCLFONTS_H */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c b/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c
new file mode 100644
index 000000000..51c0137fc
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c
@@ -0,0 +1,139 @@
+/* $Xorg: PclSpans.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclSpans.c
+** *
+** * Contents:
+** * Code to set and fill spans in the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclSpans.c,v 1.5 1999/12/13 02:12:57 robin Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "Pcl.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+
+void
+PclFillSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int fSorted)
+{
+ char t[80];
+ FILE *outFile;
+ int xoffset, yoffset;
+ xRectangle *rects, *r;
+ RegionPtr fillRegion, region = 0;
+ int i;
+ int nbox;
+ BoxPtr pbox;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == 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
+PclSetSpans(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints,
+ int *pWidths,
+ int nSpans,
+ int fSorted)
+{
+}
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclText.c b/nx-X11/programs/Xserver/Xprint/pcl/PclText.c
new file mode 100644
index 000000000..be794772c
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclText.c
@@ -0,0 +1,936 @@
+/* $Xorg: PclText.c,v 1.5 2001/03/06 16:28:48 pookie Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclText.c
+** *
+** * Contents:
+** * Character-drawing routines for the PCL DDX
+** *
+** * Created: 10/23/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclText.c,v 1.10tsi Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef DO_TWO_BYTE_PCL
+#include "iconv.h"
+#endif /* DO_TWO_BYTE_PCL */
+#include "gcstruct.h"
+#include "windowstr.h"
+
+#include "Pcl.h"
+#include "migc.h"
+#include <X11/Xatom.h>
+
+#include "PclSFonts.h"
+
+static PclFontHead8Ptr makeFontHeader8 (FontPtr, PclSoftFontInfoPtr);
+static PclFontHead16Ptr makeFontHeader16(FontPtr, PclSoftFontInfoPtr);
+static PclInternalFontPtr makeInternalFont(FontPtr, PclSoftFontInfoPtr);
+static void fillFontDescData(FontPtr, PclFontDescPtr, unsigned int);
+static PclCharDataPtr fillCharDescData(PclCharDataPtr, CharInfoPtr);
+static void output_text(FILE *, PclContextPrivPtr, unsigned char);
+static char * getFontName(FontPtr);
+static char isInternal(FontPtr);
+static void selectInternalFont(FILE *, PclInternalFontPtr, int);
+static void selectSize(FILE *, PclContextPrivPtr, PclInternalFontPtr);
+static char t[80];
+
+#ifdef DO_TWO_BYTE_PCL
+static void code_conv(PclSoftFontInfoPtr, FontPtr, char *, char *);
+#endif /* DO_TWO_BYTE_PCL */
+
+#define ESC 0x1b
+#define PER 0x25
+#define ETX 0x3
+#define ETX_ALT 0x2a
+#define DOWNLOAD_FONT 0
+#define INTERNAL_FONT 1
+
+int
+PclPolyText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ char *string)
+{
+XpContextPtr pCon;
+PclContextPrivPtr pConPriv;
+unsigned long n, i;
+int w;
+CharInfoPtr charinfo[255], *chinfo;
+
+FILE *outFile;
+PclSoftFontInfoPtr pSoftFontInfo;
+PclFontHead8Ptr pfh8 = (PclFontHead8Ptr)NULL;
+PclInternalFontPtr pin = (PclInternalFontPtr)NULL;
+PclCharDataRec cd;
+unsigned char *p;
+unsigned char last_fid;
+int max_ascent, max_descent;
+
+int nbox;
+BoxPtr pbox;
+BoxRec box;
+RegionPtr drawRegion, region;
+char font_type;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return x;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ Linear8Bit, &n, charinfo);
+ if ( n == 0 )
+ return x;
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pSoftFontInfo = pConPriv->pSoftFontInfo;
+ font_type = isInternal(pGC->font);
+ if ( font_type == DOWNLOAD_FONT ) {
+ /*
+ * Create Soft Font Header Information
+ */
+ pfh8 = makeFontHeader8(pGC->font, pSoftFontInfo);
+ if (!pfh8)
+ return x;
+
+ /*
+ * exec Soft Font Downloading
+ */
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ if ( !pfh8->index[*p] ) {
+ fillCharDescData(&cd, *chinfo);
+ PclDownloadSoftFont8(pConPriv->pJobFile, pSoftFontInfo,
+ pfh8, &cd, p);
+ xfree(cd.raster_top);
+ }
+ }
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ last_fid = 0;
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ if ( last_fid != pfh8->fid ) {
+ sprintf(t, "%c;FI%d;SS;LB", ETX, pfh8->fid);
+ SAVE_PCL( outFile, pConPriv, t );
+
+ last_fid = pfh8->fid;
+ }
+
+ output_text(outFile, pConPriv, pfh8->index[*p]);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+
+ } else {
+ int fid = 0;
+
+ pin = makeInternalFont(pGC->font, pSoftFontInfo);
+ if (!pin)
+ return x;
+
+ selectInternalFont(outFile, pin, fid);
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ selectSize(outFile, pConPriv, pin);
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ p = (unsigned char *)string;
+ for (i=0, chinfo=charinfo; i<n; i++, p++, chinfo++) {
+ output_text(outFile, pConPriv, *p);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+ }
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ box.x1 = x + pDrawable->x;
+ box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
+ box.x2 = x + w + pDrawable->x;
+ box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
+
+ drawRegion = miRegionCreate( &box, 0 );
+ region = miRegionCreate( NULL, 0 );
+ miIntersect( region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+
+ return x+w;
+}
+
+int
+PclPolyText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+XpContextPtr pCon;
+PclContextPrivPtr pConPriv;
+unsigned long n, i;
+int w;
+CharInfoPtr charinfo[255], *chinfo;
+
+FILE *outFile;
+PclSoftFontInfoPtr pSoftFontInfo;
+PclFontHead16Ptr pfh16 = (PclFontHead16Ptr)NULL;
+PclCharDataRec cd;
+FontInfoPtr pfi;
+unsigned char row, col;
+char *p;
+unsigned char last_fid;
+int max_ascent, max_descent;
+unsigned short def;
+
+int nbox;
+BoxPtr pbox;
+BoxRec box;
+RegionPtr drawRegion, region;
+char font_type;
+
+ if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
+ return x;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
+ pConPriv = (PclContextPrivPtr)
+ pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pSoftFontInfo = pConPriv->pSoftFontInfo;
+
+ font_type = isInternal(pGC->font);
+ if ( font_type == DOWNLOAD_FONT ) {
+ /*
+ * Create Soft Font Header Information
+ */
+ pfh16 = makeFontHeader16(pGC->font, pSoftFontInfo);
+ if (!pfh16)
+ return x;
+
+ /*
+ * exec Soft Font Downloading
+ */
+ pfi = (FontInfoRec *)&pGC->font->info;
+ p = (char *)string;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ row = *p & 0xff;
+ col = *(p+1) & 0xff;
+ if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
+ && (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
+ row = row - pfi->firstRow;
+ col = col - pfi->firstCol;
+ } else {
+ def = pfi->defaultCh;
+ row = ((def>>8)&0xff) - pfi->firstRow;
+ col = (def&0xff) - pfi->firstCol;
+ }
+ if ( !pfh16->index[row][col].fid ) {
+ fillCharDescData(&cd, *chinfo);
+ PclDownloadSoftFont16(pConPriv->pJobFile, pSoftFontInfo,
+ pfh16, &cd, row, col);
+ xfree(cd.raster_top);
+ }
+ }
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ SAVE_PCL_COUNT( outFile, pConPriv, "FI0;SS;LB", 9 );
+
+ last_fid = 0;
+
+ w = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ row = *p & 0xff;
+ col = *(p+1) & 0xff;
+ if ( (pfi->firstRow <= row) && (row <= pfi->lastRow)
+ && (pfi->firstCol <= col) && (col <= pfi->lastCol) ) {
+ row = row - pfi->firstRow;
+ col = col - pfi->firstCol;
+ } else {
+ def = pfi->defaultCh;
+ row = ((def>>8)&0xff) - pfi->firstRow;
+ col = (def&0xff) - pfi->firstCol;
+ }
+ if ( last_fid != pfh16->index[row][col].fid ) {
+ sprintf(t, "%cFI%d;SS;LB",
+ ETX, pfh16->index[row][col].fid);
+ SAVE_PCL( outFile, pConPriv, t );
+ last_fid = pfh16->index[row][col].fid;
+ }
+
+ output_text(outFile, pConPriv, pfh16->index[row][col].cindex);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ sprintf(t, "%c", ETX);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+ MACRO_END( outFile );
+
+ } else {
+#ifdef DO_TWO_BYTE_PCL
+ PclInternalFontPtr pin;
+ int fid = 0;
+
+ pin = makeInternalFont(pGC->font, pSoftFontInfo);
+ if (!pin)
+ return x;
+
+ selectInternalFont(outFile, pin, fid);
+ fprintf(outFile, "%c&t31P", ESC);
+
+ /*
+ * print characters
+ */
+ MACRO_START( outFile, pConPriv );
+ sprintf(t, "\033%%0B;PU%d,%dPD;TD1;DT%c,1;",
+ x + pDrawable->x, y + pDrawable->y + pGC->font->info.fontAscent,
+ ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ sprintf(t, "TD0;\033%%1A");
+ SAVE_PCL( outFile, pConPriv, t );
+
+ w = 0;
+ last_fid = 0;
+ max_ascent = charinfo[0]->metrics.ascent;
+ max_descent = charinfo[0]->metrics.descent;
+ for (i=0, p=(char *)string, chinfo=charinfo; i<n; i++, p+=2, chinfo++) {
+ char tobuf[3];
+ code_conv(pSoftFontInfo, pGC->font, (char *)p, tobuf);
+ fprintf(outFile, "%c%c", tobuf[0], tobuf[1]);
+
+ w += (*chinfo)->metrics.characterWidth;
+ max_ascent = MAX(max_ascent, (*chinfo)->metrics.ascent);
+ max_descent = MAX(max_descent, (*chinfo)->metrics.descent);
+ }
+ MACRO_END( outFile );
+#else
+ return x;
+#endif /* DO_TWO_BYTE_PCL */
+ }
+
+ /*
+ * Convert the collection of rectangles into a proper region, then
+ * intersect it with the clip region.
+ */
+ box.x1 = x + pDrawable->x;
+ box.y1 = y - max_ascent + pDrawable->y + pGC->font->info.fontAscent;
+ box.x2 = x + w + pDrawable->x;
+ box.y2 = y + max_descent + pDrawable->y + pGC->font->info.fontAscent;
+
+ drawRegion = miRegionCreate( &box, 0 );
+ region = miRegionCreate( NULL, 0 );
+ miIntersect( region, drawRegion, pGC->pCompositeClip );
+
+ /*
+ * For each rectangle in the clip region, set the HP-GL/2 "input
+ * window" and render the entire polyline to it.
+ */
+ pbox = REGION_RECTS( region );
+ nbox = REGION_NUM_RECTS( region );
+
+ PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
+
+ /*
+ * Clean up the temporary regions
+ */
+ REGION_DESTROY( pGC->pScreen, drawRegion );
+ REGION_DESTROY( pGC->pScreen, region );
+
+ return x+w;
+}
+
+void
+PclImageText8(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ int count,
+ char *string)
+{
+}
+
+void
+PclImageText16(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ int count,
+ unsigned short *string)
+{
+}
+
+void
+PclImageGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+}
+
+void
+PclPolyGlyphBlt(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nGlyphs,
+ CharInfoPtr *pCharInfo,
+ pointer pGlyphBase)
+{
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+static PclFontHead8Ptr
+makeFontHeader8(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclFontHead8Ptr phead8 = pSoftFontInfo->phead8;
+PclFontHead8Ptr pfh8 = phead8;
+PclFontHead8Ptr prev = (PclFontHead8Ptr)NULL;
+FontInfoPtr pfi;
+char *fontname;
+unsigned char nindex;
+int i;
+unsigned long n;
+CharInfoPtr charinfo[1];
+unsigned int space_width;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ while (pfh8 != (PclFontHead8Ptr) NULL) {
+ if (!strcmp(pfh8->fontname, fontname))
+ return pfh8;
+ prev = pfh8;
+ pfh8 = pfh8->next;
+ }
+
+ /*
+ * Create Font Header Information
+ */
+ pfh8 = (PclFontHead8Ptr)xalloc(sizeof(PclFontHead8Rec));
+ if (pfh8 == (PclFontHead8Ptr)NULL)
+ return (PclFontHead8Ptr)NULL;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
+ Linear8Bit, &n, charinfo);
+ if ( n )
+ space_width = charinfo[0]->metrics.characterWidth;
+ else
+ space_width = FONTMAXBOUNDS(pfont,characterWidth);
+
+ fillFontDescData(pfont, &(pfh8->fd), space_width);
+ pfh8->fid = 0;
+ pfh8->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pfh8->fontname == (char *)NULL) {
+ xfree(pfh8);
+ return (PclFontHead8Ptr) NULL;
+ }
+ strcpy(pfh8->fontname, fontname);
+
+ nindex = 0xff;
+ pfh8->index = (unsigned char *)xalloc(nindex);
+ if ( pfh8->index == (unsigned char *) NULL ) {
+ xfree(pfh8->fontname);
+ xfree(pfh8);
+ return (PclFontHead8Ptr) NULL;
+ }
+
+ for (i=0; i<=nindex; i++)
+ pfh8->index[i] = 0x0;
+
+ pfh8->next = (PclFontHead8Ptr)NULL;
+
+ if ( prev == (PclFontHead8Ptr) NULL)
+ pSoftFontInfo->phead8 = pfh8;
+ else
+ prev->next = pfh8;
+
+ return pfh8;
+}
+
+static PclFontHead16Ptr
+makeFontHeader16(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclFontHead16Ptr phead16 = pSoftFontInfo->phead16;
+PclFontHead16Ptr pfh16 = phead16;
+PclFontHead16Ptr prev = (PclFontHead16Ptr)NULL;
+PclFontMapRec ** index;
+FontInfoPtr pfi;
+char *fontname;
+unsigned char nindex_row, nindex_col;
+int i, j;
+unsigned long n;
+CharInfoPtr charinfo[1];
+unsigned int space_width;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ while (pfh16 != (PclFontHead16Ptr) NULL) {
+ if (!strcmp(pfh16->fontname, fontname))
+ return pfh16;
+ prev = pfh16;
+ pfh16 = pfh16->next;
+ }
+
+ /*
+ * Create Font Header Information
+ */
+ pfh16 = (PclFontHead16Ptr)xalloc(sizeof(PclFontHead16Rec));
+ if (pfh16 == (PclFontHead16Ptr)NULL)
+ return (PclFontHead16Ptr)NULL;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ GetGlyphs(pfont, 1, (unsigned char *)&pfi->defaultCh,
+ (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ if ( n )
+ space_width = charinfo[0]->metrics.characterWidth;
+ else
+ space_width = FONTMAXBOUNDS(pfont,characterWidth);
+
+ fillFontDescData(pfont, &(pfh16->fd), space_width);
+ pfh16->cur_fid = 0;
+ pfh16->cur_cindex = 0;
+ pfh16->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pfh16->fontname == (char *)NULL) {
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ strcpy(pfh16->fontname, fontname);
+
+ pfi = (FontInfoRec *)&pfont->info;
+ nindex_col = pfi->lastCol - pfi->firstCol + 1;
+ nindex_row = pfi->lastRow - pfi->firstRow + 1;
+ index = (PclFontMapRec **)xalloc(sizeof(PclFontMapRec *)*nindex_row);
+ if (index == (PclFontMapRec **)NULL) {
+ xfree(pfh16->fontname);
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ for (i=0; i<nindex_row; i++) {
+ index[i] = (PclFontMapRec *)xalloc(sizeof(PclFontMapRec)*nindex_col);
+ if (index[i] == (PclFontMapRec *)NULL) {
+ for(j=0; j<i; j++)
+ xfree(index[j]);
+ xfree(pfh16->fontname);
+ xfree(pfh16);
+ return (PclFontHead16Ptr) NULL;
+ }
+ for (j=0; j<=nindex_col; j++)
+ index[i][j].fid = 0x0;
+ }
+
+ pfh16->index = index;
+ pfh16->firstCol = pfi->firstCol;
+ pfh16->lastCol = pfi->lastCol;
+ pfh16->firstRow = pfi->firstRow;
+ pfh16->lastRow = pfi->lastRow;
+ pfh16->next = (PclFontHead16Ptr)NULL;
+
+ if ( prev == (PclFontHead16Ptr) NULL)
+ pSoftFontInfo->phead16 = pfh16;
+ else
+ prev->next = pfh16;
+
+ return pfh16;
+}
+
+static PclInternalFontPtr
+makeInternalFont(FontPtr pfont, PclSoftFontInfoPtr pSoftFontInfo)
+{
+PclInternalFontPtr pinfont = pSoftFontInfo->pinfont;
+PclInternalFontPtr pin = pinfont;
+PclInternalFontPtr prev = (PclInternalFontPtr)NULL;
+FontPropPtr props;
+FontInfoPtr pfi;
+char *fontname;
+Atom xa_pcl_font_name, xa_res, xa_ave_width, xa_spacing;
+int width = 1;
+int mask;
+int i;
+
+ if (pSoftFontInfo == (PclSoftFontInfoPtr) NULL)
+ return (PclInternalFontPtr)NULL;
+
+ /*
+ * Verify it has already been created, if so, return it.
+ */
+ if ( (fontname = getFontName(pfont)) == (char *)NULL)
+ return (PclInternalFontPtr)NULL;
+
+ while (pin != (PclInternalFontPtr) NULL) {
+ if (!strcmp(pin->fontname, fontname))
+ return pin;
+ prev = pin;
+ pin = pin->next;
+ }
+
+ /*
+ * Create Internal Font Information
+ */
+ pin = (PclInternalFontPtr)xalloc(sizeof(PclInternalFontRec));
+ if (pin == (PclInternalFontPtr)NULL)
+ return (PclInternalFontPtr)NULL;
+
+ pin->fontname = (char *)xalloc(strlen(fontname) + 1);
+ if (pin->fontname == (char *)NULL) {
+ xfree(pin);
+ return (PclInternalFontPtr) NULL;
+ }
+ strcpy(pin->fontname, fontname);
+
+ xa_pcl_font_name = MakeAtom("PCL_FONT_NAME", strlen("PCL_FONT_NAME"), TRUE);
+ xa_res = MakeAtom("RESOLUTION_X", strlen("RESOLUTION_X"), TRUE);
+ xa_ave_width = MakeAtom("AVERAGE_WIDTH", strlen("AVERAGE_WIDTH"), TRUE);
+ xa_spacing = MakeAtom("SPACING", strlen("SPACING"), TRUE);
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+
+ mask = 0;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( (Atom) props->name == xa_pcl_font_name ) {
+ pin->pcl_font_name = NameForAtom(props->value);
+ mask |= 0x1;
+ } else if ( props->name == XA_POINT_SIZE ) {
+ pin->height = (float) props->value / 10.0;
+ mask |= 0x2;
+ } else if ( (Atom) props->name == xa_res ) {
+ mask |= 0x4;
+ } else if ( (Atom) props->name == xa_ave_width ) {
+ width = (int) props->value / 10;
+ mask |= 0x8;
+ } else if ( (Atom) props->name == xa_spacing ) {
+ pin->spacing = NameForAtom(props->value);
+ mask |= 0x10;
+ }
+ }
+ if ( mask != 0x1f ) {
+ xfree(pin->fontname);
+ xfree(pin);
+ return (PclInternalFontPtr) NULL;
+ }
+
+ if ( *pin->spacing != 'P' || *pin->spacing != 'p' ) {
+ if (width == 0)
+ width = 1;
+ pin->pitch = (float) 300.0 / width; /* Hard-Code: Resolution is 300 */
+ }
+
+ pin->next = (PclInternalFontPtr)NULL;
+ if ( prev == (PclInternalFontPtr) NULL)
+ pSoftFontInfo->pinfont = pin;
+ else
+ prev->next = pin;
+
+ return pin;
+}
+
+static void
+fillFontDescData(FontPtr pfont, PclFontDescPtr pfd, unsigned int space)
+{
+FontInfoPtr pfi;
+
+ pfi = (FontInfoRec *)&pfont->info;
+
+ if ( (pfi->maxbounds.leftSideBearing == pfi->minbounds.leftSideBearing)
+ && (pfi->maxbounds.rightSideBearing == pfi->minbounds.rightSideBearing)
+ && (pfi->maxbounds.characterWidth == pfi->minbounds.characterWidth)
+ && (pfi->maxbounds.ascent == pfi->minbounds.ascent)
+ && (pfi->maxbounds.descent == pfi->minbounds.descent)
+ )
+ pfd->spacing = MONOSPACE;
+ else
+ pfd->spacing = PROPSPACE;
+
+ pfd->pitch = space;
+ pfd->cellheight = FONTMAXBOUNDS(pfont,ascent)
+ + FONTMAXBOUNDS(pfont,descent);
+ pfd->cellwidth = FONTMAXBOUNDS(pfont,rightSideBearing)
+ - FONTMINBOUNDS(pfont,leftSideBearing);
+ pfd->ascent = FONTMAXBOUNDS(pfont,ascent); /*FONTASCENT(pfont);*/
+ pfd->descent = FONTMAXBOUNDS(pfont,descent); /*FONTDESCENT(pfont);*/
+}
+
+static PclCharDataPtr
+fillCharDescData(PclCharDataPtr pcd, CharInfoPtr pci)
+{
+unsigned int byte_width;
+unsigned char *p;
+register int nbyGlyphWidth;
+unsigned char *pglyph, *pg;
+unsigned int i, j;
+
+ pcd->h_offset = pci->metrics.leftSideBearing;
+ pcd->v_offset = pci->metrics.ascent;
+ pcd->width = pci->metrics.rightSideBearing
+ - pci->metrics.leftSideBearing;
+ pcd->height = pci->metrics.ascent + pci->metrics.descent;
+ pcd->font_pitch = pci->metrics.characterWidth;
+
+ byte_width = (pcd->width + 7)/8;
+ pcd->raster_top = (unsigned char *)xalloc(byte_width * pcd->height);
+ if (pcd->raster_top == (unsigned char *)NULL)
+ return (PclCharDataPtr)NULL;
+
+ p = pcd->raster_top;
+ nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ for (i=0; i<pcd->height; i++) {
+ pg = pglyph + nbyGlyphWidth * i;
+ for (j=0; j<byte_width; j++)
+ *p++ = *pg++;
+ }
+ return pcd;
+}
+
+static void
+output_text(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ unsigned char index)
+{
+ if ( index == ETX ) {
+ sprintf(t, "%c;DT%c,1;LB%c%c;DT%c,1;LB",
+ ETX, ETX_ALT, ETX, ETX_ALT, ETX);
+ SAVE_PCL( outFile, pConPriv, t );
+ } else {
+ sprintf(t, "%c", index);
+ SAVE_PCL_COUNT( outFile, pConPriv, t, 1 );
+ }
+}
+
+static char *
+getFontName(FontPtr pfont)
+{
+int i;
+FontInfoPtr pfi;
+FontPropPtr props;
+char *fontname;
+
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+ fontname = (char *) NULL;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( props->name == XA_FONT ) {
+ fontname = (char *)NameForAtom(props->value);
+ break;
+ }
+ }
+ return fontname;
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Internal Font Selection */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+static char
+isInternal(FontPtr pfont)
+{
+int i;
+FontInfoPtr pfi;
+FontPropPtr props;
+Atom dest;
+
+ dest = MakeAtom("PRINTER_RESIDENT_FONT", strlen("PRINTER_RESIDENT_FONT"), TRUE);
+
+ pfi = (FontInfoRec *)&pfont->info;
+ props = pfi->props;
+ for (i=0; i<pfi->nprops; i++, props++) {
+ if ( (Atom) props->name == dest && props->value == 2 )
+ return INTERNAL_FONT;
+ }
+ return DOWNLOAD_FONT;
+}
+
+static void
+selectInternalFont(FILE *outFile, PclInternalFontPtr pin, int fid)
+{
+ fprintf(outFile, "%c*c%dD", ESC, fid);
+ if ( *pin->spacing == 'P' || *pin->spacing == 'p' )
+ fprintf(outFile, pin->pcl_font_name, pin->height);
+ else
+ fprintf(outFile, pin->pcl_font_name, pin->pitch);
+ fprintf(outFile, "%c*c6F", ESC);
+}
+
+static void
+selectSize(FILE *outFile,
+ PclContextPrivPtr pConPriv,
+ PclInternalFontPtr pin)
+{
+ if ( *pin->spacing == 'P' || *pin->spacing == 'p' ) {
+ sprintf(t, "SD4,%f;", pin->height);
+ SAVE_PCL( outFile, pConPriv, t );
+ } else {
+ sprintf(t, "SD3,%f;", pin->pitch);
+ SAVE_PCL( outFile, pConPriv, t );
+ }
+ return;
+}
+
+#ifdef DO_TWO_BYTE_PCL
+static void
+code_conv(
+ PclSoftFontInfoPtr pSoftFontInfo,
+ FontPtr pfont,
+ char *from,
+ char *to
+)
+{
+iconv_t cd;
+char frombuf[9], *fromptr;
+size_t inbyte = 5, outbyte=2;
+
+ fromptr = frombuf;
+ frombuf[0] = 0x1b; /* Esc */
+ frombuf[1] = 0x24; /* $ */
+ frombuf[2] = 0x42; /* B */
+ frombuf[3] = *from;
+ frombuf[4] = *(from+1);
+ frombuf[5] = 0x1b; /* Esc */
+ frombuf[6] = 0x28; /* ( */
+ frombuf[7] = 0x4a; /* J */
+ frombuf[8] = 0x0;
+ if ((cd = iconv_open("sjis", "jis")) == (iconv_t)(-1)) {
+ *to = (unsigned char)NULL;
+ return;
+ }
+
+ if ( iconv(cd, &fromptr, &inbyte, &to, &outbyte) == -1 )
+ *to = (unsigned char)NULL;
+
+ iconv_close(cd);
+ return;
+}
+#endif /* DO_TWO_BYTE_PCL */
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c b/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c
new file mode 100644
index 000000000..cac5826e9
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c
@@ -0,0 +1,452 @@
+/* $Xorg: PclWindow.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*******************************************************************
+**
+** *********************************************************
+** *
+** * File: PclWindow.c
+** *
+** * Contents:
+** * Window code for Pcl driver.
+** *
+** * Created: 2/02/95
+** *
+** *********************************************************
+**
+********************************************************************/
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclWindow.c,v 1.10tsi Exp $ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "mistruct.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "Pcl.h"
+
+#if 0
+/*
+ * 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.
+ */
+static /* const */ char *propStrings[] = {
+ DT_PRINT_JOB_HEADER,
+ DT_PRINT_JOB_TRAILER,
+ DT_PRINT_JOB_COMMAND, /* old-obsolete */
+ 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
+
+/*
+ * PclCreateWindow - 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
+PclCreateWindow(
+ register WindowPtr pWin)
+{
+ PclWindowPrivPtr pPriv;
+
+#if 0
+ Bool status = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ PclScreenPrivPtr pScreenPriv = (PclScreenPrivPtr)
+ pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
+ pWin->devPrivates[PclWindowPrivateIndex].ptr;
+
+ /*
+ * 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);
+ ChangeWindowProperty(pWin, propName, XA_STRING, 8,
+ PropModeReplace, strlen(propVal),
+ (pointer)propVal, FALSE);
+ xfree(propVal);
+ }
+ }
+ }
+
+ return status;
+#endif
+
+ /*
+ * Invalidate the window's private print context.
+ */
+ pPriv = (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv->validContext = 0;
+
+ return TRUE;
+}
+
+
+/*ARGSUSED*/
+Bool PclMapWindow(
+ WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PclPositionWindow(
+ register WindowPtr pWin,
+ int x,
+ int y)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+Bool
+PclUnmapWindow(
+ WindowPtr pWindow)
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void
+PclCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+}
+
+/*ARGSUSED*/
+Bool
+PclChangeWindowAttributes(
+ register WindowPtr pWin,
+ register unsigned long mask)
+{
+ if( pWin->backingStore != NotUseful )
+ {
+ pWin->backingStore = NotUseful;
+ mask |= CWBackingStore;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * This function is largely ripped from miPaintWindow, but modified so
+ * that the background is not painted to the root window, and so that
+ * the backing store is not referenced.
+ */
+void
+PclPaintWindow(
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what)
+{
+
+#define FUNCTION 0
+#define FOREGROUND 1
+#define TILE 2
+#define FILLSTYLE 3
+#define ABSX 4
+#define ABSY 5
+#define CLIPMASK 6
+#define SUBWINDOW 7
+#define COUNT_BITS 8
+
+ pointer gcval[7];
+ pointer newValues [COUNT_BITS];
+
+ BITS32 gcmask, index, mask;
+ RegionRec prgnWin;
+ DDXPointRec oldCorner;
+ BoxRec box;
+ WindowPtr pBgWin;
+ GCPtr pGC;
+ register int i;
+ register BoxPtr pbox;
+ register ScreenPtr pScreen = pWin->drawable.pScreen;
+ register xRectangle *prect;
+ int numRects;
+
+ gcmask = 0;
+
+ /*
+ * We don't want to paint a window that has no place to put the
+ * PCL output.
+ */
+ if( PclGetContextFromWindow( pWin ) == (XpContextPtr)NULL )
+ return;
+
+ if (what == PW_BACKGROUND)
+ {
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ (*pWin->parent->drawable.pScreen->PaintWindowBackground)
+ (pWin->parent, pRegion, what);
+ return;
+ case BackgroundPixel:
+ newValues[FOREGROUND] = (pointer)pWin->background.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ break;
+ case BackgroundPixmap:
+ newValues[TILE] = (pointer)pWin->background.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin |
+ GCTileStipYOrigin;
+ break;
+ }
+ }
+ else
+ {
+ if (pWin->borderIsPixel)
+ {
+ newValues[FOREGROUND] = (pointer)pWin->border.pixel;
+ newValues[FILLSTYLE] = (pointer)FillSolid;
+ gcmask |= GCForeground | GCFillStyle;
+ }
+ else
+ {
+ newValues[TILE] = (pointer)pWin->border.pixmap;
+ newValues[FILLSTYLE] = (pointer)FillTiled;
+ gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin
+ | GCTileStipYOrigin;
+ }
+ }
+
+ prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
+ sizeof(xRectangle));
+ if (!prect)
+ return;
+
+ newValues[FUNCTION] = (pointer)GXcopy;
+ gcmask |= GCFunction | GCClipMask;
+
+ i = pScreen->myNum;
+
+ pBgWin = pWin;
+ if (what == PW_BORDER)
+ {
+ while (pBgWin->backgroundState == ParentRelative)
+ pBgWin = pBgWin->parent;
+ }
+
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if (!pGC)
+ {
+ DEALLOCATE_LOCAL(prect);
+ return;
+ }
+ /*
+ * mash the clip list so we can paint the border by
+ * mangling the window in place, pretending it
+ * spans the entire screen
+ */
+ if (what == PW_BORDER)
+ {
+ prgnWin = pWin->clipList;
+ oldCorner.x = pWin->drawable.x;
+ oldCorner.y = pWin->drawable.y;
+ pWin->drawable.x = pWin->drawable.y = 0;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ REGION_INIT(pScreen, &pWin->clipList, &box, 1);
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
+ newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
+ }
+ else
+ {
+ newValues[ABSX] = (pointer)0;
+ newValues[ABSY] = (pointer)0;
+ }
+
+/*
+ * XXX Backing store is turned off for the PCL driver
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
+ GuaranteeVisBack);
+ */
+
+ mask = gcmask;
+ gcmask = 0;
+ i = 0;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+ switch (index) {
+ case GCFunction:
+ if ((pointer)(long) pGC->alu != newValues[FUNCTION]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FUNCTION];
+ }
+ break;
+ case GCTileStipXOrigin:
+ if ((pointer)(long) pGC->patOrg.x != newValues[ABSX]) {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSX];
+ }
+ break;
+ case GCTileStipYOrigin:
+ if ((pointer)(long) pGC->patOrg.y != newValues[ABSY]) {
+ gcmask |= index;
+ gcval[i++] = newValues[ABSY];
+ }
+ break;
+ case GCClipMask:
+ if ((pointer)(long) pGC->clientClipType != (pointer)CT_NONE) {
+ gcmask |= index;
+ gcval[i++] = (pointer)CT_NONE;
+ }
+ break;
+ case GCSubwindowMode:
+ if ((pointer)(long) pGC->subWindowMode != newValues[SUBWINDOW]) {
+ gcmask |= index;
+ gcval[i++] = newValues[SUBWINDOW];
+ }
+ break;
+ case GCTile:
+ if (pGC->tileIsPixel ||
+ (pointer) pGC->tile.pixmap != newValues[TILE])
+ {
+ gcmask |= index;
+ gcval[i++] = newValues[TILE];
+ }
+ break;
+ case GCFillStyle:
+ if ((pointer)(long) pGC->fillStyle != newValues[FILLSTYLE]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FILLSTYLE];
+ }
+ break;
+ case GCForeground:
+ if ((pointer) pGC->fgPixel != newValues[FOREGROUND]) {
+ gcmask |= index;
+ gcval[i++] = newValues[FOREGROUND];
+ }
+ break;
+ }
+ }
+
+ if (gcmask)
+ DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
+
+ if (pWin->drawable.serialNumber != pGC->serialNumber)
+ ValidateGC((DrawablePtr)pWin, pGC);
+
+ numRects = REGION_NUM_RECTS(pRegion);
+ pbox = REGION_RECTS(pRegion);
+ for (i= numRects; --i >= 0; pbox++, prect++)
+ {
+ prect->x = pbox->x1 - pWin->drawable.x;
+ prect->y = pbox->y1 - pWin->drawable.y;
+ prect->width = pbox->x2 - pbox->x1;
+ prect->height = pbox->y2 - pbox->y1;
+ }
+ prect -= numRects;
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
+ DEALLOCATE_LOCAL(prect);
+
+/*
+ * XXX Backing store is turned off for the PCL driver
+
+ if (pWin->backStorage)
+ (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
+ GuaranteeNothing);
+ */
+
+ if (what == PW_BORDER)
+ {
+ REGION_UNINIT(pScreen, &pWin->clipList);
+ pWin->clipList = prgnWin;
+ pWin->drawable.x = oldCorner.x;
+ pWin->drawable.y = oldCorner.y;
+ pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ }
+ FreeScratchGC(pGC);
+
+}
+
+/*ARGSUSED*/
+Bool
+PclDestroyWindow(
+ WindowPtr pWin)
+{
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h b/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h
new file mode 100644
index 000000000..5224fd9e3
--- /dev/null
+++ b/nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h
@@ -0,0 +1,213 @@
+/* $Xorg: Pclmap.h,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
+/*
+(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.
+*/
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/Pclmap.h,v 1.5 2001/07/25 15:05:00 dawes Exp $ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef _PCLMAP_H_
+#define _PCLMAP_H_
+
+#ifdef XP_PCL_COLOR
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclCr##subname
+#define CATNAME(prefix,subname) prefix##Color##subname
+#else
+#define PCLNAME(subname) PclCr/**/subname
+#define CATNAME(prefix,subname) prefix/**/Color/**/subname
+#endif
+#endif /* XP_PCL_COLOR */
+
+#ifdef XP_PCL_MONO
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclMn##subname
+#define CATNAME(prefix,subname) prefix##Mono##subname
+#else
+#define PCLNAME(subname) PclMn/**/subname
+#define CATNAME(prefix,subname) prefix/**/Mono/**/subname
+#endif
+#endif /* XP_PCL_MONO */
+
+#ifdef XP_PCL_LJ3
+#ifdef CATNAME
+#undef CATNAME
+#endif
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define PCLNAME(subname) PclLj3##subname
+#define CATNAME(prefix,subname) prefix##Lj3##subname
+#else
+#define PCLNAME(subname) PclLj3/**/subname
+#define CATNAME(prefix,subname) prefix/**/Lj3/**/subname
+#endif
+#endif /* XP_PCL_LJ3 */
+
+#ifdef PCLNAME
+
+/* PclInit.c */
+#define InitializePclDriver CATNAME(Initialize, PclDriver)
+#define PclCloseScreen PCLNAME(CloseScreen)
+#define PclGetContextFromWindow PCLNAME(GetContextFromWindow)
+#define PclScreenPrivateIndex PCLNAME(ScreenPrivateIndex)
+#define PclWindowPrivateIndex PCLNAME(WindowPrivateIndex)
+#define PclContextPrivateIndex PCLNAME(ContextPrivateIndex)
+#define PclPixmapPrivateIndex PCLNAME(PixmapPrivateIndex)
+#define PclGCPrivateIndex PCLNAME(GCPrivateIndex)
+
+/* PclPrint.c */
+#define PclStartJob PCLNAME(StartJob)
+#define PclEndJob PCLNAME(EndJob)
+#define PclStartPage PCLNAME(StartPage)
+#define PclEndPage PCLNAME(EndPage)
+#define PclStartDoc PCLNAME(StartDoc)
+#define PclEndDoc PCLNAME(EndDoc)
+#define PclDocumentData PCLNAME(DocumentData)
+#define PclGetDocumentData PCLNAME(GetDocumentData)
+
+/* PclWindow.c */
+#define PclCreateWindow PCLNAME(CreateWindow)
+#define PclMapWindow PCLNAME(MapWindow)
+#define PclPositionWindow PCLNAME(PositionWindow)
+#define PclUnmapWindow PCLNAME(UnmapWindow)
+#define PclCopyWindow PCLNAME(CopyWindow)
+#define PclChangeWindowAttributes PCLNAME(ChangeWindowAttributes)
+#define PclPaintWindow PCLNAME(PaintWindow)
+#define PclDestroyWindow PCLNAME(DestroyWindow)
+
+/* PclGC.c */
+#define PclCreateGC PCLNAME(CreateGC)
+#define PclDestroyGC PCLNAME(DestroyGC)
+#define PclGetDrawablePrivateStuff PCLNAME(GetDrawablePrivateStuff)
+#define PclSetDrawablePrivateGC PCLNAME(SetDrawablePrivateGC)
+#define PclSendPattern PCLNAME(SendPattern)
+#define PclUpdateDrawableGC PCLNAME(UpdateDrawableGC)
+#define PclComputeCompositeClip PCLNAME(ComputeCompositeClip)
+#define PclValidateGC PCLNAME(ValidateGC)
+
+/* PclAttr.c */
+#define PclGetAttributes PCLNAME(GetAttributes)
+#define PclGetOneAttribute PCLNAME(GetOneAttribute)
+#define PclAugmentAttributes PCLNAME(AugmentAttributes)
+#define PclSetAttributes PCLNAME(SetAttributes)
+
+/* PclColor.c */
+#define PclLookUp PCLNAME(LookUp)
+#define PclCreateDefColormap PCLNAME(CreateDefColormap)
+#define PclCreateColormap PCLNAME(CreateColormap)
+#define PclDestroyColormap PCLNAME(DestroyColormap)
+#define PclInstallColormap PCLNAME(InstallColormap)
+#define PclUninstallColormap PCLNAME(UninstallColormap)
+#define PclListInstalledColormaps PCLNAME(ListInstalledColormaps)
+#define PclStoreColors PCLNAME(StoreColors)
+#define PclResolveColor PCLNAME(ResolveColor)
+#define PclFindPaletteMap PCLNAME(FindPaletteMap)
+#define PclUpdateColormap PCLNAME(UpdateColormap)
+#define PclReadMap PCLNAME(ReadMap)
+
+/* PclPixmap.c */
+#define PclCreatePixmap PCLNAME(CreatePixmap)
+#define PclDestroyPixmap PCLNAME(DestroyPixmap)
+
+/* PclArc.c */
+#define PclDoArc PCLNAME(DoArc)
+#define PclPolyArc PCLNAME(PolyArc)
+#define PclPolyFillArc PCLNAME(PolyFillArc)
+
+/* PclArea.c */
+#define PclPutImage PCLNAME(PutImage)
+#define PclCopyArea PCLNAME(CopyArea)
+#define PclCopyPlane PCLNAME(CopyPlane)
+
+/* PclLine */
+#define PclPolyLine PCLNAME(PolyLine)
+#define PclPolySegment PCLNAME(PolySegment)
+
+/* PclPixel.c */
+#define PclPolyPoint PCLNAME(PolyPoint)
+#define PclPushPixels PCLNAME(PushPixels)
+
+/* PclPolygon.c */
+#define PclPolyRectangle PCLNAME(PolyRectangle)
+#define PclFillPolygon PCLNAME(FillPolygon)
+#define PclPolyFillRect PCLNAME(PolyFillRect)
+
+/* PclSpans.c */
+#define PclFillSpans PCLNAME(FillSpans)
+#define PclSetSpans PCLNAME(SetSpans)
+
+/* PclText.c */
+#define PclPolyText8 PCLNAME(PolyText8)
+#define PclPolyText16 PCLNAME(PolyText16)
+#define PclImageText8 PCLNAME(ImageText8)
+#define PclImageText16 PCLNAME(ImageText16)
+#define PclImageGlyphBlt PCLNAME(ImageGlyphBlt)
+#define PclPolyGlyphBlt PCLNAME(PolyGlyphBlt)
+#define PclPolyGlyphBlt PCLNAME(PolyGlyphBlt)
+
+/* PclFonts.c */
+#define PclRealizeFont PCLNAME(RealizeFont)
+#define PclUnrealizeFont PCLNAME(UnrealizeFont)
+
+/* PclSFonts.c */
+#define PclDownloadSoftFont8 PCLNAME(DownloadSoftFont8)
+#define PclDownloadSoftFont16 PCLNAME(DownloadSoftFont16)
+#define PclCreateSoftFontInfo PCLNAME(CreateSoftFontInfo)
+#define PclDestroySoftFontInfo PCLNAME(DestroySoftFontInfo)
+
+/* PclMisc.c */
+#define PclQueryBestSize PCLNAME(QueryBestSize)
+#define GetPropString PCLNAME(GetPropString)
+#define SystemCmd PCLNAME(SystemCmd)
+#define PclGetMediumDimensions PCLNAME(GetMediumDimensions)
+#define PclGetReproducibleArea PCLNAME(GetReproducibleArea)
+#define PclSpoolFigs PCLNAME(SpoolFigs)
+#define PclSendData PCLNAME(SendData)
+
+/* PclCursor.c */
+#define PclConstrainCursor PCLNAME(ConstrainCursor)
+#define PclCursorLimits PCLNAME(CursorLimits)
+#define PclDisplayCursor PCLNAME(DisplayCursor)
+#define PclRealizeCursor PCLNAME(RealizeCursor)
+#define PclUnrealizeCursor PCLNAME(UnrealizeCursor)
+#define PclRecolorCursor PCLNAME(RecolorCursor)
+#define PclSetCursorPosition PCLNAME(SetCursorPosition)
+
+#endif
+
+#endif /* _PCLMAP_H_ */