2016-07-06 4:26 GMT+02:00 Br. Gabriel-Marie | SSPX <brgabr...@sspx.org>:
> Sorry, I didn't realize embedded images didn't show.  I've attached them
> this time.
>
> On 7/5/2016 9:10 PM, Br. Gabriel-Marie | SSPX wrote:
>
> Mr. Morley,
>
> I want to achieve the numbering to line up at the front of the lyrics.  The
> script that your other self created to number the stanza lines does not line
> them up - it does, indeed, get the numbering, but not the justification of
> the numbers.
>
> That's why I haven't given up using instrumentName for the numbering.
> instrumentName will line up the numbers at the front.  (Problem with this,
> as I've mentioned, is that if the clef does not have the extra spacing
> provided by the three sharps in the key signature, then the lyrics can
> overlap the numbers.  )
>
> You can see in the second attachment the difference here.  If the words are
> longer then the numbers move and don't line up with the numbers on the next
> staff.
>
>
> On 7/5/2016 2:08 PM, Thomas Morley wrote:
>
> It's not clear to me at which position exactly?
> Below (if any) the Clef, KeySignature/Cancellation, TimeSignature,
> BarLine or else?
> Righ-/center-/left-aligned?
>
> Let's clear that first and then look for a method to avoid collisions.
>
> Cheers,
>   Harm
>
>

Attached best I currently can think of.
Though, please always provide tiny examples matching the images you post.

-Harm
\version "2.19.44"

%% REMARK:
%% Using instrument-names _and_ setting an invisible stanza with a certain 
%% extent at line-begin to avoid collisions

%% Thanks to David Nalesnik
%% http://lists.gnu.org/archive/html/lilypond-user/2016-07/msg00028.html

#(define create-stanza-number-grob-engraver
;; puts out a StanzaNumber for every LyricText-grob
  (lambda (context)
    (let ((stanza (ly:context-property context 'stanza)))
      `((acknowledgers
          (lyric-syllable-interface .
            ,(lambda (engraver grob source-engraver)
              (let ((new-stanza-grob 
                      (ly:engraver-make-grob engraver 'StanzaNumber '())))
              (ly:grob-set-property! new-stanza-grob 'text stanza)))))))))

#(define (at-line-beginning? grob)
   (let* ((col (ly:item-get-column grob))
          (ln (ly:grob-object col 'left-neighbor))
          (col-to-check (if (ly:grob? ln) ln col)))
     (and (eq? #t (ly:grob-property col-to-check 'non-musical))
          (= 1 (ly:item-break-dir col-to-check)))))

#(define (keep-at-line-begin grob)
   (if (and (ly:item? grob) (not (at-line-beginning? grob)))
       (ly:grob-suicide! grob)
       grob))

keepLineStartStanzaNumbers =
\layout {
  \context {
  \Lyrics
  \override StanzaNumber.after-line-breaking =
    #keep-at-line-begin
  }
}

numberLyrics =
#(define-scheme-function (instr-name move)(number? number?)
"Return a context-modification setting @code{stanza} and consisting 
@code{create-stanza-number-grob-engraver}, as well as @code{instrumentName} and
@code{shortInstrumentName}.
The latter prints the numbering using @var{instr-name}, the first is used to 
push the lyrics to the right, using @var{move}.
"
#{
  \with {
    %stanza = \markup \italic #(format #f "~a." nmbr)
    stanza = \markup \combine \null \translate #(cons move  0) \null
    \consists #create-stanza-number-grob-engraver
	instrumentName = #(format #f "~a." instr-name)
	shortInstrumentName = #(format #f "~a." instr-name)
  }
#})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\score {
  <<
    \new Staff { \key cis \major \repeat unfold 6 {  c''4 d'' e'' } }
    \new Lyrics 
      \with {
        \numberLyrics 1 3.5
	  }
      \lyricmode {
        \repeat unfold 6 {  foo -- bar -- buzz }
      }
      
    \new Lyrics  
      \with {
        \numberLyrics 2 3.5
	  }
      \lyricmode {
        \repeat unfold 6 {  very-very-long-syllable bur -- buuuzz }
      }
      
    \new Lyrics  
      \with {
        \numberLyrics 3 3.5
	  }
      \lyricmode {
        \repeat unfold 6 {  fuu -- bla -- blibbb }
      }
  >>
  \layout { 
  	  \keepLineStartStanzaNumbers 
  	  \context {
  	    \Lyrics 
  	    \override InstrumentName.X-offset = 2
  	  }
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to