]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #215.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 11 Jan 2007 12:21:51 +0000 (13:21 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 11 Jan 2007 12:21:51 +0000 (13:21 +0100)
Reorganize size setting procedure. We now have

 - set-global-staff-size (arg in pt)
 - layout-set-staff-size (arg in pt)
 - layout-set-absolute-staff-size (arg should be scaled by a
dimension)

python/convertrules.py
scm/paper.scm

index 6bb1101fe7f4578684b4dfbe608ced322b248876..a4d47978915c0915f0b14f07694f7f5040990f9c 100644 (file)
@@ -2944,3 +2944,10 @@ conversions.append (((2, 11, 10), conv, """allowBeamBreak -> Beam #'breakable =
 addquote -> addQuote
 
 """))
+
+def conv (str):
+    str = re.sub (r'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
+                  r'(layout-set-absolute-staff-size (* \1 \2))', str)
+    return str
+
+conversions.append (((2, 11, 11), conv, """layout-set-staff-size -> layout-set-absolute-staff-size"""))
index 6c0c031c02aa1ccb905dac3d9fddc358eb37afe1..4750b518f7d67db2c40eb6ae71ba648f9175142b 100644 (file)
                       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
         (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