2 score-engraver.cc -- implement Score_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "all-font-metrics.hh"
14 #include "score-engraver.hh"
15 #include "paper-score.hh"
16 #include "paper-column.hh"
17 #include "output-def.hh"
18 #include "axis-group-interface.hh"
19 #include "context-def.hh"
20 #include "global-context.hh"
21 #include "open-type-font.hh"
22 #include "paper-column-engraver.hh"
25 TODO: the column creation logic is rather hairy. Revise it.
27 Score_engraver::Score_engraver ()
34 Score_engraver::derived_mark () const
37 scm_gc_mark (pscore_->self_scm ());
38 Score_translator::derived_mark ();
39 Engraver_group::derived_mark ();
43 Score_engraver::prepare (Moment m)
47 precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, DOWN);
51 Score_engraver::finish ()
53 recurse_over_translators (context (), &Translator::finalize,
54 &Translator_group::finalize,
58 #define MUSIC_FONT "emmentaler-20"
64 Score_engraver::initialize ()
66 Font_metric *fm = all_fonts_global->find_otf (MUSIC_FONT);
69 error (_f ("cannot find `%s'", MUSIC_FONT ".otf")
71 + _ ("Music font has not been installed properly.")
73 + _f ("Search path `%s'", global_path.to_string ().to_str0 ())
78 pscore_ = new Paper_score (dynamic_cast<Output_def *> (context ()->get_output_def ()));
79 pscore_->unprotect ();
81 SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
83 Object_key const *sys_key = context ()->get_grob_key ("System");
84 pscore_->typeset_system (new System (props, sys_key));
85 system_ = pscore_->root_system ();
86 context ()->set_property ("rootSystem", system_->self_scm ());
88 Engraver_group::initialize ();
92 Score_engraver::finalize ()
94 Score_translator::finalize ();
100 Score_engraver::one_time_step ()
102 if (!to_boolean (context ()->get_property ("skipTypesetting")))
104 precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
105 Engraver_group::do_announces ();
108 precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
113 Score_engraver::announce_grob (Grob_info info)
115 announce_infos_.push (info);
116 pscore_->root_system ()->typeset_grob (info.grob ());
117 elems_.push (info.grob ());
121 Score_engraver::typeset_all ()
123 for (int i = 0; i < elems_.size (); i++)
125 Grob *elem = elems_[i];
127 if (!elem->get_parent (Y_AXIS))
128 Axis_group_interface::add_element (system_, elem);
134 Score_engraver::get_output ()
136 Music_output *o = pscore_;
137 return o->self_scm ();
144 Score_engraver::forbid_breaks ()
146 for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s))
148 Translator *tr = unsmob_translator (scm_car (s));
149 if (Paper_column_engraver *pce = dynamic_cast<Paper_column_engraver *> (tr))
150 pce->forbid_breaks ();
155 Score_engraver::try_music (Music *m)
157 if (Engraver_group::try_music (m))
163 ADD_TRANSLATOR_GROUP (Score_engraver,
164 /* doc */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
166 "This engraver decides whether a column is breakable. The default is "
167 "that a column is always breakable. However, when every Bar_engraver "
168 "that does not have a barline at a certain point will call "
169 "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
170 "means that you can make a breakpoint by creating a barline (assuming "
171 "that there are no beams or notes that prevent a breakpoint.) ",
178 "currentMusicalColumn "
179 "currentCommandColumn "
180 "verticallySpacedContexts",