I posted a snippet to do correct custom dynamic alignment a month or so ago.
I haven't had time to integrate it into the OpenLilyLib snippet, but here's
my code:

\version "2.18.2"

dynText = #(define-event-function (parser location dyn expr) (markup?
markup?)
             (let* (
                     (mark #{ \markup { \dynamic $dyn \normal-text\italic
$expr } #})
                     (offset (lambda (grob)
                               (let* (
                                       (layout (ly:grob-layout grob))
                                       (props (ly:grob-alist-chain grob
                                                (ly:output-def-lookup layout
'text-font-defaults)))
                                       (dyn-X-extent
                                        (ly:stencil-extent
                                        
(ly:text-interface::interpret-markup layout props dyn)
                                         X))
                                       (width (abs
                                               (- (cdr dyn-X-extent) (car
dyn-X-extent))))
                                       )
                                 (- 1 (/ width 2))
                                 )
                               )
                       )
                     )
               #{
                 \tweak DynamicText.X-offset #offset
                 #(make-dynamic-script mark) 
               #}
               )
             )

%%  Example

\paper {
  ragged-right = ##f
  indent = 0\cm
}

\new Staff \with {
  \omit TimeSignature
} \relative c' {
  c1\dynText "p" "sub."
  c1\dynText "fff" "espressivo"
  c1\dynText "p" "espressivo"
  c1\dynText "fffff" "sub."
  \break
  c1\p
  c1\fff
  c1\p
  c1\fffff
}

I tried just copy and pasting my offset callback into Janek's snippet, but
it doesn't quite work because the callback relies on assuming the dynamic is
at the beginning, and any additional text follows it.




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/improving-Janek-s-dynamic-function-for-combo-dynamics-tp205071p205179.html
Sent from the User mailing list archive at Nabble.com.

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

Reply via email to