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)
47 (define (dump-stencils-as-EPSes stencils book basename)
48 (define paper (ly:paper-book-paper book))
49 (define (dump-infinite-stack-EPS stencils)
50 (let* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
51 (dump-stencil-as-EPS paper dump-me basename #t)))
53 (define (dump-stencils-as-separate-EPS stencils count)
55 (let* ((line (car stencils))
56 (rest (cdr stencils)))
59 paper line (format "~a-~a" basename count)
60 (ly:get-option 'eps-font-include))
62 (dump-stencils-as-separate-EPS rest (1+ count)))))
66 (let* ((tex-system-name (format "~a-systems.tex" basename))
67 (texi-system-name (format "~a-systems.texi" basename))
68 (tex-system-port (open-output-file tex-system-name))
69 (texi-system-port (open-output-file texi-system-name)))
71 (ly:message (_ "Writing ~a...") tex-system-name)
72 (ly:message (_ "Writing ~a...") texi-system-name)
74 (set! stencils (widen-left-stencil-edges stencils))
76 (dump-stencils-as-separate-EPS stencils 1)
79 (display (format "\\ifx\\betweenLilyPondSystem \\undefined
82 \\betweenLilyPondSystem{~a}
84 " c) tex-system-port))
85 (display (format "\\includegraphics{~a-~a.eps}\n"
86 basename (1+ c)) tex-system-port)
87 (display (format "@image{~a-~a}\n"
88 basename (1+ c)) texi-system-port))
89 (iota (length stencils)))
91 (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
92 (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
94 (dump-infinite-stack-EPS stencils))
95 (postprocess-output book framework-eps-module
96 (format "~a.eps" basename) (ly:output-formats)))
100 (define-public (output-classic-framework basename book scopes fields)
101 (output-scopes scopes fields basename)
103 (if (ly:get-option 'dump-signatures)
104 (write-system-signatures basename (ly:paper-book-systems book) 0))
106 (dump-stencils-as-EPSes
107 (map paper-system-stencil (ly:paper-book-systems book))
111 (define-public (output-framework basename book scopes fields)
112 (output-scopes scopes fields basename)
113 (dump-stencils-as-EPSes
114 (map page-stencil (ly:paper-book-pages book)) book basename))
117 ; redefine to imports from framework-ps
118 (define convert-to-pdf convert-to-pdf)
119 (define convert-to-ps convert-to-ps)
120 (define convert-to-png convert-to-png)
121 (define convert-to-tex convert-to-tex)
122 (define convert-to-dvi convert-to-dvi)