From df42883ffddb4b4dd7a532a22e9b9408c011b059 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 21 Aug 2006 23:05:50 +0000 Subject: [PATCH] (make-page-stencil): don't rely on extents of page-stencil. This fixes spurious space around .EPS files produced with the EPS backend. --- ChangeLog | 8 ++++++++ input/regression/page-layout.ly | 7 ++++++- lily/stencil-scheme.cc | 24 ++++++++++++++++++----- scm/page.scm | 34 +++++++++++++-------------------- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index f240c05344..1076287bea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ +2006-08-22 Han-Wen Nienhuys + + * scm/page.scm (make-page-stencil): don't rely on extents of + page-stencil. This fixes spurious space around .EPS files produced + with the EPS backend. + 2006-08-21 Han-Wen Nienhuys + * lily/stencil-scheme.cc (LY_DEFINE): make extent arguments optional. + * lily/hara-kiri-engraver.cc (process_music): remember keepAliveInterfaces after processing \set diff --git a/input/regression/page-layout.ly b/input/regression/page-layout.ly index f999a0750a..5d2ecdff2a 100644 --- a/input/regression/page-layout.ly +++ b/input/regression/page-layout.ly @@ -37,7 +37,12 @@ This file is best viewed outside the collated files document. line-width = 15\cm %rigthmargin = 3\cm interscoreline = 3\cm -} + + annotate-spacing = ##t + + + + } \book { diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 66f1825931..2669e14808 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -213,23 +213,37 @@ LY_DEFINE (ly_stencil_add, "ly:stencil-add", } LY_DEFINE (ly_make_stencil, "ly:make-stencil", - 3, 0, 0, (SCM expr, SCM xext, SCM yext), + 1, 2, 0, (SCM expr, SCM xext, SCM yext), " \n" "Stencils are a device independent output expressions." "They carry two pieces of information: \n\n" "1: a specification of how to print this object. " "This specification is processed by the output backends, " " for example @file{scm/output-ps.scm}.\n\n" - "2: the vertical and horizontal extents of the object.\n\n") + "2: the vertical and horizontal extents of the object.\n\n" + "If the extents are unspecified, they are taken to be empty." + ) { SCM_ASSERT_TYPE (!scm_is_pair (expr) || is_stencil_head (scm_car (expr)), expr, SCM_ARG1, __FUNCTION__, "registered stencil expression"); - SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair"); - SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); - Box b (ly_scm2interval (xext), ly_scm2interval (yext)); + Interval x; + if (xext != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair"); + x = ly_scm2interval (xext); + } + + Interval y; + if (yext != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair"); + y = ly_scm2interval (yext); + } + + Box b (x, y); Stencil s (b, expr); return s.smobbed_copy (); } diff --git a/scm/page.scm b/scm/page.scm index 802c92ca17..83bcb40097 100644 --- a/scm/page.scm +++ b/scm/page.scm @@ -240,12 +240,7 @@ ))) (define (make-page-stencil page) - "Construct a stencil representing the page from LINES. - - Offsets is a list of increasing numbers. They must be negated to -create offsets. -" - + "Construct a stencil representing the page from PAGE." (page-translate-systems page) @@ -258,7 +253,6 @@ create offsets. (number (page-page-number page)) ;; TODO: naming paper-height/paper-width not analogous to TeX. - (system-xoffset (ly:output-def-lookup layout 'horizontal-shift 0.0)) (system-separator-markup (ly:output-def-lookup layout 'systemSeparatorMarkup)) @@ -272,10 +266,7 @@ create offsets. (interval-length (ly:stencil-extent (prop 'head-stencil) Y)) 0.0)) - (page-stencil (ly:make-stencil - '() - (cons (prop 'left-margin) (prop 'paper-width)) - (cons (- (prop 'top-margin)) 0))) + (page-stencil (ly:make-stencil '())) (last-system #f) (last-y 0.0) @@ -286,7 +277,7 @@ create offsets. (cons (+ system-xoffset x) (- 0 head-height y (prop 'top-margin))) - + ))))) (add-system (lambda (system) @@ -325,18 +316,18 @@ create offsets. lines (append (cdr lines) (list #f))) (paper-system-annotate-last (car (last-pair lines)) layout))) - - (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.)) + (if (and + (ly:stencil? head) + (not (ly:stencil-empty? head))) + + (set! page-stencil (ly:stencil-add page-stencil + (ly:stencil-translate-axis head + (- 0 head-height (prop 'top-margin)) Y)))) + (map add-system lines) + (ly:prob-set-property! page 'bottom-system-edge (car (ly:stencil-extent page-stencil Y))) (ly:prob-set-property! page 'space-left @@ -371,6 +362,7 @@ create offsets. (ly:output-def-lookup layout 'annotate-page #f)) (set! page-stencil (annotate-page layout page-stencil))) + page-stencil)) -- 2.39.2