lilypond-user
[Top][All Lists]
Advanced

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

Re: Center-align a score


From: Thomas Morley
Subject: Re: Center-align a score
Date: Sat, 29 Apr 2017 00:15:08 +0200

2017-04-28 17:39 GMT+02:00 David Nalesnik <address@hidden>:

> It would be relatively easy to alter the function make-page-stencil in
> scm/page.scm to do what you want.  The stencils of the individual
> systems are already made at this point, and it's just a matter of
> moving them around to your liking.  Unfortunately, this requires a
> change to program files.  I've had no luck copy/pasting code from that
> file into the LY file.

It may be possible if one could get access to the (scm page)-module.
Though, I had no luck with this either.

Nevertheless, below probably a method to avoid ly:grob-extent's side-effects:



\version "2.19.59"

\paper {
  ragged-right = ##t
  indent = 0
}

centerLines =
  \override NonMusicalPaperColumn.after-line-breaking =
    #(lambda (grob)
       (if (eqv? (ly:item-break-dir grob) 1) ; line beginning
           (let* ((sys (ly:grob-system grob))
                  ;; filter for StaffSymbol-grobs
                  (staff-symbols
                    (filter
                      (lambda (grob)
                        (grob::has-interface grob 'staff-symbol-interface))
                      (ly:grob-array->list (ly:grob-object sys 'all-elements))))
                  ;; StaffSymbols may start/end during same system
                  ;; Best bet is to look for the most left/right start/end-coord
                  (min-max
                    (lambda (list-of-pairs)
                      (cons
                        (reduce min +inf.0 (map car list-of-pairs))
                        (reduce max -inf.0 (map cdr list-of-pairs)))))
                  (line-width
                    (interval-length
                      (min-max
                        (map
                          (lambda (g) (ly:grob-property g 'X-extent))
                          staff-symbols))))
                  (layout (ly:grob-layout grob))
                  (line-full-width (ly:output-def-lookup layout 'line-width)))
             (ly:grob-set-nested-property! grob
               '(line-break-system-details X-offset)
               (/ (- line-full-width line-width) 2)))))

\layout {
  \context {
    \Score
    \centerLines
    \override BarNumber.stencil = ##f
  }
}

\score {
    \new Staff \with {
        \override StaffSymbol.line-count = #1
        \omit Staff.TimeSignature
        \omit Staff.Clef
    }
    {
        b'4 b' b'2 \break
        b'4 b' b'2 \break
        b'4 b' b' b' b' b' b'2 \break

    }
    \addlyrics {
        Häns -- chen klein
        ging al -- lein
        in die wei -- te Welt hi -- nein
    }
}


Cheers,
  Harm



reply via email to

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