]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/my-lily-lexer.cc (My_lily_lexer): copy keytable.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 May 2004 17:42:11 +0000 (17:42 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 30 May 2004 17:42:11 +0000 (17:42 +0000)
* lily/include/paper-book.hh (class Paper_book): remove height_
member.

* input/test/coriolan-margin.ly (texidoc): remove latex macros.

* lily/paper-book.cc (book_title): separate function for the book
title.

* scm/page-layout.scm (default-book-title): only account for
markup fields.

* scm/framework-tex.scm (dump-line): new file. High level
interface for output (pages, systems, header).

* lily/paper-book.cc (split_string): new function
(output): output multiple formats, i.e. --format=ps,tex

ChangeLog
input/test/coriolan-margin.ly
lily/include/paper-book.hh
lily/my-lily-lexer.cc
lily/paper-book.cc
scm/framework-tex.scm
scm/page-layout.scm

index 96a8fe44a78e569702dfda31995fea577b064842..96adb64a41dd0793a91c2ebf614e915bb04463da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-05-30  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/my-lily-lexer.cc (My_lily_lexer): copy keytable.
+
+       * lily/include/paper-book.hh (class Paper_book): remove height_
+       member.
+
+       * input/test/coriolan-margin.ly (texidoc): remove latex macros.
+
        * lily/ly-module.cc (LY_DEFINE): bugfix.
 
        * lily/paper-book.cc (book_title): separate function for the book
index 26b302fb1a361929462724112e3d30e8f9b9671d..f9c1fe29ba4e7c58df8cd8491fea19a8e7424013 100644 (file)
@@ -4,11 +4,11 @@
 
 % Ugh, we need to override some LaTeX titling stuff
 \header {
-  title =      "Ouvertüre\\vrule width0pt height 0pt depth 1ex"
-  subtitle =   "\\normalsize Zu Heinrich Joseph v. Collins Trauerspiel\\vrule width0pt height 0pt depth 1ex"
-  subsubtitle =        "\\Large\\bf Coriolan"
+  title =      "Ouvertüre"
+  subtitle =   "Zu Heinrich Joseph v. Collins Trauerspiel"
+  subsubtitle =        \markup { \large \bold "Coriolan" }
   opus = "Op. 62"
-  piece = "\\hspace*{30mm}\\normalfont\\large Allegro con brio"
+  piece = \markup { \large Allegro con brio }
   composer =    "Ludwig van Beethoven (1770-1827)"
 
 texidoc = "@cindex Orchestra Score
index b1c8a5a5fc7617faff63e906d199806160be5010..3eca0424c2ffc02f5eb1d9fbe2db9fc3065500ca 100644 (file)
@@ -33,9 +33,6 @@ class Paper_book
 
   SCM lines_;
   SCM pages_;
-
-  
-  Real height_;                        // what is this variable for? 
   SCM copyright_;
   SCM tagline_;
 public:
@@ -50,7 +47,6 @@ public:
   Stencil book_title ();
   Stencil score_title (int);
   void classic_output (String);
-  void init ();
   void output (String);
 };
 
index 68300b00f70197828d4f32a172e93002be2bca72..2738602bbce807d8c17184ea624d5596d93e9d7a 100644 (file)
@@ -102,7 +102,7 @@ My_lily_lexer::My_lily_lexer (Sources *sources)
 My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
   : Includable_lexer ()
 {
-  keytable_ = src.keytable_;
+  keytable_ = new Keyword_table (*src.keytable_);
   encoding_ = src.encoding_;
   chordmodifier_tab_ = src.chordmodifier_tab_;
   pitchname_tab_stack_ = src.pitchname_tab_stack_;
@@ -112,6 +112,13 @@ My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
   main_input_b_ = src.main_input_b_;
 }
 
+My_lily_lexer::~My_lily_lexer ()
+{
+  delete keytable_;
+}
+
+
+
 SCM
 My_lily_lexer::encoding () const
 {
@@ -205,11 +212,6 @@ My_lily_lexer::set_identifier (SCM name, SCM s)
     }
 }
 
-My_lily_lexer::~My_lily_lexer ()
-{
-  delete keytable_;
-}
-
 
 
 void
index dfbb55d6e5799df91d4208aa7ac4bb8a8b83de9c..acc87f61abbaf35e4829f35d1f0c097c9f23c641 100644 (file)
 #include "warn.hh"
 
 
+/*
+  Ugh. the Function of the Paper_book class is unclear. Trim this
+  file.
+  
+ */
+
 // JUNKME
 SCM
 stencil2line (Stencil stil, bool is_title = false)
