]> git.donarmstrong.com Git - lilypond.git/blob - scm/titling.scm
*** empty log message ***
[lilypond.git] / scm / titling.scm
1 ;;;; titling.scm -- titling functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;;          Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8 (define-public (page-properties layout)
9   (list (append `((linewidth . ,(ly:paper-get-number
10                                  layout 'linewidth)))
11                 (ly:output-def-lookup layout 'text-font-defaults))))
12
13 ;;;;;;;;;;;;;;;;;;
14
15 (define-public ((marked-up-headfoot what-odd what-even) layout scopes page-number last?)
16
17   "Read variables WHAT-ODD, WHAT-EVEN from LAYOUT, and interpret them
18 as markup. The PROPS argument will include variables set in SCOPES and
19 page:last?, page:page-number-string and page:page-number
20
21
22   (define (get sym)
23     (ly:output-def-lookup layout sym))
24
25   (define (interpret-in-page-env potential-markup)
26     (if (markup? potential-markup)
27         (let*
28             ((alists  (map ly:module->alist scopes))
29              (prefixed-alists
30               (map (lambda (alist)
31                      (map (lambda (entry)
32                             (cons
33                              (string->symbol
34                               (string-append
35                                "header:"
36                                (symbol->string (car entry))))
37                              (cdr entry)
38                              ))
39                           alist))
40                    alists))
41              (tagline (ly:modules-lookup scopes 'tagline)) 
42
43              (pgnum-alist
44                (list
45                 (cons 'header:tagline (if (markup? tagline)
46                                           tagline
47                                           TAGLINE)))
48                 (cons 'page:last? last?)
49                 (cons 'page:page-number-string
50                       (number->string page-number))
51                 (cons 'page:page-number  page-number))
52              (props (append
53                      (list pgnum-alist)
54                      prefixed-alists
55                      (page-properties layout))))
56
57           (interpret-markup layout props potential-markup))
58         
59         empty-stencil))
60
61   (interpret-in-page-env
62    (if (and (even? page-number)
63             (markup? (get what-even)))
64        (get what-even)
65        (get what-odd))))
66
67 (define-public ((marked-up-title what) layout scopes)
68   "Read variables WHAT from SCOPES, and interpret it as markup. The
69 PROPS argument will include variables set in SCOPES (prefixed with
70 `header:'
71 "
72   
73   (define (get sym)
74     (let ((x (ly:modules-lookup scopes sym)))
75       (if (markup? x) x #f)))
76
77   (let*
78       ((alists  (map ly:module->alist scopes))
79        (prefixed-alist
80         (map (lambda (alist)
81                (map (lambda (entry)
82                       (cons
83                        (string->symbol
84                         (string-append
85                          "header:"
86                          (symbol->string (car entry))))
87                        (cdr entry)
88                       ))
89                     alist))
90              alists))
91        (props (append prefixed-alist
92                       (page-properties layout)))
93
94        (markup (ly:output-def-lookup layout what))
95        )
96
97     (if (markup? markup)
98         (interpret-markup layout props markup)
99         (ly:make-stencil '() '(1 . -1) '(1 . -1)))
100   ))
101