lilypond-user
[Top][All Lists]
Advanced

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

horizontal alignment of custom stencil


From: Mark Knoop
Subject: horizontal alignment of custom stencil
Date: Mon, 23 Jun 2014 10:26:29 +0100

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 }
    >>
    #})

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
    \override MeasureCounter.direction = #UP
    \override MeasureCounter.font-encoding = #'latin1
    \override MeasureCounter.font-size = #1
  }
}

\new Staff {
  \repeat unfold 8 { c'4 }
  \time 5/4
  \repeatBars 40 { d' e' f' g' a' }
  \time 4/4
  \repeat unfold 8 { c'4 }
  \break
  \time 5/4
  \repeatBars 40 { d' e' f' g' a' }
  \time 4/4
  \repeat unfold 20 { c'4 }
  \break
  \repeatBars 40 { d' e' f' g' }
  \repeat unfold 20 { c'4 }
}


--
Mark Knoop



reply via email to

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