]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-engraver.cc
* lily/kpath.cc:
[lilypond.git] / lily / score-engraver.cc
index e0c39fc5c7065460289bdda4842993005f77c64d..514f800c94677d0c5338554bf640622be32cb8de 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "all-font-metrics.hh"
@@ -11,7 +11,6 @@
 #include "warn.hh"
 #include "main.hh"
 #include "system.hh"
-#include "item.hh"
 #include "score-engraver.hh"
 #include "paper-score.hh"
 #include "paper-column.hh"
 #include "context-def.hh"
 #include "staff-spacing.hh"
 #include "note-spacing.hh"
-#include "context.hh"
 #include "global-context.hh"
-
-
-
+#include "open-type-font.hh"
 
 /*
   TODO: the column creation logic is rather hairy. Revise it.
  */
 Score_engraver::Score_engraver ()
 {
-  system_ =0;
-  command_column_ =0;
-  musical_column_ =0;
-  breaks_ =0;
+  system_ = 0;
+  command_column_ = 0;
+  musical_column_ = 0;
+  breaks_ = 0;
   pscore_ = 0;
 }
 
@@ -50,17 +46,14 @@ Score_engraver::make_columns ()
        = updated_grob_properties (context (),
                                   ly_symbol2scm ("NonMusicalPaperColumn"));
 
-      Object_key const *key1 = get_grob_key ("NonMusicalPaperColumn");
+      Object_key const *key1 = context()->get_grob_key ("NonMusicalPaperColumn");
       
       SCM pc = updated_grob_properties (context (),
                                        ly_symbol2scm ("PaperColumn"));
-      Object_key const *key2 = get_grob_key ("PaperColumn");      
+      Object_key const *key2 = context()->get_grob_key ("PaperColumn");      
       set_columns (new Paper_column (nmp, key1), new Paper_column (pc, key2));
 
 
-      scm_gc_unprotect_object (key1->self_scm());
-      scm_gc_unprotect_object (key2->self_scm());      
-
       Grob_info i1;
       i1.grob_ = command_column_;
       i1.origin_trans_ = this;
@@ -93,41 +86,53 @@ Score_engraver::prepare (Moment m)
 void
 Score_engraver::finish ()
 {
-  if ((breaks_%8))
+  if ((breaks_ % 8))
     progress_indication ("[" + to_string (breaks_) + "]");
 
   recurse_over_translators (context (), &Translator::finalize, UP);
 }
 
+#define MUSIC_FONT "emmentaler-20"
+
 /*
   use start/finish?
  */
 void
 Score_engraver::initialize ()
 {
-  Font_metric *fm = all_fonts_global->find_afm ("feta20");
+  Font_metric *fm = all_fonts_global->find_otf (MUSIC_FONT);
   if (!fm)
-    error (_f ("can't find `%s'", "feta20.afm")
-          + "\n" +_ ("Music font has not been installed properly.  Aborting"));
-
-  SCM pfa_path = ly_kpathsea_expand_path (scm_makfrom0str ("ecrm10.pfa"));
-  if (!scm_is_string (pfa_path))
-    error (_f ("can't find `%s'", "ecrm10.pfa")
-          + "\n" +_f ("Install the ec-mftraced package from %s. Aborting",
-                      "http://lilypond.org/download/fonts/"));
-   
-
+    {
+      error (_f ("cannot find `%s'", MUSIC_FONT ".otf")
+            + "\n"
+            + _ ("Music font has not been installed properly.")
+            + "\n"
+            + _f ("Search path `%s'", global_path.to_string ().to_str0())
+            + "\n"
+            + _ ("Aborting"));       
+    }
+  
+  if (!scm_is_string (ly_kpathsea_find_file (scm_makfrom0str ("ecrm10.pfa")))
+      && (!scm_is_string (ly_kpathsea_find_file (scm_makfrom0str ("lmr10.pfb")))))
+      error (_f ("cannot find `%s'", "ecrm10.pfa")
+            + "\n"
+            + _f ("cannot find `%s'", "lmr10.pfb")
+            + "\n"
+            + _f ("Install the ec-fonts-mftraced package from: %s.",
+                  "http://lilypond.org/download/fonts/")
+            + "\n"
+            + _ ("Aborting."));
+      
   pscore_ = new Paper_score;
   pscore_->layout_ = dynamic_cast<Output_def*> (get_output_def ());
 
   SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
 
-  Object_key const *sys_key = get_grob_key ("System");
+  Object_key const *sys_key = context()->get_grob_key ("System");
   pscore_->typeset_line (new System (props, sys_key));
-  scm_gc_unprotect_object (sys_key->self_scm ());
   
-  make_columns ();
   system_ = pscore_->system_;
+  make_columns ();
   system_->set_bound (LEFT, command_column_);
   command_column_->set_property ("breakable", SCM_BOOL_T);
 
@@ -173,14 +178,16 @@ Score_engraver::announce_grob (Grob_info info)
 void
 Score_engraver::typeset_all ()
 {
-  for (int i =0; i < elems_.size (); i++) 
+  for (int i = 0; i < elems_.size (); i++) 
     {
       Grob * elem = elems_[i];
 
       
       if (dynamic_cast<Item*> (elem)) 
        {
-         if (!elem->get_parent (X_AXIS)
+         if (
+             (!elem->get_parent (X_AXIS)
+              || !unsmob_grob  (elem->get_property ("axis-group-parent-X")))
              && elem != command_column_
              && elem != musical_column_
              )
@@ -210,9 +217,6 @@ Score_engraver::stop_translation_timestep ()
        progress_indication ("[" + to_string (breaks_) + "]");
     }
 
-
-  system_->add_column (command_column_);
-  system_->add_column (musical_column_);
   
   command_column_ = 0;
   musical_column_ = 0;
@@ -235,6 +239,9 @@ Score_engraver::set_columns (Paper_column *new_command,
     {
       context ()->set_property ("currentMusicalColumn", new_musical->self_scm ());
     }
+
+  system_->add_column (command_column_);
+  system_->add_column (musical_column_);
 }
 
 Music_output*
@@ -320,7 +327,7 @@ Score_engraver::acknowledge_grob (Grob_info gi)
 
 
 
-ENTER_DESCRIPTION (Score_engraver,
+ADD_TRANSLATOR (Score_engraver,
 /* descr */       "Top level engraver. Takes care of generating columns and the complete  system (ie. System) "
 "\n\n "
 "This engraver decides whether a column is breakable. The default is "