X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fframework-eps.scm;h=ad5125d3dd549258a74abcc1df0b0af199ffd871;hb=3ee0df13c3fe001cef0bef15adcbadfb2c394fd8;hp=29d4df46b2e29c4270a60d17221a097b94905dc7;hpb=6ddd5b9373861e63801b29b336580621ca4b9ef1;p=lilypond.git diff --git a/scm/framework-eps.scm b/scm/framework-eps.scm index 29d4df46b2..ad5125d3dd 100644 --- a/scm/framework-eps.scm +++ b/scm/framework-eps.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2004--2005 Han-Wen Nienhuys +;;;; (c) 2004--2006 Han-Wen Nienhuys (define-module (scm framework-eps)) @@ -13,6 +13,8 @@ (ice-9 format) (guile) (scm framework-ps) + (scm paper-system) + (scm page) (scm output-ps) (srfi srfi-1) (srfi srfi-13) @@ -20,24 +22,53 @@ (define framework-eps-module (current-module)) + +(define (widen-left-stencil-edges stencils) + "Change STENCILS to use the union for the left extents in every +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))) + + (map (lambda (stil) + + (ly:make-stencil + (ly:stencil-expr stil) + (cons + left + (cdr (ly:stencil-extent stil X))) + (ly:stencil-extent stil Y) + )) + 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) - (ly:output-def-lookup paper 'force-eps-font-include)) - + paper line system-base-name + (ly:get-option 'include-eps-fonts)) + + (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)) @@ -45,39 +76,48 @@ (ly:message (_ "Writing ~a...") tex-system-name) (ly:message (_ "Writing ~a...") texi-system-name) + + (set! stencils (widen-left-stencil-edges stencils)) + (dump-stencils-as-separate-EPS stencils 1) (for-each (lambda (c) (if (< 0 c) - (begin - (display "\\ifx\\betweenLilyPondSystem \\undefined\n" tex-system-port) - (display " \\relax\n" tex-system-port) - (display "\\else\n" tex-system-port) - (display (format - " \\betweenLilyPondSystem{~a}\n" c) tex-system-port) - (display "\\fi\n" tex-system-port))) - (display (format "\\includegraphics{~a-~a.eps}\n" + (display (format "\\ifx\\betweenLilyPondSystem \\undefined + \\linebreak +\\else + \\betweenLilyPondSystem{~a} +\\fi +" c) tex-system-port)) + (display (format "\\includegraphics{~a-~a}\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 - '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)))) + + (define-public (output-classic-framework basename book scopes fields) (output-scopes scopes fields basename) + + (if (ly:get-option 'dump-signatures) + (write-system-signatures basename (ly:paper-book-systems book) 1)) (dump-stencils-as-EPSes - (map ly:paper-system-stencil (ly:paper-book-systems book)) + (map paper-system-stencil (ly:paper-book-systems book)) book basename)) (define-public (output-framework basename book scopes fields) (output-scopes scopes fields basename) - (dump-stencils-as-EPSes (ly:paper-book-pages book) book basename)) + (dump-stencils-as-EPSes + (map page-stencil (ly:paper-book-pages book)) book basename)) ; redefine to imports from framework-ps @@ -87,3 +127,4 @@ (define convert-to-tex convert-to-tex) (define convert-to-dvi convert-to-dvi) +