From 228af2bd27e837ffb543a46182f75f46b5f98da9 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 14 Mar 2004 01:46:49 +0000 Subject: [PATCH] * scm/lily.scm (chain-assoc-get): bugfix. * lily/paper-book.cc (stencil2line): don't make static SCMs to --- ChangeLog | 5 ++++ input/test/title-markup.ly | 2 +- lily/include/paper-book.hh | 4 +-- lily/paper-book.cc | 13 ++++++++-- scm/define-markup-commands.scm | 8 ++---- scm/lily.scm | 17 +++++++----- scm/page-layout.scm | 47 ++++++++++++---------------------- 7 files changed, 49 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54e4f0e2de..c300eb7669 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-03-14 Han-Wen Nienhuys + * scm/lily.scm (chain-assoc-get): bugfix. + + * lily/paper-book.cc (stencil2line): don't make static SCMs to + + * lily/font-interface.cc (text_font_alist_chain): rename function, and use text-font-defaults. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index a4ce65ff14..a1b999f0cd 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -65,7 +65,7 @@ spaceTest = \markup { "two space chars" } c2-\sizeTest c2-\spaceTest } \paper { - #(paper-set-staff-size (* 11.0 pt)) +% #(paper-set-staff-size (* 11.0 pt)) } } diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 8a25040733..7496ed4646 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -24,8 +24,8 @@ public: Link_array papers_; Array scores_; Real height_; - Protected_scm copyright_; - Protected_scm tagline_; + SCM copyright_; + SCM tagline_; Paper_book (); void init (); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 6bcbe0c40e..09c6253b8d 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -23,7 +23,9 @@ static Real const MAX_CRAMP = 0.05; static SCM stencil2line (Stencil* stil) { - static SCM z = ly_offset2scm (Offset (0, 0)); + static SCM z; + if (!z) + z = scm_permanent_object (ly_offset2scm (Offset (0, 0))); Offset dim = Offset (stil->extent (X_AXIS).length (), stil->extent (Y_AXIS).length ()); return scm_cons (ly_offset2scm (dim), @@ -202,6 +204,9 @@ Paper_book *paper_book; Paper_book::Paper_book () { + copyright_ = SCM_EOL; + tagline_ = SCM_EOL; + smobify_self (); } @@ -471,7 +476,11 @@ Paper_book::mark_smob (SCM smob) scm_gc_mark (pb->papers_[i]->self_scm ()); for (int i = 0; i < pb->scores_.size (); i++) scm_gc_mark (pb->scores_[i]); - return SCM_EOL; + + scm_gc_mark (pb->copyright_); + + + return pb->tagline_; } int diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 6332287c41..c42aef7c31 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -518,18 +518,14 @@ any sort of property supported by @internalsref{font-interface} and (def-markup-command (smaller paper props arg) (markup?) "Decrease the font size relative to current setting" (let* ((fs (chain-assoc-get 'font-size props 0)) - ;; FIXME: crasher fix - ;; (entry (cons 'font-size (- fs 1)))) - (entry (cons 'font-size (if (number? fs) (- fs 1) 0)))) + (entry (cons 'font-size (- fs 1)))) (interpret-markup paper (cons (list entry) props) arg))) (def-markup-command (bigger paper props arg) (markup?) "Increase the font size relative to current setting" (let* ((fs (chain-assoc-get 'font-size props 0)) - ;; FIXME: crasher fix - ;; (entry (cons 'font-size (+ fs 1)))) - (entry (cons 'font-size (if (number? fs) (+ fs 1) 0)))) + (entry (cons 'font-size (+ fs 1)))) (interpret-markup paper (cons (list entry) props) arg))) (def-markup-command larger (markup?) diff --git a/scm/lily.scm b/scm/lily.scm index 3b9e77530d..7729fdf613 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -138,12 +138,17 @@ (define (chain-assoc-get x alist-list . default) "Return ALIST entry for X. Return DEFAULT (optional, else #f) if not found." - (if (null? alist-list) - (if (pair? default) (car default) #f) - (let* ((handle (assoc x (car alist-list)))) - (if (pair? handle) - (cdr handle) - (chain-assoc-get x (cdr alist-list) default))))) + + (define (helper x alist-list default) + (if (null? alist-list) + default + (let* ((handle (assoc x (car alist-list)))) + (if (pair? handle) + (cdr handle) + (helper x (cdr alist-list) default))))) + + (helper x alist-list + (if (pair? default) (car default) #f))) (define (map-alist-vals func list) "map FUNC over the vals of LIST, leaving the keys." diff --git a/scm/page-layout.scm b/scm/page-layout.scm index 83e0bdb166..5d41927d0c 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -11,6 +11,10 @@ (variable-ref v) (if (module? (cdr modules)) (ly:modules-lookup (cdr modules) sym))))) +(define (page-properties paper) + (list (append `((linewidth . ,(ly:paper-get-number + paper 'linewidth))) + (ly:paper-lookup paper 'text-font-defaults)))) (define-public (book-title paper scopes) "Generate book title from header strings." @@ -19,10 +23,8 @@ (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)) - ) - (ly:paper-lookup paper 'text-font-defaults))))) + (let ((props (page-properties paper))) + (interpret-markup paper props (markup @@ -55,11 +57,8 @@ (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))))) + (let ((props (page-properties paper)) + (baseline-skip (chain-assoc-get 'baseline-skip props 2)) ) (stack-lines DOWN 0 BASELINE-SKIP (list (interpret-markup paper props markup)))))) @@ -70,10 +69,7 @@ (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))))) + (let ((props (page-properties paper))) (interpret-markup paper props @@ -86,10 +82,7 @@ #:fill-line (#:large #:bigger #:caps (get 'piece) ""))))))) (define-public (make-header paper page-number) - (let ((props (list (append `((linewidth . ,(ly:paper-get-number - paper 'linewidth)) - (font-family . roman)) - (ly:paper-lookup paper 'font-defaults))))) + (let ((props (page-properties paper) )) (interpret-markup paper props (markup #:fill-line ;; FIXME: font not found @@ -97,11 +90,9 @@ ("" (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 + (let ((props (page-properties paper))) + + (interpret-markup paper props (markup #:fill-line ("" (number->string page-number)))))) @@ -109,12 +100,10 @@ (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)))) + (let* ((props (page-properties paper)) (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 @@ -122,11 +111,9 @@ ((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)))) + (let ((props (page-properties paper)) (copyright (ly:modules-lookup scopes 'copyright))) + (cond ((string? copyright) (if (not (equal? copyright "")) (interpret-markup paper props -- 2.39.2