]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/parser.yy (toplevel_expression)[PAGE_LAYOUT]: Remove
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 11 Mar 2004 18:45:24 +0000 (18:45 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 11 Mar 2004 18:45:24 +0000 (18:45 +0000)
protect hack.

* scm/page-layout.scm:
* lily/paper-book.cc: Handle tagline/copyright.  Internal page
layout and titling should now match external latex based version.

ChangeLog
input/test/title-markup.ly
lily/paper-book.cc
lily/parser.yy
lily/system.cc
scm/output-ps.scm
scm/output-tex.scm
scm/page-layout.scm

index cd9ca092e226beea18ca8c7e58a7ba74dd53d95e..522e8a2009c472031bd206eba220fd105830164c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-03-11  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * lily/parser.yy (toplevel_expression)[PAGE_LAYOUT]: Remove
+       protect hack.
+
+       * scm/page-layout.scm:
+       * lily/paper-book.cc: Handle tagline/copyright.  Internal page
+       layout and titling should now match external latex based version.
+
        * scm/output-tex.scm (output-scopes): Bugfix: only write string
        header fields.
 
index f22d13f10c5904c1278383a767e3398242e8fef0..3e088c59241258ef4cd657c2fe66eef8095a5cb7 100644 (file)
@@ -1,8 +1,6 @@
 \version "2.1.30"
 %{
-   \markup in titles is WIP.
-
-   only available in direct PostScript output:
+   Experimental markup titles are available in direct PostScript output:
 
    export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
    lilypond-bin -fps input/title/title-markup.ly
@@ -35,10 +33,10 @@ sizeTest = \markup {
 
 spaceTest = \markup { "two space chars" }
 \header {
-    texidoc = "Make titles using markup (WIP)."
+    texidoc = "Make titles using markup.  Only in direct PostScript output."
 
-    tagline = "my tagline for v \version"
-    copyright = "copyright by me"
+    ##tagline = "my tagline for v \version"
+    copyright = "Copyright by /me"
     
     %dedication = "För my dør Lily"
     % ugh: encoding char-size
@@ -56,42 +54,10 @@ spaceTest = \markup { "two space chars" }
     meter = "Meter (huh?)"
     arranger = "Arranger"
     instrument = "Instrument"
-    piece = "piece"
-
-    %% this overrides automatic book title
-    xxbookTitle = \markup {
-       \column <
-           %\fill-line #linewidth < \huge \bigger \bold \title >
-            \override #'(baseline-skip . 4) \column <
-               \fill-line < \latin-i \dedication >
-               \fill-line < \huge\bigger\bigger\bigger\bigger \bold \title >
-                \override #'(baseline-skip . 3) \column <
-                    \fill-line < \large\bigger\bigger \bold \subtitle >
-                    \fill-line < \bigger\bigger \bold \subsubtitle >
-                >
-                \override #'(baseline-skip . 5) \column <
-                " "
-                >
-                \override #'(baseline-skip . 2.5) \column <
-                   \fill-line < \bigger \poet
-                                 \large\bigger \caps \composer >
-                   \fill-line < \bigger \texttranslator
-                                \bigger \opus >
-                   \fill-line < \bigger \meter
-                                \bigger \arranger >
-                    " "
-                   \fill-line < \large\bigger \instrument >
-                    " "
-                   \fill-line < \large\bigger \caps \piece  " ">
-                >
-            >
-        >    
-    }
+    piece = "Piece"
 
-%{
-     foe = \sizeTest
-     baar = \spaceTest
-%}
+    %% Override automatic book title
+    %% bookTitle = \markup { \fill-line < \huge\bold \title > > }
 }
 
 \score {
@@ -101,8 +67,8 @@ spaceTest = \markup { "two space chars" }
 }
 
 \header {
-    %% override automatic score title
-    xxscoreTitle = \markup { "Tweetje" }
+    %% Override automatic score title
+    %% scoreTitle = \markup { "Tweetje" }
     opus = "opus 1"
     piece = "Second"
 }
index f9c13d404369a4fa38adde19f99ba854c497cdb7..0fed5b78fb8b3c525da05c940dd53ce48f20f9a0 100644 (file)
@@ -26,8 +26,15 @@ stencil2line (Stencil* stil)
                   scm_list_1 (scm_cons (z, stil->smobbed_copy ())));
 }
 
-// WIP -- simplistic page interface
-// Do we need this at all?  SCM, smob?
+static SCM
+title2line (Stencil* stil)
+{
+  SCM s = stencil2line (stil);
+  /* whugh, add marker recognise titles.  */
+  return scm_cons (scm_cons (ly_symbol2scm ("title"), ly_car (s)), ly_cdr (s));
+}
+
+/* Simplistic page interface */
 class Page
 {
 public:
@@ -39,8 +46,12 @@ public:
   Protected_scm lines_;
   Protected_scm header_;
   Protected_scm footer_;
+  Protected_scm copyright_;
+  Protected_scm tagline_;
   
   Stencil *get_header () { return unsmob_stencil (header_); }
+  Stencil *get_copyright () { return unsmob_stencil (copyright_); }
+  Stencil *get_tagline () { return unsmob_stencil (tagline_); }
   Stencil *get_footer () { return unsmob_stencil (footer_); }
 
   /* actual height filled with text.  */
@@ -74,7 +85,7 @@ Page::Page (Paper_def *paper, int number)
   height_ = 0;
   lines_ = SCM_EOL;
   line_count_ = 0;
-  
+
   hsize_ = paper->get_realvar (ly_symbol2scm ("hsize"));
   vsize_ = paper->get_realvar (ly_symbol2scm ("vsize"));
   top_margin_ = paper->get_realvar (ly_symbol2scm ("top-margin"));
@@ -84,18 +95,20 @@ Page::Page (Paper_def *paper, int number)
   text_width_ = paper->get_realvar (ly_symbol2scm ("linewidth"));
   left_margin_ = (hsize_ - text_width_) / 2;
   
+  copyright_ = SCM_EOL;
+  tagline_ = SCM_EOL;
+  
   SCM make_header = scm_primitive_eval (ly_symbol2scm ("make-header"));
   SCM make_footer = scm_primitive_eval (ly_symbol2scm ("make-footer"));
 
   header_ = scm_call_2 (make_header, paper_->smobbed_copy (),
-                                       scm_int2num (number_));
+                       scm_int2num (number_));
+  // FIXME: why does this (generates Stencil) not trigger font load?
   if (get_header ())
     get_header ()->align_to (Y_AXIS, UP);
     
-  // FIXME: tagline/copyright
   footer_ = scm_call_2 (make_footer, paper_->smobbed_copy (),
                        scm_int2num (number_));
-
   if (get_footer ())
     get_footer ()->align_to (Y_AXIS, UP);
 }
