]> git.donarmstrong.com Git - lilypond.git/blob - scm/titling.scm
(marked-up-headfoot): revert Pedro's patch.
[lilypond.git] / scm / titling.scm
1 ;;;; titling.scm -- titling functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 2004--2005 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;;          Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8 (define-public (layout-extract-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* ((alists (map ly:module->alist scopes))
28                (prefixed-alists
29                 (map (lambda (alist)
30                        (map (lambda (entry)
31                               (cons
32                                (string->symbol
33                                 (string-append
34                                  "header:"
35                                  (symbol->string (car entry))))
36                                (cdr entry)))
37                             alist))
38                      alists))
39                (tagline (ly:modules-lookup scopes 'tagline)) 
40                (default-tagline (ly:output-def-lookup layout 'tagline)) 
41
42                (pgnum-alist
43                 (list
44                  (cons 'header:tagline
45                        (cond
46                         ((markup? tagline) tagline)
47                         ((markup? default-tagline) default-tagline)
48                         (else "")))
49                  (cons 'page:last? last?)
50                  (cons 'page:page-number-string
51                        (number->string page-number))
52                  (cons 'page:page-number page-number)))
53                (props (append
54                        (list pgnum-alist)
55                        prefixed-alists
56                        (layout-extract-page-properties layout))))
57
58           (interpret-markup layout props potential-markup))
59
60         empty-stencil))
61
62   (interpret-in-page-env
63    (if (and (even? page-number)
64             (markup? (get what-even)))
65        (get what-even)
66        (get what-odd))))
67
68 (define-public ((marked-up-title what) layout scopes)
69   "Read variables WHAT from SCOPES, and interpret it as markup. The
70 PROPS argument will include variables set in SCOPES (prefixed with
71 `header:'
72 "
73   
74   (define (get sym)
75     (let ((x (ly:modules-lookup scopes sym)))
76       (if (markup? x) x #f)))
77
78   (let* ((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                       alist))
89                alists))
90          (props (append prefixed-alist
91                         (layout-extract-page-properties layout)))
92
93          (markup (ly:output-def-lookup layout what)))
94
95     (if (markup? markup)
96         (interpret-markup layout props markup)
97         (ly:make-stencil '() '(1 . -1) '(1 . -1)))))