]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/lily.scm
release: 1.1.46
[lilypond.git] / scm / lily.scm
index a07a1fcd7e22ac573e6fd52da99467c7d84c77de..cc68e713a0c73d9d5a788dd391e02b6c4f3ad1e3 100644 (file)
   (string-append 
    (map (lambda (n) (string-append (number->string n ) " ")) l)))
 
+(define (reduce operator list)
+      (if (null? (cdr list)) (car list)
+         (operator (car list) (reduce operator (cdr list)))
+         )
+      )
+
+
+(define (glue-2-strings a b) (string-append a " " b))
+
 (define
   (numbers->string l)
-  (apply string-append 
-        (map (lambda (n) (string-append (number->string n) " ")) l)))
+  (reduce glue-2-strings (map number->string l)))
 
 (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
 
 (define (spanbar_non_postbreak_visibility d) (if (= d -1) '(#t . #t) '(#f . #f)))
 
 (define (non_postbreak_visibility d) (if (= d 1) '(#t . #t) '(#f . #f)))
+(define (non_prebreak_visibility d) (if (= d -1) '(#t . #t) '(#f . #f)))
 
 
 ;; Score_span_bars are only visible at start of line
 ;; i.e. if break_dir == RIGHT == 1
 (define Span_bar_engraver_visibility non_postbreak_visibility)
-
+(define mark-visibility non_prebreak_visibility)
 (define Span_score_bar_engraver_visibility postbreak_only_visibility)
 (define Piano_bar_engraver_visibility postbreak_only_visibility)
 (define Staff_group_bar_engraver_visibility postbreak_only_visibility)
 
-
-
+;; Spacing constants for prefatory matter.
+;;
+;; rules for this are complicated. See [Wanske] page 126 -- 134
+;;
+;;
+(define space-alist
+ '(
+   (("Clef_item" "Key_item") .  2.5)
+   (("Key_item" "Time_signature") . 2.5)
+   (("Clef_item"  "Time_signature") . 2.75)
+   (("Staff_bar" "Clef_item") .  1.0)
+   (("Clef_item"  "Staff_bar") . 3.7)
+   (("Time_signature" "Staff_bar") . 2.0)
+   (("Key_item"  "Staff_bar") . 2.5)
+   (("Span_bar" "Clef_item") .  1.0)
+   (("Clef_item"  "Span_bar") . 3.7)
+   (("Time_signature" "Span_bar") . 2.0)
+   (("Key_item"  "Span_bar") . 2.5)
+   (("Staff_bar" "Time_signature") . 1.0)
+   )
+ )
+
+(define (break-align-spacer this next)
+  (let ((entry (assoc `(,this ,next) space-alist)))
+    (if entry
+       (cdr entry)
+       (begin (ly-warn (string-append "Unknown spacing pair " this ", " next))
+              0.0))))
+  
+       
 
 ;;;;;;;; TeX
 
     ("volta" . "feta-nummer"))
 )
 
+(define script-alist '())
+(define (articulation-to-scriptdef a)
+  (assoc a script-alist)
+  )
 
 ;; Map style names to TeX font names.  Return false if 
 ;; no font name found. 
                  (set! font-cmd (cached-fontname font-count))
                  (set! font-alist (acons font-name font-cmd font-alist))
                  (set! font-count (+ 1 font-count))
+                 (if (equal? font-name "")
+                     (error "Empty fontname -- SELECT-FONT"))
                  (string-append "\\font" font-cmd "=" font-name font-cmd))
                (cdr font-cmd)))
          ""                            ;no switch needed
 
   (define (number->dim x)
     (string-append 
-     (number->string  (chop-decimal x)) "pt "))
+     (number->string  (chop-decimal x)) " pt "))
 
   (define (placebox x y s) 
     (string-append 
     (embedded-ps ((ps-scm 'bezier-sandwich) l)))
 
 
-  (define (start-line)
+  (define (start-line ht)
     (begin
       (clear-fontcache)
-      "\\hbox{%\n")
+      (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
     )
-
+  (define (stop-line) 
+    "}\\vss}\\interscoreline")
+  (define (stop-last-line)
+    "}\\vss}")
   (define (filledbox breapth width depth height) 
     (string-append 
      "\\kern" (number->dim (- breapth))
      "depth " (number->dim depth)
      "height " (number->dim height) " "))
 
-  (define (stop-line) 
-    "}\\interscoreline")
 
 
   (define (text s)
     (string-append "\\hbox{" (output-tex-string s) "}"))
   
-  (define (tuplet dx dy thick dir)
-    (embedded-ps ((ps-scm 'tuplet) dx dy thick dir)))
+  (define (tuplet ht dx dy thick dir)
+    (embedded-ps ((ps-scm 'tuplet) ht dx dy thick dir)))
 
   (define (volta w thick last)
     (embedded-ps ((ps-scm 'volta) w thick last)))
            (define select-font ,select-font)
            (define start-line ,start-line)
            (define stop-line ,stop-line)
+           (define stop-last-line ,stop-last-line)
            (define text ,text)
            (define tuplet ,tuplet)
            (define volta ,volta)
        ((eq? action-name 'start-line) start-line)
        ((eq? action-name 'stem) stem)
        ((eq? action-name 'stop-line) stop-line)
+       ((eq? action-name 'stop-last-line) stop-last-line)
        ((eq? action-name 'volta) volta)
        (else (error "unknown tag -- PS-TEX " action-name))
        )
   
   (define (cached-fontname i)
     (string-append
-     "lilyfont"
+     " lilyfont"
      (make-string 1 (integer->char (+ 65 i)))))
 
   (define (select-font font-name)
      (numbers->string (list width slope thick)) " draw_beam " ))
 
   (define (bracket h)
-    (invoke-dim1 "draw_bracket" h))
+    (invoke-dim1 " draw_bracket" h))
 
   (define (char i)
-    (invoke-char "show" i))
+    (invoke-char " show" i))
 
   (define (crescendo w h cont)
     (string-append 
      (numbers->string (list w h (inexact->exact cont)))
-     "draw_crescendo"))
+     " draw_crescendo"))
 
   (define (dashed-slur thick dash l)
     (string-append 
   (define (decrescendo w h cont)
     (string-append 
      (numbers->string (list w h (inexact->exact cont)))
-     "draw_decrescendo"))
+     " draw_decrescendo"))
 
 
   (define (end-output)
   
   (define (filledbox breapth width depth height) 
     (string-append (numbers->string (list breapth width depth height))
-                  "draw_stem" ))
+                  " draw_box" ))
 
   ;; obsolete?
   (define (font-def i s)
     (string-append 
      (number->string x) " "
      (number->string y) " "
-     "rulesym"))
+     " rulesym"))
 
   (define (bezier-sandwich l)
     (string-append 
      (apply string-append (map control->string l)) 
      " draw_bezier_sandwich"))
 
-  (define (start-line)
+  (define (start-line height)
     (begin
       (clear-fontcache)
       "\nstart_line {\n"))
   
   (define (stem breapth width depth height) 
     (string-append (numbers->string (list breapth width depth height))
-                  "draw_stem" ))
+                  " draw_box" ))
 
   (define (stop-line)
       "}\nstop_line\n")
   (define (volta w thick last)
     (string-append 
      (numbers->string (list w thick (inexact->exact last)))
-     "draw_volta"))
+     " draw_volta"))
 
-  (define (tuplet dx dy thick dir)
+  (define (tuplet ht dx dy thick dir)
     (string-append 
-     (numbers->string (list dx dy thick (inexact->exact dir)))
-     "draw_tuplet"))
+     (numbers->string (list ht dx dy thick (inexact->exact dir)))
+     " draw_tuplet"))
 
 
   (define (unknown) 
            (define start-line ,start-line)
            (define stem ,stem)
            (define stop-line ,stop-line)
+           (define stop-last-line ,stop-line)
            (define text ,text)
            ))
        ((eq? action-name 'tuplet) tuplet)
        (else (error "unknown tag -- PS-SCM " action-name))
        )
   )
-  
 
-;
+                                       ;
 ; Russ McManus, <mcmanus@IDT.NET>  
 ; 
 ; I use the following, which should definitely be provided somewhere