@@ -103,22 +116,41 @@ Page::Page (Paper_def *paper, int number)
 void
 Page::output (Paper_outputter *out, bool is_last)
 {
+  progress_indication ("[" + to_string (number_));
+  out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
   Offset o (left_margin_, top_margin_);
   Real vfill = line_count_ > 1 ? (text_height () - height_) / (line_count_ - 1)
     : 0;
-  out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
   if (get_header ())
-    out->output_line (stencil2line (get_header ()), &o, false);
+    {
+      out->output_line (stencil2line (get_header ()), &o, false);
+      o[Y_AXIS] += head_sep_;
+    }
   for (SCM s = lines_; gh_pair_p (s); s = ly_cdr (s))
     {
-      out->output_line (ly_car (s), &o, is_last && gh_pair_p (ly_cdr (s)));
-      if (gh_pair_p (ly_cdr (s)))
-       o[Y_AXIS] += vfill;
+      SCM line = ly_car (s);
+      SCM offset = ly_car (line);
+      if (ly_car (offset) == ly_symbol2scm ("title"))
+       line = scm_cons (ly_cdr (offset), ly_cdr (line));
+      out->output_line (line, &o,
+                       is_last && gh_pair_p (ly_cdr (s)) && !get_copyright ()
+                       && !get_tagline () && !get_footer ());
+      if (gh_pair_p (ly_cdr (s)) && ly_car (offset) != ly_symbol2scm ("title"))
+       o[Y_AXIS] += vfill; 
     }
+  if (get_copyright () || get_tagline () || get_footer ())
+    o[Y_AXIS] += foot_sep_;
+  if (get_copyright ())
+    out->output_line (stencil2line (get_copyright ()), &o,
+                     is_last && !get_tagline () && !get_footer ());
+  if (get_tagline ())
+    out->output_line (stencil2line (get_tagline ()), &o,
+                     is_last && !get_footer ());
   if (get_footer ())
     out->output_line (stencil2line (get_footer ()), &o, is_last);
   out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
                                  gh_bool2scm (is_last && !get_footer ())));
