]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hyphen-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / hyphen-engraver.cc
index b773242809d6affde510471309c282faef570a26..e4f4f3a9918656e9923eabfcb711f44a0e45eecb 100644 (file)
@@ -3,39 +3,45 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2005 Glen Prideaux <glenprideaux@iname.com>,
-  Han-Wen Nienhuys <hanwen@cs.uu.nl>,
+  (c) 1999--2006 Glen Prideaux <glenprideaux@iname.com>,
+  Han-Wen Nienhuys <hanwen@xs4all.nl>,
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "engraver.hh"
-
-#include "warn.hh"
+#include "international.hh"
 #include "item.hh"
-#include "spanner.hh"
 #include "pointer-group-interface.hh"
+#include "spanner.hh"
+#include "warn.hh"
 
 class Hyphen_engraver : public Engraver
 {
   Music *ev_;
+  Music *finished_ev_;
+
   Spanner *hyphen_;
   Spanner *finished_hyphen_;
+
 public:
   TRANSLATOR_DECLARATIONS (Hyphen_engraver);
 
 protected:
+
   DECLARE_ACKNOWLEDGER (lyric_syllable);
+
   virtual void finalize ();
   virtual bool try_music (Music *);
+
   void stop_translation_timestep ();
   void process_music ();
-private:
 };
 
 Hyphen_engraver::Hyphen_engraver ()
 {
   hyphen_ = 0;
   finished_hyphen_ = 0;
+  finished_ev_ = 0;
   ev_ = 0;
 }
 
@@ -43,9 +49,13 @@ void
 Hyphen_engraver::acknowledge_lyric_syllable (Grob_info i)
 {
   Item *item = i.item ();
+  
+  if (!hyphen_)
+    hyphen_ = make_spanner ("LyricSpace", item->self_scm ());
+
   if (hyphen_)
     hyphen_->set_bound (LEFT, item);
-
+      
   if (finished_hyphen_)
     finished_hyphen_->set_bound (RIGHT, item);
 }
@@ -67,7 +77,7 @@ completize_hyphen (Spanner *sp)
     {
       extract_item_set (sp, "heads", heads);
       if (heads.size ())
-       sp->set_bound (RIGHT, heads.top ());
+       sp->set_bound (RIGHT, heads.back ());
     }
 }
 
@@ -93,7 +103,8 @@ Hyphen_engraver::finalize ()
 
       if (!finished_hyphen_->get_bound (RIGHT))
        {
-         finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
+         if (finished_ev_)
+           finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
          finished_hyphen_->suicide ();
        }
       finished_hyphen_ = 0;
@@ -111,27 +122,36 @@ void
 Hyphen_engraver::stop_translation_timestep ()
 {
   if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT))
-    finished_hyphen_ = 0;
-
+    {
+      finished_hyphen_ = 0;
+      finished_ev_ = 0;
+    }
+  
   if (finished_hyphen_ && hyphen_)
     {
       programming_error ("hyphen not finished yet");
       finished_hyphen_ = 0;
+      finished_ev_ = 0;
     }
 
   if (hyphen_)
-    finished_hyphen_ = hyphen_;
+    {
+      finished_hyphen_ = hyphen_;
+      finished_ev_ = ev_;
+    }
+  
   hyphen_ = 0;
-
   ev_ = 0;
 }
 
 #include "translator.icc"
 
 ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable);
+
 ADD_TRANSLATOR (Hyphen_engraver,
-               /* doc */ "Create lyric hyphens",
-               /* create */ "LyricHyphen",
+               /* doc */ "Create lyric hyphens and "
+               "distance constraints between words.",
+               /* create */ "LyricHyphen LyricSpace",
                /* accept */ "hyphen-event",
                /* read */ "",
                /* write */ "");