]> git.donarmstrong.com Git - lilypond.git/blob - scm/framework-eps.scm
(dump-stencil-as-EPS): robustness: ensure
[lilypond.git] / scm / framework-eps.scm
1 ;;;; framework-ps.scm --
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c)  2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6
7 (define-module (scm framework-eps))
8
9 ;;; this is still too big a mess.
10
11 (use-modules (ice-9 regex)
12              (ice-9 string-fun)
13              (ice-9 format)
14              (guile)
15              (scm framework-ps)
16              (scm output-ps)
17              (srfi srfi-1)
18              (srfi srfi-13)
19              (lily))
20
21 (define framework-eps-module (current-module))
22
23 (define (dump-stencils-as-EPSes stencils book basename)
24   (define paper (ly:paper-book-paper book))
25   (define (dump-infinite-stack-EPS stencils)
26     (let*
27         ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
28       (dump-stencil-as-EPS paper dump-me basename #t)
29       ))
30
31   (define (dump-stencils-as-separate-EPS stencils count)
32     (if (pair? stencils)
33         (let*
34             ((line (car stencils))
35              (rest (cdr stencils)))
36           (dump-stencil-as-EPS
37            paper
38            line (format "~a-~a" basename count)
39            #f)
40
41           (dump-stencils-as-separate-EPS rest (1+ count))
42           )))
43   
44   (let* ((tex-system-name (format "~a-systems.tex" basename))
45          (texi-system-name (format "~a-systems.texi" basename))
46          (tex-system-port (open-output-file tex-system-name))
47          (texi-system-port (open-output-file texi-system-name)))
48     
49     (display (format "Writing ~a\n" tex-system-name))
50     (display (format "Writing ~a\n" texi-system-name))
51     (dump-stencils-as-separate-EPS stencils 1)
52     (for-each (lambda (c)
53                 (display (format "\\includegraphics{~a-~a.eps}%\n"
54                                  basename (1+ c)) tex-system-port)
55                 (display (format "@image{~a-~a}@c\n"
56                                  basename (1+ c)) texi-system-port))
57               (iota (length stencils)))
58
59     (display "@c eof" texi-system-port)
60     (display "% eof" tex-system-port)
61     
62     (dump-infinite-stack-EPS stencils))
63     (postprocess-output book framework-eps-module
64                         (format "~a.eps" basename) (ly:output-formats)))
65
66 (define-public (output-classic-framework
67                 basename book scopes fields)
68
69   (dump-stencils-as-EPSes
70    (map ly:paper-system-stencil (ly:paper-book-systems book))
71    book
72    basename))
73
74 (define-public (output-framework basename book scopes fields)
75   (dump-stencils-as-EPSes (ly:paper-book-pages book)
76                           book
77                           basename))
78   
79
80 ; redefine to imports from framework-ps
81 (define convert-to-pdf convert-to-pdf)
82 (define convert-to-ps convert-to-ps)
83 (define convert-to-png convert-to-png)
84 (define convert-to-tex convert-to-tex)
85 (define convert-to-dvi convert-to-dvi)
86