+  progress_indication ("]");
 }
 
 Real
@@ -127,8 +159,14 @@ Page::text_height ()
   Real h = vsize_ - top_margin_ - bottom_margin_;
   if (get_header ())
     h -= get_header ()->extent (Y_AXIS).length () + head_sep_;
+  if (get_copyright () || get_tagline () || get_footer ())
+    h -= foot_sep_;
+  if (get_copyright ())
+    h -= get_copyright ()->extent (Y_AXIS).length ();
+  if (get_tagline ())
+    h -= get_tagline ()->extent (Y_AXIS).length ();
   if (get_footer ())
-    h -= get_footer ()->extent (Y_AXIS).length () + foot_sep_;
+    h -= get_footer ()->extent (Y_AXIS).length ();
   return h;
 }
 
@@ -203,10 +241,8 @@ Paper_book::get_title (int i)
   return title;
 }
 
-/* TODO:
-   - decent page breaking algorithm
-   - top/bottom & inter-line filling
-   - footer: tagline/copyright
+/* Ideas:
+   - real page breaking algorithm (Gourlay?)
    - override: # pages, or pageBreakLines= #'(3 3 4), ?  */
 Link_array<Page>*
 Paper_book::get_pages ()
@@ -232,21 +268,43 @@ Paper_book::get_pages ()
     }
 
   Paper_def *paper = papers_[0];
+  SCM scopes = get_scopes (0);
+
+  SCM make_tagline = scm_primitive_eval (ly_symbol2scm ("make-tagline"));
+  SCM tagline = scm_call_2 (make_tagline, paper->smobbed_copy (), scopes);
+  Real tag_height = 0;
+  if (Stencil *s = unsmob_stencil (tagline))
+    tag_height = s->extent (Y_AXIS).length ();
+  book_height += tag_height;
+
+  SCM make_copyright = scm_primitive_eval (ly_symbol2scm ("make-copyright"));
+  SCM copyright = scm_call_2 (make_copyright, paper->smobbed_copy (), scopes);
+  Real copy_height = 0;
+  if (Stencil *s = unsmob_stencil (copyright))
+    copy_height = s->extent (Y_AXIS).length ();
+  book_height += copy_height;
+  
   Page::page_count_ = 0;
-  int page_number = 1;
-  Page *page = new Page (paper, page_number++);
+  int page_number = 0;
+  Page *page = new Page (paper, ++page_number);
+  int page_count = int (book_height / page->text_height () + 0.5);
+  if (unsmob_stencil (copyright))
+    page->copyright_ = copyright;
+  if (unsmob_stencil (tagline) && page_number == page_count)
+    page->tagline_ = tagline;
+  
+#if 0  
   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 ());
+  fprintf (stderr, "pages: %d\n", page_count);
+#endif
 
   /* Simplistic page breaking.  */
   Real text_height = page->text_height ();
   for (int i = 0; i < score_count; i++)
     {
-      Stencil *title = get_title (i);
-      if (title)
-       book_height += title->extent (Y_AXIS).length ();
       Real h = 0;
+      Stencil *title = get_title (i);
       if (title)
        h = title->extent (Y_AXIS).length ();
 
@@ -258,12 +316,16 @@ Paper_book::get_pages ()
          if (page->height_ + h > text_height)
            {
              pages->push (page);
-             page = new Page (paper, page_number++);
+             page = new Page (paper, ++page_number);
+             if (unsmob_stencil (tagline) && page_number == page_count)
+               page->tagline_ = tagline;
+             text_height = page->text_height ();
            }
          if (page->height_ + h <= text_height || page->height_ == 0)
            {
              if (j == 0 && title)
-               page->lines_ = ly_snoc (stencil2line (title), page->lines_);
+               page->lines_
+                 = ly_snoc (title2line (title), page->lines_);
              page->lines_ = ly_snoc (line, page->lines_);
              page->line_count_++;
              page->height_ += h;
@@ -328,4 +390,3 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   scm_puts (">", port);
   return 1;
 }
-
index d60f1f6590709db0e742257ddd843ba405cee266..190b42ce83770d0511eda246be92e06a43a41977 100644 (file)
@@ -454,11 +454,9 @@ toplevel_expression:
        
                   default_rendering (sc->music_, id->self_scm (), head, outname);
 
-                  if (output_format_global != PAGE_LAYOUT)
-                        scm_gc_unprotect_object (id->self_scm ());
+                  scm_gc_unprotect_object (id->self_scm ());
                }
