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)
13 (define this-module (current-module))
15 (debug-enable 'backtrace)
17 (if (or (equal? (minor-version) "4")
18 (equal? (minor-version) "3.4"))
19 (define-public (ps-output-expression expr port)
20 (display (eval-in-module expr this-module) port )
23 (define-public (ps-output-expression expr port)
24 (display (eval expr this-module) port )
38 (define (tex-encoded-fontswitch name-mag)
39 (let* ((iname-mag (car name-mag))
40 (ename-mag (cdr name-mag)))
43 (string-append "magfont"
44 (string-encode-integer
45 (hashq (car ename-mag) 1000000))
47 (string-encode-integer
48 (inexact->exact (* 1000 (cdr ename-mag)))))))))
50 (define (fontify name-mag-pair exp)
51 (string-append (select-font name-mag-pair)
55 (define (define-fonts internal-external-name-mag-pairs)
56 (set! font-name-alist (map tex-encoded-fontswitch
57 internal-external-name-mag-pairs))
60 (font-load-command (car x) (cdr x)))
61 (map cdr font-name-alist))))
65 ;; alist containing fontname -> fontcommand assoc (both strings)
66 (define font-alist '())
68 (define current-font "")
70 (define (select-font name-mag-pair)
73 (c (assoc name-mag-pair font-name-alist))
79 (display (object-type (car name-mag-pair)))
80 (display (object-type (caaar font-name-alist)))
82 (ly-warn (string-append
83 "Programming error: No such font known "
84 (car name-mag-pair) " "
85 (ly-number->string (cdr name-mag-pair))
88 "") ; issue no command
89 (string-append " " (cddr c) " "))
92 (define (font-load-command name-mag command)
98 "12 " (ly-number->string (cdr name-mag)) " mul "
99 "lilypondpaperoutputscale div scalefont setfont } bind def "
102 (define (beam width slope thick)
104 (numbers->string (list slope width thick)) " draw_beam" ))
107 (string-append "% " s "\n"))
109 (define (bracket arch_angle arch_width arch_height height arch_thick thick)
111 (numbers->string (list arch_angle arch_width arch_height height arch_thick thick)) " draw_bracket" ))
114 (invoke-char " show" i))
117 (define (hairpin thick width starth endh )
119 (numbers->string (list width starth endh thick))
122 ;; what the heck is this interface ?
123 (define (dashed-slur thick dash l)
125 (apply string-append (map control->string l))
126 (ly-number->string thick)
128 (ly-number->string dash)
130 (ly-number->string (* 10 thick)) ;UGH. 10 ?
131 " ] 0 draw_dashed_slur"))
133 (define (dashed-line thick on off dx dy)
135 (ly-number->string dx)
137 (ly-number->string dy)
139 (ly-number->string thick)
141 (ly-number->string on)
143 (ly-number->string off)
144 " ] 0 draw_dashed_line"))
146 (define (repeat-slash wid slope thick)
147 (string-append (numbers->string (list wid slope thick))
148 " draw_repeat_slash"))
151 "\nend-lilypond-output\n")
153 (define (experimental-on) "")
155 (define (filledbox breapth width depth height)
156 (string-append (numbers->string (list breapth width depth height))
160 (define (font-def i s)
163 (substring s 0 (- (string-length s) 4))
164 " findfont 12 scalefont setfont} bind def \n"))
166 (define (font-switch i)
167 (string-append (font i) " "))
171 ;; URG: now we can't use scm output without Lily
172 (ly-gulp-file "lilyponddefs.ps")
173 " {exch pop //systemdict /run get exec} "
174 (ly-gulp-file "music-drawing-routines.ps")
175 "{ exch pop //systemdict /run get exec } "
176 (if (defined? 'ps-testing) "\n /testing true def" "")
179 (define (lily-def key val)
181 (if (string=? (substring key 0 (min (string-length "lilypondpaper") (string-length key))) "lilypondpaper")
182 (string-append "/" key " {" val "} bind def\n")
183 (string-append "/" key " (" val ") def\n")
187 (define (header creator generate)
190 "%%Creator: " creator generate "\n"))
192 (define (invoke-char s i)
194 "(\\" (inexact->string i 8) ") " s " " ))
196 (define (invoke-dim1 s d)
198 (ly-number->string (* d (/ 72.27 72))) " " s ))
200 (define (placebox x y s)
202 (ly-number->string x) " " (ly-number->string y) " {" s "} place-box\n"))
204 (define (bezier-sandwich l thick)
206 (apply string-append (map control->string l))
207 (ly-number->string thick)
208 " draw_bezier_sandwich"))
210 ; TODO: use HEIGHT argument
211 (define (start-line height)
214 (ly-number->string height)
216 lilypondpaperoutputscale lilypondpaperoutputscale scale
219 (define (stem breapth width depth height)
220 (string-append (numbers->string (list breapth width depth height))
226 (define (stop-last-line)
230 (string-append "(" s ") show "))
233 (define (volta h w thick vert_start vert_end)
235 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
238 (define (tuplet ht gap dx dy thick dir)
240 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
247 (define (ez-ball ch letter-col ball-col)
250 (numbers->string (list letter-col ball-col))
251 " /Helvetica-Bold " ;; ugh
254 (define (define-origin a b c ) "")
255 (define (no-origin) "")