]> git.donarmstrong.com Git - lilypond.git/blob - scm/titling.scm
* scm/stencil.scm (stack-lines): return empty-stencil if argument
[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              (pgnum-alist (list
42                            (cons 'page:last? last?)
43                            (cons 'page:page-number-string
44                                  (number->string page-number))
45                            (cons 'page:page-number  page-number)))
46              (props (append
47                      (list pgnum-alist)
48                      prefixed-alists
49                      (page-properties layout)))
50              )
51
52           (interpret-markup layout props potential-markup))
53         
54         empty-stencil))
55
56   (interpret-in-page-env
57    (if (and (even? page-number)
58             (markup? (get what-even)))
59        (get what-even)
60        (get what-odd))))
61
62 (define-public ((marked-up-title what) layout scopes)
63   "Read variables WHAT from SCOPES, and interpret it as markup. The
64 PROPS argument will include variables set in SCOPES (prefixed with
65 `header:'
66 "
67   
68   (define (get sym)
69     (let ((x (ly:modules-lookup scopes sym)))
70       (if (markup? x) x #f)))
71
72   (let*
73       ((alists  (map ly:module->alist scopes))
74        (prefixed-alist
75         (map (lambda (alist)
76                (map (lambda (entry)
77                       (cons
78                        (string->symbol
79                         (string-append
80                          "header:"
81                          (symbol->string (car entry))))
82                        (cdr entry)
83                       ))
84                     alist))
85              alists))
86        (props (append prefixed-alist
87                       (page-properties layout)))
88
89        (markup (ly:output-def-lookup layout what))
90        )
91
92     (if (markup? markup)
93         (interpret-markup layout props markup)
94         (ly:make-stencil '() '(1 . -1) '(1 . -1)))
95   ))
96