]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/page-layout.scm: New file.
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 10 Mar 2004 20:10:34 +0000 (20:10 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 10 Mar 2004 20:10:34 +0000 (20:10 +0000)
ChangeLog
input/test/title-markup.ly
lily/paper-book.cc
scm/chord-generic-names.scm
scm/lily.scm
scm/output-ps.scm
scm/page-layout.scm [new file with mode: 0644]
scm/paper.scm

index 10000605ba94b680ac7e0faf32cc8f79b209479f..bcbe09fb14f34ff2aec7dce751aeca55fb4317c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@
 
 2004-03-10  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * scm/page-layout.scm: New file.
+
        * scripts/lilypond-book.py (do_file): Bugfix: texinfo paper
        settings.
        (Lilypond_snippet.is_outdated): Also check for PNG file.
index 862eab29ede2fed21418138f2cedcaa1652d795c..98cf714064db7db1724381857dbfbf189e79d05a 100644 (file)
@@ -2,8 +2,10 @@
 %{
    \markup in titles is WIP.
 
-   only available when compiled with PAGE_LAYOUT is #define'd
-   see include/paper-book.hh
+   only 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
 
 %}
 
@@ -50,22 +52,8 @@ spaceTest = \markup { "two space chars" }
     instrument = "Instrument"
     piece = "piece"
 
-%{
-    makeConditionalTitle = \markup {
-       \column <
-            #(if (defined? 'title)
-             (markup* #:fill-line (#:huge #:bigger #:bigger #:bold title))
-             (markup* ""))
-            #(if (defined? 'subtitle)
-             (markup* #:fill-line ( #:large #:bold subtitle))
-             (markup* ""))
-            #(if (defined? 'subsubtitle)
-             (markup* #:fill-line (subsubtitle))
-             (markup* ""))
-        >
-    }
-%}
-    bookTitle = \markup {
+    %% this overrides automatic book title
+    xxbookTitle = \markup {
        \column <
            %\fill-line #linewidth < \huge \bigger \bold \title >
             \override #'(baseline-skip . 4) \column <
@@ -107,7 +95,10 @@ spaceTest = \markup { "two space chars" }
 }
 
 \header {
-    scoreTitle = \markup { "Tweetje" }
+    %% override automatic score title
+    xxscoreTitle = \markup { "Tweetje" }
+    opus = "opus 1"
+    piece = "Second"
 }
 
 \score {
index 999fd0255b80035c6be2b398acd50f08b1a24813..65f4bdd966a0290961f9aa413b3580d7bab717dd 100644 (file)
@@ -81,14 +81,19 @@ Page::text_height ()
 
 /****************************************************************/
 
-
-Paper_book *paper_book;                // huh? global var? --hwn
+/* Current global paper book.  Gives default_rendering access from
+   input-file-results.  */
+Paper_book *paper_book;
 
 Paper_book::Paper_book ()
 {
   smobify_self ();
 }
 
+Paper_book::~Paper_book ()
+{
+}
+
 void
 Paper_book::output (String outname)
 {
@@ -122,37 +127,33 @@ Paper_book::get_scopes (int i)
 Stencil*
 Paper_book::get_title (int i)
 {
-  SCM make_title = scm_primitive_eval (ly_symbol2scm ("make-title"));
+  SCM user_title = scm_primitive_eval (ly_symbol2scm ("user-title"));
+  SCM book_title = scm_primitive_eval (ly_symbol2scm ("book-title"));
+  SCM score_title = scm_primitive_eval (ly_symbol2scm ("score-title"));
   SCM field = (i == 0 ? ly_symbol2scm ("bookTitle")
               : ly_symbol2scm ("scoreTitle"));
 
-  SCM s = ly_modules_lookup (get_scopes (i), field); 
+  Stencil *title = 0;
+  SCM scopes = get_scopes (i);
+  SCM s = ly_modules_lookup (scopes, field);
   if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
-    {
-      Stencil *title = unsmob_stencil (gh_call2 (make_title,
-                                                papers_[0]->self_scm (),
-                                                scm_variable_ref (s)));
-      
-      title->align_to (Y_AXIS, UP);
-      return title;
-    }
+    title = unsmob_stencil (scm_call_2 (user_title,
+                                       papers_[0]->self_scm (),
+                                       scm_variable_ref (s)));
+  else
+    title = unsmob_stencil (scm_call_2 (i == 0 ? book_title : score_title,
+                                       papers_[0]->self_scm (),
+                                       scopes));
+  if (title)
+    title->align_to (Y_AXIS, UP);
   
-  return 0;
+  return title;
 }
 
-/*
-  WIP
-
-  FIXME: titling is broken.
-  
-  TODO:
-     * ->SCM?
-     * decent page breaking algorithm
-     * header / footer (generate per Page, with page#)
-     * override: # pages, or pageBreakLines= #'(3 3 4), ?
-     * what about between-system-breaking, can we junk that?
-     
-*/
+/* TODO:
+   - decent page breaking algorithm; fill-up page
+   - header / footer (generate per Page, with page#, tagline/copyright)
+   - override: # pages, or pageBreakLines= #'(3 3 4), ?  */
 Link_array<Page>*
 Paper_book::get_pages ()
 {
@@ -281,7 +282,3 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   return 1;
 }
 
-Paper_book::~Paper_book ()
-{
-}
-
index 7f43eb210f5c5990eff85f8739fb4ef7d7a28c0c..5b8e064184947516119d5da8e95ec76b482e4e24 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c) 2003 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 2003-2004 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
 ;;;; NOTE: this is experimental code
index 41aea4a7449617fef651b3e521b6b57a1b5ef243..cf76e0afe5a42fa9ea1c9e59c7db165a7aa1152f 100644 (file)
@@ -394,22 +394,11 @@ L1 is copied, L2 not.
        (caddr d)
        (scm-error "Could not find dumper for format ~s" format))))
 
