4 texidoc
= "Title pages may require to vertically center, stretch or spread markups
5 throughout the full vertical extent of the paper. Here is a function that achieves
6 just that, much like the commonly-used `fill-line' markup command."
12 #(set-paper-size
"a6")
15 #(define-markup-command
(fill-page layout props args
)
17 ;; This code was shamelessly copied from the fill-line function
.
18 #:properties
((text-direction UP
)
22 (define
(get-fill-space line-count page-height line-space text-heights
)
24 ((null? text-heights
) '())
26 ;; special case first padding
27 ((= (length text-heights
) line-count
)
29 (-
(-
(/ page-height
(1- line-count
)) (car text-heights
))
30 (/ (car
(cdr text-heights
)) 2))
31 (get-fill-space line-count page-height line-space
(cdr text-heights
))))
32 ;; special case last padding
33 ((= (length text-heights
) 2)
34 (list
(-
(/ page-height
(1- line-count
))
35 (+
(/ (car text-heights
) 2) (car
(cdr text-heights
)))) 0))
37 (let
((default-padding
38 (-
(/ page-height
(1- line-count
))
39 (/ (+
(car text-heights
) (car
(cdr text-heights
))) 2))))
41 (if
(> line-space default-padding
)
44 (get-fill-space line-count page-height line-space
(cdr text-heights
)))))))
46 (let
* ((orig-stencils
(interpret-markup-list layout props args
))
49 (if
(ly
:stencil-empty? stc
)
54 (if
(ly
:stencil-empty? stc
)
56 (interval-length
(ly
:stencil-extent stc Y
))))
58 (text-height
(apply + text-heights
))
59 (line-count
(length stencils
))
60 (page-height
(-
(ly
:output-def-lookup layout
'paper-height
)
61 (+
(ly
:output-def-lookup layout
'top-margin
)
62 (ly
:output-def-lookup layout
'bottom-margin
))))
67 (/ (- page-height text-height
) 2)
68 (/ (- page-height text-height
) 2)))
71 (- page-height text-height
)))
73 (get-fill-space line-count page-height line-space text-heights
))))
75 (page-contents
(if
(= line-count
1)
82 (if
(null?
(remove ly
:stencil-empty? orig-stencils
))
85 (if
(= text-direction UP
)
86 (set
! page-contents
(reverse page-contents
)))
88 (stack-stencils-padding-list
89 Y UP fill-space page-contents
))
92 (ly
:stencil-translate-axis
94 (-
(car
(ly
:stencil-extent
(car stencils
) Y
)))
102 \line { on the page
. }