On 24/12/2025 00:13, Paul Scott wrote:
I am still curious if there is a way to do it the way I originally tried:

setA = { \temporary \override Score.BarNumber.stencil = "A" }

Initially I expected to be able to override Score.BarNumber.stencil and Score.BarNumber.text, but Score.BarNumber.text is modified behind the scenes to be currentBarNumber by the time the stencil is executed. I've added an extra grob property to hold markup for the special bar number and used it in the stencil function.

\version "2.24.0"

#(set-object-property! 'barletter 'backend-type? markup?)

#(define (letter_stencil grob)
  (let ((letter (ly:grob-property grob 'barletter #f)))
    (when letter (ly:grob-set-property! grob 'text letter)))
  (ly:text-interface::print grob))

{
  \override Score.BarNumber.break-visibility = ##(#f #t #t)
  \override Score.BarNumber.stencil = #letter_stencil
  c''1 c''1
  \once \override Score.BarNumber.barletter = \markup \large \italic "X"
  c''1 c''1
  \once \override Score.BarNumber.barletter = \markup \box \bold "Y"
  c''1 c''1
}

--
Timothy Lanfear, Bristol, UK.

Reply via email to