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 "all-font-metrics.hh"
13 #include "score-engraver.hh"
14 #include "paper-score.hh"
15 #include "paper-column.hh"
16 #include "output-def.hh"
17 #include "axis-group-interface.hh"
18 #include "context-def.hh"
19 #include "global-context.hh"
20 #include "open-type-font.hh"
21 #include "paper-column-engraver.hh"
23 Score_engraver::Score_engraver ()
30 Score_engraver::derived_mark () const
33 scm_gc_mark (pscore_->self_scm ());
34 Score_translator::derived_mark ();
35 Engraver_group::derived_mark ();
39 Score_engraver::prepare (Moment m)
43 precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, DOWN);
47 Score_engraver::finish ()
49 recurse_over_translators (context (), &Translator::finalize,
50 &Translator_group::finalize,
54 #define MUSIC_FONT "emmentaler-20"
60 Score_engraver::initialize ()
62 Font_metric *fm = all_fonts_global->find_otf (MUSIC_FONT);
65 error (_f ("cannot find `%s'", MUSIC_FONT ".otf")
67 + _ ("Music font has not been installed properly.")
69 + _f ("Search path `%s'", global_path.to_string ().to_str0 ())
74 pscore_ = new Paper_score (dynamic_cast<Output_def *> (context ()->get_output_def ()));
75 pscore_->unprotect ();
77 SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
79 Object_key const *sys_key = context ()->get_grob_key ("System");
80 pscore_->typeset_system (new System (props, sys_key));
81 system_ = pscore_->root_system ();
82 context ()->set_property ("rootSystem", system_->self_scm ());
84 Engraver_group::initialize ();
88 Score_engraver::finalize ()
90 Score_translator::finalize ();
96 Score_engraver::one_time_step ()
98 if (!to_boolean (context ()->get_property ("skipTypesetting")))
100 precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
101 Engraver_group::do_announces ();
104 precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
109 Score_engraver::announce_grob (Grob_info info)
111 announce_infos_.push (info);
112 pscore_->root_system ()->typeset_grob (info.grob ());
113 elems_.push (info.grob ());
117 Score_engraver::typeset_all ()
119 for (int i = 0; i < elems_.size (); i++)
121 Grob *elem = elems_[i];
123 if (!elem->get_parent (Y_AXIS))
124 Axis_group_interface::add_element (system_, elem);
130 Score_engraver::get_output ()
132 Music_output *o = pscore_;
133 return o->self_scm ();
140 Score_engraver::forbid_breaks ()
142 for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s))
144 Translator *tr = unsmob_translator (scm_car (s));
145 if (Paper_column_engraver *pce = dynamic_cast<Paper_column_engraver *> (tr))
146 pce->forbid_breaks ();
151 Score_engraver::try_music (Music *m)
153 if (Engraver_group::try_music (m))
159 ADD_TRANSLATOR_GROUP (Score_engraver,
160 /* doc */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
162 "This engraver decides whether a column is breakable. The default is "
163 "that a column is always breakable. However, when every Bar_engraver "
164 "that does not have a barline at a certain point will call "
165 "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
166 "means that you can make a breakpoint by creating a barline (assuming "
167 "that there are no beams or notes that prevent a breakpoint.) ",
174 "currentMusicalColumn "
175 "currentCommandColumn "
176 "verticallySpacedContexts",