From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Wed, 29 Sep 2004 22:57:39 +0000 (+0000)
Subject: * scm/framework-tex.scm (dump-page): take with-extents?
X-Git-Tag: release/2.3.20~14
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aaa011d32d6135f2412af3966dcd8bc129a97d3f;p=lilypond.git

* scm/framework-tex.scm (dump-page): take with-extents?
argument. If true, output Y extents. Used for lilypond-book
documents.

* scripts/lilypond-book.py (PREAMBLE_LY): set dump-extents for
\bookpaper.

* scm/framework-tex.scm (dump-page): put stencil height in dumped
page.
---

diff --git a/ChangeLog b/ChangeLog
index feeb553770..11576fba4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-09-30  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+	* scm/framework-tex.scm (dump-page): take with-extents?
+	argument. If true, output Y extents. Used for lilypond-book
+	documents.
+
+	* scripts/lilypond-book.py (PREAMBLE_LY): set dump-extents for
+	\bookpaper.
+
 	* lily/slur.cc (outside_slur_callback): epsilon-delta management
 	for slur edges.
  
diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm
index 98dc39fc38..a1358c9506 100644
--- a/scm/framework-tex.scm
+++ b/scm/framework-tex.scm
@@ -162,23 +162,27 @@
    "\\lilypondspecial\n"
    "\\lilypondpostscript\n"))
 
-(define (dump-page putter page last?)
+(define (dump-page putter page last? with-extents?)
   (ly:outputter-dump-string
    putter
    (format "\\vbox to ~a\\outputscale{%\n\\leavevmode\n\\lybox{0}{0}{0}{0}{%\n"
-	   (interval-length (ly:stencil-extent page Y))
-	   ))
+	   (if with-extents?
+	       (- (interval-start (ly:stencil-extent page Y)))
+	       	       0.0
+	       )))
   (ly:outputter-dump-stencil putter page)
   (ly:outputter-dump-string
    putter
    (if last?
-       "}\\vss\n}\n\\vss\n"
-       "}\\vss\n}\n\\vss\\lilypondpagebreak\n")))
+       "}\\vss\n}\n\\vfill\n"
+       "}\\vss\n}\n\\vfill\\lilypondpagebreak\n")))
 
 (define-public (output-framework outputter book scopes fields basename )
   (let* ((bookpaper (ly:paper-book-book-paper book))
 	 (pages (ly:paper-book-pages book))
 	 (last-page (car (last-pair pages)))
+	 (with-extents
+	  (eq? #t (ly:output-def-lookup bookpaper 'dump-extents)))
 	 )
     (for-each
      (lambda (x)
@@ -187,9 +191,9 @@
       (header bookpaper (length pages) #f)
       (define-fonts bookpaper)
       (header-end)))
-    
+    (ly:outputter-dump-string outputter "\\nopagebreak")
     (for-each
-     (lambda (page) (dump-page outputter page (eq? last-page page)))
+     (lambda (page) (dump-page outputter page (eq? last-page page) with-extents))
      pages)
     (ly:outputter-dump-string outputter "\\lilypondend\n")))
 
diff --git a/scm/lily.scm b/scm/lily.scm
index b7969de5c7..4477234724 100644
--- a/scm/lily.scm
+++ b/scm/lily.scm
@@ -323,7 +323,8 @@ L1 is copied, L2 not.
   "Length of the number-pair X, when an interval"
   (max 0 (- (cdr x) (car x)))
   )
-  
+(define-public interval-start car)
+(define-public interval-end cdr)
 
 (define (other-axis a)
   (remainder (+ a 1) 2))
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 25b185abda..7e772b11e8 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -314,7 +314,7 @@ output = {
 	},
 	}
 
-PREAMBLE_LY = r'''%%%% Generated by %(program_name)s
+PREAMBLE_LY = r"""%%%% Generated by %(program_name)s
 %%%% Options: [%(option_string)s]
 #(set! toplevel-score-handler ly:parser-print-score)
 #(set! toplevel-music-handler (lambda (p m)
@@ -322,12 +322,14 @@ PREAMBLE_LY = r'''%%%% Generated by %(program_name)s
 				p (ly:music-scorify m p))
 			    ))
 %(preamble_string)s
-\bookpaper {%(bookpaper_string)s
+\bookpaper {
+  #(define 'dump-extents #t)
+  %(bookpaper_string)s
 }
 \paper { %(paper_string)s
 }
 
-''' 
+"""
 
 FRAGMENT_LY = r'''
     %(notes_string)s{