Printing bar numbers inside boxes or circles
Bar numbers can also be printed inside boxes or circles.
\relative c' {
% Prevent bar numbers at the end of a line and permit them elsewhere
\override Score.BarNumber.break-visibility = #end-of-line-invisible
\set Score.barNumberVisibility = #(every-nth-bar-number-visible 4)
% Increase the size of the bar number by 2
\override Score.BarNumber.font-size = 2
% Draw a box round the following bar number(s)
\override Score.BarNumber.stencil
= #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
\repeat unfold 5 { c1 }
% Draw a circle round the following bar number(s)
\override Score.BarNumber.stencil
= #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
\repeat unfold 4 { c1 } \bar "|."
}