]> git.donarmstrong.com Git - lilypond.git/commitdiff
robustness wrt infinity checking.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 30 Dec 2006 16:22:06 +0000 (17:22 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 30 Dec 2006 16:22:06 +0000 (17:22 +0100)
lily/enclosing-bracket.cc
lily/horizontal-bracket.cc
scm/define-markup-commands.scm

index 60e98f0944e9131c89023620f53d8a30bdbf5b62..e647fcae868f01465c466c5f594dea77cdd922d1 100644 (file)
@@ -85,7 +85,11 @@ Enclosing_bracket::print (SCM grob)
 
   Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); 
   Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS);
-
+  if (xext.is_empty ())
+    {
+      me->programming_error ("elements have no X extent.");
+      xext = Interval (0, 0);
+    }
 
   Stencil left_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements,
                                                                Y_AXIS, LEFT);
index d2b016b49625419ee6a4a7c1005242e7842aaa13..99cdd8a5e76bac137be65798ad377cb415aeb69d 100644 (file)
@@ -72,19 +72,25 @@ Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
   Grob *common = common_refpoint_of_array (grobs, refpoint, a);
   Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a);
 
-  Stencil b = make_bracket (me, ext.length(), a, dir);
-  b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
+  if (ext.is_empty ())
+    {
+      me->programming_error ("Can't enclose empty extents with bracket");
+      return Stencil ();
+    }
+  else
+    {
+      Stencil b = make_bracket (me, ext.length(), a, dir);
+      b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
 
-  return b;
+      return b;
+    }
 }
 
-
 /*
   TODO:
 
   Support texts on the brackets?
 */
-
 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
 SCM
 Horizontal_bracket::print (SCM smob)
index f65cb8675f126f143f1e561af4f9e2a3d0a58c69..10d48d5e8a5173640482824f981ee0ffc0a14a32 100644 (file)
@@ -1168,30 +1168,42 @@ figured bass notation"
        (num-x (interval-widen (ly:stencil-extent number-stencil X)
                              (* mag 0.2)))
        (num-y (ly:stencil-extent number-stencil Y))
-       (slash-stencil 
-       (ly:make-stencil
-        `(draw-line
-          ,thickness
-          ,(car num-x) ,(- (interval-center num-y) dy)
-          ,(cdr num-x) ,(+ (interval-center num-y) dy))
-        num-x num-y
-        )))
-
-    (ly:stencil-add number-stencil
-                   (cond
-                    ((= num 5) (ly:stencil-translate slash-stencil
-                                                     ;;(cons (* mag -0.05) (* mag 0.42))
-                                                     (cons (* mag -0.00) (* mag -0.07))
-
-                                                     ))
-                    ((= num 7) (ly:stencil-translate slash-stencil
-                                                     ;;(cons (* mag -0.05) (* mag 0.42))
-                                                     (cons (* mag -0.00) (* mag -0.15))
-
-                                                     ))
-                    
-                    (else slash-stencil)))
-    ))
+       (is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
+       
+       (slash-stencil
+       (if is-sane
+           (ly:make-stencil
+            `(draw-line
+              ,thickness
+              ,(car num-x) ,(- (interval-center num-y) dy)
+              ,(cdr num-x) ,(+ (interval-center num-y) dy))
+            num-x num-y)
+           #f)))
+
+    (set! slash-stencil
+         (cond
+          ((not (ly:stencil? slash-stencil)) #f)
+          ((= num 5) (ly:stencil-translate slash-stencil
+                                           ;;(cons (* mag -0.05) (* mag 0.42))
+                                           (cons (* mag -0.00) (* mag -0.07))
+
+                                           ))
+          ((= num 7) (ly:stencil-translate slash-stencil
+                                           ;;(cons (* mag -0.05) (* mag 0.42))
+                                           (cons (* mag -0.00) (* mag -0.15))
+
+                                           ))
+          
+          (else slash-stencil)))
+
+    (if slash-stencil
+       (set! number-stencil
+             (ly:stencil-add number-stencil slash-stencil))
+       
+       (ly:warning "invalid number for slashed digit ~a" num))
+
+
+    number-stencil))
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; the note command.