PostScript 2008 7 17 Copyright c 2000 2008 Daikoku Manabu This tutorial is licensed under a Creative Commons Attribution 2.1 Japan License. 1 PostScript 5 1.1 PostScript.................................. 5 1.1.1................................ 5 1.1.2............................. 5 1.1.3 PostScript............................... 5 1.1.4................................. 5 1.2 Ghostscript................................. 6 1.2.1 Ghostscript.......................... 6 1.2.2 Ghostscript............................. 6 1.2.3................................. 6 1.2.4...................................... 6 1.2.5............................ 7 1.2.6.................. 7 1.2.7............................. 7 1.2.8...................... 8 1.3...................................... 8 1.3.1....................... 8 1.3.2.................................... 8 1.3.3...................................... 8 1.3.4.................................... 9 1.4........................................ 9 1.4.1............................... 9 1.4.2........................ 9 1.4.3................................. 10 1.4.4............................ 10 1.4.5............................... 10 1.4.6.................. 10 1.4.7.................................. 11 1.4.8............................... 11 1.4.9............................... 11 2 PostScript 12 2.1.......................................... 12 2.1.1............................. 12 2.1.2................................ 12 2.1.3........................... 12 2.1.4............................... 13 2.2.......................................... 14 2.2.1.................................. 14 2.2.2................................. 14 2.2.3..................... 14 2.2.4...................................... 14 2.3......................................... 15
2 2.3.1................................. 15 2.3.2............................... 15 2.3.3................................. 15 2.3.4............................ 15 2.3.5........................... 16 2.3.6..................... 16 2.3.7............................ 16 2.4.......................... 18 2.4.1............................. 18 2.4.2............................. 18 2.4.3............................ 18 2.4.4............................. 18 2.4.5............................. 19 2.4.6....................... 19 2.4.7..................................... 20 2.5......................................... 20 2.5.1............................ 20 2.5.2................................. 20 2.5.3................................. 20 2.5.4................................. 21 2.5.5........................ 21 2.5.6.......................... 21 2.6.......................................... 22 2.6.1................................. 22 2.6.2................................. 22 2.6.3............................. 22 2.6.4................................. 23 2.6.5............................... 23 2.6.6.......................... 24 2.7.......................................... 24 2.7.1..................................... 24 2.7.2...................................... 25 2.7.3............................... 25 2.7.4............................... 25 2.7.5............................... 26 2.7.6.................................. 26 2.8.......................................... 27 2.8.1................................. 27 2.8.2............................. 28 2.8.3.................................... 29 2.9........................................ 30 2.9.1........................... 30 2.9.2............................. 30 2.9.3........................... 30 2.9.4............................. 31 2.9.5....................... 32 2.10.......................................... 32 2.10.1................................. 32 2.10.2...................................... 33 2.10.3............................ 33 2.10.4...................................... 33 2.10.5............................... 34 2.11...................................... 34 2.11.1............................. 34 2.11.2................................. 35
3 2.11.3............................. 35 2.11.4.................................. 35 2.11.5............................. 36 2.12.......................................... 37 2.12.1.................................. 37 2.12.2.................................. 37 2.12.3............................. 37 2.12.4............................... 38 2.13........................................ 40 2.13.1............................ 40 2.13.2............................. 40 2.13.3................................. 41 2.13.4............................. 41 2.13.5........................... 41 2.13.6............................ 42 2.13.7.................................. 43 2.13.8..................... 43 2.13.9....................... 43 3 PostScript 44 3.1.............................. 44 3.1.1................................ 44 3.1.2............................. 44 3.1.3................................ 44 3.1.4..................................... 44 3.1.5............................. 44 3.1.6.................................... 45 3.2.......................................... 45 3.2.1................................. 45 3.2.2............................... 45 3.2.3........................... 46 3.2.4.................................... 46 3.2.5...................................... 46 3.2.6....................... 46 3.3.......................................... 47 3.3.1........................ 47 3.3.2....................... 47 3.3.3...................................... 48 3.3.4...................... 48 3.3.5.................................. 49 3.3.6............................. 49 3.4........................................... 50 3.4.1.................................... 50 3.4.2.................................... 50 3.4.3.................................... 51 3.4.4................................. 52 3.5........................................ 53 3.5.1................................ 53 3.5.2.................................. 53 3.5.3................................. 53 3.5.4............................... 54 3.5.5.......................... 55 3.5.6.......................... 56 3.6.......................................... 56 3.6.1.................................. 56
4 3.6.2............................ 57 3.6.3........................... 57 3.6.4............................ 57 3.7...................................... 58 3.7.1............................... 58 3.7.2..................... 58 3.7.3............................... 59 3.8..................................... 59 3.8.1.................................... 59 3.8.2............................. 60 3.8.3............................. 60 3.8.4............. 60 3.8.5........................ 61 3.8.6...................... 61 3.8.7.................................. 61 3.8.8.................................. 62 3.8.9............................... 62 3.8.10............................... 63 3.8.11................................. 63 3.8.12................................. 64 3.9..................................... 65 3.9.1............................. 65 3.9.2...................................... 65 3.9.3...................................... 65 3.9.4...................................... 66 3.10..................................... 67 3.10.1............................ 67 3.10.2............................... 67 3.11.............................. 68 3.11.1................. 68 3.11.2........................ 68 3.11.3................................. 69 3.12 DSC.......................................... 70 3.12.1 DSC................................. 70 3.12.2 DSC................................. 70 3.12.3 DSC............................. 70 3.12.4 DSC................... 70 3.12.5....................... 70 3.13 EPS.......................................... 72 3.13.1 EPS................................. 72 3.13.2 EPS................................. 72 3.13.3...................... 72 73 74
5 1 PostScript 1.1 PostScript 1.1.1 PostScript PostScript PostScript (page description language) LIPS (NEC) NPDL ESC/Page PRE- SCRIBE Hewlett-Packard Company HP PCL PostScript Adobe Systems Incorporated 1.1.2 (program) (programming language) Pascal C Java Scheme ML Erlang Smalltalk Ruby Prolog 1.1.3 PostScript PostScript PostScript PostScript 1.1.4 (machine language) (language processor) (compiler) (interpreter) PostScript PostScript PostScript (PostScript printer) PostScript PostScript PostScript Ghostscript PostScript PostScript PostScript
6 1 PostScript 1.2 Ghostscript 1.2.1 Ghostscript Ghostscript Ghostscript 1 Windows gswin32 Linux gs Ghostscript GS> PostScript Ghostscript Ghostscript Ghostscript quit 1.2.2 Ghostscript Ghostscript (1) (2) (3) PostScript Ghostscript 1.2.3 Ghostscript PostScript == == 437 == Ghostscript GS>437 == 437 GS>_ 437 1.2.4 Ghostscript PostScript add sub mul div 1 Windows (cmd.exe) Linux bash
1.2. Ghostscript 7 == == 5 3 add == 5 3 Ghostscript GS>5 3 add == 8 GS>_ 8 1.2.5 Ghostscript sample.ps sample.ps 437 == 2 437 1 PostScript PostScript PostScript.ps 1.2.6 PostScript ( ) run PostScript sample.ps Ghostscript (sample.ps) run GS>(sample.ps) run 437 GS>_ 437 1.2.7 Ghostscript (image window) PostScript Ghostscript newpath 100 100 moveto 500 700 lineto stroke showpage
8 1 PostScript Ghostscript sample2.ps Ghostscript sample2.ps newpath 100 100 moveto 500 700 lineto stroke showpage 1.2.8 GSview GSview Ghostscript GSview sample2.ps GSview 1.3 1.3.1 PostScript (space) (null character) (tab) (line feed) (carriage return) (form feed) (whitespace) ({ }) ( [ ] ) (separator) 1.3.2 PostScript (token) 5 3 add == 5 3 add == 4 1 5 3 add == 5 3 add == 1.3.3 (comment)
1.4. 9 PostScript ( % ) 5 3 add == % I am a comment. I am a comment. (comment out) 1.3.4 PostScript 5 3 5 3 add (postfix notation) (reverse Polish notation) add 5 3 (prefix notation) (Polish notation) 5 add 3 (infix notation) 1.4 1.4.1 PostScript (stack) (push) (pop) (last in, first out) (first in, last out) PostScript (operand stack) 1.4.2 1.3 PostScript
10 1 PostScript 1.4.3 PostScript (object) (executable object) (literal object) 437 1.4.4 PostScript PostScript (operator) 1.2 == add PostScript (procedure) 1.4.5 PostScript PostScript PostScript 437 == PostScript 437 == 1 == 437 1.4.6 Ghostscript 1 602 118 599 380 Ghostscript GS>602 118 599 380 GS<4>_ 4 == GS<4>== 380 GS<3>_
1.4. 11 1 1.4.7 1.2 add sub mul div 2 5 3 add Ghostscript GS>5 3 add GS<1>_ 1 == GS<1>== 8 GS>_ 1.4.8 PostScript 5 3 7 5 3 add 7 mul (1) 5 (2) 3 (3) add 3 5 5 3 (8) (4) 7 (5) mul 7 8 8 7 (56) 100 5 9 100 5 9 mul sub (1) 100 (2) 5 (3) 9 (4) mul 9 5 5 9 (45) (5) sub 45 100 100 45 (55) 1.4.9 0 0 (operand)
12 2 PostScript (result) operand 1 operand 2 operand n name result 1 result 2 result n operand 1 operand 2 operand n operand n name result 1 result 2 result n result n add num 1 num 2 add sum 0 ( ) rand 0 rand int == 0 any == clear any 1 any n clear 2 PostScript 2.1 2.1.1 (number) PostScript (integer) (floating point number) 1 2.1.2 0 9 10 437 437 ( - ) -56 56 2 8 16 10 # 2#11111111 8#377 16#ff 255 10 2.1.3
2.1. 13 0.003 41.56 723.0 0 9 (. ) 1 10 ( - ) -8.317 8.317 a e b a 10 b -3.71e-24 3.71 10 24 2.1.4 (arithmetic exec) num 1 num 2 add sum num 1 num 2 num 1 num 2 sub difference num 1 num 2 num 1 num 2 mul mul num 1 num 2 num 1 num 2 div quotient num 1 num 2 int 1 int 2 idiv quotient int 1 int 2 int 1 int 2 mod remainder int 1 int 2 num 1 abs num 2 num 1 num 1 neg num 2 num 1 num 1 ceiling num 2 num 1 num 1 floor num 2 num 1 num 1 round num 2 num 1 num 1 truncate num 2 num 1 ceiling floor round trancate 0 3.7 ceiling 4.0 num sqrt real num angle sin real angle angle cos real angle num den atan angle num/den num/den sin cos atan (degree)
14 2 PostScript base exponent exp real base exponent base exponent num ln real num e = 2.718281 num num log real num 10 num rand int 0 2 31 1 int srand int rrand int srand 2.2 2.2.1 (name) == add sub (bind) PostScript 2.2.2 namako uso800 300daigen uni@tako $827 300daigen $827 3e8 / ( ) < > { } [ ] namako Namako NAMAKO 2.2.3 PostScript ( / ) namako /namako GS>/namako == /namako 2.2.4 def name any name any def
2.3. 15 def name any /namako 718 def namako 718 GS>/namako 718 def GS>namako == 718 def 2.3 GS>/umiushi 100 def GS>umiushi == 100 GS>/umiushi 200 def GS>umiushi == 200 GS>/umiushi umiushi 40 add def GS>umiushi == 240 2.3.1 (string) PostScript (length) namako 6 0 (empty string) 2.3.2 namako (namako) (a(b)c) a(b)c () 2.3.3 == GS>(namako) == (namako) == = = GS>(namako) = namako 2.3.4 (escape sequence)
16 2 PostScript ( \ ) 1 1 \t (tab) \n (line feed) \r (carriage return) \f (form feed) \b (backspace) \( \) \\ (backslash) \ddd 1 3 8 ddd = GS>(123\n456) = 123 456 GS>(abc\(def) = abc(def GS>(\141\142\143) = abc 2.3.5 GS>(abc\ def) = abcdef 2.3.6 16 16 ( < ) ( > ) <616263> abc 16 GS><616263> = abc GS><6d 6e 6f> = mno 2.3.7 int string string 0 int GS>5 string == (\000\000\000\000\000) string length int string 1 ( Y= )
2.3. 17 GS>(interdisciplinary) length == 17 string index get int string index 0 GS>(abcdefg) 2 get == 99 string index int put string index int GS>/s (abcdefg) def GS>s 3 42 put GS>s == (abc*efg) string index count getinterval substring string index count GS>(abcdefghijk) 3 4 getinterval == (defg) string 1 index string 2 putinterval string 1 index string 2 GS>/s (abcdefghijk) def GS>s 3 (WXYZ) putinterval GS>s == (abcwxyzhijk) string cvi int string GS>(437) cvi == 437 string cvr real string GS>(3.14) cvr == 3.14 string cvn name string GS>(namako) cvn == /namako any string cvs substring any string string GS>437 10 string cvs == (437) num radix string cvrs substring radix num string string GS>4095 16 10 string cvrs == (FFF)
18 2 PostScript 2.4 2.4.1 0 1 2 3 0 2.4.2 any 1 any n pstack any 1 any n == GS>(namako) 537 801 GS<3>pstack 801 537 (namako) GS<3> any 1 any n stack any 1 any n = GS>(namako) 537 801 GS<3>stack 801 537 namako GS<3> 2.4.3 any pop GS>385 273 GS<2>pop GS<1>pstack 385 any 1 any n clear GS>518 237 661 493 504 783 GS<6>clear GS> 2.4.4 any 1 any n count any 1 any n n GS>311 427 503 664 272 987 GS<6>count == 6 GS<6>
2.4. 19 2.4.5 any dup any any GS>398 dup GS<2>pstack 398 398 any n any 0 n index any n any 0 any n n n GS>(a) (b) (c) 2 index GS<4>pstack (a) (c) (b) (a) any n 1 any 0 n copy any n 1 any 0 any n 1 any 0 n n 1 GS>(a) (b) (c) 3 copy GS<6>pstack (c) (b) (a) (c) (b) (a) 2.4.6 any 1 any 2 exch any 2 any 1 0 1 GS>(a) (b) (c) exch GS<3>pstack (b) (c) (a) any n 1 any 0 n j roll any (j 1) mod n any 0 any n 1 any j mod n j n any n 1 any 0 j j j GS>(a) (b) (c) (d) (e) 4 3 roll GS<5>pstack (b) (e) (d) (c) (a) GS<5>clear GS>(a) (b) (c) (d) (e) 4-3 roll GS<5>pstack (d) (c) (b) (e) (a)
20 2 PostScript 2.4.7 PostScript (mark) mark mark GS>mark == -markmark any 1 any n counttomark mark any 1 any n n GS>358 mark 364 283 540 881 GS<6>counttomark == 4 mark any 1 any n cleartomark GS>711 mark 133 975 468 202 GS<6>cleartomark GS<1>pstack 711 2.5 2.5.1 1.4 PostScript (object) (executable object) (literal object) (operator) (procedure) PostScript 2.5.2 (executable array) 0 ({ }) { 437 == } PostScript GS>{ 437 == } == {437 ==} 2.5.3
2.5. 21 exec exec GS>{ 437 == } exec 437 GS>{ 5 3 add == } exec 8 2.5.4 (define) (definition) /nanasen { 7000 == nanasen 2.5.5 GS>/nanasen { 7000 == GS>nanasen 7000 run hello.ps /hello { (Hello, world!) = GS>(hello.ps) run GS>hello Hello, world! 2.5.6 /sanbai { 3 mul sanbai 1 3 GS>/sanbai { 3 mul GS>5 sanbai == 15 GS>7 sanbai == 21 num square square num 2 square.ps /square { dup mul GS>(square.ps) run GS>7 square == 49
22 2 PostScript GS>0.5 square == 0.25 int sum sum 1 int sum.ps /sum { dup 1 add mul 2 idiv GS>(sum.ps) run GS>10 sum == 55 string lastchar int string lastchar.ps /lastchar { dup length 1 sub get GS>(lastchar.ps) run GS>(abcdefg) lastchar == 103 2.6 2.6.1 2.2 (bind) (dictionary) (key) (value) 2.6.2 PostScript (dictionary stack) systemdict (current dictionary) userdict 2.6.3 def 2.2
2.6. 23 key value def key value key value 2.6.4 PostScript int dict dict int (capacity) dict begin dict GS>/namako (sea cucumber) def GS>namako == (sea cucumber) GS>1 dict begin GS>/namako 4998 def GS>namako == 4998 GS> GS>namako == (sea cucumber) 2.6.5 int itos string int itos.ps /itos { 1 dict begin /s 1 string def s 0 3-1 roll put s GS>(itos.ps) run
24 2 PostScript GS>/s (umiushi) def GS>97 itos == (a) GS>s == (umiushi) 2.6.6 def exch namako /namako exch def exch hour minute 1 hmtom minute 2 hour minute 1 hmtom.ps /hmtom { 2 dict begin /minute exch def /hour exch def hour 60 mul minute add GS>(hmtom.ps) run GS>2 30 hmtom == 150 2.7 2.7.1 100 (condition) (true) (false) 100 107 94 (Boolean value) PostScript systemdict true false GS>true == true GS>false == false
2.7. 25 2.7.2 (predicate) PostScript (relational operator) (logical operator) (equality operator) (comparison operator) 2.7.3 (equality operator) any 1 any 2 eq bool (equal) any 1 any 2 GS>5 5 eq == true GS>5 8 eq == false any 1 any 2 ne bool (not equal) any 1 any 2 GS>(abc) (abc) ne == false GS>(abc) (abd) ne == true 2.7.4 (comparison operator) num 1 num 2 gt bool (greater than) num 1 num 2 num 1 num 2 lt bool (less than) num 1 num 2 num 1 num 2 ge bool (greater equal) num 1 num 2 num 1 num 2 le bool (less equal) num 1 num 2 GS>5 3 gt == true GS>5 5 gt == false GS>5 8 gt == false GS>5 3 ge == true GS>5 5 ge == true GS>5 8 ge == false (lexicographical order)
26 2 PostScript GS>(abc) (abd) lt == true GS>(abc) (abcd) lt == true 2.7.5 (logical operator) bool 1 bool 2 and bool 3 (conjunction) bool 1 bool 2 GS>true true and == true GS>true false and == false GS>false true and == false GS>false false and == false bool 1 bool 2 or bool 3 (disjunction) bool 1 bool 2 GS>true true or == true GS>true false or == true GS>false true or == true GS>false false or == false bool 1 bool 2 xor bool 3 (exclusive disjunction) bool 1 bool 2 GS>true true xor == false GS>true false xor == true GS>false true xor == true GS>false false xor == false bool 1 not bool 2 (negation) bool 1 GS>true not == false GS>false not == true 2.7.6 PostScript
2.8. 27 int even bool int even.ps /even { 2 mod 0 eq GS>(even.ps) run GS>6 even == true GS>7 even == false string 1 string 2 samelen bool string 1 string 2 samelen.ps /samelen { 2 dict begin /string2 exch def /string1 exch def string1 length string2 length eq GS>(samelen.ps) run GS>(namako) (hitode) samelen == true GS>(namako) (umiushi) samelen == false any 1 any 2 any 3 triple bool any 1 any 2 any 3 triple.ps /triple { 3 dict begin /any3 exch def /any2 exch def /any1 exch def any1 any2 eq any1 any3 eq and GS>(a) (a) (a) triple == true GS>(a) (a) (b) triple == false 2.8 2.8.1 (selection)
28 2 PostScript 2.8.2 PostScript ifelse if bool proc 1 proc 2 ifelse bool proc 1 proc 2 GS>true { (It s true.) = } { (It s false.) = } ifelse It s true. GS>false { (It s true.) = } { (It s false.) = } ifelse It s false. bool proc if bool proc GS>true { (It s true.) = } if It s true. GS>false { (It s true.) = } if GS>_ num zero string num zero not zero zero.ps /zero { 0 eq { (zero) } { (not zero) } ifelse GS>(zero.ps) run GS>0 zero == (zero) GS>5 zero == (not zero) int evenodd string int even odd evenodd.ps /even { 2 mod 0 eq /evenodd { even { (even) } { (odd) } ifelse GS>(evenodd.ps) run GS>6 evenodd == (even) GS>7 evenodd == (odd) any pornot pornot.ps /empty { count 0 eq /pornot { empty not { == } if
2.8. 29 GS>(pornot.ps) run GS>(abc) pornot (abc) GS>pornot GS>_ 2.8.3 3 (multibranch selection) ifelse ifelse bool 1 proc 1 { bool 2 proc 2 { { bool n proc n proc n+1 ifelse }... } ifelse } ifelse bool 1 bool 2... proc n+1 GS>false { 1 } { false { 2 } { true { 3 } { 4 } ifelse } ifelse } ifelse == 3 num sign string num plus minus zero sign.ps /sign { 1 dict begin /num exch def num 0 gt { (plus) } { num 0 lt { (minus) } { (zero) } ifelse } ifelse GS>(sign.ps) run GS>5 sign == (plus) GS>-5 sign == (minus) GS>0 sign == (zero)
30 2 PostScript 2.9 2.9.1 (iteration) PostScript repeat for loop forall 2.9.2 repeat int proc repeat int proc GS>5 { (namako) = } repeat namako namako namako namako namako num int power power num int num int (num int ) power.ps /power { 3 dict begin /int exch def /num exch def /p 1 def int { /p p num mul def } repeat p GS>(power.ps) run GS>3 4 power == 81 2.9.3 for (control variable) 1 (value) initial increment limit proc for initial increment limit proc initial (1) (2) (3) proc (4) increment increment increment limit limit
2.9. 31 GS>1000 30 1100 { == } for 1000 1030 1060 1090 GS>1100-30 1000 { == } for 1100 1070 1040 1010 int alldivisors int divisor.ps /divisor { mod 0 eq /alldivisors { 2 dict begin /int exch def 1 1 int { /i exch def int i divisor { i == } if } for GS>(divisor.ps) run GS>7171 alldivisors 1 71 101 7171 2.9.4 loop exit proc loop proc exit repeat for loop GS>(a) (b) (c) { count 0 eq { exit } if == } loop (c) (b) (a) n m gcm gcm n m (greatest common measure, GCM) (Euclidean algorithm) 1 n m 2 m 0 3 n m r 4 m n 5 r m 6 2 n
32 2 PostScript gcm.ps /gcm { 3 dict begin /m exch def /n exch def { m 0 eq { exit } if /r n m mod def /n m def /m r def } loop n GS>(gcm.ps) run GS>54 36 gcm == 18 2.9.5 forall string proc forall string proc GS>(abc) { == } forall 97 98 99 s c countc n s c countc.ps /countc { 3 dict begin /c exch def /s exch def /n 0 def s { c eq { /n n 1 add def } if } forall n GS>(countc.ps) run GS>(namamuginamagomenamatamago) (m) 0 get countc == 6 2.10 2.10.1 (recursion)
2.10. 33 (recursive) (recursive structure) (recursive definition) B A B A C A B C B A 2.10.2 (basis) B A B A 2.10.3 2.10.4 n n 1 n (n 1) (n 2)... 1 n (factorial) n! 0! 1 5! 5 4 3 2 1 120 n! { 0! = 1 n 1 n! = n (n 1)! n fact fact n fact.ps
34 2 PostScript /fact { 1 dict begin /n exch def n 0 eq { 1 } { n 1 ge { n n 1 sub fact mul } { (undefined) } ifelse } ifelse GS>(fact.ps) run GS>5 fact == 120 2.10.5 (Fibonacci sequence) n n (F n ) F 0 = 0 F 1 = 1 n 2 F n = F n 2 + F n 1 7 5 6 n fibona fibona n n fibona.rb /fibona { 1 dict begin /n exch def n 0 eq { 0 } { n 1 eq { 1 } { n 2 ge { n 2 sub fibona n 1 sub fibona add } { (undefined) } ifelse } ifelse } ifelse GS>(fibona.ps) run GS>20 fibona == 6765 2.11 2.11.1 (higher-order procedure) exec ifelse if repeat for loop forall (higher-order operator)
2.11. 35 2.11.2 exec ifelse proc twice proc twice.ps /twice { 1 dict begin /proc exch def proc proc GS>(twice.ps) run GS>{ (tanpopo) == } twice (tanpopo) (tanpopo) GS>5 40 300 { add } twice == 345 2.11.3 PostScript load key load value key GS>/square { dup mul GS>/square load == {dup mul} 2.11.4 (summation of sequence) n f sum sum n 1 f 1 1 1 2... n f n f(i) = f(1) + f(2) + + f(n) i=1
36 2 PostScript 10 { } sum 10 { dup mul } sum 10 { dup dup mul mul } sum 10 i=1 10 i=1 10 i=1 sum.ps /sum { 2 dict begin /f exch def /n exch def n 1 eq { 1 f } { n 2 ge { n f n 1 sub /f load sum add } { (undefined) } ifelse } ifelse GS>(sum.ps) run GS>10 { } sum == 55 GS>10 { dup mul } sum == 385 GS>10 { dup dup mul mul } sum == 3025 i = 1 + 2 + + 10 55 i 2 = 1 2 + 2 2 + + 10 2 385 i 3 = 1 3 + 2 3 + + 10 3 3025 2.11.5 (map) s 1 f maps s 2 s 1 f 1 1 s 1 f maps.ps /maps { 6 dict begin /f exch def /s1 exch def /n s1 length def /s2 n string def 0 1 n 1 sub { /i exch def /e s1 i get def s2 i e f put } for s2
2.12. 37 GS>(maps.ps) run GS>(tsuyukusa) { 32 sub } maps == (TSUYUKUSA) GS>(password) { pop 42 } maps == (********) 2.12 2.12.1 PostScript (array) 1 (element) (length) 0 (empty array) 2.12.2 ( [ ) ( ] ) [ mark 2.4 mark mark any 1 any n ] array any 1 any n GS>[ 367 28.4 (nazuna) true ] == [367 28.4 (nazuna) true] GS>[ 5 3 add 10 mul 70 33 11 idiv sub ] == [80 67] GS>[ 21 [ 53 74 ] [ 60 [ 53 48 ] 99 ] 18 ] == [21 [53 74] [60 [53 48] 99] 18] GS>[ ] == [] 2.12.3 int array array int (null object) GS>5 array == [null null null null null] array length int array GS>[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ] length == 17 array index get int array index 0 GS>[ (a) (b) (c) (d) (e) ] 2 get == (c) array index any put
38 2 PostScript array index any GS>/a [ (a) (b) (c) (d) (e) ] def GS>a 3 (*) put GS>a == [(a) (b) (c) (*) (e)] array index count getinterval subarray array index count GS>[ (a) (b) (c) (d) (e) (f) (g) ] 2 4 getinterval == [(c) (d) (e) (f)] array 1 index array 2 putinterval array 1 index array 2 GS>/a [ (a) (b) (c) (d) (e) (f) (g) ] def GS>a 2 [ (X) (Y) (Z) ] putinterval GS>a == [(a) (b) (X) (Y) (Z) (f) (g)] any 0 any n 1 array astore array array array array any i i array GS>(a) (b) (c) 3 array astore == [(a) (b) (c)] array aload any 0 any n 1 array array array array GS>[ (a) (b) (c) ] aload GS<4>pstack [(a) (b) (c)] (c) (b) (a) array proc forall array proc GS>[ (a) (b) (c) ] { == } forall (a) (b) (c) 2.12.4 a suma sum a suma.ps /suma { 2 dict begin /a exch def /sum 0 def a { /sum exch sum add def } forall sum
2.12. 39 GS>(suma.ps) run GS>[ 8000 700 60 5 ] suma == 8765 a 1 reverse a 2 a 1 reverse.ps /reverse { 5 dict begin /a1 exch def /n a1 length def /a2 n array def 0 1 n 1 sub { /i exch def /e a1 i get def a2 n i sub 1 sub e put } for a2 GS>(reverse.ps) run GS>[ (a) (b) (c) (d) (e) ] reverse == [(e) (d) (c) (b) (a)] n f arrayf array n f 1 1 0 1 2... n 1 f arrayf.ps /arrayf { 4 dict begin /f exch def /n exch def /a n array def 0 1 n 1 sub { /i exch def a i i f put } for a GS>(arrayf.ps) run GS>16 { dup mul } arrayf == [0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225] GS>10 { 100 exch sub } arrayf == [100 99 98 97 96 95 94 93 92 91] GS>8 { 2 mod 0 eq } arrayf == [true false true false true false true false] a 1 f mapa a 2 a 1 f 1 1 a 1 f
40 2 PostScript mapa.ps /mapa { 6 dict begin /f exch def /a1 exch def /n a1 length def /a2 n array def 0 1 n 1 sub { /i exch def /e a1 i get def a2 i e f put } for a2 GS>(mapa.ps) run GS>[ 38 27 64 55 43 91 ] { 10 mul } mapa == [380 270 640 550 430 910] GS>[ true false false true ] { { 1 } { 0 } ifelse } mapa == [1 0 0 1] GS>[ (sakura) (ume) (mokuren) (momo) ] { length } mapa == [6 3 7 4] 2.13 2.13.1 (file object) 2.13.2 (open) file pathname access file file access pathname (access string) r w a r+ w+ a+
2.13. 41 /in (asagao.txt) (r) file def asagao.txt in 2.13.3 (read/write position) r r+ w w+ a a+ ( of file) 2.13.4 (close) closefile file closefile file 2.13.5 file read int true file read false file 1 file string readline substring bool file 1 string string file string readstring substring bool file string string string string file token any true file token false file 1
42 2 PostScript file int write file int file string writestring file string 2.13.6 pathname cat pathname cat.ps /cat { 3 dict begin /pathname exch def /in pathname (r) file def /s 256 string def { in s readline not { pop exit } if = } loop in closefile animal.txt armadillo kangaroo orangutan GS>(cat.ps) run GS>(animal.txt) cat armadillo kangaroo orangutan pathname 1 pathname 2 copy pathname 1 pathname 2 pathname 2 copy.ps /copy { 4 dict begin /pathname2 exch def /pathname1 exch def /in pathname1 (r) file def /out pathname2 (w) file def { in read not { exit } if out exch write } loop in closefile out closefile
2.13. 43 GS>(copy.ps) run GS>(animal.txt) (animal2.txt) copy 2.13.7 (standard IO) (standard input) (standard output) (standard error) (redirect) (redirection) == = pstack print string print string == = print print GS>(warabi) print warabigs>(warabi\n) print warabi GS>_ 2.13.8 PostSctipt PostScript %stdin %stdout %stderr file /in (%stdin) (r) file def in GS>(copy.ps) run GS>(animal.txt) (%stdout) copy armadillo kangaroo orangutan 2.13.9 pathname deletefile
44 3 PostScript pathname pathname 1 pathname 2 renamefile pathname 1 pathname 2 3 PostScript 3.1 3.1.1 PostScript PostScript 3.1.2 (graphics state) (graphics state stack) (current graphics state) 3.1.3 PostScript (current page) PostScript PostScript showpage showpage 3.1.4 (coordinate system) (axis) (origin) 2 2 x (x axis) y (y axis) (coordinate) 2 x x y y (x, y) x x (x coordinate) y y (y coordinate) 3.1.5
3.2. 45 x y (default coordinate system) x y x y 72 1 3.1.6 72 1 1 72 1 PostScript 72 1 (point) 1 = 72 1 = 0.352778 PostScript (Didot point) (Anglo-American point) 1 = 0.3759 1 = 0.3514 PostScript PostScript (PostScript point) DTP (DTP point) (computer point) 1 2.834646 /mm { 2.834646 mul 7 mm 7 3.2 3.2.1 (path) (current path) (construct) (path construction operator) newpath newpath 3.2.2
46 3 PostScript (pen location) (current point) moveto rmoveto moveto rmoveto absolute relative moveto rmoveto x y moveto (x, y) 400 300 moveto (400, 300) dx dy rmoveto x dx y dy (x, y) (x + dx, y + dy) (400, 300) 70-20 rmoveto (470, 280) 3.2.3 newpath moveto moveto rmoveto 3.2.4 (subpath) 1 moveto rmoveto (current subpath) 3.2.5 (paint) (stroke) (fill) 3.2.6 (1) newpath (2) (3)
3.3. 47 (4) showpage 3.3 (1) (3) (4) 3.3.1 (line) lineto rlineto lineto rlineto x y lineto (x, y) (x, y) (400, 300) 500 600 lineto (400, 300) (500, 600) (500, 600) dx dy rlineto (x, y) (x + dx, y + dy) (x + dx, y + dy) (400, 300) 70-20 rlineto (400, 300) (470, 280) (470, 280) 3.3.2 stroke stroke lineto.ps newpath 100 500 moveto 300 700 lineto 500 500 lineto 300 300 lineto stroke showpage lineto rlineto rlineto.ps newpath 100 500 moveto 200 200 rlineto 200-200 rlineto -200-200 rlineto stroke showpage
48 3 PostScript 3.3.3 (line width) (thickness) 1 1 setlinewidth num setlinewidth num width.ps /hline { 2 dict begin /width exch def /y exch def newpath 100 y moveto 400 0 rlineto width setlinewidth stroke }def /seventeenlines { 3 dict begin /width 4 def 100 40 740 { /y exch def y width hline /width width 2 add def } for seventeenlines showpage 17 4 2 3.3.4 (open subpath) (closed subpath) 2 (polyline) (polygon) (cap) (join) (close) closepath closepath closepath close.ps newpath 200 400 moveto 200 0 rlineto
3.3. 49 0-200 rlineto -200 0 rlineto 0 200 rlineto 200 700 moveto 200 0 rlineto 0-200 rlineto -200 0 rlineto closepath 60 setlinewidth stroke showpage 3.3.5 3.2 (stroke) (fill) stroke fill fill fill.ps newpath 100 400 moveto 200-200 rlineto 200 200 rlineto 100 500 moveto 200 200 rlineto 200-200 rlineto fill showpage 2 fill 3.3.6 (insideness) PostScript (nonzero winding number rule) (even-odd rule) fill eofill fill eofill eofill eofill.ps
50 3 PostScript /star { 2 dict begin /y exch def /x exch def newpath x y moveto 300 0 rlineto -250-200 rlineto 100 300 rlineto 100-300 rlineto 0 0.4 0 setrgbcolor 150 650 star fill 150 300 star eofill showpage fill eofill 3.4 3.4.1 1 (current color) stroke fill (color space) PostScript (additive mixture of colors) (subtractive mixture of colors) (gray level) 3.4.2 (red) (green) (blue) (additive mixture of colors) RGB setrgbcolor red green blue setrgbcolor red green blue 0 1 rgb.ps /hline { 5 dict begin /blue exch def /green exch def /red exch def /y exch def /x exch def newpath x y moveto 30 0 rlineto 30 setlinewidth
3.4. 51 red green blue setrgbcolor stroke }def /hundredlines { 4 dict begin /red 0 def 300 40 660 { /y exch def /green 0 def 100 40 460 { /x exch def x y red green 0 hline /green green 0.1 add def } for /red red 0.1 add def } for hundredlines showpage 100 0 3.4.3 (cyan) (magenta) (yellow) (black) (subtractive mixture of colors) (key tone) CMYK 1 setcmykcolor cyan magenta yellow black setcmykcolor cyan magenta yellow black 0 1 cmyk.ps /hline { 6 dict begin /black exch def /yellow exch def /magenta exch def /cyan exch def /y exch def /x exch def newpath x y moveto 30 0 rlineto 30 setlinewidth cyan magenta yellow black setcmykcolor stroke }def /hundredlines { 4 dict begin /cyan 0 def 300 40 660 { /y exch def /magenta 0 def 100 40 460 { /x exch def 1 K black
52 3 PostScript x y cyan magenta 0 0 hline /magenta magenta 0.1 add def } for /cyan cyan 0.1 add def } for hundredlines showpage 100 0 3.4.4 (gray) (gray level) setgray num setgray num 0 1 0 (black) 1 (white) gray.ps /dline { newpath 150 100 moveto 300 600 rlineto 40 setlinewidth stroke /hline { 2 dict begin /gray exch def /y exch def newpath 100 y moveto 400 0 rlineto 30 setlinewidth gray setgray stroke }def /elevenlines { 3 dict begin /gray 0 def 200 40 600 { /y exch def y gray hline /gray gray 0.1 add def } for dline elevenlines showpage 1 11
3.5. 53 3.5 3.5.1 stroke 3.5.2 3.3 (cap) setlinecap int setlinecap int 0 1 2 0 (butt cap) 1 (round cap) 2 (projecting square cap) cap.ps /hline { 2 dict begin /cap exch def /y exch def newpath 150 y moveto 300 0 rlineto 100 setlinewidth 0.5 1 1 setrgbcolor cap setlinecap stroke newpath 150 y moveto 300 0 rlineto 1 setlinewidth 1 0 0 setrgbcolor 0 setlinecap stroke }def 650 0 hline 500 1 hline 350 2 hline showpage 3.5.3 3.3 (join) setlinejoin
54 3 PostScript int setlinejoin int 0 1 2 0 (miter join) 1 (round join) 2 (bevel join) join.ps /harpoon { 2 dict begin /join exch def /y exch def newpath 150 y moveto 250 0 rlineto -150 120 rlineto 80 setlinewidth 0.5 1 1 setrgbcolor join setlinejoin stroke newpath 150 y moveto 250 0 rlineto -150 120 rlineto 1 setlinewidth 1 0 0 setrgbcolor 0 setlinejoin stroke }def 600 0 harpoon 400 1 harpoon 200 2 harpoon showpage 3.5.4 PostScript (miter length) (miter limit) 10 11 2 60 setmiterlimit num setmiterlimit num num 1 miter.ps
3.5. 55 /harpoon { 2 dict begin /miterlimit exch def /y exch def newpath 150 y moveto 250 0 rlineto -150 120 rlineto 80 setlinewidth 0 0.4 0 setrgbcolor 0 setlinejoin miterlimit setmiterlimit stroke }def 600 10 harpoon 400 2 harpoon showpage 2 3.5.5 (dashed line) (solid line) (dash pattern) (dash array) 0 [ 30 10 ] 30 10 [ 20 ] [ 20 20 ] [ 10 20 30 ] [ 10 20 30 10 20 30 ] (dash offset) stroke setdash
56 3 PostScript array offset setdash array offset array 0 dash.ps /vline { newpath 100 150 moveto 100 750 lineto 500 150 moveto 500 750 lineto 1 0 0 setrgbcolor stroke /hline { 3 dict begin /offset exch def /array exch def /y exch def newpath 100 y moveto 400 0 rlineto 0 0.4 0.8 setrgbcolor 40 setlinewidth array offset setdash stroke }def vline 700 [] 0 hline 600 [ 30 10 ] 0 hline 500 [ 20 ] 0 hline 400 [ 10 20 30 ] 0 hline 300 [ 50 10 10 10 ] 0 hline 200 [ 50 10 10 10 ] 20 hline showpage 3.5.6 roudash.ps newpath 100 200 moveto 400 0 rlineto -200 500 rlineto closepath 60 setlinewidth 0.4 0.8 0 setrgbcolor 1 setlinecap 1 setlinejoin [200 80] 0 setdash stroke showpage 3.6 3.6.1 (arc) 2
3.6. 57 3.6.2 arc arcn x y r ang 1 ang 2 arc (x, y) r ang 1 ang 2 x 0 x y r ang 1 ang 2 arcn arc arc arcn arc.ps newpath 300 600 100 0 225 arc stroke 300 400 100 0 225 arcn stroke showpage 3.6.3 arc arcn arc arcn arc arcn kofun.ps newpath 200 300 moveto 300 540 100 230 310 arcn 400 300 lineto closepath stroke showpage 3.6.4 arct x 1 y 1 x 2 y 2 r arct (x 1, y 1 ) (x 1, y 1 ) (x 2, y 2 ) r arct.ps newpath
58 3 PostScript 200 200 moveto 500 600 100 600 120 arct 0 1 0.8 setrgbcolor 30 setlinewidth stroke 200 200 moveto 500 600 lineto 100 600 lineto 1 setlinewidth 1 0 0 setrgbcolor stroke showpage 3.7 3.7.1 (Bézier curve) (control point) 2 4 2 1 2 1 2 3.7.2 curveto x 1 y 1 x 2 y 2 x 3 y 3 curveto (x 1, y 1 ) 1 (x 2, y 2 ) 2 (x 3, y 3 ) (x 3, y 3 ) bezier.ps /bezier { 8 dict begin /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def /y0 exch def /x0 exch def newpath x0 y0 moveto x1 y1 x2 y2 x3 y3 curveto 0 0.8 1 setrgbcolor 40 setlinewidth stroke newpath x0 y0 moveto x1 y1 lineto x2 y2 moveto x3 y3 lineto 1 0 0 setrgbcolor 1 setlinewidth stroke 140 450 100 650 500 750 300 450 bezier
3.8. 59 140 150 100 350 300 150 500 450 bezier showpage 3.7.3 3 1 bezbez.ps /bezbez { 14 dict begin /y6 exch def /x6 exch def /y5 exch def /x5 exch def /y4 exch def /x4 exch def /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def /y0 exch def /x0 exch def newpath x0 y0 moveto x1 y1 x2 y2 x3 y3 curveto x4 y4 x5 y5 x6 y6 curveto 0 1 0.8 setrgbcolor 30 setlinewidth stroke newpath x0 y0 moveto x1 y1 lineto x2 y2 moveto x3 y3 lineto 1 0 0 setrgbcolor 1 setlinewidth stroke newpath x3 y3 moveto x4 y4 lineto x5 y5 moveto x6 y6 lineto 0 0 1 setrgbcolor stroke 150 600 100 750 350 700 250 600 300 450 500 400 400 600 bezbez 150 300 100 450 350 400 250 300 100 150 500 100 400 300 bezbez showpage 1 1 3.8 3.8.1 PostScript
60 3 PostScript (font) PostScript (font dictionary) PostScript 3 (1) (2) (3) 3.8.2 (font name) Times Roman Times-Roman findfont name findfont font name /Times-Roman findfont Times-Roman 3.8.3 (size) findfont 1 scalefont font 1 scale scalefont font 2 font 1 scale /Times-Roman findfont 24 scalefont Times-Roman 24 3.8.4 (current font) setfont font setfont font
3.8. 61 /Times-Roman findfont 24 scalefont setfont Times-Roman 24 3.8.5 moveto rmoveto rmoveto 3.8.6 show string show string show.ps 0 0.6 0.4 setrgbcolor /Times-Roman findfont 64 scalefont setfont 100 600 moveto (I am a string.) show showpage 3.8.7 (width of glyph) show ashow show ashow a x a y string ashow string (a x, a y ) ashow.ps /drawalphabet { 4 dict begin /ay exch def /ax exch def /y exch def /x exch def 0.8 0 0.3 setrgbcolor /Times-Roman findfont 18 scalefont setfont x y moveto ax ay (abcdefghijklmnopqrstuvwxyz) ashow 100 700 0 0 drawalphabet 100 650 4 0 drawalphabet 100 600 8 0 drawalphabet 100 550-2 0 drawalphabet 100 400 0 4 drawalphabet
62 3 PostScript 100 350 0-4 drawalphabet showpage 3.8.8 widthshow c x c y char string widthshow string char (c x, c y ) 32 8 0 32 (word spacing) widthshow word spacing 8 wshow.ps /drawwords { 5 dict begin /char exch def /ay exch def /ax exch def /y exch def /x exch def 0.6 0 0.8 setrgbcolor /Times-Roman findfont 18 scalefont setfont x y moveto ax ay char (one two three four five six seven) widthshow 100 700 0 0 32 drawwords 100 650 12 0 32 drawwords 100 600 24 0 32 drawwords 100 550-2 0 32 drawwords 100 400 0 16 32 drawwords 100 350 0-16 32 drawwords 100 200 72 0 105 drawwords showpage 3.8.9 Times-Roman Helvetica Courier Symbol font.ps /drawfontname { 3 dict begin /fontname exch def /y exch def /x exch def 0.4 0.6 0 setrgbcolor fontname cvn findfont 64 scalefont setfont x y moveto fontname show 100 600 (Times-Roman) drawfontname 100 500 (Helvetica) drawfontname 100 400 (Courier) drawfontname 100 300 (Symbol) drawfontname showpage
3.8. 63 3.8.10 Ryumin-Light-RKSJ-H Ryumin-Light-RKSJ-V GothicBBB-Medium-RKSJ-H GothicBBB-Medium-RKSJ-V Shift JIS RKSJ EUC EUC-JP PostScript ( ) 7 PostScript <93fa 967b 8cea 82cc 95b6 8e9a 97f1> 16 nihongo.ps /drawnihongo { 3 dict begin /fontname exch def /y exch def /x exch def 0 0.4 0.8 setrgbcolor fontname findfont 64 scalefont setfont x y moveto <90bc 9286 9387 93ec 95fb> show 100 650 /Ryumin-Light-RKSJ-H drawnihongo 100 550 /GothicBBB-Medium-RKSJ-H drawnihongo 200 450 /Ryumin-Light-RKSJ-V drawnihongo 300 450 /GothicBBB-Medium-RKSJ-V drawnihongo showpage 3.8.11 (alignment) (flush left) (flush right) (centering) show x stringwidth string stringwidth w x w y string w x x w y y
64 3 PostScript align.ps /flushleft { 3 dict begin /string exch def /y exch def /x exch def x y moveto string show /flushright { 3 dict begin /string exch def /y exch def /x exch def x y moveto string stringwidth pop neg 0 rmoveto string show /centering { 3 dict begin /string exch def /y exch def /x exch def x y moveto string stringwidth pop neg 2 div 0 rmoveto string show /threestrings { 4 dict begin /proc exch def /dy exch def /y exch def /x exch def x y moveto x y (hotokenoza) proc x y dy sub (renge) proc x y dy 2 mul sub (nanohana) proc /Times-Roman findfont 24 scalefont setfont 0 0.6 0.2 setrgbcolor 100 500 32 { flushleft } threestrings 500 500 32 { flushright } threestrings 300 500 32 { centering } threestrings showpage 3.8.12 show charpath string bool charpath string bool
3.9. 65 charpath.ps newpath /Times-Roman findfont 230 scalefont setfont 0 0.6 0.8 setrgbcolor 3 setlinewidth 100 400 moveto (char) false charpath stroke /Ryumin-Light-RKSJ-V findfont 320 scalefont setfont 300 750 moveto <95b6 8e9a> false charpath 0.8 0 0.6 setrgbcolor 4 setlinewidth stroke showpage 3.9 3.9.1 3.1 x y 1 (transformation) 3.9.2 (translation) translate t x t y translate x t x y t y transla.ps /hline { newpath 0 0 moveto 200 0 rlineto stroke /translatehline { 100 100 translate 22 { hline 8 30 translate } repeat 0.3 0.8 0 setrgbcolor 16 setlinewidth translatehline showpage 3.9.3 (rotation) rotate
66 3 PostScript angle rotate angle rotate.ps /hline { newpath 60 0 moveto 160 0 rlineto stroke /rotatehline { 300 450 translate 36 { hline 10 rotate } repeat 0 0.6 0.8 setrgbcolor 6 setlinewidth rotatehline showpage 3.9.4 (scaling) (scaling factor) x y 1 1 x 2 x 1 2 scale s x s y scale x s x y s y scale.ps /hline { newpath 0 0 moveto 100 0 rlineto stroke /scalehline { 100 150 translate 10 { hline 1.16 0.82 scale 0 150 translate } repeat 0.8 0 0.6 setrgbcolor 100 setlinewidth scalehline showpage
3.10. 67 3.10 3.10.1 PostScript (clipping) (clip) PostScript 3.10.2 (clipping path) (current clipping path) clip eoclip clip eoclip initclip clip eoclip initclip clip.ps /star { 2 dict begin /y exch def /x exch def newpath x y moveto 300 0 rlineto -250-200 rlineto 100 300 rlineto 100-300 rlineto /polkadot { 4 dict begin /y exch def /x exch def /dy y def 14 { /dy dy 25 add def /dx x def 14 {
68 3 PostScript /dx dx 25 add def newpath dx dy 8 0 360 arc stroke } repeat } repeat /polkadotstar { 150 650 star clip 100 400 polkadot /polkadotstarbyeo { 150 300 star eoclip 100 50 polkadot 1 0 0.4 setrgbcolor 6 setlinewidth polkadotstar initclip polkadotstarbyeo showpage 3.11 3.11.1 3.1 3.11.2 PostScript (graphics state stack) (1) (2) (3) gsave grestore gsave grestore gsave.ps /square {
3.11. 69 2 dict begin /y exch def /x exch def x y moveto 200 0 rlineto 0 200 rlineto -200 0 rlineto fill /specialsquare { gsave 200 200 translate 50 rotate 2 0.5 scale 0.4 0.8 0 setrgbcolor 0 0 square grestore 0 0.4 0.8 setrgbcolor 200 100 square specialsquare 200 500 square showpage specialsquare 3.11.3 stroke fill eofill gsave grestore filstro.ps 0 0.4 0 setrgbcolor 30 setlinewidth newpath 100 600 moveto 400 0 rlineto 0-300 rlineto -400 0 rlineto closepath gsave 1 1 0.4 setrgbcolor fill grestore stroke showpage gsave grestore
70 3 PostScript 3.12 DSC 3.12.1 DSC PostScript (document manager) PostScript DSC PostScript DSC (Document Structuring Conventions) 3.12.2 DSC DSC DSC (DSC comment) PostScript DSC 1 DSC 1 2 ( %% ) (comment keyword) DSC PostScript DSC EOF %%EOF 3.12.3 DSC ( : ) DSC DSC DSC (argument) PostScript DSC Title: DSC Title: DSC DSC %%Title: (I Am a Title of This Program) DSC DSC I Am a Title of This Program DSC 3.12.4 DSC 1.2 PostScript DSC DSC ( % ) 1 DSC PostScript DSC 3.0 3.12.5 PostScript 1 2 DSC
3.12. DSC 71 DSC DSC Pages: %%Pages: %%Pages: 76 DSC DSC 76 DSC DSC Page: %%Page: DSC 0 1 %%Page: (title page for Chapter Five) 63 DSC 63 title page for Chapter Five 26 xxvi DSC %%Page: xxvi 26 showpage page.ps %%Pages: 3 /showstring { 1 dict begin /string exch def 100 500 moveto 0 0.6 0 setrgbcolor /Times-Roman findfont 128 scalefont setfont string show showpage %%Page: (first page) 1 (first) showstring %%Page: (second page) 2 (second) showstring %%Page: (third page) 3 (third) showstring 1 first 2 second 3 third
72 3 PostScript 3.13 EPS 3.13.1 EPS EPS.eps EPS EPS EPS PostScript (Encapsulated PostScript) EPS PostScript (encapsulated) EPS PostScript 3.13.2 EPS EPS PostScript PostScript EPS DSC EPSF-3.0 EPS showpage EPS showpage /showpage { EPS showpage 3.13.3 (bounding box) PostScript DSC DSC (bounding box comment) BoundingBox: %%BoundingBox: llx lly urx ury llx lly urx ury 1 (llx, lly) (urx, ury) %%BoundingBox: 160 140 380 570 DSC DSC PostScript (160, 140) (380, 570) EPS DSC EPS circle.eps EPSF-3.0 %%BoundingBox: 160 360 440 640 newpath
73 300 500 100 0 360 arc closepath 0 0.6 0.8 setrgbcolor 80 setlinewidth stroke [EPSFFS,1992] Adobe Systems Incorporated, Encapsulated PostScript File Format Specification, Version 3.0, Adobe Technical Note #5002, 1992. [PSLDSCS,1992] Adobe Systems Incorporated, PostScript Language Document Structuring Conventions Specification, Version 3.0, Adobe Technical Note #5001, 1992. [PSLPD,1988] Adobe Systems Incorporated, PostScript Language Program Design, Addison- Wesley, 1988, ISBN 978-0-201-14396-6. PostScript 1990 ISBN 978-4-7561-0047-4 [PSLRM,1999] Adobe Systems Incorporated, PostScript Language Reference Manual, Third Edition, Addison-Wesley, 1999, ISBN 978-0-201-37922-8. PostScript 3 2001 ISBN 978-4-7561-3822-4 [PSLTC,1985] Adobe Systems Incorporated, PostScript Language Tutorial and Cookbook, Addison-Wesley, 1985, ISBN 978-0-201-10179-9. PostScript 1989 ISBN 978-4-7561-0005-4 [,1993] PostScript 1993 ISBN 978-4-88317-032-6 [,1997] Ghostscript Another Manual 1997 ISBN 978-4-7973-0344-5 [,1997] PostScript CQ 1997 ISBN 978-4-7898-1851-3
74 %%BoundingBox:, 72 %%EOF, 70 %%Page:, 71 %%Pages:, 71 %%Title:, 70.eps, 72.ps, 7 =, 15, 18, 43 ==, 6, 10, 12, 15, 18, 43 [, 37 \, 16 \(, 16 \), 16 \\, 16 \b, 16 \ddd, 16 \f, 16 \n, 16 \r, 16 \t, 16 ], 37 10, 12, 13 16, 16, 63 2, 21 8, 16 a, 40 a+, 40 abs, 13 add, 6, 12, 13 Adobe Systems Incorporated, 5 aload, 38 and, 26 arc, 57 arcn, 57 arct, 57 array, 37 ashow, 61 astore, 38 atan, 13 begin, 23 C, 5 ceiling, 13 charpath, 64 clear, 12, 18 cleartomark, 20 clip, 67 closefile, 41 closepath, 48 CMYK, 51 copy, 19 cos, 13 count, 18 counttomark, 20 Courier, 62 curveto, 58 cvi, 17 cvn, 17 cvr, 17 cvrs, 17 cvs, 17 def, 14, 22 deletefile, 43 dict, 23 div, 6, 13 DSC, 70, 70 DSC, 70, 70, 70 DTP, 45 dup, 19, 23 eoclip, 67 eofill, 49, 69 EPS, 72, 72 eq, 25 Erlang, 5 ESC/Page, 5 EUC-JP, 63 exch, 19, 24 exec, 21, 34 exit, 31 exp, 14 false, 24 file, 40, 43 fill, 49, 50, 69 findfont, 60
75 floor, 13 for, 30, 34 forall, 30, 34, 38, 32 GCM, 31 ge, 25 get, 37, 17 getinterval, 38, 17 Ghostscript, 5, 6, 6, 6, 6 GothicBBB-Medium-RKSJ-H, 63 GothicBBB-Medium-RKSJ-V, 63 grestore, 68 gs, 6 gsave, 68 GSview, 8 gswin32, 6 gt, 25 Helvetica, 62 Hewlett-Packard Company, 5 HP PCL, 5 idiv, 13 if, 28, 34 ifelse, 28, 29, 34 index, 19 initclip, 67 Java, 5 le, 25 length, 37, 16 lineto, 47 LIPS, 5 ln, 14 load, 35 log, 14 loop, 30, 31, 34 lt, 25 mark, 20, 37 ML, 5 mod, 13 moveto, 46, 61 mul, 6, 13 ne, 25 NEC, 5 neg, 13 newpath, 45, 46 not, 26 NPDL, 5 or, 26 Pascal, 5 pop, 18 PostScript, 7, 5, 72 PostScript, 5 PostScript, 45 PRESCRIBE, 5 print, 43 Prolog, 5 pstack, 18, 43 put, 37, 17 putinterval quit, 6, 38, 17 r, 40 r+, 40 rand, 12, 14 read, 41 readline, 41 readstring, 41 renamefile, 44 repeat, 30, 34 RGB, 50 rlineto, 47 rmoveto, 46, 61 roll, 19 rotate, 66 round, 13 rrand, 14 Ruby, 5 run, 7, 21
76 Ryumin-Light-RKSJ-H, 63 Ryumin-Light-RKSJ-V, 63 scale, 66 scalefont, 60 Scheme, 5 setcmykcolor, 51 setdash, 56 setfont, 60 setgray, 52 setlinecap, 53 setlinejoin, 54 setlinewidth, 48 setmiterlimit, 54 setrgbcolor, 50 Shift JIS, 63 show, 61 showpage, 44, 71, 72 sin, 13 Smalltalk, 5 sqrt, 13 srand, 14 stack, 18 string, 16 stringwidth, 63 stroke, 47, 49, 50, 53, 55, 69 sub, 6, 13 Symbol, 62 systemdict, 22 Times-Roman, 60, 62 token, 41 translate, 65 true, 24 truncate, 13 userdict, 22 w, 40 w+, 40 widthshow, 62 write, 42 writestring, 42 xor, 26 x, 44 x, 44 y, 44 y, 44, 13, 50, 50, 40, 22, 30, 9, 13, 45, 51, 44, 68, 23, 46, 65, 7, 19, 44, 50, 68, 50, 5, 15, 71, 56, 57, 57, 57, 16, 62, 60, 40, 38, 17, 17, 37, 10, 20, 22, 18, 18, 19, 18, 20, 20, 11, 21, 24, 9, 18, 10, 20, 18, 28
, 37, 16, 41, 48, 41, 14, 12, 17, 28, 33 Ghostscript, 6, 13, 8, 16, 16, 9, 5, 5, 46, 33, 49, 67, 27, 28, 30, 37, 65, 8, 16, 8, 71, 15, 8, 44 EPS, 72, 68, 8, 68, 44, 68, 66, 60, 66, 30, 30, 31, 30 PostScript, 7, 38, 6, 6, 13, 32, 67, 67, 68, 45 PostScript, 72, 50, 50, 67, 52, 50, 52, 51, 52, 41, 44, 67, 6, 46, 22, 45, 60, 44, 46, 46, 46, 57, 62, 61, 25, 53, 68, 53, 53, 68, 56, 12, 21, 5, 35, 6, 13, 44, 65, 44, 68, 50, 51, 45, 34, 34, 24, 22, 5, 33, 9 77
78, 45, 13, 33, 20, 35, 18, 10, 20, 20, 20, 9, 70, 70, 5, 55, 36, 36, 45 Ghostscript, 6, 32, 25, 15, 33, 33, 33, 33, 31, 69, 13, 9, 43, 44, 44, 65, 65, 66, 65, 18, 6, 15, 60, 19, 24, 31, 6, 13, 16, 63, 14, 6, 13, 13, 52, 24, 24, 44, 65, 46, 12, 46, 17, 48, 48, 48, 13, 35, 53, 9, 18, 51, 51, 51, 44, 45, 68, 22, 23, 18, 19, 19, 18, 18, 18, 14, 23, 22, 23, 23, 23, 25, 22, 23, 35, 23, 14, 58, 30, 30, 30, 13, 5, 12, 13, 12, 17
, 8, 70, 46, 23, 57, 37, 9, 40, 47, 16, 13 Ghostscript, 6, 57, 48, 53, 14, 53, 68, 56, 33, 13, 21, 33, 48, 45, 60, 28, 6, 45, 10, 20, 53, 21, 46, 47, 49, 69, 33, 48, 20, 35, 21, 70, 23, 27, 28, 44, 65, 63, 9, 13, 25, 18, 44, 48, 68, 22, 48, 8, 22, 35, 14, 22, 24, 21, 16, 63 Ghostscript, 6, 48, 29, 14, 8, 16, 45, 66, 68, 62, 13, 48, 53, 53, 68, 56, 8, 20, 12, 12, 15 PostScript, 5, 48, 48, 13, 38, 17, 17, 37, 49, 45, 66, 68, 37, 15, 16, 14, 14, 24 79
80, 21, 23, 17, 24, 24, 5, 63, 46, 49, 69, 37, 8, 16, 16, 63, 26, 25, 25, 46, 47, 49, 69, 46, 59, 43, 43, 43, 43, 48, 40, 41 DSC, 70, 43, 9, 70, 40, 18, 20, 40, 26, 34, 63, 60, 63, 62, 37, 63, 37, 60, 68, 37, 60, 37, 60, 38, 60, 72, 60, 72, 60, 45, 68, 69, 68, 46, 45, 70, 44, 19, 55, 29, 56, 13, 53, 55, 68, 8, 16, 53, 55, 68, 9, 55, 23, 16, 20, 16, 12, 53, 12, 17, 18, 71, 48, 13, 38, 25, 38, 50, 17 DSC, 70, 17, 37, 5
, 5, 54 DSC, 70, 53, 54, 68, 6, 10, 12, 13, 51, 16, 70, 22, 70, 15, 63, 71, 13, 22, 37, 22, 16, 13, 63, 44, 50, 71, 45, 70, 5, 23, 70, 17, 14, 30, 61, 58, 17, 59, 22, 54, 63, 61, 45, 15, 46, 68, 17, 65, 17, 65, 17, 24, 36, 23, 16, 17, 15, 17, 16, 17, 15, 17, 15, 16, 63, 44, 59, 32, 45, 64, 45, 17, 16, 45, 68, 17, 9, 23, 68, 31, 9, 18, 18, 31, 23, 20, 37, 8, 16, 37, 20, 37, 38, 20, 32, 20, 20, 23, 54, 13 81
82, 41, 41, 25, 25, 25, 25, 53, 54, 71, 14, 14, 14, 43, 43, 10, 20, 46, 49, 69, 64, 59, 25, 26, 26, 26, 49, 67