1 ;;;; framework-ps.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 (define-module (scm framework-eps))
9 ;;; this is still too big a mess.
11 (use-modules (ice-9 regex)
23 (define framework-eps-module (current-module))
26 (define (widen-left-stencil-edges stencils)
27 "Change STENCILS to use the union for the left extents in every
28 stencil, so LaTeX includegraphics doesn't fuck up the alignment."
35 (interval-start (ly:stencil-extent stc X)))
42 (ly:stencil-expr stil)
45 (cdr (ly:stencil-extent stil X)))
46 (ly:stencil-extent stil Y)
50 (define (dump-stencils-as-EPSes stencils book basename)
51 (define do-pdf (member "pdf" (ly:output-formats)))
52 (define paper (ly:paper-book-paper book))
53 (define (dump-infinite-stack-EPS stencils)
54 (let* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
55 (dump-stencil-as-EPS paper dump-me basename #t)))
57 (define (dump-counted-stencil stencil-count-pair)
60 ((stencil (car stencil-count-pair))
61 (number (cdr stencil-count-pair))
62 (name (format "~a-~a" basename number)))
66 (ly:get-option 'include-eps-fonts))
68 (string-append name ".eps")))
70 (define (dump-stencils-as-separate-EPS stencils count)
72 (let* ((line (car stencils))
74 (system-base-name (format "~a-~a" basename count))
78 paper line system-base-name)
81 (postscript->pdf 0 0 (string-append system-base-name ".eps")))
82 (dump-stencils-as-separate-EPS rest (1+ count)))))
85 (let* ((write-file (lambda (str-port ext)
87 ((name (format "~a-systems.~a" basename ext))
88 (port (open-output-file name)))
89 (ly:message (_ "Writing ~a...") name)
90 (display (get-output-string str-port) port)
91 (close-output-port port)
94 (tex-system-port (open-output-string))
95 (texi-system-port (open-output-string))
96 (widened-stencils (widen-left-stencil-edges stencils))
97 (counted-systems (count-list widened-stencils))
98 (eps-files (map dump-counted-stencil counted-systems))
103 ;; par-for-each: a bit faster ...
106 (postscript->pdf 0 0 y))
109 (for-each (lambda (c)
111 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
114 \\betweenLilyPondSystem{~a}
116 " c) tex-system-port))
117 (display (format "\\includegraphics{~a-~a}\n"
118 basename (1+ c)) tex-system-port)
119 (display (format "@image{~a-~a}\n"
120 basename (1+ c)) texi-system-port))
121 (iota (length stencils)))
123 (display "@c eof." texi-system-port)
124 (display "% eof. " tex-system-port)
126 (dump-infinite-stack-EPS stencils)
127 (postprocess-output book framework-eps-module
128 (format "~a.eps" basename) (ly:output-formats))
130 (write-file texi-system-port "texi")
131 (write-file tex-system-port "tex")
136 (define-public (output-classic-framework basename book scopes fields)
137 (output-scopes scopes fields basename)
139 (if (ly:get-option 'dump-signatures)
140 (write-system-signatures basename (ly:paper-book-systems book) 1))
142 (dump-stencils-as-EPSes
143 (map paper-system-stencil (ly:paper-book-systems book))
147 (define-public (output-framework basename book scopes fields)
148 (output-scopes scopes fields basename)
149 (dump-stencils-as-EPSes
150 (map page-stencil (ly:paper-book-pages book)) book basename))
153 ; redefine to imports from framework-ps
154 (define convert-to-pdf convert-to-pdf)
155 (define convert-to-ps convert-to-ps)
156 (define convert-to-png convert-to-png)
157 (define convert-to-tex convert-to-tex)
158 (define convert-to-dvi convert-to-dvi)