1 ;;; ps.scm -- implement Scheme output routines for PostScript
3 ;;; source file of the GNU LilyPond music typesetter
5 ;;; (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 (define (ps-scm action-name)
11 ;; alist containing fontname -> fontcommand assoc (both strings)
12 (define font-alist '())
14 (define current-font "")
17 (define (cached-fontname i)
20 (make-string 1 (integer->char (+ 65 i)))))
23 (define (select-font name-mag-pair)
26 (c (assoc name-mag-pair font-name-alist))
32 (display (object-type (car name-mag-pair)))
33 (display (object-type (caaar font-name-alist)))
35 (ly-warn (string-append
36 "Programming error: No such font known "
37 (car name-mag-pair) " "
38 (number->string (cdr name-mag-pair))
41 "") ; issue no command
42 (string-append " " (cddr c) " "))
45 (define (font-load-command name-mag command)
51 "12 " (number->string (cdr name-mag)) " mul "
52 "lilypondpaperoutputscale div scalefont setfont } bind def "
56 (define (beam width slope thick)
58 (numbers->string (list width slope thick)) " draw_beam" ))
61 (string-append "% " s))
63 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
65 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
68 (invoke-char " show" i))
70 (define (crescendo thick w h cont )
72 (numbers->string (list w h (inexact->exact cont) thick))
75 ;; what the heck is this interface ?
76 (define (dashed-slur thick dash l)
78 (apply string-append (map control->string l))
79 (number->string thick)
83 (number->string (* 10 thick)) ;UGH. 10 ?
84 " ] 0 draw_dashed_slur"))
86 (define (dashed-line thick on off dx dy)
92 (number->string thick)
97 " ] 0 draw_dashed_line"))
99 (define (decrescendo thick w h cont)
101 (numbers->string (list w h (inexact->exact cont) thick))
102 " draw_decrescendo"))
108 (define (experimental-on) "")
110 (define (filledbox breapth width depth height)
111 (string-append (numbers->string (list breapth width depth height))
115 (define (font-def i s)
118 (substring s 0 (- (string-length s) 4))
119 " findfont 12 scalefont setfont} bind def \n"))
121 (define (font-switch i)
122 (string-append (font i) " "))
126 ;; URG: now we can't use scm output without Lily
127 (ly-gulp-file "lilyponddefs.ps")
128 " {exch pop //systemdict /run get exec} "
129 (ly-gulp-file "lily.ps")
130 "{ exch pop //systemdict /run get exec } "
133 (define (lily-def key val)
135 (if (string=? (substring key 0 (min (string-length "lilypondpaper") (string-length key))) "lilypondpaper")
136 (string-append "/" key " {" val "} bind def\n")
137 (string-append "/" key " (" val ") def\n")
141 (define (header creator generate)
144 "%%Creator: " creator generate "\n"))
146 (define (invoke-char s i)
148 "(\\" (inexact->string i 8) ") " s " " ))
150 (define (invoke-dim1 s d)
152 (number->string (* d (/ 72.27 72))) " " s ))
154 (define (placebox x y s)
156 (number->string x) " " (number->string y) " {" s "} placebox "))
158 (define (bezier-sandwich l thick)
160 (apply string-append (map control->string l))
161 (number->string thick)
162 " draw_bezier_sandwich"))
164 (define (start-line height)
166 lilypondpaperoutputscale lilypondpaperoutputscale scale
169 (define (stem breapth width depth height)
170 (string-append (numbers->string (list breapth width depth height))
177 (string-append "(" s ") show "))
180 (define (volta h w thick vert_start vert_end)
182 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
185 (define (tuplet ht gap dx dy thick dir)
187 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
195 (define (define-origin a b c ) "")
196 (define (no-origin) "")
199 (cond ((eq? action-name 'all-definitions)
202 (define tuplet ,tuplet)
203 (define bracket ,bracket)
205 (define crescendo ,crescendo)
206 (define volta ,volta)
207 (define bezier-sandwich ,bezier-sandwich)
208 (define dashed-line ,dashed-line)
209 (define dashed-slur ,dashed-slur)
210 (define decrescendo ,decrescendo)
211 (define end-output ,end-output)
212 (define experimental-on ,experimental-on)
213 (define filledbox ,filledbox)
214 (define font-def ,font-def)
215 (define font-switch ,font-switch)
216 (define header-end ,header-end)
217 (define lily-def ,lily-def)
218 (define font-load-command ,font-load-command)
219 (define header ,header)
220 (define invoke-char ,invoke-char)
221 (define invoke-dim1 ,invoke-dim1)
222 (define placebox ,placebox)
223 (define select-font ,select-font)
224 (define start-line ,start-line)
226 (define stop-line ,stop-line)
227 (define stop-last-line ,stop-line)
229 (define no-origin ,no-origin)
230 (define define-origin ,define-origin)
232 ((eq? action-name 'tuplet) tuplet)
233 ((eq? action-name 'beam) beam)
234 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
235 ((eq? action-name 'bracket) bracket)
236 ((eq? action-name 'char) char)
237 ((eq? action-name 'crescendo) crescendo)
238 ((eq? action-name 'dashed-line) dashed-line)
239 ((eq? action-name 'dashed-slur) dashed-slur)
240 ((eq? action-name 'decrescendo) decrescendo)
241 ((eq? action-name 'experimental-on) experimental-on)
242 ((eq? action-name 'filledbox) filledbox)
243 ((eq? action-name 'select-font) select-font)
244 ((eq? action-name 'volta) volta)
245 (else (error "unknown tag -- PS-SCM " action-name))
249 (define (scm-ps-output)
250 (ly-eval (ps-scm 'all-definitions)))