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* ((tex-system-name (format "~a-systems.tex" basename))
86 (texi-system-name (format "~a-systems.texi" basename))
87 (tex-system-port (open-output-file tex-system-name))
88 (texi-system-port (open-output-file texi-system-name))
89 (widened-stencils (widen-left-stencil-edges stencils))
90 (counted-systems (count-list widened-stencils))
91 (eps-files (map dump-counted-stencil counted-systems))
94 (ly:message (_ "Writing ~a...") tex-system-name)
95 (ly:message (_ "Writing ~a...") texi-system-name)
99 ;; par-for-each: a bit faster ...
102 (postscript->pdf 0 0 y))
105 (for-each (lambda (c)
107 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
110 \\betweenLilyPondSystem{~a}
112 " c) tex-system-port))
113 (display (format "\\includegraphics{~a-~a}\n"
114 basename (1+ c)) tex-system-port)
115 (display (format "@image{~a-~a}\n"
116 basename (1+ c)) texi-system-port))
117 (iota (length stencils)))
119 (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
120 (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
122 (close-output-port texi-system-port)
123 (close-output-port tex-system-port)
125 (dump-infinite-stack-EPS stencils)
126 (postprocess-output book framework-eps-module
127 (format "~a.eps" basename) (ly:output-formats))))
131 (define-public (output-classic-framework basename book scopes fields)
132 (output-scopes scopes fields basename)
134 (if (ly:get-option 'dump-signatures)
135 (write-system-signatures basename (ly:paper-book-systems book) 1))
137 (dump-stencils-as-EPSes
138 (map paper-system-stencil (ly:paper-book-systems book))
142 (define-public (output-framework basename book scopes fields)
143 (output-scopes scopes fields basename)
144 (dump-stencils-as-EPSes
145 (map page-stencil (ly:paper-book-pages book)) book basename))
148 ; redefine to imports from framework-ps
149 (define convert-to-pdf convert-to-pdf)
150 (define convert-to-ps convert-to-ps)
151 (define convert-to-png convert-to-png)
152 (define convert-to-tex convert-to-tex)
153 (define convert-to-dvi convert-to-dvi)