summaryrefslogtreecommitdiff
path: root/sys/src/cmd/postscript/cropmarks
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/postscript/cropmarks
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/postscript/cropmarks')
-rwxr-xr-xsys/src/cmd/postscript/cropmarks/cropmarks.ps131
-rwxr-xr-xsys/src/cmd/postscript/cropmarks/cropmarks.rc74
-rwxr-xr-xsys/src/cmd/postscript/cropmarks/mkfile22
3 files changed, 227 insertions, 0 deletions
diff --git a/sys/src/cmd/postscript/cropmarks/cropmarks.ps b/sys/src/cmd/postscript/cropmarks/cropmarks.ps
new file mode 100755
index 000000000..256891a9a
--- /dev/null
+++ b/sys/src/cmd/postscript/cropmarks/cropmarks.ps
@@ -0,0 +1,131 @@
+%
+% Center pages, based on pageheight and pagewidth, and redefine showpage
+% to put cropmarks at each corner. Device dependent code to expand the
+% paper size goes in procedure expandpagesize. Currently only supports
+% a Linotronic 200P typesetter using 12 inch wide paper. You'll have to
+% add code to expandpagesize to support different typesetters or even a
+% 200P that's running differently.
+%
+
+/CropmarkDict 40 dict dup begin
+
+/expandpage true def
+/magnification 1 def
+/pageheight 11.0 def
+/pagewidth 8.5 def
+/scaletofit false def
+/scaling 1 def
+
+/marklength .3 def % inches
+/markstart .125 def % inches
+/markend .04 def % inches
+/marklinewidth .25 def % points
+
+/inch {72 mul} def
+/min {2 copy gt {exch} if pop} def
+/max {2 copy lt {exch} if pop} def
+
+/setup {
+ /markspace markstart marklength add markend add inch marklinewidth add def
+ /totalheight pageheight inch markspace 2 mul add def
+ /totalwidth pagewidth inch markspace 2 mul add def
+
+ pagedimensions
+ checkpagesize
+ /scaling getscaling def
+ xcenter ycenter translate
+ scaling scaling scale
+ pagewidth inch 2 div neg pageheight inch 2 div neg translate
+ clippage
+} def
+
+/pagedimensions {
+ clippath pathbbox newpath
+ 4 -1 roll exch 4 1 roll 4 copy
+ sub /width exch def
+ sub /height exch def
+ add 2 div /xcenter exch def
+ add 2 div /ycenter exch def
+} def
+
+/checkpagesize {
+ height totalheight lt width totalwidth lt or expandpage and {
+ expandpagesize
+ pagedimensions
+ } if
+} def
+
+/expandpagesize { % device dependent code
+ /Product statusdict begin /product where {pop product}{()} ifelse end def
+
+ Product (Linotype) eq { % Linotronic 200P and other models?
+ statusdict /setpageparams known {
+ /maxwidth 12.0 inch def % 12 inch wide paper?
+ totalheight maxwidth le {
+ totalheight
+ totalwidth
+ maxwidth totalheight sub 2 div
+ 0
+ }{
+ totalwidth maxwidth min
+ totalheight
+ maxwidth totalwidth maxwidth min sub 2 div
+ 1
+ } ifelse
+ statusdict /setpageparams get exec
+ } if
+ } if
+} def
+
+/getscaling {
+ scaletofit
+ {height totalheight div width totalwidth div min 1 min}
+ {1}
+ ifelse
+} def
+
+/clippage {
+ newpath
+ 0 0 moveto
+ pagewidth inch 0 rlineto
+ 0 pageheight inch rlineto
+ pagewidth neg inch 0 rlineto
+ closepath clip
+ newpath
+} def
+
+/cropmark {
+ gsave
+ translate
+ rotate
+ marklinewidth dup translate
+ 0 0 transform round exch round exch itransform translate
+ markstart inch 0 moveto marklength inch 0 rlineto stroke
+ 0 markstart inch moveto 0 marklength inch rlineto stroke
+ grestore
+} bind def
+
+/@PreviousShowpage /showpage load def
+
+end def
+
+%
+% Cropmarks - in the default coordinate system.
+%
+
+/showpage {
+ gsave
+ CropmarkDict begin
+ initgraphics
+ marklinewidth setlinewidth
+ xcenter ycenter translate
+ scaling scaling scale
+ 0 pagewidth inch 2 div pageheight inch 2 div cropmark
+ 90 pagewidth inch neg 2 div pageheight inch 2 div cropmark
+ 180 pagewidth inch neg 2 div pageheight inch 2 div neg cropmark
+ 270 pagewidth inch 2 div pageheight inch 2 div neg cropmark
+ @PreviousShowpage
+ end
+ grestore
+} bind def
+
diff --git a/sys/src/cmd/postscript/cropmarks/cropmarks.rc b/sys/src/cmd/postscript/cropmarks/cropmarks.rc
new file mode 100755
index 000000000..43ada5c69
--- /dev/null
+++ b/sys/src/cmd/postscript/cropmarks/cropmarks.rc
@@ -0,0 +1,74 @@
+#!/bin/rc
+# Center pages and put cropmarks at each corner. Physical page size
+# is set with -w and -h. The default is 8.5 by 11.0 inches. Device
+# dependent code to change paper size (e.g. with setpageparams) goes
+# in the prologue. You may need to customize the device dependent
+# code that we distribute. By default it only supports variable page
+# sizes on Linotronic typesetters, and assumes those typesetters are
+# using 12 inch wide paper. Use -d to disable execution of device
+# dependent PostScript code.
+#
+# What's here was written quickly and will likely be very different
+# in our next release. It should be part of a more general program!!
+#
+
+POSTLIB=/sys/lib/postscript/prologues
+PROLOGUE=$POSTLIB/cropmarks.ps
+
+EXPANDPAGE=true
+PAGEWIDTH=8.5
+PAGEHEIGHT=11.0
+SCALETOFIT=false
+XOFFSET=0.0
+YOFFSET=0.0
+
+NONCONFORMING=%!PS
+ENDPROLOG=%%EndProlog
+BEGINSETUP=%%BeginSetup
+ENDSETUP=%%EndSetup
+
+while (! ~ $#* 0 && ~ $1 -*) {
+ switch ($1) {
+ case -d; EXPANDPAGE=false
+
+ case -h; shift; PAGEHEIGHT=$1
+ case -h*; PAGEHEIGHT=`{echo $1 | sed s/-h//}
+
+ case -s; SCALETOFIT=true
+
+ case -w; shift; PAGEWIDTH=$1
+ case -w*; PAGEWIDTH=`{echo $1 | sed s/-w//}
+
+ case -x; shift; XOFFSET=$1
+ case -x*; XOFFSET=`{echo $1 | sed s/-x//}
+
+ case -y; shift; YOFFSET=$1
+ case -y*; YOFFSET=`{echo $1 | sed s/-y//}
+
+ case -L; shift; PROLOGUE=$1
+ case -L*; PROLOGUE=`{echo $1 | sed s/-L//}
+
+ case --;
+
+ case -*; echo '$0: illegal option $1' >[1=2]; exit 1
+
+ }
+ shift
+}
+
+echo $NONCONFORMING
+cat $PROLOGUE
+echo $ENDPROLOG
+echo $BEGINSETUP
+echo 'CropmarkDict begin'
+echo '/pageheight '$PAGEHEIGHT' def'
+echo '/pagewidth '$PAGEWIDTH' def'
+echo '/expandpage '$EXPANDPAGE' def'
+echo '/scaletofit '$SCALETOFIT' def'
+echo '/xoffset '$XOFFSET' def'
+echo '/yoffset '$YOFFSET' def'
+echo 'setup'
+echo 'end'
+echo $ENDSETUP
+
+cat $*
diff --git a/sys/src/cmd/postscript/cropmarks/mkfile b/sys/src/cmd/postscript/cropmarks/mkfile
new file mode 100755
index 000000000..ce9dbd4df
--- /dev/null
+++ b/sys/src/cmd/postscript/cropmarks/mkfile
@@ -0,0 +1,22 @@
+</$objtype/mkfile
+
+<../config
+
+all:V: cropmarks
+
+install:V: $POSTBIN/cropmarks $POSTLIB/cropmarks.ps
+
+installall:V: install
+
+$POSTLIB/cropmarks.ps: cropmarks.ps
+ cp $prereq $target
+
+$POSTBIN/cropmarks: cropmarks
+ cp $prereq $target
+
+cropmarks: cropmarks.rc
+ sed 's?^POSTLIB=.*?POSTLIB='$POSTLIB'?' cropmarks.rc >cropmarks
+ chmod 775 cropmarks
+
+clean nuke:V:
+ rm -f cropmarks