1 ; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ; source file of the GNU LilyPond music typesetter
5 ; (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 ; - ready ps code (draw_bracket) vs tex/ps macros/calls (pianobrace),
10 ; all preparations from ps,tex to scm
16 (map (lambda (n) (string-append (number->string n) " ")) l)))
18 (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
20 (define (number->octal-string x)
21 (let* ((n (inexact->exact x))
23 (n8 (quotient (- n (* n64 64)) 8)))
27 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
29 (define (inexact->string x radix)
30 (let ((n (inexact->exact x)))
31 (number->string n radix)))
36 (number->string (chop-decimal x)) "pt "))
41 (string-append (number->string (car c)) " ")
42 (string-append (number->string (cadr c)) " ")))
46 (string-append "\\embeddedps{" s "}"))
51 "(\\" (inexact->string i 8) ") " s " " ))
56 "\n\\" s "{" (inexact->string i 10) "}" ))
61 (number->string d) " " s ))
66 "\n\\" s "{" (number->dim-tex d) "}"))
70 (eval-string (string-append s "-" o)))
72 ;;; output definitions
75 (beam o width slope thick)
76 ((invoke-output o "beam") width slope thick))
79 (beam-ps width slope thick)
81 (numbers->string (list width slope thick)) " draw_beam " ))
84 (beam-tex width slope thick)
85 (embedded-ps-tex (beam-ps width slope thick)))
89 ((invoke-output o "bracket") h))
93 (invoke-dim1-ps "draw_bracket" h))
97 (embedded-ps-tex (bracket-ps h)))
101 ((invoke-output o "invoke-char") "show" n))
104 (dashed-slur o thick dash l)
105 ((invoke-output o "dashed-slur") thick dash l))
108 (dashed-slur-ps thick dash l)
110 (apply string-append (map control->string l))
111 (number->string thick)
113 (if (> 1 dash) (number->string (- (* thick dash) thick)) "0") " "
114 (number->string (* 2 thick))
115 " ] 0 draw_dashed_slur"))
118 (dashed-slur-tex thick dash l)
119 (embedded-ps-tex (dashed-slur-ps thick dash l)))
123 ((invoke-output o "invoke-dim1") "doublebar" h))
127 ((invoke-output o "empty")))
138 (emptybar o h) (empty o))
142 ((invoke-output o "end-output")))
150 "\n\\EndLilyPondOutput")
154 ((invoke-output o "experimental-on")))
157 (experimental-on-ps) "")
160 (experimental-on-tex) "\\turnOnExperimentalFeatures")
164 ((invoke-output o "invoke-dim1") "fatdoublebar" h))
168 ((invoke-output o "invoke-dim1") "finishbar" h))
174 (make-string 1 (integer->char (+ (char->integer #\A) i)))
179 ((invoke-output o "font-def") i s))
185 (substring s 0 (- (string-length s) 4))
186 " findfont 12 scalefont setfont} bind def\n"))
191 "\\font" (font-switch-tex i) "=" s "\n"))
195 ((invoke-output o "font-switch") i))
199 (string-append (font i) " "))
207 (generalmeter o num den)
208 ((invoke-output o "generalmeter") num den))
211 (generalmeter-ps num den)
212 (string-append (number->string (inexact->exact num)) " " (number->string (inexact->exact den)) " generalmeter "))
215 (generalmeter-tex num den)
217 "\\generalmeter{" (number->string (inexact->exact num)) "}{" (number->string (inexact->exact den)) "}"))
220 (header o creator generate)
221 ((invoke-output o "header") creator generate))
224 (header-ps creator generate)
227 "%%Creator: " creator generate "\n"))
230 (header-tex creator generate)
232 "%created by: " creator generate "\n"))
236 ((invoke-output o "header-end")))
242 (header-end-tex) "\\turnOnPostScript")
246 ((invoke-output o "lily-def") key val))
249 (lily-def-ps key val)
251 "/" key " {" val "} bind def\n"))
254 (lily-def-tex key val)
256 "\\def\\" key "{" val "}\n"))
260 ((invoke-output o "invoke-dim1") "maatstreep" h))
264 ((invoke-output o "invoke-char") "pianobrace" i))
268 ((invoke-output o "placebox") x y (b o)))
273 (number->string x) " " (number->string y) " {" s "} placebox "))
279 (number->dim-tex y) "}{" (number->dim-tex x) "}{" s "}"))
283 ((invoke-output o "invoke-dim1") "repeatbar" h))
286 (repeatbarstartrepeat o h)
287 ((invoke-output o "invoke-dim1") "repeatbarstartrepeat" h))
291 ((invoke-output o "rulesym") x y))
296 (number->string x) " "
297 (number->string y) " "
303 "\\rulesym{" (number->dim-tex x) "}{" (number->dim-tex y) "}"))
307 ((invoke-output o "text") "bold" s))
310 (setdynamic o s) (empty o))
314 ((invoke-output o "text") "finger" s))
318 ((invoke-output o "text") "huge" s))
322 ((invoke-output o "text") "italic" s))
326 ((invoke-output o "text") "large" s))
330 ((invoke-output o "text") "Large" s))
334 ((invoke-output o "text") "number" s))
338 ((invoke-output o "text") "text" s))
342 ((invoke-output o "text") "typewriter" s))
346 ((invoke-output o "slur") l))
351 (apply string-append (map control->string l))
356 (embedded-ps-tex (slur-ps l)))
359 (stem o kern width height depth)
360 ((invoke-output o "stem") kern width height depth))
363 (stem-ps kern width height depth)
364 (string-append (numbers->string (list kern width height depth))
368 (stem-tex kern width height depth)
370 "\\kern" (number->dim-tex kern)
371 "\\vrule width " (number->dim-tex width)
372 "depth " (number->dim-tex depth)
373 "height " (number->dim-tex height) " "))
377 ((invoke-output o "start-line")))
389 ((invoke-output o "invoke-dim1") "startrepeat" h))
393 ((invoke-output o "stop-line")))
405 ((invoke-output o "invoke-dim1") "stoprepeat" h))
409 (string-append "(" s ") set" f " "))
413 (string-append "\\set" f "{" s "}"))