From c90fed8a9b1e2e68c4c14300462aff6c7a3a6ffe Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 17 Jul 2006 09:40:36 +0000 Subject: [PATCH] * stepmake/stepmake/texinfo-rules.make: strip DVI support. * scm/framework-eps.scm (dump-stencils-as-EPSes): generate systems.pdftex too.o * scm/backend-library.scm (postscript->pdf): use -dEPSCrop for PDF. * make/lilypond-vars.make (TEXINPUTS): add pdf output format. * Documentation/topdocs/NEWS.tely (Top): add pdftex note. * scm/output-ps.scm (resetrotation): use gsave/grestore for rotation. * lily/main.cc (parse_argv): don't overwrite previous --formats string. * scm/backend-library.scm (postscript->pdf): strip .eps too. --- ChangeLog | 19 +++++++++++++++++++ Documentation/topdocs/NEWS.tely | 7 ++++++- lily/main.cc | 7 ++++++- make/lilypond-vars.make | 2 +- make/ly-rules.make | 12 ++++++------ scm/backend-library.scm | 22 ++++++++++++++++------ scm/framework-eps.scm | 26 +++++++++++++++++++------- scm/output-ps.scm | 12 +++++------- scm/stencil.scm | 1 + scripts/lilypond-book.py | 18 +++++++++--------- stepmake/stepmake/texinfo-rules.make | 5 ++--- 11 files changed, 90 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6298d72322..56e88a65f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2006-07-17 Han-Wen Nienhuys + + * stepmake/stepmake/texinfo-rules.make: strip DVI support. + + * scm/framework-eps.scm (dump-stencils-as-EPSes): generate + systems.pdftex too.o + + * scm/backend-library.scm (postscript->pdf): use -dEPSCrop for PDF. + + * make/lilypond-vars.make (TEXINPUTS): add pdf output format. + + * Documentation/topdocs/NEWS.tely (Top): add pdftex note. + + * scm/output-ps.scm (resetrotation): use gsave/grestore for rotation. + + * lily/main.cc (parse_argv): don't overwrite previous --formats string. + + * scm/backend-library.scm (postscript->pdf): strip .eps too. + 2006-07-14 Nicolas Sceaux * scm/layout-page-layout.scm: Define module, tidy code, use more diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index 47e3c70838..45d3c18e35 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -65,6 +65,11 @@ which scares away people. * only show user-visible changes. @end ignore +@item +@code{lilypond-book} now includes support for PDF@TeX{}. + +This feature was sponsored by David Roundy. + @item Nested tuplets can have different formatting for each nesting level, @@ -73,7 +78,7 @@ Nested tuplets can have different formatting for each nesting level, \time 5/4 \tweak #'text #tuplet-number::calc-fraction-text \times 5/3 { - \tweak #'tupletNumberFormatFunction #tuplet-number::calc-denominator-text + \tweak #'text #tuplet-number::calc-denominator-text \times 2/3 { c'8[ c'8 c'8] } diff --git a/lily/main.cc b/lily/main.cc index 5f9b2a77f6..bfdf01566f 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -540,7 +540,12 @@ parse_argv (int argc, char **argv) break; case 'f': - output_format_global = option_parser->optional_argument_str0_; + { + vector components + = string_split (option_parser->optional_argument_str0_, ','); + for (vsize i = 0; i < components.size (); i++) + add_output_format (components[i]); + } break; case 'H': diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 67ff5fca9a..107dd0a506 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -25,7 +25,7 @@ CONVERT_LY = $(script-dir)/convert-ly.py LILYPOND_BOOK = $(script-dir)/lilypond-book.py LILYPOND_BOOK_INCLUDES = -I $(src-dir)/ -I $(outdir) -I $(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/manual/ -I $(input-dir)/tutorial/ -I $(top-build-dir)/mf/$(outconfbase)/ -I $(top-build-dir)/mf/out/ LILYPOND_BOOK_LILYPOND_FLAGS=-dgs-font-load -LILYPOND_BOOK_FLAGS = --process="$(LILYPOND_BINARY) --backend=eps --formats=ps,png --header=texidoc -I $(top-src-dir)/input/manual -dinternal-type-checking -ddump-signatures -danti-alias-factor=2 $(LILYPOND_BOOK_LILYPOND_FLAGS)" +LILYPOND_BOOK_FLAGS = --process="$(LILYPOND_BINARY) --backend=eps --formats=ps,png,pdf -deps-font-include -dgs-font-load --header=texidoc -I $(top-src-dir)/input/manual -dinternal-type-checking -ddump-signatures -danti-alias-factor=2 $(LILYPOND_BOOK_LILYPOND_FLAGS)" TEXINPUTS=$(top-src-dir)/tex/:: export TEXINPUTS diff --git a/make/ly-rules.make b/make/ly-rules.make index b3c4f4108c..e7dbb42719 100644 --- a/make/ly-rules.make +++ b/make/ly-rules.make @@ -1,19 +1,19 @@ -.SUFFIXES: .doc .dvi .tely .texi .ly +.SUFFIXES: .doc .tely .texi .ly -$(outdir)/%.latex $(outdir)/%.psfonts: %.doc +$(outdir)/%.latex: %.doc $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --verbose $(LILYPOND_BOOK_FLAGS) $< # don't do ``cd $(outdir)'', and assume that $(outdir)/.. is the src dir. # it is not, for --srcdir builds $(outdir)/%.texi: %.tely - rm -f $$(grep -LF '% eof' $(outdir)/lily-*systems.tex 2>/dev/null) - $(PYTHON) $(LILYPOND_BOOK) --psfonts $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $< + rm -f $$(grep -LF '% eof' $(outdir)/lily-*systems.*tex 2>/dev/null) + $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $< $(outdir)/%.texi: $(outdir)/%.tely - rm -f $$(grep -LF '% eof' $(outdir)/lily-*systems.tex 2>/dev/null) - $(PYTHON) $(LILYPOND_BOOK) --psfonts $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $< + rm -f $$(grep -LF '% eof' $(outdir)/lily-*systems.*tex 2>/dev/null) + $(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BINARY) $(LILYPOND_BOOK_INCLUDES)' --output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) --verbose $(LILYPOND_BOOK_FLAGS) $< # # DON'T REMOVE SOURCE FILES, otherwise the .TEXI ALWAYS OUT OF DATE. # rm -f $< diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 689478f291..42cc2688da 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -48,15 +48,25 @@ ;; must be sure that we don't catch stuff from old GUBs. (search-executable '("gs"))) - + (define-public (postscript->pdf paper-width paper-height name) - (let* ((pdf-name (string-append (basename name ".ps") ".pdf")) + (let* ((pdf-name (string-append + (basename (basename name ".ps") ".eps") + ".pdf")) + (is-eps (string-match "\\.eps$" name)) + (paper-size-string (if is-eps + " -dEPSCrop " + (format "-dDEVICEWIDTHPOINTS=~,2f \ +-dDEVICEHEIGHTPOINTS=~,2f " + paper-width + paper-height))) + (cmd (format #f "~a\ ~a\ ~a\ + ~a\ -dCompatibilityLevel=1.4 \ - -dDEVICEWIDTHPOINTS=~,2f -dDEVICEHEIGHTPOINTS=~,2f\ -dNOPAUSE\ -dBATCH\ -r1200 \ @@ -70,8 +80,7 @@ (if (ly:get-option 'gs-font-load) " -dNOSAFER " " -dSAFER ") - paper-width - paper-height + paper-size-string pdf-name name))) ;; The wrapper on windows cannot handle `=' signs, @@ -112,9 +121,10 @@ (lambda (x) (member x formats)) completed))) + (for-each (lambda (f) - ((eval (string->symbol (string-append "convert-to-" f)) module) + ((eval (string->symbol (format "convert-to-~a" f)) module) paper-book filename)) completed) diff --git a/scm/framework-eps.scm b/scm/framework-eps.scm index 2260c00c2e..23f5779f86 100644 --- a/scm/framework-eps.scm +++ b/scm/framework-eps.scm @@ -44,32 +44,41 @@ 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)) (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) + (define (dump-stencils-as-separate-EPS stencils count ) (if (pair? stencils) (let* ((line (car stencils)) - (rest (cdr stencils))) + (rest (cdr stencils)) + (system-base-name (format "~a-~a" basename count)) + ) (dump-stencil-as-EPS - paper line (format "~a-~a" basename count) + paper line system-base-name (ly:get-option 'eps-font-include)) - + + (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)) + (pdftex-system-name (format "~a-systems.pdftex" 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))) + (texi-system-port (open-output-file texi-system-name)) + (pdftex-system-port (open-output-file pdftex-system-name))) (ly:message (_ "Writing ~a...") tex-system-name) (ly:message (_ "Writing ~a...") texi-system-name) + (ly:message (_ "Writing ~a...") pdftex-system-name) (set! stencils (widen-left-stencil-edges stencils)) @@ -84,6 +93,8 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment." " c) tex-system-port)) (display (format "\\includegraphics{~a-~a.eps}\n" basename (1+ c)) tex-system-port) + (display (format "\\includegraphics{~a-~a.pdf}\n" + basename (1+ c)) pdftex-system-port) (display (format "@image{~a-~a}\n" basename (1+ c)) texi-system-port)) (iota (length stencils))) @@ -91,9 +102,9 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment." (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)) + (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)))) @@ -121,3 +132,4 @@ stencil, so LaTeX includegraphics doesn't fuck up the alignment." (define convert-to-tex convert-to-tex) (define convert-to-dvi convert-to-dvi) + diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 2e8c78e2d5..1beaef6361 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -248,12 +248,6 @@ ;; restore color from stack (define (resetcolor) "setrgbcolor\n") -;; reset rotation -(define (resetrotation ang x y) - (format "~a translate ~a rotate ~a translate\n" - (numbers->string4 (list x y)) - (number->string (* -1 ang)) - (numbers->string4 (list (* -1 x) (* -1 y))))) (define (round-filled-box left right bottom top blotdiam) (let* ((halfblot (/ blotdiam 2)) @@ -272,11 +266,15 @@ ;; rotation around given point (define (setrotation ang x y) - (format "~a translate ~a rotate ~a translate\n" + (format "gsave ~a translate ~a rotate ~a translate\n" (numbers->string4 (list x y)) (number->string ang) (numbers->string4 (list (* -1 x) (* -1 y))))) +(define (resetrotation ang x y) + "grestore ") + + (define (text font s) ;; (ly:warning (_ "TEXT backend-command encountered in Pango backend")) ;; (ly:warning (_ "Arguments: ~a ~a"" font str)) diff --git a/scm/stencil.scm b/scm/stencil.scm index 0c4bf830cf..e4befe50d3 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -279,6 +279,7 @@ grestore (write-system-signatures basename (cdr paper-systems) (1+ count)))))) +(use-modules (scm paper-system)) (define-public (write-system-signature filename paper-system) (define (float? x) (and (number? x) (inexact? x))) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 29e112e498..3fe9421fa2 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -1743,18 +1743,18 @@ def main (): exit (1) if global_options.format in (TEXINFO, LATEX): - if not global_options.psfonts: - warning (_ ("option --psfonts not used")) - warning (_ ("processing with dvips will have no fonts")) - psfonts_file = os.path.join (global_options.output_name, basename + '.psfonts') output = os.path.join (global_options.output_name, basename + '.dvi' ) - progress ('\n') - progress (_ ("DVIPS usage:")) - progress ('\n') - progress (" dvips -h %(psfonts_file)s %(output)s" % vars ()) - progress ('\n') + if not global_options.psfonts: + warning (_ ("option --psfonts not used")) + warning (_ ("processing with dvips will have no fonts")) + else: + progress ('\n') + progress (_ ("DVIPS usage:")) + progress ('\n') + progress (" dvips -h %(psfonts_file)s %(output)s" % vars ()) + progress ('\n') inputs = note_input_file ('') inputs.pop () diff --git a/stepmake/stepmake/texinfo-rules.make b/stepmake/stepmake/texinfo-rules.make index 5941224ed1..5cf8c2d011 100644 --- a/stepmake/stepmake/texinfo-rules.make +++ b/stepmake/stepmake/texinfo-rules.make @@ -20,9 +20,8 @@ $(outdir)/%.ps.gz.omf: %.texi $(outdir)/%/%.html: $(outdir)/%.texi $(MAKEINFO) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html $< - -$(outdir)/%.dvi: $(outdir)/%.texi - cd $(outdir); texi2dvi $(TEXI2DVI_FLAGS) --batch $(TEXINFO_PAPERSIZE_OPTION) $(