1 ;;;; framework-ps.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004--2005 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)
21 (define framework-eps-module (current-module))
24 (define (widen-left-stencil-edges stencils)
25 "Change STENCILS to use the union for the left extents in every
26 stencil, so LaTeX includegraphics doesn't fuck up the alignment."
31 (interval-start (ly:stencil-extent stc X)))
37 (ly:stencil-expr stil)
40 (cdr (ly:stencil-extent stil X)))
41 (ly:stencil-extent stil Y)
45 (define (dump-stencils-as-EPSes stencils book basename)
46 (define paper (ly:paper-book-paper book))
47 (define (dump-infinite-stack-EPS stencils)
48 (let* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
49 (dump-stencil-as-EPS paper dump-me basename #t)))
51 (define (dump-stencils-as-separate-EPS stencils count)
53 (let* ((line (car stencils))
54 (rest (cdr stencils)))
58 line (format "~a-~a" basename count)
59 (ly:output-def-lookup paper 'force-eps-font-include))
61 (dump-stencils-as-separate-EPS rest (1+ count)))))
65 (let* ((tex-system-name (format "~a-systems.tex" basename))
66 (texi-system-name (format "~a-systems.texi" basename))
67 (tex-system-port (open-output-file tex-system-name))
68 (texi-system-port (open-output-file texi-system-name)))
70 (ly:message (_ "Writing ~a...") tex-system-name)
71 (ly:message (_ "Writing ~a...") texi-system-name)
73 (set! stencils (widen-left-stencil-edges stencils))
75 (dump-stencils-as-separate-EPS stencils 1)
78 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
81 \\betweenLilyPondSystem{~a}
83 " c) tex-system-port))
84 (display (format "\\includegraphics{~a-~a.eps}\n"
85 basename (1+ c)) tex-system-port)
86 (display (format "@image{~a-~a}\n"
87 basename (1+ c)) texi-system-port))
88 (iota (length stencils)))
90 (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
91 (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
93 (dump-infinite-stack-EPS stencils))
94 (postprocess-output book framework-eps-module
95 (format "~a.eps" basename) (ly:output-formats)))
97 (define-public (output-classic-framework basename book scopes fields)
98 (output-scopes scopes fields basename)
100 (dump-stencils-as-EPSes
101 (map paper-system-stencil (ly:paper-book-systems book))
105 (define-public (output-framework basename book scopes fields)
106 (output-scopes scopes fields basename)
107 (dump-stencils-as-EPSes (ly:paper-book-pages book) book basename))
110 ; redefine to imports from framework-ps
111 (define convert-to-pdf convert-to-pdf)
112 (define convert-to-ps convert-to-ps)
113 (define convert-to-png convert-to-png)
114 (define convert-to-tex convert-to-tex)
115 (define convert-to-dvi convert-to-dvi)