-
-(define-public (make-title paper markup)
-  (if (markup? markup)
-      (let ((BASELINE-SKIP 2)
-            (props (list (append `((linewidth . ,(ly:paper-get-number
-                                                 paper 'linewidth))
-                                   (font-family . roman))
-                                 (ly:paper-lookup paper 'font-defaults)))))
-       (stack-lines DOWN 0 BASELINE-SKIP
-                    (list (interpret-markup paper props markup))))))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other files.
 
 (map ly:load
-                                       ; load-from-path
+     ;; load-from-path
      '("define-music-types.scm"
        "output-lib.scm"
        "c++.scm"
@@ -440,6 +429,7 @@ L1 is copied, L2 not.
        "define-grobs.scm"
        "define-grob-interfaces.scm"
 
+       "page-layout.scm"
        "paper.scm"
        ))
 
index 464c85fa770324a7d0727f053e82119f22e683a8..6850996fe140cb61d3ca7856271abb8b5241e6d4 100644 (file)
@@ -3,16 +3,12 @@
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
 ;;;; (c)  1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;;                 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
 ;;;; Note: currently misused as testbed for titles with markup, see
 ;;;;       input/test/title-markup.ly
 ;;;; 
 ;;;; TODO:
-;;;;   * move makeTitle (input/test/title-markup.ly) out of user space, but
-;;;;   * allow customisation of makeTitle markup.
-;;;;   * makePieceTitle markup
-;;;;   * page layout?
 ;;;;   * special characters, encoding.
 ;;;;     + implement encoding switch (switches?  input/output??),
 ;;;;     + move encoding definitions to ENCODING.ps files, or
 
     ;; FIXME: duplicates output-paper's scope-entry->string, mostly
     (define (scope-entry->string key var)
-      (let ((val (variable-ref var)))
-       (if (memq key fields)
-           (header-to-file basename key val))
-       (cond
-        ((string? val) (ps-string-def prefix key val))
-        ((number? val) (ps-number-def prefix key val))
-       (else ""))))
+      (if (variable-bound? var)
+         (let ((val (variable-ref var)))
+           (if (memq key fields)
+               (header-to-file basename key val))
+           (cond
+            ((string? val) (ps-string-def prefix key val))
+            ((number? val) (ps-number-def prefix key val))
+            (else "")))
+         ""))
     
     (define (output-scope scope)
       (apply string-append (module-map scope-entry->string scope)))
   (string-append
    "\n" (ly:number->string height)
    " start-system\n"
-   ;;(draw-line 2 0 (* OUTPUT-SCALE height) 100 0)
-   (draw-line 2 0 0 50 (- 0 (* OUTPUT-SCALE height)))
+   ;; Show height of system
+   (draw-line 1 0 0 (- 0 10) (- 0 (* OUTPUT-SCALE height)))
    "{\n"
    "set-ps-scale-to-lily-scale\n"))
 
diff --git a/scm/page-layout.scm b/scm/page-layout.scm
new file mode 100644 (file)
index 0000000..1d508dc
--- /dev/null
@@ -0,0 +1,86 @@
+;;;; page-layout.scm -- page layout functions
+;;;;
+;;;;  source file of the GNU LilyPond music typesetter
+;;;; 
+;;;; (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+
+
+(define (ly:modules-lookup modules sym)
+  (let ((v (module-variable (car modules) sym)))
+    (if (and v (variable-bound? v) (variable-ref v))
+       (variable-ref v)
+       (if (module? (cdr modules)) (ly:modules-lookup (cdr modules) sym)))))
+
+
+(define-public (book-title paper scopes)
+  "Generate book title from header strings."
+  
+  (define (get sym)
+    (let ((x (ly:modules-lookup scopes sym)))
+      (if (and x (not (unspecified? x))) x "")))
+  
+  (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
+      #:column
+      (#:override '(baseline-skip . 4)
+      #:column
+      (#:fill-line
+       (#:latin-i (get 'dedication))
+       #:fill-line
+       (#:huge #:bigger #:bigger #:bigger #:bigger #:bold (get 'title))
+       #:override '(baseline-skip . 3)
+       #:column
+       (#:fill-line
+       (#:large #:bigger #:bigger #:bold (get 'subtitle))
+       #:fill-line (#:bigger #:bigger #:bold (get 'subsubtitle)))
+       #:override '(baseline-skip . 5)
+       #:column ("")
+       #:override '(baseline-skip . 2.5)
+       #:column
+       (#:fill-line
+       (#:bigger (get 'poet) #:large #:bigger #:caps (get 'composer))
+       #:fill-line (#:bigger (get 'texttranslator) #:bigger (get 'opus))
+       #:fill-line
+       (#:bigger (get 'meter) #:bigger (get 'arranger))
+       ""
+       #:fill-line (#:large #:bigger (get 'instrument))
+       " "
+       #:fill-line (#:large #:bigger #:caps (get 'piece) ""))))))))
+
+(define-public (user-title paper markup)
+  "Generate book title from header markup."
+  (if (markup? markup)
+      (let ((BASELINE-SKIP 2)
+            (props (list (append `((linewidth . ,(ly:paper-get-number
+                                                 paper 'linewidth))
+                                   (font-family . roman))
+                                 (ly:paper-lookup paper 'font-defaults)))))
+       (stack-lines DOWN 0 BASELINE-SKIP
+                    (list (interpret-markup paper props markup))))))
+
+(define-public (score-title paper scopes)
+  "Generate score title from header strings."
+  
+  (define (get sym)
+    (let ((x (ly:modules-lookup scopes sym)))
+      (if (and x (not (unspecified? x))) x "")))
+  
+  (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
+      #:column
+      (#:override '(baseline-skip . 4)
+      #:column
+      (#:fill-line
+       ("" (get 'opus))
+       #:fill-line (#:large #:bigger #:caps (get 'piece) "")))))))
index 3a9c908a8e63f544e1a75b22381386abb2451de0..bb152b057aa0d8fe29742e4613f9a869d6667a9c 100644 (file)
@@ -80,4 +80,4 @@
          (module-define! (current-module) '$defaultpaper new-paper)
          )
        (ly:warning (string-append "Unknown papersize: " name))
-       )))
\ No newline at end of file
+       )))