Hi Michiel,
Generalising your code so you don't need to create a function with hard coded offsets for every dynamic used and every instance leads to:
== snip
parenOffsetDyn =
#(define-event-function (dyn x-off y-off) (ly:event? number? number?)
(make-dynamic-script
#{ \markup \concat {
\normal-text \italic \fontsize #2 (
\pad-x #0.2 \translate #(cons x-off y-off) #(ly:music-property dyn 'text)
\normal-text \italic \fontsize #2 )
}
#}))
== snip
Example usage:
c\parenOffsetDyn\p 0.2 -0.2
You could play around with this concept. Obviously the offsets will need to be small or else it starts to look poor.
With recent lilypond versions you no longer need to use the parser and location arguments.
Andrew