1 ;;;; paper.scm -- manipulate the paper block.
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 (define-public (paper-set-staff-size sz)
9 "Function to be called inside a \\paper{} block to set the staff size."
10 (let* ((m (current-module))
15 (module-define! m 'fonts (make-font-tree (/ sz (* 20 pt))))
17 (module-define! m 'staffheight sz)
18 (module-define! m 'staff-space ss)
19 (module-define! m 'staffspace ss)
22 ;; !! synchronize with feta-params.mf
23 (module-define! m 'linethickness (+ (* 0.3 pt) (* 0.04 ss)))
24 (module-define! m 'outputscale ss)
25 (module-define! m 'ledgerlinethickness (+ (* 0.5 pt) (/ ss 10)))
26 (module-define! m 'blotdiameter (* 0.35 pt))
27 (module-define! m 'interscoreline (* 4 mm))))
29 (define-public (set-global-staff-size sz)
30 "Set the default staff size, where SZ is thought to be in PT."
31 (let* ((old-mod (current-module))
32 (pap (eval '$defaultpaper old-mod))
33 (new-paper (ly:output-def-clone pap))
34 (new-scope (ly:output-def-scope new-paper)))
35 (set-current-module new-scope)
36 (paper-set-staff-size (* sz (eval 'pt new-scope)))
37 (set-current-module old-mod)
38 (module-define! old-mod '$defaultpaper new-paper)))
41 '(("a6" . (cons (* 105 mm) (* 148.95 mm)))
42 ("a5" . (cons (* 148.95 mm) (* 210 mm)))
43 ("a4" . (cons (* 210 mm) (* 297.9 mm)))
44 ("a3" . (cons (* 297.9 mm) (* 420 mm)))
45 ("legal" . (cons (* 8.5 in) (* 14.0 in)))
46 ("letter" . (cons (* 8.5 in) (* 11.0 in)))
47 ("tabloid" . (cons (* 11.0 in) (* 17.0 in)))))
49 ;; todo: take dimension arguments.
51 (define (set-paper-dimensions m w h)
52 "M is a module (i.e. paper->scope_ )"
53 (let* ((mm (eval 'mm m)))
54 (module-define! m 'hsize w)
55 (module-define! m 'vsize h)
56 (module-define! m 'linewidth (- w (* 20 mm)))
57 (module-define! m 'raggedright #f)
58 (module-define! m 'packed #f)
59 (module-define! m 'indent (/ w 14))
61 ;; page layout - what to do with (printer specific!) margin settings?
62 (module-define! m 'top-margin (* 5 mm))
63 (module-define! m 'bottom-margin (* 6 mm))
64 (module-define! m 'head-sep (* 4 mm))
65 (module-define! m 'foot-sep (* 4 mm))))
67 (define-public (set-paper-size name)
68 (let* ((entry (assoc name paper-alist))
69 (pap (eval '$defaultpaper (current-module)))
70 (new-paper (ly:output-def-clone pap))
71 (m (ly:output-def-scope new-paper))
76 (set! entry (eval (cdr entry) m))
77 (set-paper-dimensions m (car entry) (cdr entry))
78 (module-define! m 'papersize name)
79 (module-define! m 'papersizename name)
80 (set-paper-dimensions m (car entry) (cdr entry))
81 (module-define! (current-module) '$defaultpaper new-paper))
82 (ly:warning (string-append "Unknown papersize: " name)))))