]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-book.cc
* lily/paper-book.cc (get_pages): Bugfix: set dimensions for titles.
[lilypond.git] / lily / paper-book.cc
index 0394a1c3c92df147c20a8b8ccafb65146ce63183..5eedc873fef5c05c455dee3b8be18701868084f5 100644 (file)
@@ -90,12 +90,14 @@ Paper_book::Paper_book ()
 void
 Paper_book::output (String outname)
 {
-  Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
+  /* Generate all stencils to trigger font loads.  */
+  Link_array<Page> *pages = get_pages ();
 
-  out->output_metadata (get_scopes (0), papers_.top ());
-  out->output_header (papers_.top ());
+  Paper_def *paper = papers_[0];
+  Paper_outputter *out = paper->get_paper_outputter (outname);
+  out->output_metadata (get_scopes (0), paper);
+  out->output_header (paper);
 
-  Link_array<Page> *pages = get_pages ();
   int page_count = pages->size ();
   for (int i = 0; i < page_count; i++)
     (*pages)[i]->output (out, i + 1 == page_count);
@@ -124,9 +126,15 @@ Paper_book::get_title (int i)
 
   SCM s = ly_modules_lookup (get_scopes (i), field); 
   if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
-    return unsmob_stencil (gh_call2 (make_title,
-                                    papers_[i]->self_scm (),
-                                    scm_variable_ref (s)));
+    {
+      Stencil *title = unsmob_stencil (gh_call2 (make_title,
+                                                papers_[0]->self_scm (),
+                                                scm_variable_ref (s)));
+      
+      title->align_to (Y_AXIS, UP);
+      return title;
+    }
+  
   return 0;
 }
 
@@ -154,7 +162,6 @@ Paper_book::get_pages ()
   Real book_height = 0;
   for (int i = 0; i < score_count; i++)
     {
-      //SCM lines = scores_[i];
       Stencil *title = get_title (i);
       if (title)
        book_height += title->extent (Y_AXIS).length ();
@@ -167,7 +174,8 @@ Paper_book::get_pages ()
        }
     }
 
-  Page *page = new Page (papers_.top ());
+  Paper_def *paper = papers_[0];
+  Page *page = new Page (paper);
   fprintf (stderr, "book_height: %f\n", book_height);
   fprintf (stderr, "vsize: %f\n", page->vsize_);
   fprintf (stderr, "pages: %f\n", book_height / page->text_height ());
@@ -191,18 +199,22 @@ Paper_book::get_pages ()
          if (page->height_ + h > text_height)
            {
              pages->push (page);
-             page = new Page (papers_.top ());
+             page = new Page (paper);
            }
          if (page->height_ + h <= text_height || page->height_ == 0)
            {
              if (j == 0 && title)
-               page->lines_
-                 = ly_snoc (scm_cons (ly_offset2scm (Offset (0, 0)),
-                                      scm_list_1
-                                      (scm_cons
-                                       (ly_offset2scm (Offset (0, 0)),
-                                        title->smobbed_copy ()))),
+               {
+                 Offset dim = Offset (title->extent (X_AXIS).length (),
+                                      title->extent (Y_AXIS).length ());
+                 page->lines_
+                   = ly_snoc (scm_cons (ly_offset2scm (dim),
+                                        scm_list_1
+                                        (scm_cons
+                                         (ly_offset2scm (Offset (0, 0)),
+                                          title->smobbed_copy ()))),
                             page->lines_);
+               }
              page->lines_ = ly_snoc (line, page->lines_);
              page->height_ += h;
              h = 0;
@@ -240,8 +252,17 @@ IMPLEMENT_SIMPLE_SMOBS (Paper_book)
 IMPLEMENT_TYPE_P (Paper_book, "ly:paper_book?")
 
 SCM
-Paper_book::mark_smob (SCM)
+Paper_book::mark_smob (SCM smob)
 {
+  Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
+
+#if 0 //TODO
+  scm_gc_mark (b->scores_);
+  scm_gc_mark (b->global_headers_);
+  scm_gc_mark (b->headers_);
+  scm_gc_mark (b->papers_);
+#endif
+
   return SCM_EOL;
 }