(FILECREATED " 7-Oct-86 15:02:00" {MCS:MCS:STANFORD}<LANE>HPGL.LSP;2        

      changes to:  (FNS \DRAWLINE.HPGL)

      previous date: " 1-May-86 08:26:04" {MCS:MCS:STANFORD}<LANE>HPGL.LSP;1)


(PRETTYCOMPRINT HPGLCOMS)

(RPAQQ HPGLCOMS ((* * User Functions)
	(FNS MAKEHPGL OPENHPGLSTREAM HARDCOPYW.HPGL)
	(* * ImageOp Functions)
	(FNS \BITBLT.HPGL \BLTSHADE.HPGL \CLOSEFN.HPGL \COLOR.HPGL \DRAWCIRCLE.HPGL \DRAWCURVE.HPGL 
	     \DRAWLINE.HPGL \DRAWPOLYGON.HPGL \FILLCIRCLE.HPGL \FONT.HPGL \LEFTMARGIN.HPGL 
	     \LINEFEED.HPGL \MOVETO.HPGL \RESET.HPGL \RIGHTMARGIN.HPGL \SCALEDBITBLT.HPGL 
	     \STRINGWIDTH.HPGL \CLIPPINGREGION.HPGL \TERPRI.HPGL \XPOSITION.HPGL \YPOSITION.HPGL)
	(* * Internal Functions)
	(FNS \DUMPSTRING.HPGL \FONTCREATE.HPGL \INIT.HPGL \OUTCHAR.HPGL \SEARCH.HPGL.FONTS \FILL.HPGL 
	     \DASHING.HPGL)
	(* * etc.)
	(VARS HPGL.FONTS HPGL.OPTIONS HPGL.FONT.EXPANSIONS HPGL.DASHING (SKETCHINCOLORFLG T))
	(INITVARS (HPGL.TERMINATOR (CHARCODE ↑A))
		  \HPGLIMAGEOPS \NULLFDEV SK.DASHING.PATTERNS)
	(GLOBALVARS HPGL.FONTS HPGL.OPTIONS HPGL.FONT.EXPANSIONS HPGL.DASHING HPGL.TERMINATOR 
		    \HPGLIMAGEOPS \NULLFDEV)
	(RECORDS PLOTTERDATA)
	[ADDVARS (PRINTERTYPES ((PLOTTER HPGL)
				(CANPRINT (HPGL))
				(STATUS TRUE)
				(BITMAPFILE (HARDCOPYW.HPGL FILE BITMAP SCALEFACTOR REGION ROTATION 
							    TITLE))
				(PROPERTIES NILL)))
		 [PRINTFILETYPES (HPGL (EXTENSION (HPGL PLOT))
				       (CONVERSION (TEXT MAKEHPGL TEDIT
							 (LAMBDA (FILE PFILE)
								 (SETQ FILE (OPENTEXTSTREAM FILE))
								 (TEDIT.FORMAT.HARDCOPY FILE PFILE T 
											NIL NIL NIL
											'HPGL)
								 (CLOSEF? FILE)
								 PFILE]
		 (IMAGESTREAMTYPES (HPGL (OPENSTREAM OPENHPGLSTREAM)
					 (FONTCREATE \FONTCREATE.HPGL)
					 (FONTSAVAILABLE \SEARCH.HPGL.FONTS)
					 (CREATECHARSET NILL]
	(FILES COLOR)
	(P [if (FGETD (FUNCTION SK.DASHING.LABEL))
	       then
	       (for ENTRY in HPGL.DASHING do (push SK.DASHING.PATTERNS (LIST (SK.DASHING.LABEL
									       (CDR ENTRY))
									     (CDR ENTRY]
	   (\INIT.HPGL))))
(* * User Functions)

(DEFINEQ

(MAKEHPGL
  [LAMBDA (FILE PFILE FONTS HEADING TABS)                    (* cdl "12-Jun-85 11:22")
    (TEXTTOIMAGEFILE FILE PFILE 'HPGL
		       FONTS HEADING TABS])

(OPENHPGLSTREAM
  [LAMBDA (FILE OPTIONS)                                     (* cdl "30-Apr-86 19:15")
                                                             (* DECLARATIONS: (RECORD PAIR 
							     (KEY VALUE)))
    (LET (HPGLSTREAM POSITION (STREAM (OPENSTREAM FILE 'OUTPUT))
		     (SCALE (create POSITION
				      XCOORD ← SCREENWIDTH
				      YCOORD ← SCREENHEIGHT)))
         (if (AND (SETQ POSITION (LISTGET OPTIONS 'SCALE))
		      (POSITIONP POSITION))
	     then (SETQ SCALE POSITION))
         (SETQ HPGLSTREAM (create STREAM
				      IMAGEOPS ← \HPGLIMAGEOPS
				      IMAGEDATA ←(create PLOTTERDATA
							   PD.STREAM ← STREAM
							   PD.SCALE ← SCALE
							   PD.RIGHTMARGIN ←(with POSITION SCALE 
										   XCOORD))
				      OUTCHARFN ←(FUNCTION \OUTCHAR.HPGL)
				      CBUFPTR ← NIL
				      CBUFSIZE ← 0
				      DEVICE ← \NULLFDEV using STREAM))
         (with STREAM STREAM (SETQ LINELENGTH MAX.SMALLP))
         (with POSITION SCALE (printout STREAM "DF" "SC" "0" , XCOORD , "0" , YCOORD "DT"
					  (CHARACTER HPGL.TERMINATOR)))
         [bind ENTRY for PAIR on OPTIONS by (CDDR PAIR)
	    do (with PAIR PAIR (if (SETQ ENTRY (ASSOC KEY HPGL.OPTIONS))
				       then (printout STREAM (CDR ENTRY)
							VALUE]
         (DSPFONT DEFAULTFONT HPGLSTREAM)
         (DSPRESET HPGLSTREAM)
     HPGLSTREAM])

(HARDCOPYW.HPGL
  [LAMBDA (FILE BITMAP SCALEFACTOR REGION ROTATION TITLE)    (* cdl " 1-May-85 09:21")
    (PROG ((PFILE (OPENHPGLSTREAM FILE)))
	    (with REGION REGION (BITBLT BITMAP LEFT BOTTOM PFILE NIL NIL WIDTH HEIGHT))
	    (RETURN (CLOSEF PFILE])
)
(* * ImageOp Functions)

(DEFINEQ

(\BITBLT.HPGL
  [LAMBDA (BITMAP SOURCELEFT SOURCEBOTTOM STREAM DESTINATIONLEFT DESTINATIONBOTTOM WIDTH HEIGHT 
		  SOURCETYPE OPERATION TEXTURE CLIPPINGREGION CLIPPEDSOURCELEFT CLIPPEDSOURCEBOTTOM)
                                                             (* cdl "11-Jul-85 10:31")
    (\DUMPSTRING.HPGL STREAM)
    (bind (FILESTREAM ←(with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
				 PD.STREAM))
       for Y from SOURCEBOTTOM to (SUB1 (PLUS SOURCEBOTTOM HEIGHT)) as J from 
										DESTINATIONBOTTOM
       do [bind PI (STATE ← 0) for X from SOURCELEFT to (SUB1 (PLUS SOURCELEFT WIDTH))
	       as I from DESTINATIONLEFT do (if (NEQ STATE (BITMAPBIT BITMAP X Y))
						      then (if (ZEROP (SETQ STATE
									      (IDIFFERENCE 1 STATE))
									    )
								 then (printout FILESTREAM "PD")
									(if (NEQ PI (SUB1
										       I))
									    then
									     (printout FILESTREAM
										       (SUB1 I)
										       , J))
							       else (printout FILESTREAM "PU" I , J)
								   )
							     (SETQ PI I))
	       finally (if (NOT (ZEROP STATE))
			     then (printout FILESTREAM "PD")
				    (if (NEQ PI (SUB1 I))
					then (printout FILESTREAM (SUB1 I)
							 , J]
       finally (printout FILESTREAM "PU"))
    T])

(\BLTSHADE.HPGL
  [LAMBDA (TEXTURE STREAM DESTINATIONLEFT DESTINATIONBOTTOM WIDTH HEIGHT OPERATION CLIPPINGREGION)
                                                             (* cdl "19-Jul-85 16:29")
    (IMAGEOP 'IMMOVETO
	     STREAM STREAM DESTINATIONLEFT DESTINATIONBOTTOM)
    (\FILL.HPGL STREAM TEXTURE)
    [with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (printout PD.STREAM "RA" (SUB1 (PLUS DESTINATIONLEFT WIDTH))
		      ,
		      (SUB1 (PLUS DESTINATIONBOTTOM HEIGHT]
    T])

(\CLOSEFN.HPGL
  [LAMBDA (STREAM)                                           (* cdl "11-Jul-85 13:55")
    (\DUMPSTRING.HPGL STREAM)
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (printout PD.STREAM "PU;")
	    (CLOSEF? PD.STREAM)
	    (SETQ PD.STREAM NIL))
    T])

(\COLOR.HPGL
  [LAMBDA (STREAM COLOR)                                     (* cdl "20-Nov-85 18:42")
    (DECLARE (GLOBALVARS COLORNAMES))
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (PROG1 PD.COLOR (if (RGBP COLOR)
				  then (SETQ COLOR
					   (for NAME in COLORNAMES as I from 0
					      thereis (EQUAL COLOR (CDR NAME)) yield I)))
		     (if (AND (FIXP COLOR)
				  (NEQ COLOR PD.COLOR))
			 then (\DUMPSTRING.HPGL STREAM)
				(printout PD.STREAM "SP" (ADD1 (SETQ PD.COLOR COLOR])

(\DRAWCIRCLE.HPGL
  [LAMBDA (STREAM CENTERX CENTERY RADIUS BRUSH DASHING)      (* cdl "30-Apr-86 19:44")
    (DECLARE (SPECVARS . T))
    (\DUMPSTRING.HPGL STREAM)
    [if (LISTP BRUSH)
	then (with BRUSH BRUSH (if BRUSHCOLOR
				       then (IMAGEOP 'IMCOLOR
						       STREAM STREAM BRUSHCOLOR]
    [RESETLST [RESETSAVE NIL (BQUOTE (\DASHING.HPGL , STREAM , (\DASHING.HPGL STREAM 
											DASHING]
		(RESETSAVE NIL (BQUOTE (DSPCOLOR , (IMAGEOP 'IMCOLOR
								  STREAM STREAM
								  (if (LISTP BRUSH)
								      then (with BRUSH BRUSH 
										     BRUSHCOLOR)))
						       , STREAM)))
		(with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
			(with POSITION PD.POSITION (printout PD.STREAM "PU" (SETQ XCOORD CENTERX)
							       ,
							       (SETQ YCOORD CENTERY)
							       "CI" RADIUS]
    T])

(\DRAWCURVE.HPGL
  [LAMBDA (STREAM KNOTS CLOSED BRUSH DASHING)                (* cdl "30-Apr-86 19:46")
    (DECLARE (SPECVARS . T))
    (\DUMPSTRING.HPGL STREAM)
    (if (FGETD 'DRAWCURVE.STREAM)
	then (RESETLST (RESETSAVE NIL (BQUOTE (DSPCOLOR ,
								  (IMAGEOP 'IMCOLOR
									   STREAM STREAM
									   (if (LISTP BRUSH)
									       then (with BRUSH 
											    BRUSH 
										       BRUSHCOLOR)))
								  , STREAM)))
			   (DRAWCURVE.STREAM STREAM KNOTS CLOSED BRUSH DASHING))
      else (IMAGEOP 'IMDRAWPOLYGON
		      STREAM STREAM KNOTS CLOSED BRUSH DASHING])

(\DRAWLINE.HPGL
  [LAMBDA (STREAM X1 Y1 X2 Y2 WIDTH OPERATION COLOR DASHING)
                                                             (* cdl " 7-Oct-86 15:01")
    (DECLARE (SPECVARS . T))
    (\DUMPSTRING.HPGL STREAM)
    [RESETLST [RESETSAVE NIL (BQUOTE (\DASHING.HPGL , STREAM , (\DASHING.HPGL STREAM 
											DASHING]
		(RESETSAVE NIL (BQUOTE (DSPCOLOR , (IMAGEOP 'IMCOLOR
								  STREAM STREAM COLOR)
						       , STREAM)))
		(with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
			(with POSITION PD.POSITION (if [NOT (AND (OR (EQ X1 T)
									       (EQ X1 XCOORD))
									 (OR (EQ Y1 T)
									       (EQ Y1 YCOORD]
							 then (printout PD.STREAM "PU"
									  (if (EQ X1 T)
									      then XCOORD
									    else X1)
									  ,
									  (if (EQ Y1 T)
									      then YCOORD
									    else Y1)))
				(printout PD.STREAM "PD" (SETQ XCOORD X2)
					  ,
					  (SETQ YCOORD Y2]
    T])

(\DRAWPOLYGON.HPGL
  [LAMBDA (STREAM POINTS CLOSED BRUSH DASHING)               (* cdl "30-Apr-86 19:44")
    (DECLARE (SPECVARS . T))
    (\DUMPSTRING.HPGL STREAM)
    [RESETLST [RESETSAVE NIL (BQUOTE (\DASHING.HPGL , STREAM , (\DASHING.HPGL STREAM 
											DASHING]
		(RESETSAVE NIL (BQUOTE (DSPCOLOR , (IMAGEOP 'IMCOLOR
								  STREAM STREAM
								  (if (LISTP BRUSH)
								      then (with BRUSH BRUSH 
										     BRUSHCOLOR)))
						       , STREAM)))
		(with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
			(with POSITION (CAR POINTS)
				(printout PD.STREAM "PU" XCOORD , YCOORD "PD"))
			(for POINT in (CDR POINTS)
			   do (with POSITION POINT (printout PD.STREAM XCOORD , YCOORD ,)))
			(if CLOSED
			    then (with POSITION (CAR POINTS)
					   (printout PD.STREAM XCOORD , YCOORD)))
			(with POSITION (CAR (LAST POINTS))
				(create POSITION
					  XCOORD ← XCOORD
					  YCOORD ← YCOORD smashing PD.POSITION]
    T])

(\FILLCIRCLE.HPGL
  [LAMBDA (STREAM CENTERX CENTERY RADIUS TEXTURE)            (* cdl "20-Nov-85 18:51")
    (\DUMPSTRING.HPGL STREAM)
    (\FILL.HPGL STREAM TEXTURE)
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with POSITION PD.POSITION (printout PD.STREAM "PU" (SETQ XCOORD CENTERX)
						   ,
						   (SETQ YCOORD CENTERY)
						   "WG" RADIUS , "0" , "360")))
    T])

(\FONT.HPGL
  [LAMBDA (STREAM FONT)                                      (* cdl "24-Apr-86 20:01")
                                                             (* DECLARATIONS: (RECORD FACE 
							     (WEIGHT SLOPE EXPANSION)))
    [if (type? FONTCLASS FONT)
	then (SETQ FONT (FONTCLASSCOMPONENT FONT (IMAGESTREAMTYPE STREAM]
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (if (AND FONT (NEQ FONT PD.FONT))
		then (\DUMPSTRING.HPGL STREAM)
		       [with FONTDESCRIPTOR FONT [if (NEQ FONTFAMILY (fetch FONTFAMILY
									      of PD.FONT))
						       then (printout PD.STREAM "CS"
									(OR (CDR (FASSOC 
										       FONTFAMILY 
										       HPGL.FONTS))
									      (CONSTANT null]
			       [if (NEQ ROTATION (fetch ROTATION of PD.FONT))
				   then (printout PD.STREAM "DI")
					  (if (AND ROTATION (NOT (ZEROP ROTATION)))
					      then (printout PD.STREAM (COS ROTATION)
							       ,
							       (SIN ROTATION]
			       (with POSITION PD.SCALE (printout PD.STREAM "SR")
				       (PRINTNUM '(FLOAT NIL 3)
						   (QUOTIENT
						     (QUOTIENT [TIMES FONTAVGCHARWIDTH
									  (with
									    FACE FONTFACE
									    (CDR (ASSOC EXPANSION 
									     HPGL.FONT.EXPANSIONS]
								 3)
						     XCOORD)
						   PD.STREAM)
				       (printout PD.STREAM ,)
				       (PRINTNUM '(FLOAT NIL 3)
						   (QUOTIENT (TIMES \SFHeight 100.0)
							       YCOORD)
						   PD.STREAM))
			       (with FACE FONTFACE (if (NEQ SLOPE (fetch (FACE SLOPE)
									   of (fetch FONTFACE
										   of PD.FONT)))
							 then (printout PD.STREAM "SL"
									  (SELECTQ
									    SLOPE
									    (REGULAR (CONSTANT
										       null))
									    (ITALIC 1)
									    (SHOULDNT]
		       (PROG1 PD.FONT (SETQ PD.FONT FONT))
	      else PD.FONT])

(\LEFTMARGIN.HPGL
  [LAMBDA (STREAM XPOSITION)                                 (* cdl "25-Jun-85 15:33")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (PROG1 PD.LEFTMARGIN (if XPOSITION
				       then (SETQ PD.LEFTMARGIN XPOSITION])

(\LINEFEED.HPGL
  [LAMBDA (STREAM DELTAY)                                    (* cdl "24-Jul-85 08:01")
    (MINUS (TIMES 2 (FONTPROP (with STREAM STREAM (with PLOTTERDATA IMAGEDATA PD.FONT))
				    'HEIGHT])

(\MOVETO.HPGL
  [LAMBDA (STREAM X Y)                                       (* cdl "11-Jul-85 10:12")
    (\DUMPSTRING.HPGL STREAM)
    [with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with POSITION PD.POSITION (printout PD.STREAM "PU" (SETQ XCOORD X)
						   ,
						   (SETQ YCOORD Y]
    T])

(\RESET.HPGL
  [LAMBDA (STREAM)                                           (* cdl "19-Jul-85 16:30")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (IMAGEOP 'IMMOVETO
		     STREAM STREAM PD.LEFTMARGIN (PLUS (with POSITION PD.SCALE YCOORD)
							 (IMAGEOP 'IMLINEFEED
								  STREAM STREAM])

(\RIGHTMARGIN.HPGL
  [LAMBDA (STREAM XPOSITION)                                 (* cdl "25-Jun-85 15:34")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (PROG1 PD.RIGHTMARGIN (if XPOSITION
					then (SETQ PD.RIGHTMARGIN XPOSITION])

(\SCALEDBITBLT.HPGL
  [LAMBDA (BITMAP SOURCELEFT SOURCEBOTTOM STREAM DESTINATIONLEFT DESTINATIONBOTTOM WIDTH HEIGHT 
		  SOURCETYPE OPERATION TEXTURE CLIPPINGREGION CLIPPEDSOURCELEFT CLIPPEDSOURCEBOTTOM 
		  SCALE)                                     (* cdl "31-Jul-85 15:11")
    (\DUMPSTRING.HPGL STREAM)
    (bind (FILESTREAM ←(with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
				 PD.STREAM))
	    (SOURCEWIDTH ←(SUB1 (PLUS SOURCELEFT WIDTH))) for Y from SOURCEBOTTOM
       to (SUB1 (PLUS SOURCEBOTTOM HEIGHT)) as J from DESTINATIONBOTTOM by SCALE
       do [for Z from J to (PLUS J (SUB1 SCALE))
	       do (bind PI LASTPOSITION (STATE ← 0) for X from SOURCELEFT to SOURCEWIDTH
		       as I from DESTINATIONLEFT by SCALE
		       do (if (NEQ STATE (BITMAPBIT BITMAP X Y))
				then (if (ZEROP (SETQ STATE (DIFFERENCE 1 STATE)))
					   then (printout FILESTREAM "PD")
						  (if (NOT (IEQP PI (SUB1 I)))
						      then (printout FILESTREAM (SUB1 I)
								       , Z))
					 else (printout FILESTREAM "PU" I , Z))
				       (SETQ PI I))
		       finally (if (NOT (ZEROP STATE))
				     then (printout FILESTREAM "PD")
					    (if (NOT (IEQP PI (SUB1 I)))
						then (printout FILESTREAM (SUB1 I)
								 , Z]
       finally (printout FILESTREAM "PU"))
    T])

(\STRINGWIDTH.HPGL
  [LAMBDA (STREAM STRING RDTBL)                              (* cdl "29-Apr-85 14:31")
    (STRINGWIDTH STRING (DSPFONT NIL STREAM)
		   RDTBL RDTBL])

(\CLIPPINGREGION.HPGL
  [LAMBDA (STREAM REGION)                                    (* cdl "16-Oct-85 10:57")
    (with STREAM STREAM (with PLOTTERDATA IMAGEDATA (with POSITION PD.SCALE
								(CREATEREGION 0 0 XCOORD YCOORD])

(\TERPRI.HPGL
  [LAMBDA (STREAM)                                           (* cdl "24-Jul-85 09:26")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with POSITION PD.POSITION (IMAGEOP 'IMMOVETO
						  STREAM STREAM PD.LEFTMARGIN
						  (PLUS YCOORD (IMAGEOP 'IMLINEFEED
									  STREAM STREAM])

(\XPOSITION.HPGL
  [LAMBDA (STREAM XPOSITION)                                 (* cdl "11-Jul-85 10:16")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with POSITION PD.POSITION (PROG1 XCOORD (if XPOSITION
							     then (\DUMPSTRING.HPGL STREAM)
								    (printout PD.STREAM "PU"
									      (SETQ XCOORD 
										XPOSITION)
									      , YCOORD])

(\YPOSITION.HPGL
  [LAMBDA (STREAM YPOSITION)                                 (* cdl "11-Jul-85 10:15")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with POSITION PD.POSITION (PROG1 YCOORD (if YPOSITION
							     then (\DUMPSTRING.HPGL STREAM)
								    (printout PD.STREAM "PU" XCOORD ,
									      (SETQ YCOORD 
										YPOSITION])
)
(* * Internal Functions)

(DEFINEQ

(\DUMPSTRING.HPGL
  [LAMBDA (STREAM)                                           (* cdl "24-Apr-86 19:22")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (if PD.TEXT
		then (printout PD.STREAM "LB")
		       (for CHARCODE in (DREVERSE PD.TEXT) do (BOUT PD.STREAM CHARCODE))
		       (BOUT PD.STREAM HPGL.TERMINATOR)
		       (SETQ PD.TEXT NIL)
		       T])

(\FONTCREATE.HPGL
  [LAMBDA (FAMILY SIZE FACE ROTATION)                        (* cdl "18-Feb-86 14:29")
    (if (ASSOC FAMILY HPGL.FONTS)
	then (LET ((WIDTHSBLOCK (\CREATECSINFOELEMENT))
		     (FONTDESCRIPTOR (create FONTDESCRIPTOR
					       FONTDEVICE ← 'HPGL
					       FONTFAMILY ← FAMILY
					       FONTSIZE ← SIZE
					       FONTFACE ← FACE
					       ROTATION ← ROTATION
					       FIRSTCHAR ← 0
					       LASTCHAR ← 127
					       \SFHeight ← SIZE
					       \SFAscent ← SIZE
					       \SFDescent ← 0)))
		    (bind (WIDTH ←(FIX (QUOTIENT (TIMES 3 SIZE)
						       4)))
		       for N from 0 to 254 do (\FSETWIDTH WIDTHSBLOCK N WIDTH))
		    (with FONTDESCRIPTOR FONTDESCRIPTOR
			    (\SETCHARSETINFO FONTCHARSETVECTOR 0
					     (create CHARSETINFO
						       WIDTHS ← WIDTHSBLOCK
						       IMAGEWIDTHS ← WIDTHSBLOCK
						       CHARSETASCENT ← SIZE
						       CHARSETDESCENT ← 0)))
		FONTDESCRIPTOR)
      else (FONTCREATE (CAAR HPGL.FONTS)
			   SIZE FACE ROTATION 'HPGL])

(\INIT.HPGL
  [LAMBDA NIL                                                (* cdl "12-Nov-85 11:49")
    (SETQ \NULLFDEV (create FDEV
				CLOSEFILE ←(FUNCTION NILL)))
    (SETQ \HPGLIMAGEOPS (create IMAGEOPS
				    IMAGETYPE ← 'HPGL
				    IMCLOSEFN ←(FUNCTION \CLOSEFN.HPGL)
				    IMXPOSITION ←(FUNCTION \XPOSITION.HPGL)
				    IMYPOSITION ←(FUNCTION \YPOSITION.HPGL)
				    IMFONT ←(FUNCTION \FONT.HPGL)
				    IMLEFTMARGIN ←(FUNCTION \LEFTMARGIN.HPGL)
				    IMRIGHTMARGIN ←(FUNCTION \RIGHTMARGIN.HPGL)
				    IMLINEFEED ←(FUNCTION \LINEFEED.HPGL)
				    IMDRAWLINE ←(FUNCTION \DRAWLINE.HPGL)
				    IMDRAWCURVE ←(FUNCTION \DRAWCURVE.HPGL)
				    IMDRAWCIRCLE ←(FUNCTION \DRAWCIRCLE.HPGL)
				    IMDRAWELLIPSE ←(FUNCTION DRAWELLIPSEWITHDRAWCURVE)
				    IMFILLCIRCLE ←(FUNCTION \FILLCIRCLE.HPGL)
				    IMBITBLT ←(FUNCTION \BITBLT.HPGL)
				    IMBLTSHADE ←(FUNCTION \BLTSHADE.HPGL)
				    IMMOVETO ←(FUNCTION \MOVETO.HPGL)
				    IMSCALE ←(FUNCTION [LAMBDA (STREAM SCALE)
					1])
				    IMTERPRI ←(FUNCTION \TERPRI.HPGL)
				    IMFONTCREATE ← 'HPGL
				    IMCOLOR ←(FUNCTION \COLOR.HPGL)
				    IMSTRINGWIDTH ←(FUNCTION \STRINGWIDTH.HPGL)
				    IMCHARWIDTH ←(FUNCTION \STRINGWIDTH.HPGL)
				    IMRESET ←(FUNCTION \RESET.HPGL)
				    IMCLIPPINGREGION ←(FUNCTION \CLIPPINGREGION.HPGL)
				    IMDRAWPOLYGON ←(FUNCTION \DRAWPOLYGON.HPGL)
				    IMSCALEDBITBLT ←(FUNCTION \SCALEDBITBLT.HPGL)))
    (SETFONTCLASSCOMPONENT DEFAULTFONT 'HPGL
			     (FONTCREATE 'STANDARD
					   10 NIL NIL 'HPGL))
    (SETFONTCLASSCOMPONENT LITTLEFONT 'HPGL
			     (FONTCREATE 'STANDARD
					   8 NIL NIL 'HPGL))
    (SETFONTCLASSCOMPONENT BIGFONT 'HPGL
			     (FONTCREATE 'STANDARD
					   12 NIL NIL 'HPGL))
    (SETFONTCLASSCOMPONENT BOLDFONT 'HPGL
			     (FONTCREATE 'STANDARD
					   10
					   'BOLD
					   NIL
					   'HPGL])

(\OUTCHAR.HPGL
  [LAMBDA (STREAM CHARCODE)                                  (* cdl " 3-Oct-85 13:20")
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (SELCHARQ CHARCODE
		      (EOL (\TERPRI.HPGL STREAM))
		      (if (AND (GEQ CHARCODE (CHARCODE SPACE))
				   (LEQ CHARCODE (CHARCODE ~)))
			  then (with POSITION PD.POSITION (add XCOORD (CHARWIDTH CHARCODE 
											 PD.FONT)))
				 (push PD.TEXT CHARCODE])

(\SEARCH.HPGL.FONTS
  [LAMBDA (FAMILY SIZE FACE ROTATION DEVICE)                 (* cdl " 1-May-85 09:34")
    (if (EQ DEVICE 'HPGL)
	then (if (FASSOC FAMILY HPGL.FONTS)
		   then (LIST (LIST FAMILY SIZE FACE ROTATION DEVICE])

(\FILL.HPGL
  [LAMBDA (STREAM TEXTURE)                                   (* cdl "20-Nov-85 19:05")
                                                             (* DECLARATIONS: (RECORD TEXTURE 
							     (TYPE SPACING ANGLE)) (RECORD TEXTURECOLORPAIR 
							     (TEXURE COLOR)))
    (\DUMPSTRING.HPGL STREAM)
    (if [AND (LISTP TEXTURE)
		 (with TEXTURECOLORPAIR TEXTURE (OR (RGBP COLOR)
							(HSLP COLOR]
	then (with TEXTURECOLORPAIR TEXTURE (IMAGEOP 'IMCOLOR
							 STREAM STREAM COLOR))
	       (SETQ TEXTURE (with TEXTURECOLORPAIR TEXTURE TEXTURE)))
    [if (FIXP TEXTURE)
	then (SETQ TEXTURE (create TEXTURE
					 TYPE ←(if (IEQP TEXTURE BLACKSHADE)
						   then 1
						 elseif (IEQP TEXTURE WHITESHADE)
						   then 3
						 else 4)
					 SPACING ← 0
					 ANGLE ←(TIMES (LOGAND TEXTURE 3)
							 45]
    [with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (with TEXTURE TEXTURE (printout PD.STREAM "FT" (if (AND (FIXP TYPE)
									  (GEQ TYPE 1)
									  (LEQ TYPE 4))
								 then TYPE
							       else 1)
					      ,
					      (if (FIXP SPACING)
						  then SPACING
						else 0)
					      ,
					      (if (AND (FIXP ANGLE)
							   (ZEROP (IMOD ANGLE 45)))
						  then ANGLE
						else 0]
    T])

(\DASHING.HPGL
  [LAMBDA (STREAM DASHING)                                   (* cdl "30-Apr-86 19:48")
                                                             (* DECLARATIONS: (RECORD ENTRY 
							     (INDEX . LENGTHS)))
    (with PLOTTERDATA (with STREAM STREAM IMAGEDATA)
	    (PROG1 (if PD.DASHING
			 then (CDR (ASSOC PD.DASHING HPGL.DASHING)))
		     (if DASHING
			 then [LET (INDEX)
				     [if (SETQ DASHING (MKLIST DASHING))
					 then (SETQ INDEX (for ENTRY in HPGL.DASHING
								 thereis (with ENTRY ENTRY
										   (EQUAL DASHING 
											  LENGTHS))
								 yield (with ENTRY ENTRY INDEX]
				     (if (AND (FIXP INDEX)
						  (NEQ INDEX PD.DASHING))
					 then (\DUMPSTRING.HPGL STREAM)
						(printout PD.STREAM "LT" (SETQ PD.DASHING INDEX]
		       else (\DUMPSTRING.HPGL STREAM)
			      (printout PD.STREAM "LT")
			      (SETQ PD.DASHING NIL])
)
(* * etc.)


(RPAQQ HPGL.FONTS ((STANDARD . 0)
		     (9825 . 1)
		     (FRENCH . 2)
		     (SCANDINAVIAN . 3)
		     (SPANISH . 4)
		     (JISASCII . 6)
		     (ROMAN . 7)
		     (KATAKANA . 8)
		     (IRV . 9)
		     (SWEDISH . 30)
		     (SWEDISH2 . 31)
		     (NORWAY . 32)
		     (GERMAN . 33)
		     (FRENCH2 . 34)
		     (BRITISH . 35)
		     (ITIALIAN . 36)
		     (SPANISH2 . 37)
		     (PORTUGUESE . 38)
		     (NORWAY2 . 39)))

(RPAQQ HPGL.OPTIONS ((ROTATE . "RO")
		       (VELOCITY . "VS")
		       (PAPER . "PS")
		       (TERMINATOR . "DT")))

(RPAQQ HPGL.FONT.EXPANSIONS ((REGULAR . 200.0)
			       (COMPRESSED . 100.0)
			       (EXPANDED . 400.0)))

(RPAQQ HPGL.DASHING ((1 1 49)
		       (2 25)
		       (3 35 15)
		       (4 39 5 1 5)
		       (5 35 5 5 5)
		       (6 25 5 5 5 5 5)))

(RPAQQ SKETCHINCOLORFLG T)

(RPAQ? HPGL.TERMINATOR (CHARCODE ↑A))

(RPAQ? \HPGLIMAGEOPS NIL)

(RPAQ? \NULLFDEV NIL)

(RPAQ? SK.DASHING.PATTERNS NIL)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS HPGL.FONTS HPGL.OPTIONS HPGL.FONT.EXPANSIONS HPGL.DASHING HPGL.TERMINATOR \HPGLIMAGEOPS 
	    \NULLFDEV)
)
[DECLARE: EVAL@COMPILE 

(RECORD PLOTTERDATA (PD.STREAM PD.POSITION PD.FONT PD.TEXT PD.COLOR PD.SCALE PD.LEFTMARGIN 
				 PD.RIGHTMARGIN PD.DASHING)
		      PD.POSITION ←(create POSITION)
		      PD.COLOR ← 0 PD.LEFTMARGIN ← 0)
]

(ADDTOVAR PRINTERTYPES ((PLOTTER HPGL)
			  (CANPRINT (HPGL))
			  (STATUS TRUE)
			  (BITMAPFILE (HARDCOPYW.HPGL FILE BITMAP SCALEFACTOR REGION ROTATION TITLE))
			  (PROPERTIES NILL)))

(ADDTOVAR PRINTFILETYPES [HPGL (EXTENSION (HPGL PLOT))
				 (CONVERSION (TEXT MAKEHPGL TEDIT
						   (LAMBDA (FILE PFILE)
							   (SETQ FILE (OPENTEXTSTREAM FILE))
							   (TEDIT.FORMAT.HARDCOPY FILE PFILE T NIL 
										  NIL NIL
										  'HPGL)
							   (CLOSEF? FILE)
							   PFILE])

(ADDTOVAR IMAGESTREAMTYPES (HPGL (OPENSTREAM OPENHPGLSTREAM)
				   (FONTCREATE \FONTCREATE.HPGL)
				   (FONTSAVAILABLE \SEARCH.HPGL.FONTS)
				   (CREATECHARSET NILL)))
(FILESLOAD COLOR)
[if (FGETD (FUNCTION SK.DASHING.LABEL))
    then
    (for ENTRY in HPGL.DASHING do (push SK.DASHING.PATTERNS (LIST (SK.DASHING.LABEL (CDR ENTRY))
								  (CDR ENTRY]
(\INIT.HPGL)
STOP