Hi Werner,
> I don't understand, why the \hspace #0 influences the raise
As I understand it, the \hspace defines the height of the entire
markup box -- i.e., it is explicitly taller than either the fermata
or the (e.g.) "1." -- and thus it is this "larger" box (as set by the
height of an \hspace object) that is affected by the spacing code.
You can also use this hint to line up custom dynamics with opposing
descenders and ascenders, e.g.,
pp gorgeous % all descenders
pp fantastic % all ascenders
will not line up "correctly" by default.
Nice. For the last year or so I've been using a transparent-f trick for the same purpose, for example:
pppX = #(make-dynamic-script (markup #:combine
#:transparent #:dynamic "f"
#:line(#:hspace 0 #:dynamic "ppp" #:hspace 0)))
and
fffX = #(make-dynamic-script (markup #:combine
#:transparent #:dynamic "f"
#:line(#:hspace 0 #:dynamic "fff" #:hspace 0)))
It's looks like craziness, but writing c'4 \ppX c'4 \fffX causes the dynamics to align absolutely perfectly once you've set DynamicLineSpanner #'staff-padding.
I have a definition file of nothing but these custom dynamics that I use exclusively. It's been more than a year since I've used a built-in Lily dynamic like \pp or \ff because the vertical alignment with the transparent-f trick is so much better. (I'd actually suggest changing out the default dynamics definitions in the distro, but not sure if that's the behavior anyone else would actually want.)