As is tradition, I am almost certainly over-engineering here. However,
would the following approach be of any use:
%%%%
\version "2.20.0"
transformText =
#(define-music-function
(grob-path proc)
((key-list? 'TextScript) procedure?)
#{ \override $grob-path . before-line-breaking =
#(grob-transformer 'before-line-breaking
(lambda (grob orig)
(ly:grob-set-property! grob 'text
(proc (ly:grob-property grob 'text))))) #})
boxIt = #(lambda (text) (markup #:box text))
flipIt = #(lambda (text) (markup #:rotate 180 text))
sizeIt =
#(define-scheme-function (size) (number?)
(lambda (text) (markup #:abs-fontsize size text)))
\layout {
\context {
\Staff
\transformText \sizeIt #8
}
}
\score {
\new Staff { b'2.^"Lorem" \once \transformText \boxIt b'4_"ipsum" }
\layout { #(layout-set-staff-size 8) }
}
\score {
\new Staff { b'2.^"Lorem" b'4_"ipsum" }
\layout { #(layout-set-staff-size 13) }
}
\score {
\new Staff { \once \transformText \flipIt b'2.^"Lorem" b'4_"ipsum" }
\layout { #(layout-set-staff-size 21) }
}
%%%%
That's great too!