]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-ps.scm (utf8-string): add utf8-string for completeness.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 Jan 2005 22:06:06 +0000 (22:06 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 Jan 2005 22:06:06 +0000 (22:06 +0000)
* scm/framework-ps.scm (dump-stencil-as-EPS): new function

* Documentation/user/invoking.itely (Invoking lilypond): add note
about EPS backend.

* scm/framework-eps.scm: new file: create per-system/per-page EPS
files for inclusion in lilypond-book document.

* input/tutorial/lbook-latex-test.tex: rename from lilbook.tex

* input/tutorial/lbook-texi-test.texi: new file.

* scm/safe-lily.scm (safe-objects): add
{begin,end}-of-line-(in)?visible as safe.

18 files changed:
ChangeLog
Documentation/user/invoking.itely
input/tutorial/GNUmakefile
input/tutorial/lbook-latex-test.tex [new file with mode: 0644]
input/tutorial/lbook-texi-test.texi [new file with mode: 0644]
input/tutorial/lilbook.tex [deleted file]
lily/pango-font.cc
lily/paper-book.cc
lily/stencil.cc
make/lilypond-vars.make
scm/backend-library.scm [new file with mode: 0644]
scm/define-markup-commands.scm
scm/framework-eps.scm [new file with mode: 0644]
scm/framework-ps.scm
scm/lily.scm
scm/output-ps.scm
scm/safe-lily.scm
scripts/lilypond-book.py

index f4eef5afa8e76fecc3099af0dd2a834bbb2abab7..ed126f28dad7194d4ccdecf8b7e233319d872216 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2005-01-30  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/output-ps.scm (utf8-string): add utf8-string for completeness.
+
+       * scm/framework-ps.scm (dump-stencil-as-EPS): new function
+
+       * Documentation/user/invoking.itely (Invoking lilypond): add note
+       about EPS backend.
+
+       * scm/framework-eps.scm: new file: create per-system/per-page EPS
+       files for inclusion in lilypond-book document.
+
+       * input/tutorial/lbook-latex-test.tex: rename from lilbook.tex
+
+       * input/tutorial/lbook-texi-test.texi: new file.
+
+       * scm/safe-lily.scm (safe-objects): add
+       {begin,end}-of-line-(in)?visible as safe.
 2005-01-30  Graham Percival  <gperlist@shaw.ca>
 
        * Documentation/user/changing-defaults.itely: fixed example
@@ -15,6 +34,9 @@
 
 2005-01-29  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/stencil.cc (moved_to_edge): don't halt on adding empty
+       stencils.
+
        * ps/lilyponddefs.ps: add start-page, start-system doesn't
        translate to top of page. Fixes alignment problems of
        lilypond-generated EPS files.
index cac60b65940b88ccd9796863b4256a5bea9b8e14..6bbb2b6caaf957ae38aaa62f62cbfe9492c7842b 100644 (file)
@@ -68,10 +68,17 @@ for @TeX{} output, to be processed with La@TeX{}.  If present, the file
 @item texstr
 dump text strings to @file{.texstr} file, which can be run through
 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
-extents of strings of text. 
+extents of strings of text.
 @item ps
  for PostScript
 @cindex PostScript output
+@item eps
+ for encapsulated PostScript. This dumps every page (system) as a separate
+@file{EPS} file, without fonts, and as one collated @file{EPS} file with
+all pages (systems) including fonts.
+
+This mode  is used by default by lilypond-book.
+
 @item svg
  for SVG (Scalable Vector Graphics)
 @cindex SVG (Scalable Vector Graphics)
index 45447ca2a56537651b172d8f27a4a1073dae8af6..20ab9e088f47936d4ecdf3900c4a9ceb7eb2b052 100644 (file)
@@ -2,7 +2,7 @@ depth = ../..
 
 LOCALSTEPMAKE_TEMPLATES=ly mutopia
 
-EXTRA_DIST_FILES=lilbook.tex
+EXTRA_DIST_FILES=lilbook.tex lbook-texi-test.texi
 
 include $(depth)/make/stepmake.make 
 
diff --git a/input/tutorial/lbook-latex-test.tex b/input/tutorial/lbook-latex-test.tex
new file mode 100644 (file)
index 0000000..f5cfa1c
--- /dev/null
@@ -0,0 +1,25 @@
+\documentclass[a4paper]{article}
+\usepackage{graphics}
+\begin{document}
+
+Documents for lilypond-book may freely mix music and text.  For
+example,
+
+\begin{lilypond}
+\relative {
+  c2^"test" g'2 \times 2/3 { f8 e d } c'2 g4
+} 
+\end{lilypond}
+
+Options are put in brackets.
+
+\begin[fragment,quote,staffsize=26,verbatim]{lilypond}
+  c'4 f16
+\end{lilypond}
+
+Larger examples can be put in a separate file, and introduced with
+\verb+\lilypondfile+.
+
+%\lilypondfile[quote,noindent]{screech-boink.ly}
+
+\end{document}
diff --git a/input/tutorial/lbook-texi-test.texi b/input/tutorial/lbook-texi-test.texi
new file mode 100644 (file)
index 0000000..6920999
--- /dev/null
@@ -0,0 +1,34 @@
+\input texinfo @c -*-texinfo-*-
+@setfilename lilbook.info
+@settitle  lilypond-book test
+@node Top, , , 
+@top
+
+@chapter lilypond-book test
+
+@section Introduction
+
+Blah blah blah Blah blah blah Blah blah blah Blah blah blah Blah blah
+blah
+
+Fragment:
+
+
+@lilypond
+\relative {
+  c2 g'2^"test" \times 2/3 { f8 e d } c'2  g4
+} 
+@end lilypond
+
+
+Bla bla blah
+
+This is a multipage / multipicture fragment:
+
+@lilypond
+\book {
+  \score { { c1 \break \pageBreak c1 } }
+} 
+@end lilypond
+
+@bye
diff --git a/input/tutorial/lilbook.tex b/input/tutorial/lilbook.tex
deleted file mode 100644 (file)
index f5cfa1c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-\documentclass[a4paper]{article}
-\usepackage{graphics}
-\begin{document}
-
-Documents for lilypond-book may freely mix music and text.  For
-example,
-
-\begin{lilypond}
-\relative {
-  c2^"test" g'2 \times 2/3 { f8 e d } c'2 g4
-} 
-\end{lilypond}
-
-Options are put in brackets.
-
-\begin[fragment,quote,staffsize=26,verbatim]{lilypond}
-  c'4 f16
-\end{lilypond}
-
-Larger examples can be put in a separate file, and introduced with
-\verb+\lilypondfile+.
-
-%\lilypondfile[quote,noindent]{screech-boink.ly}
-
-\end{document}
index 236770910c9cbc60839adfa910a0d25ca1a343eb..87e22e1b367ce3e77e6c7c6975a82b8908bfa04d 100644 (file)
@@ -162,7 +162,12 @@ Pango_font::text_stencil (String str) const
       ptr = ptr->next;      
     }
 
