[comp.lang.postscript] troff to PS

peterk@hparc0.HP.COM (Peter Kempinski) (07/23/90)

I'm trying to use a troff to PostScript translator which is a part
of AT&T SYSV DWB.
I am familiar with troff but I have very little understanding of
PostScript.
While printing a file I received a stack underflow error on one of
the exch operators.
I included a copy of the offending header file in hope that one of the
net experts may help me pinpoint the problem.
I apologize for a long include ...
 --
 Peter M. Kempinski                                        _      
 Hewlett-Packard Australia                           ___   _     -    
 Phone: +61 3 284 2219                             _- . -__-.-  
 UUCP !hp-lsd.cos.hp.com!hparc0.hp.com!peterk    --. . . . . .-  
 Internet: peterk@hparc0.HP.COM               - . . . . . . . . - 
 ACSnet: peterk%hparc0@aso.oz.au             - . . . . . . . . . -
 DESK: Peter KEMPINSKI / HP9061/HU           -. . . . . . . . . ._ 
 Snail: 126-142 Trenery Crescent              -_ ._------_ . . ._ 
        Abbotsford, Vic. 3067                   --        -_.X_- 
        AUSTRALIA.                                          -- \__________
___________________________________________________________________________

( /usr/lib/dwb/dpost.ps )

%!PS
%%Version: 2.2
%%DocumentFonts: (atend)
%%Pages: (atend)
%%EndComments
save
mark
%
% Library file used by the PostScript translator for device independent troff
% output.
%

/margin 5 def

/min {
    1 index 1 index gt {exch} if pop
}def

/mapfonts {
    /Symbol /S Sdefs cf
    /Times-Roman /S1 S1defs cf

    /R /Times-Roman def
    /I /Times-Italic def
    /B /Times-Bold def
    /BI /Times-BoldItalic def
    /H /Helvetica def
    /HI /Helvetica-Oblique def
    /HB /Helvetica-Bold def
    /HX /Helvetica-BoldOblique def
    /CW /Courier def
    /CO /Courier def
    /CI /Courier-Oblique def
    /CB /Courier-Bold def
    /CX /Courier-BoldOblique def
    /PA /Palatino-Roman def
    /PI /Palatino-Italic def
    /PB /Palatino-Bold def
    /PX /Palatino-BoldItalic def
    /Hr /Helvetica-Narrow def
    /Hi /Helvetica-Narrow-Oblique def
    /Hb /Helvetica-Narrow-Bold def
    /Hx /Helvetica-Narrow-BoldOblique def
    /KR /Bookman-Light def
    /KI /Bookman-LightItalic def
    /KB /Bookman-Demi def
    /KX /Bookman-DemiItalic def
    /AR /AvantGarde-Book def
    /AI /AvantGarde-BookOblique def
    /AB /AvantGarde-Demi def
    /AX /AvantGarde-DemiOblique def
    /NR /NewCenturySchlbk-Roman def
    /NI /NewCenturySchlbk-Italic def
    /NB /NewCenturySchlbk-Bold def
    /NX /NewCenturySchlbk-BoldItalic def
    /S /S def
    /S1 /S1 def
    /GR /Symbol def
    /ZD /ZapfDingbats def
    /ZI /ZapfChancery-MediumItalic def
} def

/setup {
    /res exch def
    /penwidth exch def

    /aspect exch def
    /mag exch def
    /mode exch def
    /forms exch def
    /copies exch def
    -72 mul /yorigin exch def
    72 mul /xorigin exch def

    forms 1 eq {/margin 0 def} if

    /columns forms sqrt ceiling cvi def
    /rows forms columns div ceiling cvi def
    /form 0 def

    clippath pathbbox
    2 index margin 2 mul add sub dup
    /height exch def /pheight exch def
    2 index margin 2 mul add sub dup
    /width exch def /pwidth exch def

    margin add exch margin add exch translate
    0 pheight translate

    (landscape) mode eq {
	height width /height exch def /width exch def
	rows columns /rows exch def /columns exch def
    } if

    pwidth width columns mul div pheight height rows mul div min
    pheight width columns mul div pwidth height rows mul div min

    1 index 1 index lt {
	0 pheight neg translate
	90 rotate
	pwidth pheight /pwidth exch def /pheight exch def
	exch
    } if

    pop dup dup scale
    dup pwidth exch div width columns mul sub 2 div
    exch pheight exch div height rows mul sub 2 div neg translate

    /fac 72 res div def
    mapfonts

    xorigin yorigin translate
    0 0 moveto
    senv
} def

