From a10833e185f24d63ba084634e24933347e347185 Mon Sep 17 00:00:00 2001
From: Keith OHara <k-ohara5a5a@oco.net>
Date: Tue, 4 Dec 2012 21:34:32 -0800
Subject: [PATCH] stencil.cc: Backspacing stencils are not empty

---
 lily/stencil.cc                |  7 +++++--
 scm/define-markup-commands.scm | 10 ++--------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/lily/stencil.cc b/lily/stencil.cc
index a488c59813..eb3420d072 100644
--- a/lily/stencil.cc
+++ b/lily/stencil.cc
@@ -66,10 +66,13 @@ Stencil::extent (Axis a) const
 
 bool
 Stencil::is_empty () const
+/* If only one of X- or Y-extent is empty; such a stencil can be useful
+ * for backspacing, as with \hspace #-2, so we do not consider it empty.
+ */
 {
   return (expr_ == SCM_EOL
-          || dim_[X_AXIS].is_empty ()
-          || dim_[Y_AXIS].is_empty ());
+          || (dim_[X_AXIS].is_empty ()
+              && dim_[Y_AXIS].is_empty ()));
 }
 
 SCM
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index 2c6ca98aa0..ff11b20451 100755
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -548,7 +548,6 @@ Create a box of the same height as the space in the current font."
 		     (ly:stencil-extent m X)
 		     )))
 
-;; todo: fix negative space
 (define-markup-command (hspace layout props amount)
   (number?)
   #:category align
@@ -568,11 +567,8 @@ Create an invisible object taking up horizontal space @var{amount}.
 }
 @end lilypond"
   (let ((corrected-space (- amount word-space)))
-    (if (> corrected-space 0)
-	(ly:make-stencil "" (cons 0 corrected-space) '(0 . 0))
-	(ly:make-stencil "" (cons corrected-space corrected-space) '(0 . 0)))))
+    (ly:make-stencil "" (cons 0 corrected-space) '(0 . 0))))
 
-;; todo: fix negative space
 (define-markup-command (vspace layout props amount)
  (number?)
  #:category align
@@ -594,9 +590,7 @@ of @var{amount} multiplied by 3.
 }
 @end lilypond"
   (let ((amount (* amount 3.0)))
-    (if (> amount 0)
-        (ly:make-stencil "" (cons 0 0) (cons 0 amount))
-        (ly:make-stencil "" (cons 0 0) (cons amount amount)))))
+    (ly:make-stencil "" (cons 0 0) (cons 0 amount))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-- 
2.39.5