Mark Knoop <m...@opus11.net> writes: > Hi, > > I'm (mis)using the Measure_counter_engraver to indicate numbers of > repeats, overriding the default stencil with customStencilFromMarkup > from openlilylib. > > Is it possible to adjust the horizontal alignment of the stencil such > that it is always centered on the barline? The current situation varies > depending on line breaks and changing time-signatures - see example > below. > > Any suggestions? > > > \version "2.18.2" > > customStencilFromMarkup = > #(define-music-function (parser location name mrkup) (string? markup?) > (let* ((name (string-regexp-substitute " " "" name)) > ; remove any spaces > (name-components (string-split name #\.)) > (context-name "Voice") > (grob-name #f)) > > (if (> 2 (length name-components)) > (set! grob-name (car name-components)) > (begin > (set! grob-name (cadr name-components)) > (set! context-name (car name-components)))) > #{ > \override $context-name . $grob-name #'stencil = > #(lambda (grob) > (grob-interpret-markup > grob mrkup)) > #})) > > repeatBars = #(define-music-function > (parser location times music) > (number? ly:music?) > (_i "make a repeat structure") > #{ > \customStencilFromMarkup "Staff.MeasureCounter" > \markup \whiteout \box \concat { > \vcenter "×" \vcenter \number #(ly:number->string times) > } > \startMeasureCount > << > \repeat volta #times { $music } > { s16 \stopMeasureCount } > >> > #})
This is not actually an answer to your problem at hand, but all that name-splitting seems tedious. You could just do customStencilFromMarkup = #(define-music-function (parser location name mrkup) (symbol-list? markup?) #{ \override #name . stencil = #(lambda (grob) (grob-interpret-markup grob mrkup)) #}) repeatBars = #(define-music-function (parser location times music) (number? ly:music?) (_i "make a repeat structure") #{ \customStencilFromMarkup Staff.MeasureCounter \markup \whiteout \box \concat { \vcenter "×" \vcenter \number #(ly:number->string times) } \startMeasureCount << \repeat volta #times { $music } { s16 \stopMeasureCount } >> #}) in 2.18. It might be worth considering to exchange the order of name and mrkup and turn name into the type symbol-list-or-music? instead, then use a tweak rather than an override. That way, customStencilFromMarkup could be used as either a tweak or an override. While swapping the argument order is not strictly necessary, combining multiple tweaks becomes awkward fast if the music argument does not come last. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user