Add 128th flags
[lilypond.git] / scm / titling.scm
blobd34b7113d46aa89eee62234d4c45f1db76832f4f
1 ;;;; titling.scm -- titling functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;;
5 ;;;; (c) 2004--2008 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;;          Han-Wen Nienhuys <hanwen@xs4all.nl>
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))))
13 ;;;;;;;;;;;;;;;;;;
15 (define-public ((marked-up-headfoot what-odd what-even)
16                 layout scopes page-number is-last-bookpart is-bookpart-last-page)
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:is-bookpart-last-page, page:is-last-bookpart, page:page-number-string
21 and page:page-number" 
23   (define (get sym)
24     (ly:output-def-lookup layout sym))
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:is-last-bookpart is-last-bookpart)
46                  (cons 'page:is-bookpart-last-page is-bookpart-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           (interpret-markup layout props potential-markup))
56         empty-stencil))
58   (interpret-in-page-env
59    (if (and (even? page-number)
60             (markup? (get what-even)))
61        (get what-even)
62        (get what-odd))))
64 (define-public ((marked-up-title what) layout scopes)
65   "Read variables WHAT from SCOPES, and interpret it as markup. The
66 PROPS argument will include variables set in SCOPES (prefixed with
67 `header:'
69   
70   (define (get sym)
71     (let ((x (ly:modules-lookup scopes sym)))
72       (if (markup? x) x #f)))
74   (let* ((alists (map ly:module->alist scopes))
75          (prefixed-alist
76           (map (lambda (alist)
77                  (map (lambda (entry)
78                         (cons
79                          (string->symbol
80                           (string-append
81                            "header:"
82                            (symbol->string (car entry))))
83                          (cdr entry)))
84                       alist))
85                alists))
86          (props (append prefixed-alist
87                         (layout-extract-page-properties layout)))
89          (markup (ly:output-def-lookup layout what)))
91     (if (markup? markup)
92         (interpret-markup layout props markup)
93         (ly:make-stencil '() '(1 . -1) '(1 . -1)))))