1 ;;;; framework-ps.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004--2006 Han-Wen Nienhuys <hanwen@cs.uu.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."
33 (interval-start (ly:stencil-extent stc X)))
39 (ly:stencil-expr stil)
42 (cdr (ly:stencil-extent stil X)))
43 (ly:stencil-extent stil Y)
48 (define (dump-stencils-as-EPSes stencils book basename)
49 (define do-pdf (member "pdf" (ly:output-formats)))
50 (define paper (ly:paper-book-paper book))
51 (define (dump-infinite-stack-EPS stencils)
52 (let* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
53 (dump-stencil-as-EPS paper dump-me basename #t)))
55 (define (dump-stencils-as-separate-EPS stencils count )
57 (let* ((line (car stencils))
59 (system-base-name (format "~a-~a" basename count))
63 paper line system-base-name
64 (ly:get-option 'include-eps-fonts))
67 (postscript->pdf 0 0 (string-append system-base-name ".eps")))
68 (dump-stencils-as-separate-EPS rest (1+ count)))))
72 (let* ((tex-system-name (format "~a-systems.tex" basename))
73 (texi-system-name (format "~a-systems.texi" basename))
74 (tex-system-port (open-output-file tex-system-name))
75 (texi-system-port (open-output-file texi-system-name)))
77 (ly:message (_ "Writing ~a...") tex-system-name)
78 (ly:message (_ "Writing ~a...") texi-system-name)
80 (set! stencils (widen-left-stencil-edges stencils))
82 (dump-stencils-as-separate-EPS stencils 1)
85 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
88 \\betweenLilyPondSystem{~a}
90 " c) tex-system-port))
91 (display (format "\\includegraphics{~a-~a}\n"
92 basename (1+ c)) tex-system-port)
93 (display (format "@image{~a-~a}\n"
94 basename (1+ c)) texi-system-port))
95 (iota (length stencils)))
97 (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
98 (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
100 (dump-infinite-stack-EPS stencils)
101 (postprocess-output book framework-eps-module
102 (format "~a.eps" basename) (ly:output-formats))))
106 (define-public (output-classic-framework basename book scopes fields)
107 (output-scopes scopes fields basename)
109 (if (ly:get-option 'dump-signatures)
110 (write-system-signatures basename (ly:paper-book-systems book) 1))
112 (dump-stencils-as-EPSes
113 (map paper-system-stencil (ly:paper-book-systems book))
117 (define-public (output-framework basename book scopes fields)
118 (output-scopes scopes fields basename)
119 (dump-stencils-as-EPSes
120 (map page-stencil (ly:paper-book-pages book)) book basename))
123 ; redefine to imports from framework-ps
124 (define convert-to-pdf convert-to-pdf)
125 (define convert-to-ps convert-to-ps)
126 (define convert-to-png convert-to-png)
127 (define convert-to-tex convert-to-tex)
128 (define convert-to-dvi convert-to-dvi)