]> git.donarmstrong.com Git - lilypond.git/blob - scm/framework-eps.scm
(LY_DEFINE): ly:parser-output-name:
[lilypond.git] / scm / framework-eps.scm
1 ;;;; framework-ps.scm --
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 2004--2005 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* ((dump-me (stack-stencils Y DOWN 2.0 stencils)))
27       (dump-stencil-as-EPS paper dump-me basename #t)))
28
29   (define (dump-stencils-as-separate-EPS stencils count)
30     (if (pair? stencils)
31         (let* ((line (car stencils))
32                (rest (cdr stencils)))
33
34           (dump-stencil-as-EPS
35            paper
36            line (format "~a-~a" basename count)
37            (ly:output-def-lookup paper 'force-eps-font-include))
38           
39           (dump-stencils-as-separate-EPS rest (1+ count)))))
40   
41   (let* ((tex-system-name (format "~a-systems.tex" basename))
42          (texi-system-name (format "~a-systems.texi" basename))
43          (tex-system-port (open-output-file tex-system-name))
44          (texi-system-port (open-output-file texi-system-name)))
45     
46     (ly:message (_ "Writing ~a...") tex-system-name)
47     (ly:message (_ "Writing ~a...") texi-system-name)
48     (dump-stencils-as-separate-EPS stencils 1)
49     (for-each (lambda (c)
50                 (if (< 0 c)
51                     (begin 
52                       (display "\\ifx\\betweenLilyPondSystem \\undefined\n" tex-system-port)
53                       (display "  \\relax\n" tex-system-port)
54                       (display "\\else\n" tex-system-port)
55                       (display (format 
56                                 "  \\betweenLilyPondSystem{~a}\n" c) tex-system-port)
57                       (display "\\fi\n" tex-system-port)))
58                 (display (format "\\includegraphics{~a-~a.eps}\n"
59                                  basename (1+ c)) tex-system-port)
60                 (display (format "@image{~a-~a}\n"
61                                  basename (1+ c)) texi-system-port))
62               (iota (length stencils)))
63     (display "@c eof - 'eof' is a Makefile marker; do not remove. " texi-system-port)
64     (display "% eof - 'eof' is Makefile marker; do not remove. " tex-system-port)
65     
66     (dump-infinite-stack-EPS stencils))
67     (postprocess-output book framework-eps-module
68                         (format "~a.eps" basename) (ly:output-formats)))
69
70 (define-public (output-classic-framework basename book scopes fields)
71   (output-scopes scopes fields basename)
72   
73   (dump-stencils-as-EPSes
74    (map ly:paper-system-stencil (ly:paper-book-systems book))
75    book
76    basename))
77
78 (define-public (output-framework basename book scopes fields)
79   (output-scopes scopes fields basename)
80   (dump-stencils-as-EPSes (ly:paper-book-pages book) book basename))
81   
82
83 ; redefine to imports from framework-ps
84 (define convert-to-pdf convert-to-pdf)
85 (define convert-to-ps convert-to-ps)
86 (define convert-to-png convert-to-png)
87 (define convert-to-tex convert-to-tex)
88 (define convert-to-dvi convert-to-dvi)
89