]> git.donarmstrong.com Git - lilypond.git/blob - scm/titling.scm
28e0e9c8c8fc4c81ec80682e817fb51e64a40b00
[lilypond.git] / scm / titling.scm
1 ;;;; titling.scm -- titling functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 2004--2007 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;;          Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 (define-public (layout-extract-page-properties layout)
9   (list (append `((line-width . ,(ly:paper-get-number
10                                  layout 'line-width)))
11                 (ly:output-def-lookup layout 'text-font-defaults))))
12
13 ;;;;;;;;;;;;;;;;;;
14
15 (define-public ((marked-up-headfoot what-odd what-even)
16                 layout scopes page-number is-book-last-page is-part-last-page)
17
18   "Read variables WHAT-ODD, WHAT-EVEN from LAYOUT, and interpret them
19 as markup. The PROPS argument will include variables set in SCOPES and
20 page:last?, page:page-number-string and page:page-number
21
22
23   (define (get sym)
24     (ly:output-def-lookup layout sym))
25
26   (define (interpret-in-page-env potential-markup)
27     (if (markup? potential-markup)
28         (let* ((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                             alist))
39                      alists))
40                (pgnum-alist
41                 (list
42                  (cons 'header:tagline
43                        (ly:modules-lookup scopes 'tagline
44                                           (ly:output-def-lookup layout 'tagline)))
45                  (cons 'page:last? is-book-last-page)
46                  (cons 'page:part-last? is-part-last-page)
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                        (layout-extract-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                         (layout-extract-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)))))