X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fpaper.scm;h=87d171802e27a73d16b9e3552f2ba0d83f5248b8;hb=63f0404bafc5e217d0719096bfb9c56a1dd6abd1;hp=5cd99e70cdbda708e8809f464d54a18d40bace43;hpb=a3b77f0ba946e812b2188db4725e4a40cd4574bd;p=lilypond.git diff --git a/scm/paper.scm b/scm/paper.scm index 5cd99e70cd..87d171802e 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2004--2006 Han-Wen Nienhuys +;;;; (c) 2004--2007 Han-Wen Nienhuys (define-public (set-paper-dimension-variables mod) (module-define! mod 'dimension-variables @@ -13,50 +13,65 @@ staff-space line-thickness ledgerline-thickness blot-diameter left-margin right-margin))) -(define-public (layout-set-staff-size sz) - "Function to be called inside a \\layout{} block to set the staff size." - (let* ((m (current-module)) - (ss (/ sz 4)) - (pt (eval 'pt m)) - - - ;; linear interpolation. - (x1 (* 4.125 pt)) - (x0 (* 5 pt)) - (f1 (* 0.47 pt)) - (f0 (* 0.50 pt)) - (lt (/ - (+ - (* f1 (- ss x0)) - (* f0 (- x1 ss))) - (- x1 x0))) - - (mm (eval 'mm m))) - - (module-define! m 'text-font-size (* 12 (/ sz (* 20 pt)))) +(define (calc-line-thickness staff-space pt) + ;; linear interpolation. + + ;; !! synchronize with feta-params.mf + (let* + ((x1 (* 4.125 pt)) + (x0 (* 5 pt)) + (f1 (* 0.47 pt)) + (f0 (* 0.50 pt))) + + (/ + (+ + (* f1 (- staff-space x0)) + (* f0 (- x1 staff-space))) + (- x1 x0)))) + +(define-public (layout-set-absolute-staff-size-in-module m staff-height) + (let* + ((pt (eval 'pt m)) + (ss (/ staff-height 4)) + (factor (/ staff-height (* 20 pt)))) + + (module-define! m 'text-font-size (* 12 factor)) (module-define! m 'output-scale ss) (module-define! m 'fonts (if tex-backend? - (make-cmr-tree (/ sz (* 20 pt))) - (make-century-schoolbook-tree - (/ sz (* 20 pt))))) - (module-define! m 'staff-height sz) - (module-define! m 'staff-space ss) + (make-cmr-tree factor) + (make-century-schoolbook-tree factor))) + (module-define! m 'staff-height staff-height) (module-define! m 'staff-space ss) - ;; !! synchronize with feta-params.mf - (module-define! m 'line-thickness lt) + (module-define! m 'line-thickness (calc-line-thickness ss pt)) + + ;; sync with feta (module-define! m 'ledgerline-thickness (+ (* 0.5 pt) (/ ss 10))) + + ;; sync with feta (module-define! m 'blot-diameter (* 0.4 pt)) )) + (define-public (layout-set-absolute-staff-size sz) + "Function to be called inside a \\layout{} block to set the staff size. SZ is in +points" + + (layout-set-absolute-staff-size-in-module (current-module) sz)) + +(define-public (layout-set-staff-size sz) + "Function to be called inside a \\layout{} block to set the staff +size. SZ is in points" + + (layout-set-absolute-staff-size (* (eval 'pt (current-module)) sz))) + (define-safe-public (set-global-staff-size sz) "Set the default staff size, where SZ is thought to be in PT." - (let* ((old-mod (current-module)) - (pap (eval '$defaultpaper old-mod)) - (in-layout? (or (module-defined? old-mod 'is-paper) - (module-defined? old-mod 'is-layout))) + (let* ((current-mod (current-module)) + (pap (eval '$defaultpaper current-mod)) + (in-layout? (or (module-defined? current-mod 'is-paper) + (module-defined? current-mod 'is-layout))) ; maybe not necessary. ; but let's be paranoid. Maybe someone still refers to the @@ -66,11 +81,11 @@ (new-scope (ly:output-def-scope new-paper))) (if in-layout? - (ly:warning (_ "Not in toplevel scope"))) - (set-current-module new-scope) - (layout-set-staff-size (* sz (eval 'pt new-scope))) - (set-current-module old-mod) - (module-define! old-mod '$defaultpaper new-paper))) + (ly:warning (_ "set-global-staff-size: not in toplevel scope"))) + + (layout-set-absolute-staff-size-in-module new-scope + (* sz (eval 'pt new-scope))) + (module-define! current-mod '$defaultpaper new-paper))) (define-public paper-alist @@ -78,10 +93,10 @@ ;; ISO 216 has a tolerance of +- 2mm '(("a7" . (cons (* 74 mm) (* 105 mm))) - ("a6" . (cons (* 105 mm) (* 149 mm))) - ("a5" . (cons (* 149 mm) (* 210 mm))) - ("a4" . (cons (* 210 mm) (* 298 mm))) - ("a3" . (cons (* 298 mm) (* 420 mm))) + ("a6" . (cons (* 105 mm) (* 148 mm))) + ("a5" . (cons (* 148 mm) (* 210 mm))) + ("a4" . (cons (* 210 mm) (* 297 mm))) + ("a3" . (cons (* 297 mm) (* 420 mm))) ("legal" . (cons (* 8.5 in) (* 14.0 in))) ("letter" . (cons (* 8.5 in) (* 11.0 in))) ("11x17" . (cons (* 11.0 in) (* 17.0 in))) @@ -94,7 +109,10 @@ (let* ((mm (eval 'mm m))) (module-define! m 'paper-width w) (module-define! m 'paper-height h) - (module-define! m 'line-width (- w (* 20 mm))) + (module-define! m 'line-width (- w + (ly:modules-lookup (list m) 'left-margin (* 10 mm)) + (ly:modules-lookup (list m) 'right-margin (* 10 mm)))) + (module-define! m 'indent (/ w 14)) ;; page layout - what to do with (printer specific!) margin settings?