/ff {
    renv
    forms 1 gt {
	gsave
	.1 setlinewidth
	border stroke
	grestore
    } if
    width 0 translate
    /form form 1 add def
    form columns mod 0 eq {
	columns width mul neg height neg translate
    } if
    form forms mod 0 eq {
	sp
	form columns mod width mul neg
	forms columns idiv height mul translate
	/form 0 def
    } if
    0 0 moveto
    senv
} def

/border {
    newpath
    xorigin neg yorigin neg moveto
    width 0 rlineto
    0 height neg rlineto
    width neg 0 rlineto
    closepath
} def

/senv {
    save /env exch def
    mag fac mul dup aspect mul exch scale
} def

/renv {
    env restore
} def

/sf {
    dup /font exch def findfont exch
    dup /ptsize exch def fac div dup /size exch def scalefont setfont
    penwidth ptsize mul fac 10 mul div setlinewidth
} def

/t {
    count 2 idiv {y moveto show} repeat
} def

/m {
    neg dup /y exch def moveto
} def

/sp {
    copies {copypage} repeat
    erasepage
} def

/done {
    form 0 gt {sp} if
} def

/Dl {
    newpath
    neg moveto
    neg lineto
    stroke
} def

/De {
    newpath
    2 div /yrad exch def
    2 div /xrad exch def
    /savematrix matrix currentmatrix def
    neg exch xrad add exch translate
    xrad yrad scale
    0 0 1 0 360 arc
    savematrix setmatrix
    stroke
} def

/Da {
    newpath
    neg /dy2 exch def
    /dx2 exch def
    /dy1 exch def
    neg /dx1 exch def
    dy1 dx1 atan /angle1 exch def
    dy2 dx2 atan /angle2 exch def
    dx1 dx1 mul dy1 dy1 mul add sqrt /radius exch def
    neg dy1 sub exch dx1 sub exch radius angle1 angle2 arc
    stroke
} def

/Ds {
    newpath
    neg /y2 exch def
    /x2 exch def
    neg /y1 exch def
    /x1 exch def
    neg /y0 exch def
    /x0 exch def
    x0 x1 add 2 div y0 y1 add 2 div moveto
    x0 5 x1 mul add 6 div
    y0 5 y1 mul add 6 div
    x2 5 x1 mul add 6 div
    y2 5 y1 mul add 6 div
    x1 x2 add 2 div
    y1 y2 add 2 div
    curveto
    stroke
} def

/cf {
    dup length 2 idiv
    /entries exch def
    /chtab exch def
    /newfont exch def

    findfont dup length 1 add dict
    /newdict exch def

    {
	1 index /FID ne
	    {newdict 3 1 roll put}
	    {pop pop}
	ifelse
    } forall

    newdict /Metrics entries dict put
    newdict /Metrics get
    begin
	chtab aload pop
	1 1 entries {pop def} for
	newfont newdict definefont pop
    end
} def

%
% A few arrays used to adjust reference points and character widths in some
% of the printer resident fonts. If square roots are too high try changing
% the lines describing /radical and /radicalex to,
%
%	/radical	[0 -75 550 0]
%	/radicalex	[-50 -75 500 0]
%

/Sdefs [
    /bracketlefttp	[220 500]
    /bracketleftbt	[220 500]
    /bracketrighttp	[-70 380]
    /bracketrightbt	[-70 380]
    /braceleftbt	[220 490]
    /radical		[0 0 550 0]
    /radicalex		[-50 0 500 0]
    /parenleftex	[-20 -170 0 0]
    /integral		[100 -50 500 0]
    /infinity		[10 -75 730 0]
] def

/S1defs [
    /underscore		[0 80 500 0]
    /endash		[7 90 65 0]
] def
/resolution 720
setup
%%EndProlog
%%Page: 1 1
save
mark
cleartomark
showpage
restore
%%EndPage: 1 1
%%Page: 2 2
save
mark
cleartomark
showpage
restore
%%EndPage: 2 2
%%Trailer
done
restore
%%Pages: 2