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 ; This file contains various routines in Scheme that are easier to
10 ; do here than in C++. At present it is a unorganised mess. Sorry.
14 ;(debug-enable 'backtrace)
18 (use-modules (ice-9 regex))
20 ;; The regex module may not be available, or may be broken.
21 ;; If you have trouble with regex, define #f
22 ;;(define use-regex #t)
23 ;;(define use-regex #f)
26 (let ((os (string-downcase (vector-ref (uname) 0))))
27 (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
29 ;; do nothing in .scm output
30 (define (comment s) "")
36 (define (cons-map f x)
37 (cons (f (car x)) (f (cdr x))))
39 (define (reduce operator list)
40 (if (null? (cdr list)) (car list)
41 (operator (car list) (reduce operator (cdr list)))
46 (define (numbers->string l)
47 (apply string-append (map ly-number->string l)))
49 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
51 (define (number->octal-string x)
52 (let* ((n (inexact->exact x))
54 (n8 (quotient (- n (* n64 64)) 8)))
58 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
60 (define (inexact->string x radix)
61 (let ((n (inexact->exact x)))
62 (number->string n radix)))
65 (define (control->string c)
66 (string-append (number->string (car c)) " "
67 (number->string (cdr c)) " "))
73 (make-string 1 (integer->char (+ (char->integer #\A) i)))
78 (define (scm-scm action-name)
81 (define security-paranoia #f)
84 ;; See documentation of Item::visibility_lambda_
85 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
86 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
87 (define (all-visible d) '(#f . #f))
88 (define (all-invisible d) '(#t . #t))
89 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
90 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
93 ;; Score_span_bars are only visible at start of line
94 ;; i.e. if break_dir == RIGHT == 1
95 (define Span_bar_engraver-visibility begin-of-line-invisible)
96 (define mark-visibility end-of-line-invisible)
98 ;; Spacing constants for prefatory matter.
100 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
104 ;; (Measured in staff space)
107 ((none Instrument_name) . (extra-space 1.0))
108 ((Instrument_name Left_edge_item) . (extra-space 1.0))
109 ((Left_edge_item Clef_item) . (extra-space 1.0))
110 ((none Left_edge_item) . (extra-space 0.0))
111 ((Left_edge_item Staff_bar) . (extra-space 0.0))
112 ; ((none Left_edge_item) . (extra-space -15.0))
113 ; ((none Left_edge_item) . (extra-space -15.0))
114 ((none Clef_item) . (minimum-space 1.0))
115 ((none Staff_bar) . (minimum-space 0.0))
116 ((none Clef_item) . (minimum-space 1.0))
117 ((none Key_item) . (minimum-space 0.5))
118 ((none Time_signature) . (extra-space 0.0))
119 ((none begin-of-note) . (minimum-space 1.5))
120 ((Clef_item Key_item) . (minimum-space 4.0))
121 ((Key_item Time_signature) . (extra-space 1.0))
122 ((Clef_item Time_signature) . (minimum-space 3.5))
123 ((Staff_bar Clef_item) . (minimum-space 1.0))
124 ((Clef_item Staff_bar) . (minimum-space 3.7))
125 ((Time_signature Staff_bar) . (minimum-space 2.0))
126 ((Key_item Staff_bar) . (extra-space 1.0))
127 ((Staff_bar Time_signature) . (minimum-space 1.5)) ;double check this.
128 ((Time_signature begin-of-note) . (extra-space 2.0)) ;double check this.
129 ((Key_item begin-of-note) . (extra-space 2.5))
130 ((Staff_bar begin-of-note) . (extra-space 1.0))
131 ((Clef_item begin-of-note) . (minimum-space 5.0))
132 ((none Breathing_sign) . (minimum-space 0.0))
133 ((Breathing_sign Key_item) . (minimum-space 1.5))
134 ((Breathing_sign begin-of-note) . (minimum-space 1.0))
135 ((Breathing_sign Staff_bar) . (minimum-space 1.5))
136 ((Breathing_sign Clef_item) . (minimum-space 2.0))
140 ;; (define (ly-warn s) (error s))
141 (define (break-align-spacer this next)
142 (let ((entry (assoc (list this next) space-alist)))
145 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
146 '(minimum-space 0.0)))))
149 (define (noteheadsymbol duration style)
151 ((equal? style "cross") "2cross")
152 ((equal? style "harmonic") "0mensural")
153 ((equal? style "baroque")
154 (string-append (number->string duration)
155 (if (< duration 0) "mensural" "")))
157 (string-append (number->string duration) style))))
162 ;; this is silly, can't we use something like
163 ;; roman-0, roman-1 roman+1 ?
166 ("brace" . "feta-braces")
167 ("default" . "cmr10")
168 ("dynamic" . "feta-din")
172 ("typewriter" . "cmtt")
178 ("mark" . "feta-nummer")
179 ("finger" . "feta-nummer")
180 ("timesig" . "feta-nummer")
181 ("number" . "feta-nummer")
182 ("volta" . "feta-nummer"))
185 (define (string-encode-integer i)
188 ((< i 0) (string-append "n" (string-encode-integer (- i))))
190 (make-string 1 (integer->char (+ 65 (modulo i 26))))
191 (string-encode-integer (quotient i 26))
198 (cdr (assoc i '((-4 . 482)
211 (define script-alist '())
212 (define (articulation-to-scriptdef a)
213 (assoc a script-alist)
216 ;; Map style names to TeX font names. Return false if
217 ;; no font name found.
218 (define (style-to-cmr s)
224 (define font-name-alist '())
225 (define (font-command name-mag)
227 (string-append "magfont"
228 (string-encode-integer (hashq (car name-mag) 1000000))
230 (string-encode-integer (cdr name-mag)))
234 (define (define-fonts names)
235 (set! font-name-alist (map font-command names))
238 (font-load-command (car x) (cdr x))) font-name-alist)
241 (define (fontify name exp)
242 (string-append (select-font name)
249 ; Make a function that checks score element for being of a specific type.
250 (define (make-type-checker name)
252 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
255 ;;;;;;;;;;;;;;;;;;; TeX output
256 (define (tex-scm action-name)
261 (define (select-font font-name-symbol)
264 (c (assoc font-name-symbol font-name-alist))
269 (ly-warn (string-append
270 "Programming error: No such font known " (car font-name-symbol)))
271 "") ; issue no command
272 (string-append "\\" (cdr c)))
277 (define (beam width slope thick)
278 (embedded-ps ((ps-scm 'beam) width slope thick)))
280 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
281 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
283 (define (dashed-slur thick dash l)
284 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
286 (define (crescendo thick w h cont)
287 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
290 (string-append "\\char" (inexact->string i 10) " "))
292 (define (dashed-line thick dash w)
293 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
295 (define (decrescendo thick w h cont)
296 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
298 (define (font-load-command name-mag command)
300 "\\font\\" command "="
301 (symbol->string (car name-mag))
303 (number->string (magstep (cdr name-mag)))
306 (define (embedded-ps s)
307 (string-append "\\embeddedps{" s "}"))
310 (string-append "% " s))
313 "\n\\EndLilyPondOutput")
315 (define (experimental-on)
318 (define (font-switch i)
322 (define (font-def i s)
324 "\\font" (font-switch i) "=" s "\n"))
330 ;; URG: ly-gulp-file: now we can't use scm output without Lily
332 ;; fixed in 1.3.4 for powerpc -- broken on Windows
333 (regexp-substitute/global #f "\n"
334 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
335 (ly-gulp-file "lily.ps"))
337 "\\input lilyponddefs \\turnOnPostScript"))
339 (define (header creator generate)
341 "%created by: " creator generate "\n"))
343 (define (invoke-char s i)
345 "\n\\" s "{" (inexact->string i 10) "}" ))
347 (define (invoke-dim1 s d)
349 "\n\\" s "{" (number->dim d) "}"))
354 ;; need to do something to make this really safe.
356 (define (output-tex-string s)
357 (if security-paranoia
359 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
360 (begin (display "warning: not paranoid") (newline) s))
363 (define (lily-def key val)
367 ;; fixed in 1.3.4 for powerpc -- broken on Windows
368 (regexp-substitute/global #f "_"
369 (output-tex-string key) 'pre "X" 'post)
370 (output-tex-string key))
371 "{" (output-tex-string val) "}\n"))
373 (define (number->dim x)
375 (ly-number->string x) " pt "))
377 (define (placebox x y s)
380 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
382 (define (bezier-sandwich l thick)
383 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
385 (define (start-line ht)
386 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
389 "}\\vss}\\interscoreline")
390 (define (stop-last-line)
392 (define (filledbox breapth width depth height)
394 "\\kern" (number->dim (- breapth))
395 "\\vrule width " (number->dim (+ breapth width))
396 "depth " (number->dim depth)
397 "height " (number->dim height) " "))
400 (string-append "\\hbox{" (output-tex-string s) "}"))
402 (define (tuplet ht gapx dx dy thick dir)
403 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
405 (define (volta h w thick vert_start vert_end)
406 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
409 ;; The procedures listed below form the public interface of TeX-scm.
410 ;; (should merge the 2 lists)
411 (cond ((eq? action-name 'all-definitions)
413 (define font-load-command ,font-load-command)
415 (define bezier-sandwich ,bezier-sandwich)
416 (define bracket ,bracket)
418 (define crescendo ,crescendo)
419 (define dashed-line ,dashed-line)
420 (define dashed-slur ,dashed-slur)
421 (define decrescendo ,decrescendo)
422 (define end-output ,end-output)
423 (define experimental-on ,experimental-on)
424 (define filledbox ,filledbox)
425 (define font-def ,font-def)
426 (define font-switch ,font-switch)
427 (define header-end ,header-end)
428 (define lily-def ,lily-def)
429 (define header ,header)
430 (define invoke-char ,invoke-char)
431 (define invoke-dim1 ,invoke-dim1)
432 (define placebox ,placebox)
433 (define select-font ,select-font)
434 (define start-line ,start-line)
435 (define stop-line ,stop-line)
436 (define stop-last-line ,stop-last-line)
438 (define tuplet ,tuplet)
439 (define volta ,volta)
442 ((eq? action-name 'beam) beam)
443 ((eq? action-name 'tuplet) tuplet)
444 ((eq? action-name 'bracket) bracket)
445 ((eq? action-name 'crescendo) crescendo)
446 ((eq? action-name 'dashed-line) dashed-line)
447 ((eq? action-name 'dashed-slur) dashed-slur)
448 ((eq? action-name 'decrescendo) decrescendo)
449 ((eq? action-name 'end-output) end-output)
450 ((eq? action-name 'experimental-on) experimental-on)
451 ((eq? action-name 'font-def) font-def)
452 ((eq? action-name 'font-switch) font-switch)
453 ((eq? action-name 'header-end) header-end)
454 ((eq? action-name 'lily-def) lily-def)
455 ((eq? action-name 'header) header)
456 ((eq? action-name 'invoke-char) invoke-char)
457 ((eq? action-name 'invoke-dim1) invoke-dim1)
458 ((eq? action-name 'placebox) placebox)
459 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
460 ((eq? action-name 'start-line) start-line)
461 ((eq? action-name 'stem) stem)
462 ((eq? action-name 'stop-line) stop-line)
463 ((eq? action-name 'stop-last-line) stop-last-line)
464 ((eq? action-name 'volta) volta)
465 (else (error "unknown tag -- PS-TEX " action-name))
471 (define (ps-scm action-name)
473 ;; alist containing fontname -> fontcommand assoc (both strings)
474 (define font-alist '())
475 (define font-count 0)
476 (define current-font "")
479 (define (cached-fontname i)
482 (make-string 1 (integer->char (+ 65 i)))))
484 (define (mag-to-size m)
485 (number->string (case m
488 (2 14) ; really: 14.400
489 (3 17) ; really: 17.280
490 (4 21) ; really: 20.736
491 (5 24) ; really: 24.888
492 (6 30) ; really: 29.856
496 (define (select-font font-name-symbol)
499 (c (assoc font-name-symbol font-name-alist))
504 (ly-warn (string-append
505 "Programming error: No such font known " (car font-name-symbol)))
506 "") ; issue no command
507 (string-append " " (cdr c) " "))
512 (define (font-load-command name-mag command)
516 (symbol->string (car name-mag))
518 (number->string (magstep (cdr name-mag)))
519 " 1000 div 12 mul scalefont setfont } bind def "
523 (define (beam width slope thick)
525 (numbers->string (list width slope thick)) " draw_beam" ))
528 (string-append "% " s))
530 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
532 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
535 (invoke-char " show" i))
537 (define (crescendo thick w h cont )
539 (numbers->string (list w h (inexact->exact cont) thick))
542 ;; what the heck is this interface ?
543 (define (dashed-slur thick dash l)
545 (apply string-append (map control->string l))
546 (number->string thick)
548 (number->string dash)
550 (number->string (* 10 thick)) ;UGH. 10 ?
551 " ] 0 draw_dashed_slur"))
553 (define (dashed-line thick dash width)
555 (number->string width)
557 (number->string thick)
559 (number->string dash)
561 (number->string dash)
562 " ] 0 draw_dashed_line"))
564 (define (decrescendo thick w h cont)
566 (numbers->string (list w h (inexact->exact cont) thick))
567 " draw_decrescendo"))
573 (define (experimental-on) "")
575 (define (filledbox breapth width depth height)
576 (string-append (numbers->string (list breapth width depth height))
580 (define (font-def i s)
583 (substring s 0 (- (string-length s) 4))
584 " findfont 12 scalefont setfont} bind def \n"))
586 (define (font-switch i)
587 (string-append (font i) " "))
591 ;; URG: now we can't use scm output without Lily
592 (ly-gulp-file "lilyponddefs.ps")
593 " {exch pop //systemdict /run get exec} "
594 (ly-gulp-file "lily.ps")
595 "{ exch pop //systemdict /run get exec } "
598 (define (lily-def key val)
600 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
601 (string-append "/" key " {" val "} bind def\n")
602 (string-append "/" key " (" val ") def\n")
606 (define (header creator generate)
609 "%%Creator: " creator generate "\n"))
611 (define (invoke-char s i)
613 "(\\" (inexact->string i 8) ") " s " " ))
615 (define (invoke-dim1 s d)
617 (number->string (* d (/ 72.27 72))) " " s ))
619 (define (placebox x y s)
621 (number->string x) " " (number->string y) " {" s "} placebox "))
623 (define (bezier-sandwich l thick)
625 (apply string-append (map control->string l))
626 (number->string thick)
627 " draw_bezier_sandwich"))
629 (define (start-line height)
632 (define (stem breapth width depth height)
633 (string-append (numbers->string (list breapth width depth height))
640 (string-append "(" s ") show "))
643 (define (volta h w thick vert_start vert_end)
645 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
648 (define (tuplet ht gap dx dy thick dir)
650 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
659 (cond ((eq? action-name 'all-definitions)
662 (define tuplet ,tuplet)
663 (define bracket ,bracket)
665 (define crescendo ,crescendo)
666 (define volta ,volta)
667 (define bezier-sandwich ,bezier-sandwich)
668 (define dashed-line ,dashed-line)
669 (define dashed-slur ,dashed-slur)
670 (define decrescendo ,decrescendo)
671 (define end-output ,end-output)
672 (define experimental-on ,experimental-on)
673 (define filledbox ,filledbox)
674 (define font-def ,font-def)
675 (define font-switch ,font-switch)
676 (define header-end ,header-end)
677 (define lily-def ,lily-def)
678 (define font-load-command ,font-load-command)
679 (define header ,header)
680 (define invoke-char ,invoke-char)
681 (define invoke-dim1 ,invoke-dim1)
682 (define placebox ,placebox)
683 (define select-font ,select-font)
684 (define start-line ,start-line)
686 (define stop-line ,stop-line)
687 (define stop-last-line ,stop-line)
690 ((eq? action-name 'tuplet) tuplet)
691 ((eq? action-name 'beam) beam)
692 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
693 ((eq? action-name 'bracket) bracket)
694 ((eq? action-name 'char) char)
695 ((eq? action-name 'crescendo) crescendo)
696 ((eq? action-name 'dashed-line) dashed-line)
697 ((eq? action-name 'dashed-slur) dashed-slur)
698 ((eq? action-name 'decrescendo) decrescendo)
699 ((eq? action-name 'experimental-on) experimental-on)
700 ((eq? action-name 'filledbox) filledbox)
701 ((eq? action-name 'select-font) select-font)
702 ((eq? action-name 'volta) volta)
703 (else (error "unknown tag -- PS-SCM " action-name))
708 (define (arg->string arg)
709 (cond ((number? arg) (inexact->string arg 10))
710 ((string? arg) (string-append "\"" arg "\""))
711 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
713 (define (func name . args)
719 (map (lambda (x) (string-append " " (arg->string x))) args)))
725 (inexact->exact (/ x (abs x)))))
728 (define (as-scm action-name)
730 (define (beam width slope thick)
732 (func "set-line-char" "#")
733 (func "rline-to" width (* width slope))
737 (define (bezier-sandwich l thick)
744 (dy (- (cdr c3) (cdr c0)))
746 (c1-dx (- (car c1) x))
747 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
748 (dir (if (< c1-line-y (cdr c1)) 1 -1))
749 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
751 (func "rmove-to" x y)
752 (func "put" (if (< 0 dir) "/" "\\\\"))
753 (func "rmove-to" 1 (if (< 0 dir) 1 0))
754 (func "set-line-char" "_")
755 (func "h-line" (- dx 1))
756 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
757 (func "put" (if (< 0 dir) "\\\\" "/"))))))
759 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
761 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
763 (func "set-line-char" "|")
764 (func "rmove-to" 0 1)
765 (func "v-line" (+ height 1))
766 (func "rmove-to" 0 (+ height 1))
776 (define (experimental-on)
779 (define (filledbox breapth width depth height)
780 (let ((dx (+ width breapth))
781 (dy (+ depth height)))
783 (func "rmove-to" (* -1 breapth) (* -1 depth))
786 (func "set-line-char"
787 (if (<= dx 1) "|" "#"))
790 (func "set-line-char"
791 (if (<= dy 1) "-" "="))
792 (func "h-line" dx))))))
794 (define (font-load-command name-mag command)
795 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
797 (define (header creator generate)
798 (func "header" creator generate))
803 ;; urg: this is good for half of as2text's execution time
804 (define (xlily-def key val)
805 (string-append "(define " key " " (arg->string val) ")\n"))
807 (define (lily-def key val)
809 (or (equal? key "mudelapaperlinewidth")
810 (equal? key "mudelapaperstaffheight"))
811 (string-append "(define " key " " (arg->string val) ")\n")
814 (define (placebox x y s)
815 (let ((ey (inexact->exact y)))
816 (string-append "(move-to " (number->string (inexact->exact x)) " "
817 (if (= 0.5 (- (abs y) (abs ey)))
822 (define (select-font font-name-symbol)
823 (let* ((c (assoc font-name-symbol font-name-alist)))
828 "Programming error: No such font known "
829 (car font-name-symbol)))
830 "") ; issue no command
831 (func "select-font" (car font-name-symbol)))))
833 (define (start-line height)
834 (func "start-line" height))
842 (define (volta h w thick vert-start vert-end)
845 (func "set-line-char" "|")
846 (func "rmove-to" 0 -4)
847 ;; definition strange-way around
851 (func "rmove-to" 1 h)
852 (func "set-line-char" "_")
853 (func "h-line" (- w 1))
854 (func "set-line-char" "|")
857 (func "rmove-to" (- w 1) (* -1 h))
858 (func "v-line" (* -1 h)))
861 (cond ((eq? action-name 'all-definitions)
864 (define bracket ,bracket)
866 ;;(define crescendo ,crescendo)
867 (define bezier-sandwich ,bezier-sandwich)
868 ;;(define dashed-slur ,dashed-slur)
869 ;;(define decrescendo ,decrescendo)
870 (define end-output ,end-output)
871 (define experimental-on ,experimental-on)
872 (define filledbox ,filledbox)
873 ;;(define font-def ,font-def)
874 (define font-load-command ,font-load-command)
875 ;;(define font-switch ,font-switch)
876 (define header ,header)
877 (define header-end ,header-end)
878 (define lily-def ,lily-def)
879 ;;(define invoke-char ,invoke-char)
880 ;;(define invoke-dim1 ,invoke-dim1)
881 (define placebox ,placebox)
882 (define select-font ,select-font)
883 (define start-line ,start-line)
884 ;;(define stem ,stem)
885 (define stop-line ,stop-line)
886 (define stop-last-line ,stop-line)
888 ;;(define tuplet ,tuplet)
889 (define volta ,volta)
891 ;;((eq? action-name 'tuplet) tuplet)
892 ;;((eq? action-name 'beam) beam)
893 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
894 ;;((eq? action-name 'bracket) bracket)
895 ((eq? action-name 'char) char)
896 ;;((eq? action-name 'crescendo) crescendo)
897 ;;((eq? action-name 'dashed-slur) dashed-slur)
898 ;;((eq? action-name 'decrescendo) decrescendo)
899 ;;((eq? action-name 'experimental-on) experimental-on)
900 ((eq? action-name 'filledbox) filledbox)
901 ((eq? action-name 'select-font) select-font)
902 ;;((eq? action-name 'volta) volta)
903 (else (error "unknown tag -- MUSA-SCM " action-name))
908 (define (gulp-file name)
909 (let* ((port (open-file name "r"))
910 (content (let loop ((text ""))
911 (let ((line (read-line port)))
912 (if (or (eof-object? line)
915 (loop (string-append text line "\n")))))))
919 ;; urg: Use when standalone, do:
920 ;; (define (ly-gulp-file name) (scm-gulp-file name))
921 (define (scm-gulp-file name)
923 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
924 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
926 (let ((path (%search-load-path name)))
931 (define (scm-tex-output)
932 (eval (tex-scm 'all-definitions)))
934 (define (scm-ps-output)
935 (eval (ps-scm 'all-definitions)))
937 (define (scm-as-output)
938 (eval (as-scm 'all-definitions)))
940 ; Russ McManus, <mcmanus@IDT.NET>
942 ; I use the following, which should definitely be provided somewhere
943 ; in guile, but isn't, AFAIK:
947 (define (hash-table-for-each fn ht)
949 ((= i (vector-length ht)))
950 (do ((alist (vector-ref ht i) (cdr alist)))
952 (fn (car (car alist)) (cdr (car alist))))))
954 (define (hash-table-map fn ht)
957 ((= i (vector-length ht)) (reverse ret-ls))
958 (do ((alist (vector-ref ht i) (cdr alist)))
960 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
964 (define (index-cell cell dir)
970 ; How should a bar line behave at a break?
972 (define (break-barline glyph dir)
973 (let ((result (assoc glyph
974 '((":|:" . (":|" . "|:"))
977 ("|:" . ("|" . "|:"))
978 ("|." . ("|." . nil))
979 (":|" . (":|" . nil))
980 ("||" . ("||" . nil))
981 (".|." . (".|." . nil))
982 ("scorebar" . (nil . "scorepostbreak"))
983 ("brace" . (nil . "brace"))
984 ("bracket" . (nil . "bracket"))
988 (if (equal? result #f)
989 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
990 (index-cell (cdr result) dir))
995 (define (slur-ugly ind ht)
1000 (> ht (+ (* 2 ind) -4))
1001 (< ht (+ (* -2 ind) 8)))