- lines offsets paper scopes number last? )
- "Construct a stencil representing the page from LINES. "
- (let*
- ((topmargin (ly:output-def-lookup paper 'topmargin))
-
- ;; TODO: naming vsize/hsize not analogous to TeX.
-
- (vsize (ly:output-def-lookup paper 'vsize))
- (hsize (ly:output-def-lookup paper 'hsize))
-
- (lmargin (ly:output-def-lookup paper 'leftmargin))
- (leftmargin (if lmargin
- lmargin
- (/ (- hsize
- (ly:output-def-lookup paper 'linewidth)) 2)))
-
- (rightmargin (ly:output-def-lookup paper 'rightmargin))
- (bottom-edge (- vsize
- (ly:output-def-lookup paper 'bottommargin)))
-
- (head (page-headfoot paper scopes number 'make-header 'headsep UP last?))
- (foot (page-headfoot paper scopes number 'make-footer 'footsep DOWN last?))
- (line-stencils (map ly:paper-system-stencil lines))
- (height-proc (ly:output-def-lookup paper 'page-music-height))
-
- (page-stencil (ly:make-stencil '()
- (cons leftmargin hsize)
- (cons (- topmargin) 0)))
- (was-title #t)
- (add-system (lambda (stencil-position)
- (set! page-stencil
- (ly:stencil-add
- (ly:stencil-translate-axis
- (car stencil-position)
- (- 0
- (cadr stencil-position)
- topmargin)
- Y)
- page-stencil))))
- )
-
-
- (map add-system (zip line-stencils offsets))
- (if (ly:stencil? foot)
+ lines offsets layout scopes number last?)
+ "Construct a stencil representing the page from LINES.
+
+ Offsets is a list of increasing numbers. They must be negated to
+create offsets.
+ "
+
+ (let* ((topmargin (ly:output-def-lookup layout 'topmargin))
+
+ ;; TODO: naming vsize/hsize not analogous to TeX.
+
+ (vsize (ly:output-def-lookup layout 'vsize))
+ (hsize (ly:output-def-lookup layout 'hsize))
+
+ (system-separator-markup (ly:output-def-lookup layout 'systemSeparatorMarkup))
+ (system-separator-stencil (if (markup? system-separator-markup)
+ (interpret-markup layout
+ (layout-extract-page-properties layout)
+ system-separator-markup)
+ #f))
+ (lmargin (ly:output-def-lookup layout 'leftmargin))
+ (leftmargin (if lmargin
+ lmargin
+ (/ (- hsize
+ (ly:output-def-lookup layout 'linewidth)) 2)))
+
+ (rightmargin (ly:output-def-lookup layout 'rightmargin))
+ (bottom-edge (- vsize
+ (ly:output-def-lookup layout 'bottommargin)))
+
+ (head (page-headfoot layout scopes number 'make-header 'headsep UP last?))
+ (foot (page-headfoot layout scopes number 'make-footer 'footsep DOWN last?))
+
+ (head-height (if (ly:stencil? head)
+ (interval-length (ly:stencil-extent head Y))
+ 0.0))
+
+ (height-proc (ly:output-def-lookup layout 'page-music-height))
+
+ (page-stencil (ly:make-stencil '()
+ (cons leftmargin hsize)
+ (cons (- topmargin) 0)))
+ (last-system #f)
+ (last-y 0.0)
+ (add-to-page (lambda (stencil y)
+ (set! page-stencil
+ (ly:stencil-add page-stencil
+ (ly:stencil-translate-axis stencil
+ (- 0 head-height y topmargin) Y)))))
+ (add-system
+ (lambda (stencil-position)
+ (let* ((system (car stencil-position))
+ (stencil (ly:paper-system-stencil system))
+ (y (cadr stencil-position))
+ (is-title (ly:paper-system-title?
+ (car stencil-position))))
+ (add-to-page stencil y)
+ (if (and (ly:stencil? system-separator-stencil)
+ last-system
+ (not (ly:paper-system-title? system))
+ (not (ly:paper-system-title? last-system)))
+ (add-to-page
+ system-separator-stencil
+ (average (- last-y
+ (car (ly:paper-system-staff-extents last-system)))
+ (- y
+ (cdr (ly:paper-system-staff-extents system))))))
+ (set! last-system system)
+ (set! last-y y)))))
+
+ (if #f
+ (display (list
+ "leftmargin " leftmargin "rightmargin " rightmargin
+ )))
+
+ (set! page-stencil (ly:stencil-combine-at-edge
+ page-stencil Y DOWN
+ (if (and
+ (ly:stencil? head)
+ (not (ly:stencil-empty? head)))
+ head
+ (ly:make-stencil "" (cons 0 0) (cons 0 0)))
+ 0. 0.))
+
+ (map add-system (zip lines offsets))
+ (if (and (ly:stencil? foot)
+ (not (ly:stencil-empty? foot)))