]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/framework-eps.scm
* The grand 2005-2006 replace.
[lilypond.git] / scm / framework-eps.scm
index 348929c1c49f7cd82a2820e86082bef19c16cea0..78de309b8f47097f4d5ca0245a572133e8fd5bf2 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;;
-;;;; (c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;; (c) 2004--2006 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
 (define-module (scm framework-eps))
 
 
 (define framework-eps-module (current-module))
 
+
+(define (widen-left-stencil-edges stencils)
+  "Change STENCILS to use the union for the left extents in every
+stencil, so LaTeX includegraphics doesn't fuck up the alignment."
+
+  (define left
+    (apply min
+          (map (lambda (stc)
+                 (interval-start (ly:stencil-extent stc X)))
+               stencils)))
+
+  (map (lambda (stil)
+        
+        (ly:make-stencil
+         (ly:stencil-expr stil)
+         (cons
+          left
+          (cdr (ly:stencil-extent stil X)))
+         (ly:stencil-extent stil Y)
+         ))
+       stencils))
+
 (define (dump-stencils-as-EPSes stencils book basename)
   (define paper (ly:paper-book-paper book))
   (define (dump-infinite-stack-EPS stencils)
     (if (pair? stencils)
        (let* ((line (car stencils))
               (rest (cdr stencils)))
+
          (dump-stencil-as-EPS
-          paper
-          line (format "~a-~a" basename count)
+          paper line (format "~a-~a" basename count)
           (ly:output-def-lookup paper 'force-eps-font-include))
          
          (dump-stencils-as-separate-EPS rest (1+ count)))))
-  
+
+
+  ;; main body 
   (let* ((tex-system-name (format "~a-systems.tex" basename))
         (texi-system-name (format "~a-systems.texi" basename))
         (tex-system-port (open-output-file tex-system-name))
     
     (ly:message (_ "Writing ~a...") tex-system-name)
     (ly:message (_ "Writing ~a...") texi-system-name)
+
+    (set! stencils (widen-left-stencil-edges stencils))
+    
     (dump-stencils-as-separate-EPS stencils 1)
     (for-each (lambda (c)
+               (if (< 0 c)
+                   (display (format "\\ifx\\betweenLilyPondSystem \\undefined
+  \\linebreak
+\\else
+  \\betweenLilyPondSystem{~a}
+\\fi
+" c) tex-system-port))
                (display (format "\\includegraphics{~a-~a.eps}\n"
                                 basename (1+ c)) tex-system-port)
                (display (format "@image{~a-~a}\n"
                                 basename (1+ c)) texi-system-port))
              (iota (length stencils)))
-
-    (display "@c eof - 'eof' is a Makefile marker; don not remove. " texi-system-port)
+    
+    (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
     (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
     
     (dump-infinite-stack-EPS stencils))
@@ -61,8 +95,9 @@
 
 (define-public (output-classic-framework basename book scopes fields)
   (output-scopes scopes fields basename)
+  
   (dump-stencils-as-EPSes
-   (map ly:paper-system-stencil (ly:paper-book-systems book))
+   (map paper-system-stencil (ly:paper-book-systems book))
    book
    basename))