From e0407d20831d03468072ba0f219ccee787cd2621 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 30 Jan 2005 22:06:06 +0000 Subject: [PATCH] * 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. --- ChangeLog | 22 +++ Documentation/user/invoking.itely | 9 +- input/tutorial/GNUmakefile | 2 +- .../{lilbook.tex => lbook-latex-test.tex} | 0 input/tutorial/lbook-texi-test.texi | 34 ++++ lily/pango-font.cc | 7 +- lily/paper-book.cc | 3 +- lily/stencil.cc | 2 +- make/lilypond-vars.make | 2 +- scm/backend-library.scm | 86 +++++++++ scm/define-markup-commands.scm | 5 +- scm/framework-eps.scm | 86 +++++++++ scm/framework-ps.scm | 169 ++++-------------- scm/lily.scm | 81 +-------- scm/output-ps.scm | 3 + scm/safe-lily.scm | 7 + scripts/lilypond-book.py | 59 +++--- 17 files changed, 336 insertions(+), 241 deletions(-) rename input/tutorial/{lilbook.tex => lbook-latex-test.tex} (100%) create mode 100644 input/tutorial/lbook-texi-test.texi create mode 100644 scm/backend-library.scm create mode 100644 scm/framework-eps.scm diff --git a/ChangeLog b/ChangeLog index f4eef5afa8..ed126f28da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2005-01-30 Han-Wen Nienhuys + + * 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 * Documentation/user/changing-defaults.itely: fixed example @@ -15,6 +34,9 @@ 2005-01-29 Han-Wen Nienhuys + * 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. diff --git a/Documentation/user/invoking.itely b/Documentation/user/invoking.itely index cac60b6594..6bbb2b6caa 100644 --- a/Documentation/user/invoking.itely +++ b/Documentation/user/invoking.itely @@ -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) diff --git a/input/tutorial/GNUmakefile b/input/tutorial/GNUmakefile index 45447ca2a5..20ab9e088f 100644 --- a/input/tutorial/GNUmakefile +++ b/input/tutorial/GNUmakefile @@ -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/lilbook.tex b/input/tutorial/lbook-latex-test.tex similarity index 100% rename from input/tutorial/lilbook.tex rename to input/tutorial/lbook-latex-test.tex diff --git a/input/tutorial/lbook-texi-test.texi b/input/tutorial/lbook-texi-test.texi new file mode 100644 index 0000000000..69209999c2 --- /dev/null +++ b/input/tutorial/lbook-texi-test.texi @@ -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/lily/pango-font.cc b/lily/pango-font.cc index 236770910c..87e22e1b36 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -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. diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 9b7c313a6f..0708c99bbe 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -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, diff --git a/lily/stencil.cc b/lily/stencil.cc index 4f8157bca7..3a9f503b02 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -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]; diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index c72c0cec42..21956228fe 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -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 index 0000000000..e7076b9f69 --- /dev/null +++ b/scm/backend-library.scm @@ -0,0 +1,86 @@ +;;;; backend-library.scm -- helpers for the backends. +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2005 Jan Nieuwenhuizen +;;;; Han-Wen Nienhuys + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; 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) + diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 641a448507..ebfcd540e5 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -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 index 0000000000..9389302e08 --- /dev/null +++ b/scm/framework-eps.scm @@ -0,0 +1,86 @@ +;;;; framework-ps.scm -- +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2004 Han-Wen Nienhuys + +(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) + diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index eb31642463..2af732a818 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -236,8 +236,7 @@ (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)) @@ -265,10 +264,43 @@ (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 )) @@ -278,133 +310,10 @@ (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))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/scm/lily.scm b/scm/lily.scm index 265e506978..ac39758fdb 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 8c415713ec..19193d4fc7 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -173,6 +173,9 @@ " draw_box")) +(define (utf8-string pango-font-description string) + (ly:warn "utf8-string encountered in PS backend")) + (define (glyph-string postscript-font-name size diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index 98a7c38504..3bc46e52b0 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -282,6 +282,13 @@ 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) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 4617ce5ae6..99ddb8f5c3 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -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 = '' @@ -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 () -- 2.39.2