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