From ab8291c74c11daaf42ec8438cfb55097a3d6f77d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 10 Mar 2004 20:10:34 +0000 Subject: [PATCH] * scm/page-layout.scm: New file. --- ChangeLog | 2 + input/test/title-markup.ly | 29 +++++-------- lily/paper-book.cc | 57 ++++++++++++------------ scm/chord-generic-names.scm | 2 +- scm/lily.scm | 14 +----- scm/output-ps.scm | 26 ++++++----- scm/page-layout.scm | 86 +++++++++++++++++++++++++++++++++++++ scm/paper.scm | 2 +- 8 files changed, 141 insertions(+), 77 deletions(-) create mode 100644 scm/page-layout.scm diff --git a/ChangeLog b/ChangeLog index 10000605ba..bcbe09fb14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ 2004-03-10 Jan Nieuwenhuizen + * 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. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index 862eab29ed..98cf714064 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -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 { diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 999fd0255b..65f4bdd966 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -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* 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 () -{ -} - diff --git a/scm/chord-generic-names.scm b/scm/chord-generic-names.scm index 7f43eb210f..5b8e064184 100644 --- a/scm/chord-generic-names.scm +++ b/scm/chord-generic-names.scm @@ -2,7 +2,7 @@ ;;;; ;;;; source file of the GNU LilyPond music typesetter ;;;; -;;;; (c) 2003 Jan Nieuwenhuizen +;;;; (c) 2003-2004 Jan Nieuwenhuizen ;;;; NOTE: this is experimental code diff --git a/scm/lily.scm b/scm/lily.scm index 41aea4a744..cf76e0afe5 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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" )) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 464c85fa77..6850996fe1 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -3,16 +3,12 @@ ;;;; source file of the GNU LilyPond music typesetter ;;;; ;;;; (c) 1998--2004 Jan Nieuwenhuizen -;;;; Han-Wen Nienhuys +;;;; Han-Wen Nienhuys ;;;; 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 @@ -317,13 +313,15 @@ ;; 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))) @@ -378,8 +376,8 @@ (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 index 0000000000..1d508dca82 --- /dev/null +++ b/scm/page-layout.scm @@ -0,0 +1,86 @@ +;;;; page-layout.scm -- page layout functions +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2004 Jan Nieuwenhuizen + + +(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) ""))))))) diff --git a/scm/paper.scm b/scm/paper.scm index 3a9c908a8e..bb152b057a 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -80,4 +80,4 @@ (module-define! (current-module) '$defaultpaper new-paper) ) (ly:warning (string-append "Unknown papersize: " name)) - ))) \ No newline at end of file + ))) -- 2.39.2