@@ -129,7 +135,6 @@ void
 Paper_book::output (String outname)
 {
   if (!score_lines_.size ())
-    // FIXME: no end-output?
     return;
     
   /* Generate all stencils to trigger font loads.  */
@@ -296,55 +301,6 @@ Paper_book::score_title (int i)
 
   
 
-
-/* calculate book height, #lines, stencils.  */
-void
-Paper_book::init ()
-{
-  int score_count = score_lines_.size ();
-
-  /* Calculate the full book height.  Hmm, can't we cache system
-     heights while making stencils?  */
-  height_ = 0;
-  Stencil btitle = book_title ();
-  if (!btitle.is_empty ())
-    height_ += btitle.extent (Y_AXIS).length ();
-  
-  for (int i = 0; i < score_count; i++)
-    {
-      Stencil title = score_title (i);
-      if (!title.is_empty ())
-       height_ += title.extent (Y_AXIS).length ();
-
-      int line_count = SCM_VECTOR_LENGTH (score_lines_[i].lines_);
-      for (int j = 0; j < line_count; j++)
-       {
-         SCM s = scm_vector_ref ((SCM) score_lines_[i].lines_, scm_int2num (j));
-         height_ += unsmob_paper_line (s)->dim ()[Y_AXIS];
-       }
-    }
-
-  Output_def *paper = bookpaper_;
-  
-  SCM scopes = SCM_EOL;
-  if (ly_c_module_p (header_))
-    scopes = scm_cons (header_, scopes);
-
-  SCM make_tagline = paper->c_variable ("make-tagline");
-  tagline_ = scm_call_2 (make_tagline, paper->self_scm (), scopes);
-  Real tag_height = 0;
-  if (Stencil *s = unsmob_stencil (tagline_))
-    tag_height = s->extent (Y_AXIS).length ();
-  height_ += tag_height;
-
-  SCM make_copyright = paper->c_variable ("make-copyright");
-  copyright_ = scm_call_2 (make_copyright, paper->self_scm (), scopes);
-  Real copy_height = 0;
-  if (Stencil *s = unsmob_stencil (copyright_))
-    copy_height = s->extent (Y_AXIS).length ();
-  height_ += copy_height;
-}
-
 SCM
 Paper_book::lines ()
 {
@@ -374,13 +330,29 @@ Paper_book::lines ()
   return lines_;
 }
 
+
+SCM
+make_tagline (Output_def*paper, SCM scopes)
+{
+  SCM make_tagline = paper->c_variable ("make-tagline");
+  SCM tagline = scm_call_2 (make_tagline, paper->self_scm (), scopes);
+  return tagline;
+}
+
+SCM
+make_copyright (Output_def *paper, SCM scopes)
+{
+  SCM make_copyright = paper->c_variable ("make-copyright");
+  SCM  copyright = scm_call_2 (make_copyright, paper->self_scm (), scopes);
+  return copyright;
+}
+
 SCM
 Paper_book::pages ()
 {
   if (ly_c_pair_p (pages_))
     return pages_;
 
-  init ();
   Output_def *paper = bookpaper_;
   Page *page = new Page (paper, 1);
 
@@ -396,15 +368,23 @@ Paper_book::pages ()
 
   SCM all = lines ();
   SCM proc = paper->c_variable ("page-breaking");
-  SCM breaks = scm_apply_0 (proc, scm_list_n (all, scm_make_real (height_),
+  SCM breaks = scm_apply_0 (proc, scm_list_n (all,
+                                             self_scm (),
                                              scm_make_real (text_height),
                                              scm_make_real (-copy_height),
                                              scm_make_real (-tag_height),
                                              SCM_UNDEFINED));
 
-  /* Copyright on first page.  */
-  if (unsmob_stencil (copyright_))
-    page->copyright_ = copyright_;
+
+  /*
+    UGH - move this out of C++.
+   */
+  SCM scopes = SCM_EOL;
+  if (ly_c_module_p (header_))
+    scopes = scm_cons (header_, scopes);
+  
+  tagline_ = make_tagline (bookpaper_, scopes);
+  copyright_ = make_tagline (bookpaper_, scopes);
 
   int page_count = SCM_VECTOR_LENGTH ((SCM) breaks);
   int line = 1;
@@ -431,25 +411,52 @@ Paper_book::pages ()
       pages_ = scm_cons (page->self_scm (), pages_);
     }
 
-  /* Tagline on last page.  */
-  if (unsmob_stencil (tagline_))
-    page->tagline_ = tagline_;
-
   pages_ =  scm_reverse (pages_);
   return pages_;
 }
 
+
+
 static SCM
-c_ragged_page_breaks (SCM lines, Real book_height, Real text_height,
+c_ragged_page_breaks (SCM lines,
+                     Paper_book *book,
+                     Real text_height,
                      Real first, Real last)
 {
   int page_number = 0;
-  int page_count = int (book_height / text_height + 0.5);
+
+  Real book_height =0.;
+  for (SCM s = lines ; ly_c_pair_p (s);  s = ly_cdr (s))
+    {
+      book_height += unsmob_paper_line (s)->dim ()[Y_AXIS];
+    }
+
+  /*
+    UGH.
+   */
+  SCM scopes = SCM_EOL;
+  if (ly_c_module_p (book->header_))
+    scopes = scm_cons (book->header_, scopes);
+  
+
+  SCM tag = make_tagline (book->bookpaper_, scopes);
+  if (unsmob_stencil (tag))
+    {
+      book_height += unsmob_stencil (tag)->extent (Y_AXIS).length ();
+    }
+
+  SCM cr = make_copyright (book->bookpaper_, scopes);
+  if (unsmob_stencil (cr))
+    {
+      book_height += unsmob_stencil (cr)->extent (Y_AXIS).length ();
+    }
+
+  int page_count = int (book_height / text_height + 0.5); // ceil?
   SCM breaks = SCM_EOL;
   Real page_height = text_height + first;
   Real h = 0;
   int number = 0;
-  for (SCM s = lines; s != SCM_EOL; s = ly_cdr (s))
+  for (SCM s = lines; ly_c_pair_p (s); s = ly_cdr (s))
     {
       Paper_line *pl = unsmob_paper_line (ly_car (s));
       if (!pl->is_title () && h < page_height)
@@ -473,14 +480,16 @@ LY_DEFINE (ly_ragged_page_breaks, "ly:ragged-page-breaks",
           5, 0, 0, (SCM lines, SCM book, SCM text, SCM first, SCM last),
           "Return a vector with line numbers of page breaks.")
 {
+  Paper_book* b = unsmob_paper_book (book);
+
   SCM_ASSERT_TYPE (scm_pair_p (lines), lines, SCM_ARG1, __FUNCTION__, "list");
-  SCM_ASSERT_TYPE (ly_c_number_p (book), book, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (ly_c_number_p (text), text, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (ly_c_number_p (first), first, SCM_ARG2, __FUNCTION__, "real");
-  SCM_ASSERT_TYPE (ly_c_number_p (last), last, SCM_ARG2, __FUNCTION__, "real");
+  SCM_ASSERT_TYPE (b, book, SCM_ARG2, __FUNCTION__, "Paper_book");
+  SCM_ASSERT_TYPE (ly_c_number_p (text), text, SCM_ARG3, __FUNCTION__, "number");
+  SCM_ASSERT_TYPE (ly_c_number_p (first), first, SCM_ARG4, __FUNCTION__, "number");
+  SCM_ASSERT_TYPE (ly_c_number_p (last), last, SCM_ARG5, __FUNCTION__, "number");
 
-  return c_ragged_page_breaks (lines,
-                              ly_scm2double (book), ly_scm2double (text),
+  return c_ragged_page_breaks (lines, b,
+                              ly_scm2double (text),
                               ly_scm2double (first), ly_scm2double (last));
 }
 
index 1c1b897de6ad558483e4e894fe2c38a4bde02386..16682df3db5555c01f13c4260e6a32f85c2b4aa5 100644 (file)
    (lambda (x)
      (ly:outputter-dump-string outputter x))
    (list
-    (header  "creator"
+    (header  "creator"                 ;FIXME
             "timestamp"
             bookpaper
             (length lines)
index 15c14fcc0f3582e4e599a8d8e30d87aaa85a1c94..5312e1a3b5bf8793c251717743872b8c8149ad38 100644 (file)
@@ -96,7 +96,9 @@
 ;; max density %
 (define MAX-CRAMP 0.05)
 
-(define-public (ly:optimal-page-breaks lines book-height text-height
+(define-public (ly:optimal-page-breaks lines
+                                      paper-book
+                                      text-height
                                       first-diff last-diff)
   "DOCME"
   ;; FIXME: may need some tweaking: square, cubic
       (if (= page-number 1)
          (set! h (+ h first-diff)))
       (if (= page-number page-count)
-         ;;(> page-number (/ book-height text-height))
        (set! h (+ h last-diff)))
       h))
 
 
     (if (ly:get-option 'verbose)
        (begin
-         (format (current-error-port) "Estimated page count: ~S\n"
-                 (/ book-height text-height))
-       (format (current-error-port) "breaks: ~S\n" breaks)
-       (force-output (current-error-port))))
-       ;; TODO: if solution is bad return no breaks and revert to
-       ;;       ragged bottom
+         (format (current-error-port) "breaks: ~S\n" breaks)
+         (force-output (current-error-port))))
+    
+    ;; TODO: if solution is bad return no breaks and revert to
+    ;;       ragged bottom
     (list->vector breaks)))