X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fbackend-library.scm;h=c0f5b5ba5dc4a4eea99bf03664e17a190dc3419e;hb=57aed6a58e0e064d5e6c58280dbda8208f9c828b;hp=25b2ae9e7b3d427cd798467ba1a1af29a0779b1b;hpb=b7f005cbf2757c8c1d3383a0ccc935cf5e3c2e38;p=lilypond.git diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 25b2ae9e7b..c0f5b5ba5d 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2005 Jan Nieuwenhuizen +;;;; (c) 2005--2006 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -27,9 +27,11 @@ (throw 'ly-file-failed))))) (define-public (sanitize-command-option str) + "Kill dubious shell quoting" + (string-append "\"" - (regexp-substitute/global #f "[^- 0-9,.a-zA-Z'\"\\]" str 'pre 'post) + (regexp-substitute/global #f "[^-_ 0-9,.a-zA-Z'\"\\]" str 'pre 'post) "\"")) (define-public (search-executable names) @@ -43,16 +45,27 @@ (helper path names))) (define-public (search-gs) - (search-executable '("gs-nox" "gs-8.15" "gs"))) + + ;; 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 (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 ))) -(define-public (postscript->pdf papersizename name) - (let* ((pdf-name (string-append (basename name ".ps") ".pdf")) (cmd (format #f "~a\ ~a\ ~a\ + ~a\ -dCompatibilityLevel=1.4 \ - -sPAPERSIZE=~a\ -dNOPAUSE\ -dBATCH\ -r1200 \ @@ -63,10 +76,10 @@ " (search-gs) (if (ly:get-option 'verbose) "" "-q") - (if (ly:get-option 'gs-font-load) + (if (ly:get-option 'gs-load-fonts) " -dNOSAFER " " -dSAFER ") - (sanitize-command-option papersizename) + paper-size-string pdf-name name))) ;; The wrapper on windows cannot handle `=' signs, @@ -82,29 +95,44 @@ (ly:message (_ "Converting to `~a'...") pdf-name) (ly:progress "\n") (ly:system cmd) - - (if (ly:get-option 'delete-intermediate-files) - (delete-file name)))) + )) (use-modules (scm ps-to-png)) -(define-public (postscript->png resolution paper-size-name name) + +(define-public (postscript->png resolution paper-width paper-height name) ;; Do not try to guess the name of the png file, ;; GS produces PNG files like BASE-page%d.png. ;;(ly:message (_ "Converting to `~a'...") ;; (string-append (basename name ".ps") "-page1.png" ))) - (let ((paper-size (sanitize-command-option paper-size-name)) - (verbose (ly:get-option 'verbose)) - (rename-page-1 #t)) + (let ((verbose (ly:get-option 'verbose)) + (rename-page-1 #f)) + (ly:message (_ "Converting to ~a...") "PNG") - (make-ps-images name resolution paper-size rename-page-1 verbose) + (make-ps-images name resolution paper-width paper-height rename-page-1 verbose + (ly:get-option 'anti-alias-factor)) (ly:progress "\n"))) (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)) + (let* + ((completed (completize-formats formats)) + (base (string-regexp-substitute "\\.[a-z]+$" "" filename)) + (intermediate (remove + (lambda (x) + (member x formats)) + completed))) + + (for-each + (lambda (f) + ((eval (string->symbol (format "convert-to-~a" f)) module) + paper-book filename)) + completed) + + (if (ly:get-option 'delete-intermediate-files) + (for-each + (lambda (f) + (delete-file (string-append base "." f))) + intermediate)) + )) (define-public (completize-formats formats) (define new-fmts '())