2 score-engraver.cc -- implement Score_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "score-engraver.hh"
11 #include "all-font-metrics.hh"
12 #include "axis-group-interface.hh"
13 #include "context-def.hh"
14 #include "global-context.hh"
15 #include "international.hh"
17 #include "open-type-font.hh"
18 #include "output-def.hh"
19 #include "paper-column-engraver.hh"
20 #include "paper-column.hh"
21 #include "paper-score.hh"
25 Score_engraver::Score_engraver ()
32 Score_engraver::derived_mark () const
35 scm_gc_mark (pscore_->self_scm ());
36 Score_translator::derived_mark ();
37 Engraver_group::derived_mark ();
41 Score_engraver::prepare (Moment m)
45 precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, DOWN);
49 Score_engraver::finish ()
51 recurse_over_translators (context (), &Translator::finalize,
52 &Translator_group::finalize,
56 #define MUSIC_FONT "emmentaler-20"
62 Score_engraver::initialize ()
64 Font_metric *fm = all_fonts_global->find_otf (MUSIC_FONT);
67 error (_f ("cannot find `%s'", MUSIC_FONT ".otf")
69 + _ ("Music font has not been installed properly.")
71 + _f ("Search path `%s'", global_path.to_string ().c_str ())
76 pscore_ = new Paper_score (dynamic_cast<Output_def *> (context ()->get_output_def ()));
77 pscore_->unprotect ();
79 SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
81 Object_key const *sys_key = context ()->get_grob_key ("System");
82 pscore_->typeset_system (new System (props, sys_key));
84 system_ = pscore_->root_system ();
85 context ()->set_property ("rootSystem", system_->self_scm ());
87 Engraver_group::initialize ();
91 Score_engraver::finalize ()
93 Score_translator::finalize ();
99 Score_engraver::one_time_step ()
101 if (!to_boolean (context ()->get_property ("skipTypesetting")))
103 precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
104 Engraver_group::do_announces ();
107 precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
112 Score_engraver::announce_grob (Grob_info info)
114 announce_infos_.push_back (info);
115 pscore_->root_system ()->typeset_grob (info.grob ());
116 elems_.push_back (info.grob ());
120 Score_engraver::typeset_all ()
122 for (vsize i = 0; i < elems_.size (); i++)
124 Grob *elem = elems_[i];
126 if (!elem->get_parent (Y_AXIS))
127 Axis_group_interface::add_element (system_, elem);
133 Score_engraver::get_output ()
135 Music_output *o = pscore_;
136 return o->self_scm ();
143 Score_engraver::forbid_breaks ()
145 for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s))
147 Translator *tr = unsmob_translator (scm_car (s));
148 if (Paper_column_engraver *pce = dynamic_cast<Paper_column_engraver *> (tr))
149 pce->forbid_breaks ();
154 Score_engraver::try_music (Music *m)
156 if (Engraver_group::try_music (m))
162 ADD_TRANSLATOR_GROUP (Score_engraver,
163 /* doc */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
165 "This engraver decides whether a column is breakable. The default is "
166 "that a column is always breakable. However, when every Bar_engraver "
167 "that does not have a barline at a certain point will call "
168 "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
169 "means that you can make a breakpoint by creating a barline (assuming "
170 "that there are no beams or notes that prevent a breakpoint.) ",
177 "currentMusicalColumn "
178 "currentCommandColumn "
179 "verticallySpacedContexts",