rest-height)
(- space-left stretch)))))
+ (define (total-padding systems)
+ (let ((layout (ly:paper-book-paper paper-book)))
+ (if (or (null? systems)
+ (null? (cdr systems)))
+ 0.0
+ (+ (line-next-padding (car systems) (cadr systems) layout)
+ (total-padding (cdr systems))))))
+
(let* ((page (make-page paper-book
'page-number page-number
'is-last last))
; yet, etc. If we overstretch because of underestimation, the result
; is very bad. So we stick in some extra space, just to be sure.
(buffer (/ height 10.0))
- (total-system-height (apply + (map height-estimate systems)))
+ (total-system-height (+ (apply + (map height-estimate systems))
+ (total-padding systems)))
(height-left (- height total-system-height buffer)))
- (if (not ragged)
+ (if (and
+ (not ragged)
+ (> height-left 0))
(set-line-stretch! (sort systems
(lambda (s1 s2)
(< (height-estimate s1)
(height-estimate s2))))
(apply + (map height-estimate
(filter stretchable? systems)))
- (- (page-printable-height page)
- total-system-height)))
+ height-left))
(let* ((lines (map print-system systems))
(posns (if (null? lines)
`next-line' can be #f, meaning that `line' is the last line."
(let* ((title (paper-system-title? line))
(next-title (and next-line (paper-system-title? next-line))))
- (cond ((and title next-title)
- (ly:output-def-lookup layout 'between-title-space))
- (title
- (ly:output-def-lookup layout 'after-title-space))
- (next-title
- (ly:output-def-lookup layout 'before-title-space))
- (else
- (ly:prob-property
- line 'next-space
- (ly:output-def-lookup layout 'between-system-space))))))
+ (ly:prob-property
+ line 'next-space
+ (ly:output-def-lookup layout
+ (cond ((and title next-title) 'between-title-space)
+ (title 'after-title-space)
+ (next-title 'before-title-space)
+ (else 'between-system-space))))))
(define (line-next-padding line next-line layout)
"Return padding to use between `line' and `next-line'.
`next-line' can be #f, meaning that `line' is the last line."
- (ly:prob-property
- line 'next-padding
- (ly:output-def-lookup layout 'between-system-padding)))
+ (let ((default (ly:output-def-lookup layout 'between-system-padding)))
+ (if (ly:grob? line)
+ (let* ((details (ly:grob-property line 'line-break-system-details))
+ (padding (assq 'next-padding details)))
+ (if padding
+ (cdr padding)
+ default))
+ (ly:prob-property line 'next-padding default))))
(define (line-minimum-distance line next-line layout ignore-padding)
"Ideal distance between `line' reference position and `next-line'
reference position. If next-line is #f, return #f."
(and next-line
- (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
- (if ignore-padding 0 (line-next-padding line next-line layout)))
- (interval-start (paper-system-staff-extents line))))
- (line-next-space line next-line layout))))
+ (max (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
+ (if ignore-padding 0 (line-next-padding line next-line layout)))
+ (interval-start (paper-system-staff-extents line))))
+ (line-next-space line next-line layout))
+ (line-minimum-distance line next-line layout ignore-padding))))
(define (first-line-position line layout)
"Position of the first line on page"
'())))
(springs (map (lambda (prev-line line)
(list (line-ideal-distance prev-line line paper ignore-padding)
- (/ 1.0 (line-next-space prev-line line paper))))
+ (line-next-space prev-line line paper)))
lines
cdr-lines))
(rods (map (let ((i -1))