-                  if (output_format_global != PAGE_LAYOUT)
-                       scm_gc_unprotect_object (sc->self_scm ());
+               scm_gc_unprotect_object (sc->self_scm ());
        }
        | output_def {
                SCM id = SCM_EOL;
index 393d2abf5b50a11c15c4aa630e48d4c3be6034f2..36a2bac602c1b0131368c69b2c78878b1b775ec1 100644 (file)
@@ -373,7 +373,7 @@ System::post_processing ()
   /* Generate all stencils to trigger font loads.
      This might seem inefficient, but Stencils are cached per grob
      anyway. */
-  SCM all = get_property ("all-elements")  ;
+  SCM all = get_property ("all-elements");
   all = uniquify_list (all);
 
   this->get_stencil ();
index c6bd8a4a6d6eabe0a0c8070fb7a2b777a31366da..3bb2094353c97ae1eef932fe04770504cd1d833a 100644 (file)
     (define (scope-entry->string key var)
       (if (variable-bound? var)
          (let ((val (variable-ref var)))
-           (if (and (memq sym fields) (string? val))
+           (if (and (memq key fields) (string? val))
                (header-to-file basename key val))
            (cond
             ((string? val) (ps-string-def prefix key val))
index 578ef3339b2a9ab9450aa69a8962736c73efdd1b..e825cc02e30e8dfbc8c1194c00f1fdb475d2b3e7 100644 (file)
@@ -1,9 +1,9 @@
-;;; tex.scm -- implement Scheme output routines for TeX
-;;;
-;;;  source file of the GNU LilyPond music typesetter
-;;; 
-;;; (c)  1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;; tex.scm -- implement Scheme output routines for TeX
+;;;;
+;;;;  source file of the GNU LilyPond music typesetter
+;;;; 
+;;;; (c)  1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;;                  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
 
 (define-module (scm output-tex) )
index eb0af1b92882598d475db88effa960084f1e7668..db61cee29176c5bebc7d44accca8373f6dc91c84 100644 (file)
                                              paper 'linewidth))
                               (font-family . roman))
                             (ly:paper-lookup paper 'font-defaults)))))
-    
   (interpret-markup paper props
-                   (markup #:fill-line ("" (number->string page-number))))))
-
+                   (markup #:fill-line
+                           ;; FIXME: font not found
+                           ;; ("" #:bold (number->string page-number))))))
+                           ("" (number->string page-number))))))
 
 (define-public (make-footer paper page-number)
   (let ((props (list (append `((linewidth . ,(ly:paper-get-number
                                              paper 'linewidth))
                               (font-family . roman))
                             (ly:paper-lookup paper 'font-defaults)))))
-    
   (interpret-markup paper props
                    (markup #:fill-line ("" (number->string page-number))))))
 
+
+(define TAGLINE
+  (string-append "Engraved by LilyPond (version " (lilypond-version) ")"))
+
+(define-public (make-tagline paper scopes)
+  (let* ((props (list (append `((linewidth . ,(ly:paper-get-number
+                                              paper 'linewidth))
+                               (font-family . roman))
+                             (ly:paper-lookup paper 'font-defaults))))
+        (tagline-var (ly:modules-lookup scopes 'tagline))
+        (tagline (if (markup? tagline-var) tagline-var TAGLINE)))
+    (cond ((string? tagline)
+          (if (not (equal? tagline ""))
+              (interpret-markup paper props
+                                (markup #:fill-line (tagline "")))))
+         ((markup? tagline) (interpret-markup paper props tagline)))))
+
+(define-public (make-copyright paper scopes)
+  (let ((props (list (append `((linewidth . ,(ly:paper-get-number
+                                             paper 'linewidth))
+                              (font-family . roman))
+                            (ly:paper-lookup paper 'font-defaults))))
+       (copyright (ly:modules-lookup scopes 'copyright)))
+    (cond ((string? copyright)
+          (if (not (equal? copyright ""))
+              (interpret-markup paper props
+                                (markup #:fill-line (copyright "")))))
+         ((markup? copyright) (interpret-markup paper props copyright)))))
+
+