🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #8069

postscript bug

#8069
From: Piet van Oostrum
Date: Wed, 01 Mar 1989 16:24
250 lines
5659 bytes
We have a problem with an Apple LaserWriter (plus). Some characters are
printed on the wrong pixel. 

Output is generated from TEX by dvi2ps. This is done by sending bitmaps to
the laserprinter and imaging them in a 1/300 inch coordinate system.

The error appears when printing a dash (-) followed by an arrow (->). In
the bitmaps these align properly, but on paper they are one pixel different
in vertical position. Sometimes the same misalignment appears in vertical
bars.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% This file is not correctly printed on the laserwriter. See lines
%%%% starting with %%%%

/TeXDict 200 dict def
TeXDict begin
/Resolution 300 def
/Inch{Resolution mul}def
/Mtrx 6 array def
/@a4
{a4 initmatrix
72 Resolution div dup neg scale
270 -3215 translate
Mtrx currentmatrix pop
}def
/@letter
{letter initmatrix
72 Resolution div dup neg scale
340 -3005 translate
Mtrx currentmatrix pop
}def
/@note
{note initmatrix
72 Resolution div dup neg scale
340 -3005 translate
Mtrx currentmatrix pop
}def
/@landscape
{letter initmatrix
72 Resolution div dup neg scale
Mtrx currentmatrix 0 0.0 put
Mtrx 1 -1.0 put
Mtrx 2 1.0 put
Mtrx 3 0.0 put
Mtrx  setmatrix
300 340  translate
Mtrx currentmatrix pop
}def
/@legal
{legal initmatrix
72 Resolution div dup neg scale
295 -3880 translate
Mtrx currentmatrix pop
}def
/@manualfeed
{statusdict /manualfeed true put
}def
/@copies
{/#copies exch def
}def
/@restore /restore load def
/restore
{vmstatus pop
dup @VMused lt{pop @VMused}if
exch pop exch @restore /@VMused exch def
}def
/@pri
{
( ) print
(                                       ) cvs print
}def
/@FontMatrix [1 0 0 -1 0 0] def
/@FontBBox [0 0 1 1] def
/@newfont
{/newname exch def
newname 7 dict def
newname load begin
/FontType 3 def
/FontMatrix @FontMatrix def
/FontBBox @FontBBox def
/BitMaps 128 array def
/BuildChar{CharBuilder}def
/Encoding 128 array def
0 1 127{Encoding exch /.undef put}for
end
newname newname load definefont pop
}def
/ch-image{ch-data 0 get}def
/ch-width{ch-data 1 get}def
/ch-height{ch-data 2 get}def
/ch-xoff{ch-data 3 get}def
/ch-yoff{ch-data 4 get}def
/ch-tfmw{ch-data 5 get}def
/CharBuilder
{save 3 1 roll exch /BitMaps get exch get /ch-data exch def
ch-data null ne
{
%%%% The setcachedevice gives a wrong image. The dash will be one pixel lower
%%%% than the arrow
%ch-tfmw 0 ch-xoff neg ch-yoff neg ch-width ch-xoff sub ch-height ch-yoff sub
%setcachedevice

%%%%% But if we use setcharwidth everything prints OK
ch-tfmw 0 setcharwidth


ch-width ch-height true [1 0  0 1  ch-xoff ch-yoff]
{ch-image}imagemask
}if
restore
}def
/@sf
{setfont
}def
/@dc
{/ch-code exch def
dup 0 get
length 2 lt
{pop [ <00> 1 1 0 0 8.00 ]}
if
/ch-data exch def
currentfont /BitMaps get ch-code ch-data put
currentfont /Encoding get ch-code
dup (   ) cvs cvn
put
}def
/@pc
{pop
/ch-data exch def
currentpoint translate
ch-width ch-height true [1 0 0 -1 ch-xoff ch-yoff]
{ch-image}imagemask
}def
/@bop0
{pop
}def
/@bop1
{pop
erasepage initgraphics
Mtrx setmatrix
/SaveImage save def
}def
/@eop
{showpage
SaveImage restore
}def
/@start
{@a4
vmstatus pop /@VMused exch def pop
}def
/@end
end
}def
/p
{moveto
}def
/r
{0 rmoveto
}def
/s
{show
}def
/c
{c-string exch 0 exch put
c-string s
}def
/c-string ( ) def
/ru
{/dy exch neg def
/dx exch def
/x currentpoint /y exch def def
newpath x y moveto
dx 0 rlineto
0 dy rlineto
dx neg 0 rlineto
closepath fill
x y moveto
}def
/@SpecialDefaults
{/hs 8.5 Inch def
/vs 11 Inch def
/ho 0 def
/vo 0 def
/hsc 1 def
/vsc 1 def
/CLIP false def
}def
/@hsize{/hs exch def /CLIP true def}def
/@vsize{/vs exch def /CLIP true def}def
/@hoffset{/ho exch def}def
/@voffset{/vo exch def}def
/@hscale{/hsc exch def}def
/@vscale{/vsc exch def}def
/@setclipper
{hsc vsc scale
CLIP
{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto closepath clip}
if
}def
/@beginspecial
{gsave /SpecialSave save def
currentpoint transform initgraphics itransform translate
@SpecialDefaults
/showpage{}def
}def
/@setspecial
{ho vo translate @setclipper}
def
/@endspecial
{SpecialSave restore
grestore
}def
end
statusdict /waittimeout 300 put
TeXDict begin @start
%%Title: test.dvi
%%Creator: dvips 2.40
%%EndProlog
1 @bop0
/cmsy10.300 @newfont
cmsy10.300 @sf
%%%% define dash
[<FFFFFF80FFFFFF80> 25 2 -3 -9 32] 0 @dc
%%%% define arrow
[<000000040000000002000000000200000000010000000000800000000040FFFFFFFFF8FFFFFFFFF800000000400000000080
  0000000100000000020000000002000000000400> 37 14 -2 -3 42] 33 @dc
1 @bop1
cmsy10.300 @sf
%%%% print ---
324 307 p 0 c
%%%% print -->
-7 r 33 c
@eop
@end

%%%% end of postscript

I did some experimentation and found the following things:

I suspect the LaserWriter. I changed the setcachedevice call in the
postscript to setcharwidth and lo and behold: The output was correct.

Our laserwriter has version 42.2.

Anybody got a clue?
-- 
Piet van Oostrum, Dept of Computer Science, University of Utrecht
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
Telephone: +31-30-531806. piet@cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)
Technical Details
Message-ID: <1166@ruuinf.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!hp4nl!ruuinf!piet

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!hp4nl!ruuinf!piet
From: piet@ruuinf (Piet van Oostrum)
Newsgroups: comp.lang.postscript
Subject: postscript bug
Message-ID: <1166@ruuinf.UUCP>
Date: 1 Mar 89 16:24:32 GMT
Sender: piet@ruuinf.UUCP
Reply-To: piet@ruuinf (Piet van Oostrum)
Organization: Dept of Computer Science, University of Utrecht, Holland
Lines: 250