]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/framework-eps.scm
Run `make grand-replace'.
[lilypond.git] / scm / framework-eps.scm
index 5026f6126ff8890616c40610c26a4dea6a8d4403..cff610e8d3b623481295b91e606a9d5598d904d2 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;;
-;;;; (c) 2004--2006 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;; (c) 2004--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 (define-module (scm framework-eps))
 
@@ -10,7 +10,6 @@
 
 (use-modules (ice-9 regex)
             (ice-9 string-fun)
-            (ice-9 format)
             (guile)
             (scm framework-ps)
             (scm paper-system)
@@ -20,6 +19,8 @@
             (srfi srfi-13)
             (lily))
 
+(define format ergonomic-simple-format)
+
 (define framework-eps-module (current-module))
 
 
 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)))
+    (if (pair? stencils)
 
+       (apply min
+              (map (lambda (stc)
+                     (interval-start (ly:stencil-extent stc X)))
+                   stencils))
+       0.0))
+    
   (map (lambda (stil)
         
         (ly:make-stencil
@@ -44,7 +48,6 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
          ))
        stencils))
 
-  
 (define (dump-stencils-as-EPSes stencils book basename)
   (define do-pdf (member  "pdf" (ly:output-formats)))
   (define paper (ly:paper-book-paper book))
@@ -52,7 +55,20 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
     (let* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
       (dump-stencil-as-EPS paper dump-me basename #t)))
 
-  (define (dump-stencils-as-separate-EPS stencils count )
+  (define (dump-counted-stencil stencil-count-pair)
+    "Return EPS filename" 
+    (let*
+       ((stencil (car stencil-count-pair))
+        (number (cdr stencil-count-pair))
+        (name (format "~a-~a" basename number)))
+
+      (dump-stencil-as-EPS
+       paper stencil name
+       (ly:get-option 'include-eps-fonts))
+
+      (string-append name ".eps")))
+  
+  (define (dump-stencils-as-separate-EPS stencils count)
     (if (pair? stencils)
        (let* ((line (car stencils))
               (rest (cdr stencils))
@@ -60,26 +76,38 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
               )
 
          (dump-stencil-as-EPS
-          paper line system-base-name
-          (ly:get-option 'eps-font-include))
+          paper line system-base-name)
 
          (if do-pdf
              (postscript->pdf  0 0  (string-append system-base-name ".eps")))
          (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))
-        (texi-system-port (open-output-file texi-system-name)))
+  (let* ((write-file (lambda (str-port ext)
+                      (let*
+                          ((name (format "~a-systems.~a" basename ext))
+                           (port (open-output-file name)))
+                        (ly:message (_ "Writing ~a...") name)
+                        (display (get-output-string str-port) port)
+                        (close-output-port port)
+                        )))
+        
+        (tex-system-port (open-output-string))
+        (texi-system-port (open-output-string))
+        (count-system-port (open-output-string))
+        (widened-stencils (widen-left-stencil-edges stencils))
+        (counted-systems  (count-list widened-stencils))
+        (eps-files (map dump-counted-stencil  counted-systems))
+        )
     
-    (ly:message (_ "Writing ~a...") tex-system-name)
-    (ly:message (_ "Writing ~a...") texi-system-name)
+    (if do-pdf
+
+       ;; par-for-each: a bit faster ...  
+       (for-each
+        (lambda (y)
+          (postscript->pdf 0 0 y))
+        eps-files))
 
-    (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
@@ -94,12 +122,20 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
                                 basename (1+ c)) texi-system-port))
              (iota (length stencils)))
     
-    (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)
-    
+    (display "@c eof." texi-system-port)
+    (display "% eof. " tex-system-port)
+    (display (format "~a" (length stencils)) count-system-port)
     (dump-infinite-stack-EPS stencils)
     (postprocess-output book framework-eps-module
-                       (format "~a.eps" basename) (ly:output-formats))))
+                       (format "~a.eps" basename) (ly:output-formats))
+
+    (write-file texi-system-port "texi")
+    (write-file tex-system-port "tex")
+
+    ;; do this as the last action so we know the rest is complete if
+    ;; this file is present.
+    (write-file count-system-port "count")
+    ))
 
 
 
@@ -116,6 +152,9 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment."
 
 (define-public (output-framework basename book scopes fields)
   (output-scopes scopes fields basename)
+  (if (ly:get-option 'clip-systems)
+      (clip-system-EPSes basename book))
+
   (dump-stencils-as-EPSes
    (map page-stencil (ly:paper-book-pages book)) book basename))