lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode accidentals vs. Markup accidentals,Re: Unicode accidentals v


From: Jean Abou Samra
Subject: Re: Unicode accidentals vs. Markup accidentals,Re: Unicode accidentals vs. Markup accidentals
Date: Mon, 16 Jan 2023 17:16:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]