Paste: justify
Author: | psiloveyou |
Mode: | postscript |
Date: | Sat, 16 Jun 2012 01:14:21 |
Plain Text |
/concat
{ exch dup length
2 index length add string
dup dup 4 2 roll copy length
4 -1 roll putinterval
} def
/concat! { exch dup load 3 -1 roll concat def } def
/pagenumber 0 def
/newpage {
pagenumber 0 gt { grestore showpage } if gsave
6 6 6 pop translate
/pagenumber 1 incr
/lineheight gridh def
/textwidth gridv 30 mul def
/textheight gridh 42 mul def
/posx gridh 5 mul def
/posy textheight gridv 4 mul add def
posx posy moveto
} def
/munchword { /TXTQ exch spacechar concat concat! } def
/resetbuf { /TXTQ () def } def
/resetspace { /SPACELEFT textwidth def } def
/resetline { resetbuf resetspace } def resetline
/eatspace { /SPACELEFT exch decr } def
/spaceleft? { SPACELEFT 0 gt } def
/newline { resetline /posy lineheight decr posx posy moveto } def
/putline { TXTQ
dup dup spacecount 1 sub
exch stringwidth pop
spacewidth sub
textwidth exch sub
exch div 0 spaceint
4 -1 roll widthshow newline
} def
/putlast { 0 0 spaceint TXTQ widthshow newline } def
/spacechar ( ) def
/spaceint 32 def
/spacewidth { spacechar stringwidth pop } def
/spacecount { 0 exch
{ dup spaceint eq { exch 1 add exch } if pop }
forall } def
/measure { dup stringwidth pop spacewidth add } def
/nextword { spacechar search } def
/justify {
{ nextword exch measure dup eatspace spaceleft? not
{ putline eatspace } { pop } ifelse
munchword { pop } { putlast exit } ifelse } loop
} def
New Annotation