Le 16/01/2023 à 16:57, Kieren MacMillan a écrit :
Hi all,In any case, please submit this to the LSR!I was *just* going to look at this to see if it could be improved viz-a-viz Jean’s suggestion that callbacks using after-line-breaking are often better done with grob-transformer. [Yes, I know this is *before*-line-breaking…] If so, that should happen before LSR submission, I would think! Maybe Someone™ can just tell me if it’s worth investigating or not…?
In this case, you cannot use \override TextScript.text = #(grob-transformer 'text ...) because Text_engraver sets the property on the TextScript, so this overwrites
any overrides you might have done. However, you could do
\version "2.24.0"
tsharp = \markup \fontsize #-2 \number "♯"
tflat = \markup \fontsize #-2 \number "♭"
tnatural = \markup \fontsize #-2 \number "♮"
\new Staff {
\override TextScript.stencil =
#(lambda (grob)
(let ((text (ly:grob-property grob 'text)))
(grob-interpret-markup
grob
#{ \markup \replace #`(("♭" . ,#{ \markup \tflat #})
("♯" . ,#{ \markup \tsharp #})
("♮" . ,#{ \markup \tnatural #}))
#text #})))
c'1^"B♭"
c'1^"C♯"
c'1^"D♮"
}
Although it's probably simplest to do
\version "2.24.0"
\paper {
#(add-text-replacements!
`(("♯" . ,#{ \markup \fontsize #-2 \number "♯" #})
("♭" . ,#{ \markup \fontsize #-2 \number "♭" #})
("♮" . ,#{ \markup \fontsize #-2 \number "♮" #})))
}
\markup { A♯ B♭ C♮ }
\score {
\header {
piece = "Prelude in C♯"
}
{
c'1^"B♭"
c'1^"C♯"
c'1^"D♮"
}
}
As you can see, add-text-replacements! install the replacements
for all places markup can be used, not just for TextScript.
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature
