Hello all,

The snippet below includes Janek's \dynamic function, which has a rather lovely 
interface.
Unfortunately, it doesn't align leading dynamics as expected (i.e., centered on 
the notehead).

What's the easiest way to fix the function so that it does?

Thanks,
Kieren.

%%%  SNIPPET BEGINS
\version "2.19.64"

#(use-modules (ice-9 regex))

dynamic =
#(define-event-function (text) (markup?)
   (if (string? text)
       (let* ((underscores-replaced
               (string-map
                (lambda (x) (if (eq? x #\_) #\space x))
                text))
              (split-text (string-split underscores-replaced #\space))
              (formatted (map
                          (lambda (word)
                            (if (string-match "^[mrzfps]*$" word)
                                (markup #:dynamic word #:hspace 0.25)
                                (markup #:normal-text #:fontsize 0.625 #:italic 
word)))
                          split-text)))
         #{
           -\tweak X-offset #0
               #(make-dynamic-script (make-line-markup formatted))
         #})

       ;; user provided a full-blown markup, so we don't mess with it:
       #{
         #(make-dynamic-script (markup #:normal-text #:fontsize 0.625 text))
       #}))

<<
  \new Staff { c''\dynamic "fffff testing" }
  \new Staff { c''\fffff }
>>
%%%  SNIPPET ENDS
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to