+
+ scm_remember_upto_here_1 (scaled_def);
+ scm_remember_upto_here_1 (scaled_bookdef);
+}
+
+/*
+ PAPERBOOK should be scaled already.
+ */
+SCM
+Score::book_rendering (String outname,
+ Output_def *paperbook,
+ Output_def *default_def)
+{
+ SCM scaled_bookdef = SCM_EOL;
+ Real scale = 1.0;
+
+ if (paperbook && paperbook->c_variable ("is-bookpaper") == SCM_BOOL_T)
+ {
+ scale = ly_scm2double (paperbook->c_variable ("outputscale"));
+ }
+
+ SCM out = scm_makfrom0str (outname.to_str0 ());
+ SCM systems = SCM_EOL;
+ int outdef_count = defs_.size ();
+ for (int i = 0; !i || i < outdef_count; i++)
+ {
+ Output_def *def = outdef_count ? defs_[i] : default_def;
+ SCM scaled= SCM_EOL;
+ if (def->c_variable ("is-paper") == SCM_BOOL_T)
+ {
+ def = scale_output_def (def, scale);
+ def->parent_ = paperbook;
+ scaled = def->self_scm ();
+ scm_gc_unprotect_object (scaled);
+ }
+
+ if (!(no_paper_global_b && dynamic_cast<Output_def*> (def)))
+ {
+ SCM context = ly_run_translator (music_, def->self_scm ());
+ if (dynamic_cast<Global_context*> (unsmob_context (context)))
+ {
+ SCM s = ly_format_output (context, out);
+ if (s != SCM_UNDEFINED)
+ {
+ systems = s;
+ }
+ }
+ }
+
+ scm_remember_upto_here_1 (scaled);
+ }
+
+ scm_remember_upto_here_1 (scaled_bookdef);
+ return systems;
+}
+
+LY_DEFINE (ly_score_bookify, "ly:score-bookify",
+ 1, 0, 0,
+ (SCM score_smob),
+ "Return SCORE encapsulated in a BOOK.")
+{
+ SCM_ASSERT_TYPE (unsmob_score (score_smob), score_smob, SCM_ARG1, __FUNCTION__, "score_smob");
+
+ Score *score = unsmob_score (score_smob);
+ Book *book = new Book;
+ book->scores_.push (score);
+ scm_gc_unprotect_object (book->self_scm ());
+ return book->self_scm ();