[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Example of two-pass vertical spacing tweaking
From: |
Nicolas Sceaux |
Subject: |
Example of two-pass vertical spacing tweaking |
Date: |
Sat, 04 Mar 2006 11:40:30 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
Hi,
Here is an example showing how to use the two-pass vertical spacing
feature. (It cannot be added to LSR, which uses version 2.6).
nicolas
\version "2.7.36"
%{
For the first pass, use the write-tweak option:
$ lilypond -d write-tweaks file.ly
This will write the file-page-layout.ly tweak file.
Second pass:
$ lilypond file.ly
The file-page-layout.ly will be included, and tweaks
used in the score. The file-page-layout.ly file will
not be written.
%}
%%%
%%% utility function for including tweaks depending
%%% on the write-tweak option passed to lilypond
%%%
#(use-modules (srfi srfi-39) (ice-9 format))
#(define *write-tweaks* (make-parameter (ly:get-option 'write-tweaks)))
spacingTweaks =
#(define-music-function (parser location props) (list?)
"Tweak the system vertical stretching, if not asked to write
the page-layout file."
(if (*write-tweaks*)
(make-music 'SequentialMusic)
(let* ((space-left (cdr (assoc 'page-space-left props)))
(music-size (apply + (cdr (assoc 'music-system-heights props))))
(system-size (* -1 (cadr (assoc 'system-Y-extent props))))
(extra-space (/ (* system-size space-left) music-size)))
#{
\overrideProperty #"Score.NonMusicalPaperColumn"
#'line-break-system-details
#$(list (cons 'alignment-extra-space extra-space))
#})))
includePageLayout =
#(define-music-function (parser location) ()
"Include the page-layout file, if not asked to write it."
(if (not (*write-tweaks*))
(let ((tweak-filename (format #f "~a-page-layout.ly"
(ly:parser-output-name parser))))
(if (access? tweak-filename R_OK)
(begin
(format #t "Including tweak file ~a~%" tweak-filename)
(ly:parser-parse-string
parser
(format #f "\\include \"~a\"" tweak-filename))))))
(make-music 'SequentialMusic 'void #t))
includeScoreTweak =
#(define-music-function (parser location name) (string?)
"Include the score tweak, named by name (aa string), if not
asked to write the page layout file."
(if (not (*write-tweaks*))
(let ((tweak-music (ly:parser-lookup parser (string->symbol name))))
(if (ly:music? tweak-music)
tweak-music
(make-music 'SequentialMusic)))
(make-music 'SequentialMusic)))
\paper {
ragged-bottom = ##t
ragged-last-bottom = ##t
annotate-spacing = #(*write-tweaks*)
#(define write-page-layout (ly:get-option 'write-tweaks))
}
%%%
%%% The scores
%%%
\includePageLayout
\score {
\new StaffGroup <<
\new Staff << \includeScoreTweak "A"
{ \clef french c''1 \break c''1 } >>
\new Staff { \clef soprano g'1 g'1 }
\new Staff { \clef mezzosoprano e'1 e'1 }
\new Staff { \clef alto g1 g1 }
\new Staff { \clef bass c1 c1 }
>>
\header {
title = "Score A"
}
\layout { #(define tweak-key "A") }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Example of two-pass vertical spacing tweaking,
Nicolas Sceaux <=