1 ;;; ps.scm -- implement Scheme output routines for PostScript
3 ;;; source file of the GNU LilyPond music typesetter
5 ;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 (define-module (scm ps)
11 :export (ps-output-expression)
15 (define this-module (current-module))
17 (define (ps-output-expression expr port)
18 (display (eval expr this-module) port)
31 (define (tex-encoded-fontswitch name-mag)
32 (let* ((iname-mag (car name-mag))
33 (ename-mag (cdr name-mag)))
36 (string-append "magfont"
37 (string-encode-integer
38 (hashq (car ename-mag) 1000000))
40 (string-encode-integer
41 (inexact->exact (* 1000 (cdr ename-mag)))))))))
43 (define (fontify name-mag-pair exp)
44 (string-append (select-font name-mag-pair)
48 (define (define-fonts internal-external-name-mag-pairs)
49 (set! font-name-alist (map tex-encoded-fontswitch
50 internal-external-name-mag-pairs))
53 (font-load-command (car x) (cdr x)))
54 (map cdr font-name-alist))))
58 ;; alist containing fontname -> fontcommand assoc (both strings)
59 (define font-alist '())
61 (define current-font "")
63 (define (select-font name-mag-pair)
66 (c (assoc name-mag-pair font-name-alist))
72 (display (object-type (car name-mag-pair)))
73 (display (object-type (caaar font-name-alist)))
75 (ly-warn (string-append
76 "Programming error: No such font known "
77 (car name-mag-pair) " "
78 (ly-number->string (cdr name-mag-pair))
81 "") ; issue no command
82 (string-append " " (cddr c) " "))
85 (define (font-load-command name-mag command)
91 "12 " (ly-number->string (cdr name-mag)) " mul "
92 "lilypondpaperoutputscale div scalefont setfont } bind def "
95 (define (beam width slope thick)
97 (numbers->string (list slope width thick)) " draw_beam" ))
100 (string-append "% " s "\n"))
102 (define (bracket arch_angle arch_width arch_height height arch_thick thick)
104 (numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket" ))
107 (invoke-char " show" i))
110 (define (hairpin thick width starth endh )
112 (numbers->string (list width starth endh thick))
115 ;; what the heck is this interface ?
116 (define (dashed-slur thick dash l)
118 (apply string-append (map control->string l))
119 (ly-number->string thick)
121 (ly-number->string dash)
123 (ly-number->string (* 10 thick)) ;UGH. 10 ?
124 " ] 0 draw_dashed_slur"))
126 (define (dashed-line thick on off dx dy)
128 (ly-number->string dx)
130 (ly-number->string dy)
132 (ly-number->string thick)
134 (ly-number->string on)
136 (ly-number->string off)
137 " ] 0 draw_dashed_line"))
139 (define (repeat-slash wid slope thick)
140 (string-append (numbers->string (list wid slope thick))
141 " draw_repeat_slash"))
144 "\nend-lilypond-output\n")
146 (define (experimental-on) "")
148 (define (filledbox breapth width depth height)
149 (string-append (numbers->string (list breapth width depth height))
153 (define (font-def i s)
156 (substring s 0 (- (string-length s) 4))
157 " findfont 12 scalefont setfont} bind def \n"))
159 (define (font-switch i)
160 (string-append (font i) " "))
164 ;; URG: now we can't use scm output without Lily
165 (ly-gulp-file "lilyponddefs.ps")
166 " {exch pop //systemdict /run get exec} "
167 (ly-gulp-file "music-drawing-routines.ps")
168 "{ exch pop //systemdict /run get exec } "
169 (if (defined? 'ps-testing) "\n /testing true def" "")
172 (define (lily-def key val)
174 (if (string=? (substring key 0 (min (string-length "lilypondpaper") (string-length key))) "lilypondpaper")
175 (string-append "/" key " {" val "} bind def\n")
176 (string-append "/" key " (" val ") def\n")
180 (define (header creator generate)
183 "%%Creator: " creator generate "\n"))
185 (define (invoke-char s i)
187 "(\\" (inexact->string i 8) ") " s " " ))
189 (define (invoke-dim1 s d)
191 (ly-number->string (* d (/ 72.27 72))) " " s ))
193 (define (placebox x y s)
195 (ly-number->string x) " " (ly-number->string y) " {" s "} place-box\n"))
197 (define (bezier-sandwich l thick)
199 (apply string-append (map control->string l))
200 (ly-number->string thick)
201 " draw_bezier_sandwich"))
203 ; TODO: use HEIGHT argument
204 (define (start-line height)
207 (ly-number->string height)
209 lilypondpaperoutputscale lilypondpaperoutputscale scale
212 (define (stem breapth width depth height)
213 (string-append (numbers->string (list breapth width depth height))
219 (define (stop-last-line)
223 (string-append "(" s ") show "))
226 (define (volta h w thick vert_start vert_end)
228 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
231 (define (tuplet ht gap dx dy thick dir)
233 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
240 (define (ez-ball ch letter-col ball-col)
243 (numbers->string (list letter-col ball-col))
244 " /Helvetica-Bold " ;; ugh
247 (define (define-origin a b c ) "")
248 (define (no-origin) "")