-  if (output_backend_global != "ps")
+  /*
+    UGH. Should have flags per output format signifying supported
+    options.
+   */
+  if (output_backend_global != "ps"
+      && output_backend_global != "eps")
     {
       /*
        For Pango based backends, we take a shortcut.
index 9b7c313a6f6953470f4b8c8e6896c6e8924ba6da..0708c99bbe2335d398314b4add8fd68e85d1f74f 100644 (file)
@@ -56,7 +56,6 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   scm_puts ("#<", port);
   scm_puts (classname (b), port);
   scm_puts (" ", port);
-  //scm_puts (b->, port);
   scm_puts (">", port);
   return 1;
 }
@@ -133,9 +132,9 @@ Paper_book::classic_output (String outname)
       
   SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
   SCM func = scm_c_module_lookup (mod, "output-classic-framework");
 
   func = scm_variable_ref (func);
-      
   scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
                                 self_scm (),
                                 scopes,
index 4f8157bca73dc4defb7563b9540991f9f95b73ae..3a9f503b0233316dbf384224d6266beb572cf181 100644 (file)
@@ -163,7 +163,7 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s,
     {
       programming_error ("Stencil::moved_to_edge: adding empty stencil.");
       his_extent = 0.0;
-      SCM_ASSERT_TYPE (0, SCM_EOL, SCM_ARG1, __FUNCTION__, "");
+      //      SCM_ASSERT_TYPE (0, s.expr (), SCM_ARG1, __FUNCTION__, "non-empty stencil");
     }
   else
     his_extent = i[-d];
index c72c0cec4281e5303eb07a50f6218cb3bb83cd72..21956228fe77cd3c8a1d979c2246d2903c7045a2 100644 (file)
@@ -38,7 +38,7 @@ CONVERT_LY = $(script-dir)/convert-ly.py
 LILYPOND = $(builddir)/lily/$(outconfbase)/lilypond
 LILYPOND_BOOK = $(script-dir)/lilypond-book.py
 LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ -I $(builddir)/mf/$(outconfbase)/  -I $(builddir)/mf/out/
-LILYPOND_BOOK_FLAGS = --process="lilypond --backend ps  --formats=ps,png --header=texidoc -I $(srcdir)/input/test -e '(ly:set-option (quote internal-type-checking) \#t)'"
+LILYPOND_BOOK_FLAGS = --process="lilypond --backend eps  --formats=ps,png --header=texidoc -I $(srcdir)/input/test -e '(ly:set-option (quote internal-type-checking) \#t)'"
 
 #texi-html for www only:
 LILYPOND_BOOK_FORMAT=$(if $(subst out-www,,$(notdir $(outdir))),texi,texi-html)
diff --git a/scm/backend-library.scm b/scm/backend-library.scm
new file mode 100644 (file)
index 0000000..e7076b9
--- /dev/null
@@ -0,0 +1,86 @@
+;;;; backend-library.scm -- helpers for the backends.
+;;;;
+;;;;  source file of the GNU LilyPond music typesetter
+;;;; 
+;;;; (c)  2005 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
+;; backend helpers.
+
+(define-public (ly:system command)
+  (let* ((status 0)
+
+        (silenced
+         (string-append command (if (ly:get-option 'verbose)
+                                    ""
+                                    " > /dev/null 2>&1 "))))
+    
+    (if (ly:get-option 'verbose)
+       (format  (current-error-port) (_ "Invoking `~a'...\n") command))
+    
+    (set! status (system silenced))
+    (if (> status 0)
+       (begin
+         (format (current-error-port)
+                 (_ "Error invoking `~a'. Return value ~a") silenced status)
+         (newline (current-error-port))))))
+
+(define-public (sanitize-command-option str)
+  (string-append
+   "\""
+   (regexp-substitute/global #f "[^- 0-9,.a-zA-Z'\"\\]" str 'pre 'post)
+   "\""))
+
+(define-public (postscript->pdf papersizename name)
+  (let* ((cmd (string-append "ps2pdf "
+                            (string-append
+                             " -sPAPERSIZE="
+                             (sanitize-command-option papersizename)
+                             " "
+                             name)))
+        (pdf-name (string-append (basename name ".ps") ".pdf" )))
+
+    (if (access? pdf-name W_OK)
+       (delete-file pdf-name))
+
+    (format (current-error-port) (_ "Converting to `~a'...") pdf-name)
+    (ly:system cmd)))
+
+(define-public (postscript->png resolution name)
+  (let ((cmd (string-append
+             "ps2png --resolution="
+             (if (number? resolution)
+                 (number->string resolution)
+                 "90 ")
+             (if (ly:get-option 'verbose)
+                 "--verbose "
+                 " ")
+             name)))
+
+    (ly:system cmd)))
+
+(define-public (postprocess-output paper-book module filename formats)
+  (for-each
+   (lambda (f)
+     ((eval (string->symbol (string-append "convert-to-" f))
+           module)
+      paper-book filename))
+   
+   formats))
+
+(define-public (completize-formats formats)
+  (define new-fmts '())
+
+  (if (member "png" formats)
+      (set! formats (cons "ps" formats)))
+  (if (member "pdf" formats)
+      (set! formats (cons "ps" formats)))
+
+  (for-each
+   (lambda (x)
+     (if (member x formats) (set! new-fmts (cons x new-fmts))))
+   '("tex" "dvi" "ps" "pdf" "png"))
+
+  new-fmts)
+
index 641a4485074c521eb1e5d58b834b27ec8dc89fb7..ebfcd540e506c6f294a974cd4091a58c26638a8b 100644 (file)
@@ -685,7 +685,7 @@ the elements marked in @var{indices}, which is a list of numbers."
   (define (stack-stencils stencils bskip last-stencil)
     (cond
      ((null? stencils) '())
-     ((not last-stencil)
+     ((not (ly:stencil? last-stencil))
       (cons (car stencils)
            (stack-stencils (cdr stencils) bskip (car stencils))))
      (else
@@ -730,7 +730,8 @@ the elements marked in @var{indices}, which is a list of numbers."
                  x)) args))
         (leading
          (chain-assoc-get 'baseline-skip props))
-        (stacked (stack-stencils stencils 1.25 #f))
+        (stacked (stack-stencils
+                  (remove ly:stencil-empty? stencils) 1.25 #f))
         (brackets (make-brackets stacked indices '())))
 
     (apply ly:stencil-add
diff --git a/scm/framework-eps.scm b/scm/framework-eps.scm
new file mode 100644 (file)
index 0000000..9389302
--- /dev/null
@@ -0,0 +1,86 @@
+;;;; framework-ps.scm --
+;;;;
+;;;;  source file of the GNU LilyPond music typesetter
+;;;;
+;;;; (c)  2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+(define-module (scm framework-eps))
+
+;;; this is still too big a mess.
+
+(use-modules (ice-9 regex)
+            (ice-9 string-fun)
+            (ice-9 format)
+            (guile)
+            (scm framework-ps)
+            (scm output-ps)
+            (srfi srfi-1)
+            (srfi srfi-13)
+            (lily))
+
+(define framework-eps-module (current-module))
+
+(define (dump-stencils-as-EPSes stencils book basename)
+  (define paper (ly:paper-book-paper book))
+  (define (dump-infinite-stack-EPS stencils)
+    (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)
+    (if (pair? stencils)
+       (let*
+           ((line (car stencils))
+            (rest (cdr stencils)))
+         (dump-stencil-as-EPS
+          paper
+          line (format "~a-~a" basename count)
+          #f)
+
+         (dump-stencils-as-separate-EPS rest (1+ count))
+         )))
+  
+  (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)))
+    
+    (display (format "Writing ~a\n" tex-system-name))
+    (display (format "Writing ~a\n" texi-system-name))
+    (dump-stencils-as-separate-EPS stencils 1)
+    (for-each (lambda (c)
+               (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" texi-system-port)
+    (display "% eof" tex-system-port)
+    
+    (dump-infinite-stack-EPS stencils))
+    (postprocess-output book framework-eps-module
+                       (format "~a.eps" basename) (ly:output-formats)))
+
+(define-public (output-classic-framework
+               basename book scopes fields)
+
+  (dump-stencils-as-EPSes
+   (map ly:paper-system-stencil (ly:paper-book-systems book))
+   book
+   basename))
+
+(define-public (output-framework basename book scopes fields)
+  (dump-stencils-as-EPSes (ly:paper-book-pages book)
+                         book
+                         basename))
+  
+
+; redefine to imports from framework-ps
+(define convert-to-pdf convert-to-pdf)
+(define convert-to-ps convert-to-ps)
+(define convert-to-png convert-to-png)
+(define convert-to-tex convert-to-tex)
+(define convert-to-dvi convert-to-dvi)
+
index eb316424638b6640640bcf258f01df0be183bc27..2af732a818ffefb02d18a9238e4f2184161f4909 100644 (file)
 
 (define-public (output-framework basename book scopes fields)
   (let* ((filename (format "~a.ps" basename))
-        (outputter  (ly:make-paper-outputter filename
-                                             (ly:output-backend)))
+        (outputter  (ly:make-paper-outputter filename "ps"))
         (paper (ly:paper-book-paper book))
         (pages (ly:paper-book-pages book))
         (landscape? (eq? (ly:output-def-lookup paper 'landscape) #t))
 (if (not (defined? 'inf?))
     (define (inf? x) #f))
 
+
+(define-public (dump-stencil-as-EPS paper dump-me filename load-fonts?)
+  (let*
+      ((outputter (ly:make-paper-outputter (format "~a.eps" filename)
+                                          "ps"))
+       
+       (port (ly:outputter-port outputter))
+       (xext (ly:stencil-extent dump-me X))
+       (yext (ly:stencil-extent dump-me Y))
+       (scale  (ly:output-def-lookup paper 'outputscale))
+       (bbox
+       (map
+        (lambda (x)
+          (if (or (nan? x) (inf? x))
+              0.0 x))
+        (list (car xext) (car yext)
+              (cdr xext) (cdr yext))))
+       (rounded-bbox
+       (map
+        (lambda (x)
+          (inexact->exact
+           (round (* x scale mm-to-bigpoint)))) bbox))
+       (port (ly:outputter-port outputter))
+       (header (eps-header paper rounded-bbox load-fonts?)))
+
+    (display header port)
+    (write-preamble paper load-fonts? port)
+    (display "start-system { set-ps-scale-to-lily-scale \n" port)
+    (ly:outputter-dump-stencil outputter dump-me)
+    (display "} stop-system\n%%Trailer\n%%EOF\n" port)
+    (ly:outputter-close outputter)
+    ))
+
+
 (define-public (output-preview-framework basename book scopes fields )
-  (let* ((filename (format "~a.ps" basename))
-        (outputter  (ly:make-paper-outputter filename
-                                             (ly:output-backend)))
+  (let* ((outputter  (ly:make-paper-outputter filename
+                                             "ps"))
         (paper (ly:paper-book-paper book))
         (systems (ly:paper-book-systems book))
         (scale  (ly:output-def-lookup paper 'outputscale ))
         (dump-me
          (stack-stencils Y DOWN 0.0
                          (map ly:paper-system-stencil
-                              (append titles (list non-title)))))
-        (xext (ly:stencil-extent dump-me X))
-        (yext (ly:stencil-extent dump-me Y))
-        (bbox
-         (map
-          (lambda (x)
-            (if (or (nan? x) (inf? x))
-                0.0 x))
-          (list (car xext) (car yext)
-                (cdr xext) (cdr yext))))
-        (rounded-bbox
-         (map
-          (lambda (x)
-            (inexact->exact
-             (round (* x scale mm-to-bigpoint))))))
-        (port (ly:outputter-port outputter))
-         )
-    
-
-    (display (eps-header paper rounded-bbox #t) port)
-    (write-preamble paper #t port)
-    (display "start-system { set-ps-scale-to-lily-scale \n" port)
-    (ly:outputter-dump-stencil outputter dump-me)
-    (display outputter "} stop-system\n%%Trailer\n%%EOF\n" port)
-    (ly:outputter-close outputter)
-    (postprocess-output book framework-ps-module filename
-                       (ly:output-formats))
-))
-
+                              (append titles (list non-title))))))
+    (dump-stencil-as-EPS paper dump-me basename #t)))
 
-(define-public (output-classic-framework
-               basename book scopes fields)
-  (define paper (ly:paper-book-paper book))
-  (define (dump-line outputter line)
-    (let*
-       ((dump-me (ly:paper-system-stencil line))
-        (xext (ly:stencil-extent dump-me X))
-        (yext (ly:stencil-extent dump-me Y))
-        (scale  (ly:output-def-lookup paper 'outputscale))
-        (bbox
-         (map
-          (lambda (x)
-            (if (or (nan? x) (inf? x))
-                0.0 x))
-          (list (car xext) (car yext)
-                (cdr xext) (cdr yext))))
-        (rounded-bbox
-         (map
-          (lambda (x)
-            (inexact->exact
-             (round (* x scale mm-to-bigpoint)))) bbox))
-        (port (ly:outputter-port outputter))
-        (header (eps-header paper rounded-bbox #f)))
 
-    (display header port)
-    (write-preamble paper #f port)
-    (display "start-system { set-ps-scale-to-lily-scale \n" port)
-    (ly:outputter-dump-stencil outputter dump-me)
-    (display "} stop-system\n%%Trailer\n%%EOF\n" port)
-    (ly:outputter-close outputter)))
-
-
-  (define (dump-infinite-page lines)
-    (let*
-       ((outputter  (ly:make-paper-outputter (format "~a.eps" basename)
-                                             (ly:output-backend)))
-        (stencils (map ly:paper-system-stencil lines))
-        (dump-me (stack-stencils Y DOWN 2.0 stencils))
-        (xext (ly:stencil-extent dump-me X))
-        (yext (ly:stencil-extent dump-me Y))
-        (scale  (ly:output-def-lookup paper 'outputscale))
-        (bbox
-         (map
-          (lambda (x)
-            (if (or (nan? x) (inf? x))
-                0.0 x))
-          (list (car xext) (car yext)
-                (cdr xext) (cdr yext))))
-        (ps-bbox (map (lambda (x)
-                        (inexact->exact
-                         (round (* x scale mm-to-bigpoint))))
-                      bbox))
-        
-        (port (ly:outputter-port outputter))
-        (header (eps-header paper ps-bbox #t)))
-
-      (display header port)
-      (write-preamble paper #t port)
-      (display "start-system { set-ps-scale-to-lily-scale \n" port)
-      (ly:outputter-dump-stencil outputter dump-me)
-      (display "} stop-system\n%%Trailer\n%%EOF\n" port)
-      (ly:outputter-close outputter)))
-
-  (define (dump-lines lines count)
-    (if (pair? lines)
-       (let*
-           ((outputter  (ly:make-paper-outputter (format "~a-~a.eps" basename count)
-                                                 (ly:output-backend)))
-            (line (car lines))
-            (rest (cdr lines)))
-         (dump-line outputter line)
-         (dump-lines rest (1+ count))
-         )))
-
-  (let* ((lines (ly:paper-book-systems book))
-        (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))
-        (last-line (car (last-pair lines)))
-        (pages (ly:paper-book-pages book))
-        )
-
-    (display (format "Writing ~a\n" tex-system-name))
-    (display (format "Writing ~a\n" texi-system-name))
-    (dump-lines lines 1)
-    (for-each (lambda (c)
-               (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 lines)))
-
-    (display "@c eof" texi-system-port)
-    (display "% eof" tex-system-port)
-    (dump-infinite-page lines))
-    (postprocess-output book framework-ps-module (format "~a.eps" basename) (ly:output-formats)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
index 265e506978285c233bbecb143a902a4133e92fe3..ac39758fdb4d96cfb906967edaedf8bc02902f59 100644 (file)
@@ -197,7 +197,7 @@ predicates. Print a message at LOCATION if any predicate failed."
            "titling.scm"
            
            "paper.scm"
-
+           "backend-library.scm"
                                        ; last:
            "safe-lily.scm"))
 
@@ -271,85 +271,6 @@ predicates. Print a message at LOCATION if any predicate failed."
      outfile)))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
-;; backend helpers.
-
-(define-public (ly:system command)
-  (let* ((status 0)
-
-        (silenced
-         (string-append command (if (ly:get-option 'verbose)
-                                    ""
-                                    " > /dev/null 2>&1 "))))
-    
-    (if (ly:get-option 'verbose)
-       (format  (current-error-port) (_ "Invoking `~a'...\n") command))
-    
-    (set! status (system silenced))
-    (if (> status 0)
-       (begin
-         (format (current-error-port)
-                 (_ "Error invoking `~a'. Return value ~a") silenced status)
-         (newline (current-error-port))))))
-
-(define-public (sanitize-command-option str)
-  (string-append
-   "\""
-   (regexp-substitute/global #f "[^- 0-9,.a-zA-Z'\"\\]" str 'pre 'post)
-   "\""))
-
-(define-public (postscript->pdf papersizename name)
-  (let* ((cmd (string-append "ps2pdf "
-                            (string-append
-                             " -sPAPERSIZE="
-                             (sanitize-command-option papersizename)
-                             " "
-                             name)))
-        (pdf-name (string-append (basename name ".ps") ".pdf" )))
-
-    (if (access? pdf-name W_OK)
-       (delete-file pdf-name))
-
-    (format (current-error-port) (_ "Converting to `~a'...") pdf-name)
-    (ly:system cmd)))
-
-(define-public (postscript->png resolution name)
-  (let ((cmd (string-append
-             "ps2png --resolution="
-             (if (number? resolution)
-                 (number->string resolution)
-                 "90 ")
-             (if (ly:get-option 'verbose)
-                 "--verbose "
-                 " ")
-             name)))
-
-    (ly:system cmd)))
-
-(define-public (postprocess-output paper-book module filename formats)
-  (for-each
-   (lambda (f)
-     ((eval (string->symbol (string-append "convert-to-" f))
-           module)
-      paper-book filename))
-   
-   formats))
-
-(define-public (completize-formats formats)
-  (define new-fmts '())
-
-  (if (member "png" formats)
-      (set! formats (cons "ps" formats)))
-  (if (member "pdf" formats)
-      (set! formats (cons "ps" formats)))
-
-  (for-each
-   (lambda (x)
-     (if (member x formats) (set! new-fmts (cons x new-fmts))))
-   '("tex" "dvi" "ps" "pdf" "png"))
-
-  new-fmts)
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (lilypond-main files)
index 8c415713ecef1ce4a85d19b01e20f31aa9fabf5b..19193d4fc78df82f1d4c2beab552179070e5f5cb 100644 (file)
                 " draw_box"))
 
 
+(define (utf8-string pango-font-description string)
+  (ly:warn "utf8-string encountered in PS backend"))
+
 (define (glyph-string
         postscript-font-name
         size
index 98a7c385042397a3f004d91ccd9f92b975ecbe27..3bc46e52b0ff2e572418f4b47c52547ead7ab1fd 100644 (file)
      Vaticana_ligature::brew_ligature_primitive
      Vaticana_ligature::print
      Volta_bracket_interface::print
+
+     begin-of-line-invisible
+     begin-of-line-visible
+     
+     end-of-line-invisible
+     end-of-line-visible
+     
      )))
 
 (define-public (make-safe-lilypond-module)
index 4617ce5ae681b7a3b6596d18f6590c64be5472ac..99ddb8f5c31f964d1dd9bc9d896d7ac91c1648f1 100644 (file)
@@ -134,6 +134,7 @@ NOQUOTE = 'noquote'
 NOTES = 'body'
 NOTIME = 'notime'
 OUTPUT = 'output'
+OUTPUTIMAGE = 'outputimage'
 PAPER = 'paper'
 PREAMBLE = 'preamble'
 PRINTFILENAME = 'printfilename'
@@ -486,11 +487,12 @@ output = {
 %(code)s
 @lilypond''',
 
-               OUTPUT: r'''@noindent
+               OUTPUT: r'''
 @iftex
 @include %(base)s-systems.texi
-@end iftex
+@end iftex''',
 
+               OUTPUTIMAGE: r'''@noindent
 @ifnottex
 @image{%(base)s,,,[image of music],%(ext)s}
 @end ifnottex
@@ -934,7 +936,10 @@ class Lilypond_snippet (Snippet):
                        # URG, makeinfo implicitly prepends dot to extension.
                        # Specifying no extension is most robust.
                        ext = ''
-                       str += output[TEXINFO][OUTPUT] % vars ()
+                       str += output[TEXINFO][OUTPUTIMAGE] % vars ()
+
+               base = self.basename()
+               str += output[format][OUTPUT] % vars()
                return str
 
        def output_latex (self):
@@ -957,6 +962,7 @@ class Lilypond_snippet (Snippet):
                        base = self.basename ()
                        filename = self.substring ('filename')
                        str = output[format][PRINTFILENAME] % vars ()
+
                return str
 
        def output_texinfo (self):
@@ -981,6 +987,7 @@ class Lilypond_snippet (Snippet):
                                str = output[TEXINFO][NOQUOTE] % vars()
 
                str += self.output_info ()
+               
 #              str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
 #              str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
 #              str += ('@html\n' + self.output_html () + '\n@end html\n')
@@ -1228,19 +1235,20 @@ def do_process_cmd (chunks):
                ly.progress (_ ("All snippets are up to date..."))
        ly.progress ('\n')
 
+def guess_format (input_filename):
+       format = None
+       e = os.path.splitext (input_filename)[1]
+       if e in ext2format.keys ():
+               # FIXME
+               format = ext2format[e]
+       else:
+               ly.error (_ ("cannot determine format for: %s" \
+                            % input_filename))
+               ly.exit (1)
+       return format
+       
 def do_file (input_filename):
        # Ugh.
-       global format
-       if not format:
-               e = os.path.splitext (input_filename)[1]
-               if e in ext2format.keys ():
-                       # FIXME
-                       format = ext2format[e]
-               else:
-                       ly.error (_ ("cannot determine format for: %s" \
-                                    % input_filename))
-                       ly.exit (1)
-
        if not input_filename or input_filename == '-':
                in_handle = sys.stdin
                input_fullname = '<stdin>'
@@ -1412,13 +1420,19 @@ def do_options ():
 
 def main ():
        files = do_options ()
-       global process_cmd
+       if not files:
+               ly.warning ("Need to have command line option")
+               ly.exit (2)
+
+       file = files[0]
+       global process_cmd, format
+       format = guess_format (files[0])
 
        formats = "ps"
        if format == TEXINFO:
-               formats += ",png" 
+               formats += ',png' 
        if process_cmd == '':
-               process_cmd = lilypond_binary + ' --formats=%s  --backend ps ' % formats
+               process_cmd = lilypond_binary + ' --formats=%s --backend eps ' % formats
 
        if process_cmd:
                process_cmd += string.join ([(' -I %s' % p)
@@ -1426,11 +1440,12 @@ def main ():
 
        ly.identify (sys.stderr)
        ly.setup_environment ()
-       if files:
-               try:
-                       do_file (files[0])
-               except Compile_error:
-                       ly.exit (1)
+
+       try:
+               do_file (file)
+       except Compile_error:
+               ly.exit (1)
+
 
 if __name__ == '__main__':
        main ()