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)))
57 paper line (format "~a-~a" basename count)
58 (ly:output-def-lookup paper 'force-eps-font-include))
60 (dump-stencils-as-separate-EPS rest (1+ count)))))
64 (let* ((tex-system-name (format "~a-systems.tex" basename))
65 (texi-system-name (format "~a-systems.texi" basename))
66 (tex-system-port (open-output-file tex-system-name))
67 (texi-system-port (open-output-file texi-system-name)))
69 (ly:message (_ "Writing ~a...") tex-system-name)
70 (ly:message (_ "Writing ~a...") texi-system-name)
72 (set! stencils (widen-left-stencil-edges stencils))
74 (dump-stencils-as-separate-EPS stencils 1)
77 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
80 \\betweenLilyPondSystem{~a}
82 " c) tex-system-port))
83 (display (format "\\includegraphics{~a-~a.eps}\n"
84 basename (1+ c)) tex-system-port)
85 (display (format "@image{~a-~a}\n"
86 basename (1+ c)) texi-system-port))
87 (iota (length stencils)))
89 (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
90 (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
92 (dump-infinite-stack-EPS stencils))
93 (postprocess-output book framework-eps-module
94 (format "~a.eps" basename) (ly:output-formats)))
96 (define-public (output-classic-framework basename book scopes fields)
97 (output-scopes scopes fields basename)
99 (dump-stencils-as-EPSes
100 (map paper-system-stencil (ly:paper-book-systems book))
104 (define-public (output-framework basename book scopes fields)
105 (output-scopes scopes fields basename)
106 (dump-stencils-as-EPSes (ly:paper-book-pages book) book basename))
109 ; redefine to imports from framework-ps
110 (define convert-to-pdf convert-to-pdf)
111 (define convert-to-ps convert-to-ps)
112 (define convert-to-png convert-to-png)
113 (define convert-to-tex convert-to-tex)
114 (define convert-to-dvi convert-to-dvi)