Paste: pslib
Author: | nlogax |
Mode: | postscript |
Date: | Mon, 18 Jun 2012 17:23:43 |
Plain Text |
/Courier findfont setfont
/dprint { { = } repeat } bind def
/dec! {
exch dup load 3 2 roll sub def
} bind def
/inc! {
exch dup load 3 2 roll add def
} bind def
/map {
mark 3 1 roll forall ] } bind def
/max { dup 2 index gt { exch } if pop } bind def
/min { dup 2 index lt { exch } if pop } bind def
/show- { currentpoint 3 2 roll show moveto } bind def
/gridx 15 def
/gridy 15 def
/gridlinethin { 0.1 setlinewidth 0.1 0.075 0 0 setcmykcolor } bind def
/gridlinethick { 0.5 setlinewidth 0.2 0.15 0 0 setcmykcolor } bind def
/gridshow {
gsave
1 setlinejoin
gridlinethick
newpath 0 0 moveto 0 pageheight rlineto pagewidth 0 rlineto 0 pageheight neg rlineto closepath stroke
0 setlinejoin
0 gridx pagewidth
{ dup dup gridx 4 mul mod 0 eq { gridlinethick } { gridlinethin }
ifelse 0 moveto pageheight lineto stroke } for
0 gridy pageheight
{ dup dup gridy 4 mul mod 0 eq { gridlinethick } { gridlinethin }
ifelse 0 exch moveto pagewidth exch lineto stroke } for
grestore
} bind def
/pageheight gridx 52 mul def
/pagewidth gridx 40 mul def
/concat { exch dup length
2 index length add string
dup dup 4 2 roll copy length
4 -1 roll putinterval
} bind def
/concat! { exch dup load 3 -1 roll concat def } bind def
/excif { dup currentdict exch known
{ load exec } { pop } ifelse } bind def
/PAGENUM 0 def
/newpage {
/on:newpage excif
/PAGENUM 1 inc!
PAGENUM 1 gt { grestore showpage } if
gsave
6 6 6 pop translate
/lineheight gridx def
/textwidth gridy 26 mul def
/textheight gridx 38 mul def
/pagebottom gridy 7 mul def
/posx gridx 7 mul def
/posy textheight gridy 6 mul add def
posx posy moveto
resetline
} bind def
/lastpage { /on:newpage excif grestore showpage } bind def
/on:newpage {
pageheader
pagefooter
} bind def
/pageheader { gsave grestore } bind def
/pagefooter { gsave (BOOBS) =
20 gridx mul
3 gridy mul
PAGENUM 10 string cvs
dup stringwidth pop 2 div
4 -1 roll exch sub
3 2 roll moveto show
grestore
} bind def
/begin:doc { (begin:doc!) 1 dprint newpage } bind def
/end:doc { (end:doc!) 1 dprint lastpage } bind def
/autopage { posy pagebottom lt { (autopage!) 1 dprint newpage } if } bind def
/munchword { /LINE exch spacechar concat concat! } bind def
/resetbuf { /LINE () def } bind def
/resetspace { /SPACELEFT textwidth def } bind def
/resetline { resetbuf resetspace } bind def
/eatspace { /SPACELEFT exch dec! } bind def
/spaceleft? { SPACELEFT 0 gt } bind def
/newline { resetline /posy lineheight dec! autopage posx posy moveto } bind def
/putlinefj { LINE
dup dup spacecount 1 sub
exch stringwidth pop
spacewidth sub
textwidth exch sub
exch div 0 spaceint
4 -1 roll widthshow newline
} bind def
/putlast {
LINE stringwidth pop
textwidth lineheight sub ge
{ putline }
{ 0 0 spaceint LINE widthshow newline }
ifelse
} bind def
/spacechar ( ) def
/spaceint 32 def
/spacewidth { spacechar stringwidth pop } bind def
/spacecount { 0 exch
{ dup spaceint eq { exch 1 add exch } if pop }
forall } bind def
/measure { dup stringwidth pop spacewidth add } bind def
/nextword { spacechar search } bind def
/justify {
{ nextword exch measure dup eatspace spaceleft? not
{ putline eatspace } { pop } ifelse
munchword { pop } { putlast exit } ifelse } loop
} bind def
/putline /putlinefj load def
/mfont {
[ 3 1 roll /exch cvx /findfont cvx
/exch cvx /scalefont cvx /setfont cvx ]
cvx bind def
} bind def
/H1 { font-H1 justify newline } bind def
/P { font-P justify newline } bind def
/P- { font-P justify } bind def
/BR { newline } bind def
/glyphwidth { gsave nulldevice 0 0 moveto glyphshow currentpoint grestore } bind def
/begin:math { } bind def
/end:math { newline } bind def
/mvar { font-math-i show font-math } bind def
/mvar- { font-math-i show- font-math } bind def
/mcentr { 2 div exch stringwidth pop 2 div sub 0 rmoveto } bind def
/mfrac {
gsave
font-math
0 gridy neg 2 div rmoveto
dup stringwidth pop exch
mvar- exch
0.8315 setlinewidth
0 gridy rmoveto
dup stringwidth pop exch
mvar-
0 gridy neg 3 div rmoveto
max 0 rlineto stroke
grestore
} bind def
/begin:eps {
/pre-eps-state save def
/dictc countdictstack def
/op_count count 1 sub def
userdict begin
/showpage { } bind def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [ ] 0 setdash newpath
/languagelevel where
{ pop languagelevel
1 ne { false setstrokeadjust false setoverprint } if
} if
} bind def
/end:eps {
count op_count sub { pop } repeat
countdictstack dictc sub { end } repeat
pre-eps-state restore
} bind def
/newlines { /newline load repeat } bind def
/font-H1 /Helvetica-Bold 18 mfont
/font-P /Georgia 12 mfont
begin:doc
gridshow
(Look, a heading!) H1
(A paragraph with some lorem ipsum dolor sit amet, consectetur adipisicing elit, \
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip.) P
(It occurs to me that this example document should be a tutorial that prints itself.) P
(Not much else to show, I guess. I'll draw a grid and add some more stuff so that another page is created.) P
BR BR BR BR BR
(Weeeeee.) P
BR BR BR BR BR
(Stuff.) P
(Stuff.) P
(Stuff.) P
(Stuff.) P
(Stuff.) P
(Stuff.) P
(Stuff.) P
(Is there another page now?) H1
(It would appear so! The automagic should have added a page number now, as well.) P
end:doc
New Annotation