2004-11-21 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * scm/stencil.scm (stack-lines): return empty-stencil if argument
+ is '()
+ (stack-stencils): idem.
+
+ * Documentation/user/changing-defaults.itely (Creating titles):
+ document new title layout options.
+
+ * lily/parser.yy (lilypond_header_body): copy previous
+ $globalheader if present.
+
+ * lily/ly-module.cc (LY_DEFINE): rename ly:import-module to
+ ly:module-copy
+
+ * scm/page-layout.scm (marked-up-headfoot): remove old functions.
+
+ * scm/titling.scm: remove old titling functions
+
* lily/stencil.cc (translate): remove absolute dimension.
* ly/titling-init.ly (oddFooterMarkup): new file. Generate titles
@}
@end example
-A more advanced option is to change the Scheme functions
-@code{make-book-title} and @code{make-score-title} functions, defined
-in the @code{\paper} section of the @code{\book} block. These functions
-create a block of titling, given the information in the
-@code{\header}. The init file @file{ly/@/titling@/.scm} shows how the
-default format is created, and it may be used as a template for
-different styles.
+A more advanced option is to change the definitions of the following
+variables in the @code{\paper} block. The init file
+@file{ly/titling-init.ly} lists the default layout.
+
+@itemize @code
+@item bookTitleMarkup
+ This is the title put over an entire @code{\book} block. Typically,
+ it has the composer and the title of the piece
+
+@item scoreTitleMarkup
+ This is the title put over a @code{\score} block within a
+@code{\book}. Typically, it has the name of the movement (@code{piece}
+field).
+
+@item oddHeaderMarkup
+ This is the page header for odd-numbered pages.
+
+ @item evenHeaderMarkup
+ This is the page header for even-numbered pages. If unspecified,
+ the odd header is used instead.
+
+ By default, headers are defined such that the page number is on the
+ outside edge, and the instrument is centered.
+
+ @item oddFooterMarkup
+ This is the page footer for odd-numbered pages.
+
+@item evenFooterMarkup
+ This is the page footer for even-numbered pages. If unspecified,
+ the odd header is used instead.
+
+ By default, the footer has the copyright notice on the first, and
+ the tagline on the last page.
+@end itemize
+
-
@cindex \paper
@cindex header
@cindex footer
betweensystempadding = 0\mm
}
-\score{
- \sarabandeCelloStaff
- \midi{ \tempo 4 = 40 }
- \layout { }
- \header{
- opus= ""
- piece ="Sarabande" }
+\book {
+ \score{
+ \sarabandeCelloStaff
+ \layout { }
+ \midi{ \tempo 4 = 40 }
+ \header{
+ opus= ""
+ piece ="Sarabande" }
+ }
}
-
%%% Local variables:
%%% LilyPond-indent-level:2
%%% End:
#include "lily-guile.hh"
SCM ly_make_anonymous_module (bool safe);
-SCM ly_import_module (SCM dest, SCM src);
+SCM ly_module_copy (SCM dest, SCM src);
SCM ly_module2alist (SCM mod);
SCM ly_module_lookup (SCM module, SCM sym);
SCM ly_modules_lookup (SCM modules, SCM sym, SCM);
for (SCM s = src.scopes_; scm_is_pair (s); s = scm_cdr (s))
{
SCM newmod = ly_make_anonymous_module (false);
- ly_import_module (newmod, scm_car (s));
+ ly_module_copy (newmod, scm_car (s));
*tail = scm_cons (newmod, SCM_EOL);
tail = SCM_CDRLOC (*tail);
}
#define FUNC_NAME __FUNCTION__
static SCM
-ly_module_define (void *closure, SCM key, SCM val, SCM result)
+module_define_closure_func (void *closure, SCM key, SCM val, SCM result)
{
(void) result;
SCM module = (SCM) closure;
typedef SCM (*Hash_cl_func)();
/*
- Check me. This is NOT an actual import. It just copies the
- definitions.
-
If a variable in changed in SRC, we DEST doesn't see the
definitions.
*/
-LY_DEFINE (ly_import_module, "ly:import-module",
+LY_DEFINE (ly_module_copy, "ly:module-copy",
2, 0, 0, (SCM dest, SCM src),
- "Import all bindings from module SRC into DEST.")
+ "Copy all bindings from module SRC into DEST.")
{
SCM_VALIDATE_MODULE (1, src);
- scm_internal_hash_fold ((Hash_cl_func) &ly_module_define, (void*) dest,
+ scm_internal_hash_fold ((Hash_cl_func) &module_define_closure_func,
+ (void*) dest,
SCM_EOL, SCM_MODULE_OBARRAY (src));
return SCM_UNSPECIFIED;
}
input_origin_ = s.input_origin_;
scope_= ly_make_anonymous_module (false);
if (ly_c_module_p (s.scope_))
- ly_import_module (scope_, s.scope_);
+ ly_module_copy (scope_, s.scope_);
}
Output_def::~Output_def ()
header_ = ly_make_anonymous_module (false);
if (ly_c_module_p (s.header_))
- ly_import_module (header_, s.header_);
+ ly_module_copy (header_, s.header_);
}
/* FIXME: 100CM should relate to paper size. */
if (fabs (total_off) > 100 CM)
- programming_error (String_convert::form_string ("Improbable offset for grob %s: %f%s", me->name (), total_off, INTERNAL_UNIT));
-
+ {
+ String msg
+ = String_convert::form_string ("Improbable offset for grob %s: %f%s",
+ me->name ().to_str0 (), total_off,
+ INTERNAL_UNIT);
+
+ programming_error (msg);
+ }
return scm_make_real (total_off);
}
return scm_apply_2 (func, layout_smob, props, args);
}
- return SCM_EOL;
+ else
+ {
+ programming_error ("Is not a markup: ");
+ scm_display (markup, scm_current_error_port());
+ assert (false);
+ Box b;
+ b[X_AXIS].set_empty();
+ b[Y_AXIS].set_empty();
+
+ Stencil s(b, SCM_EOL);
+ return s.smobbed_copy();
+ }
}
MAKE_SCHEME_CALLBACK (Text_interface,print,1);
outputscale = #1.7573
- #(define-public score-title default-score-title)
-% #(define-public user-title default-user-title)
-% #(define-public book-title default-book-title)
#(define-public book-title (marked-up-title 'bookTitleMarkup))
#(define-public score-title (marked-up-title 'scoreTitleMarkup))
%% use lmodern in latin1 (cork) flavour if EC is not available.
#(define text-font-defaults
`((font-encoding
- . ,(if (and (not (ly:kpathsea-find-file "ecrm10.pfa"))
- (ly:kpathsea-find-file "cork-lm.enc")) 'cork-lm 'Extended-TeX-Font-Encoding---Latin))
+ . cork-lm)
+; . ,(if (and ; (not (ly:kpathsea-find-file "ecrm10.pfa"))
+; (ly:kpathsea-find-file "cork-lm.enc")) 'cork-lm 'Extended-TeX-Font-Encoding---Latin))
(baseline-skip . 2)
(word-space . 0.6)))
-
bookTitleMarkup = \markup {
\column <
\fill-line < \fromproperty #'header:dedication >
>
\fill-line <
\override #'(baseline-skip . 3)
- \column <
- \fill-line <
- \huge \bigger \bigger
- \bold \fromproperty #'header:subtitle
- >
- \fill-line <
- \huge \bigger
- \bold \fromproperty #'header:subsubtitle
- >
- >
+ \column <
+ \fill-line <
+ \huge \bigger \bigger
+ \bold \fromproperty #'header:subtitle
+ >
+ \fill-line <
+ \huge \bigger
+ \bold \fromproperty #'header:subsubtitle
+ >
+ >
>
\fill-line <
\fromproperty #'header:poet
\fromproperty #'header:instrument
\column <
- \fromproperty #'header:composer
- \fromproperty #'header:arranger
- >
+ \fromproperty #'header:composer
+ \fromproperty #'header:arranger
>
+ >
>
}
oddFooterMarkup = \markup {
\column <
\fill-line <
+
+ % put copyright only on pagenr. 1
\on-the-fly #(lambda (layout props arg)
(if (= 1 (chain-assoc-get 'page:page-number props -1))
(interpret-markup layout props arg)
\fromproperty #'header:copyright
>
\fill-line <
+ % put tagline only on last page
\on-the-fly #(lambda (layout props arg)
(if (chain-assoc-get 'page:last? props #f)
(interpret-markup layout props arg)
>
}
-
-
-
;; syntax, description and example.
(define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
+(define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
(def-markup-command (stencil layout props stil) (ly:stencil?)
"Stencil as markup"
If there are no arguments, return an empty stencil.
"
- (let* ((stencils (filter
- (lambda (stc) (not (ly:stencil-empty? stc)))
+ (let* ((orig-stencils
(map (lambda (x) (interpret-markup layout props x))
- markups)))
- (text-width (apply + (map interval-length
- (map (lambda (x)
- (ly:stencil-extent x X))
- stencils))))
- (word-count (length stencils))
- (word-space (chain-assoc-get 'word-space props))
- (line-width (chain-assoc-get 'linewidth props))
- (fill-space (if (< line-width text-width)
- word-space
- (/ (- line-width text-width)
- (if (= word-count 1) 2 (- word-count 1)))))
- (line-stencils (if (= word-count 1)
- (list
- (ly:make-stencil '() '(0 . 0) '(0 . 0))
- (car stencils)
- (ly:make-stencil '() '(0 . 0) '(0 . 0)) )
- stencils)))
-
- (if (null? stencils)
+ markups))
+ (stencils
+ (map (lambda (stc)
+ (if (ly:stencil-empty? stc)
+ point-stencil
+ stc)) orig-stencils))
+ (text-width (apply +
+ (map (lambda (stc)
+ (if (ly:stencil-empty? stc)
+ 0.0
+ (interval-length (ly:stencil-extent stc X))))
+ stencils)))
+ (word-count (length stencils))
+ (word-space (chain-assoc-get 'word-space props))
+ (line-width (chain-assoc-get 'linewidth props))
+ (fill-space (if (< line-width text-width)
+ word-space
+ (/ (- line-width text-width)
+ (if (= word-count 1) 2 (- word-count 1)))))
+ (line-stencils (if (= word-count 1)
+ (list
+ point-stencil
+ (car stencils)
+ point-stencil)
+ stencils)))
+
+ (if (null? (remove ly:stencil-empty? orig-stencils))
empty-stencil
(stack-stencils X RIGHT fill-space line-stencils))))
-
+
(define (font-markup qualifier value)
(lambda (layout props arg)
(interpret-markup layout
(define TAGLINE
(string-append "Engraved by LilyPond (version " (lilypond-version) ")"))
-
-;; TODO: take <optimally-broken-page-node> iso. page-number
-;; for all of these functions ?
-
-(define-public (plain-header layout scopes page-number last?)
- "Standard header for a part: page number --outside-- and instrument--centered."
-
- (let* ((props (page-properties layout))
- (pnum
- (if (ly:output-def-lookup layout 'printpagenumber)
- (markup #:bold (number->string page-number))
- ""))
- (instr (ly:modules-lookup scopes 'instrument))
-
- (line (list "" (if (markup? instr) instr "") pnum)))
-
- (if (even? page-number)
- (set! line (reverse line)))
-
- (if ((if (ly:output-def-lookup layout 'printfirstpagenumber)
- <=
- <)
- (ly:output-def-lookup layout 'firstpagenumber) page-number)
- (interpret-markup layout props (make-fill-line-markup line))
- '())))
-
-(define-public ((marked-up-headfoot what-odd what-even) layout scopes page-number last?)
-
- "Read variables WHAT-ODD, WHAT-EVEN, and interpret them as
-markup. The PROPS argument will include variables set in SCOPES and
-page:last?, page:page-number-string and page:page-number
-"
-
- (define (get sym)
- (let ((x (ly:modules-lookup scopes sym)))
- (if (markup? x) x #f)))
- (define (interpret-in-page-env potential-markup)
- (if (markup? potential-markup)
- (let*
- ((alists (map ly:module->alist scopes))
- (prefixed-alists
- (map (lambda (alist)
- (map (lambda (entry)
- (cons
- (string->symbol
- (string-append
- "header:"
- (symbol->string (car entry))))
- (cdr entry)
- ))
- alist))
- alists))
- (pgnum-alist (list
- (cons 'page:last? last?)
- (cons 'page:page-number-string
- (number->string page-number))
- (cons 'page:page-number page-number)))
- (props (append
- (list pgnum-alist)
- prefixed-alists
- (page-properties layout)))
- )
-
- (interpret-markup layout props potential-markup))
-
- empty-stencil))
-
- (interpret-in-page-env
- (if (and (even? page-number)
- (markup? (get what-even)))
- (get what-even)
- (get what-odd))))
-
-
-
-;; TODO: add publisher ID on non-first page.
-(define-public (plain-footer layout scopes page-number last?)
- "Standard footer. Empty, save for first (copyright) and last (tagline) page."
-
- (let*
- ((props (page-properties layout))
- (copyright (ly:modules-lookup scopes 'copyright))
- (tagline-var (ly:modules-lookup scopes 'tagline))
- (tagline (if (markup? tagline-var) tagline-var TAGLINE))
- (stencil #f))
-
- (if last?
- (set! stencil
- (ly:stencil-combine-at-edge
- stencil Y DOWN (interpret-markup layout props tagline)
- 0.0
- )))
-
- (if (and (= 1 page-number)
- (markup? copyright))
-
- (set! stencil
- (ly:stencil-combine-at-edge
- stencil Y DOWN (interpret-markup layout props copyright)
- 0.0
- )))
-
- stencil))
(define (page-headfoot layout scopes number sym sepsym dir last?)
"Create a stencil including separating space."
(define-public (stack-stencils axis dir padding stils)
"Stack stencils STILS in direction AXIS, DIR, using PADDING."
(if (null? stils)
- '()
+ empty-stencil
(if (pair? stils)
(ly:stencil-combine-at-edge
(car stils) axis dir (stack-stencils axis dir padding (cdr stils))
(define-public (stack-lines dir padding baseline stils)
"Stack vertically with a baseline-skip."
(if (null? stils)
- '()
+ empty-stencil
(if (null? (cdr stils))
(car stils)
(ly:stencil-combine-at-edge
;;;;;;;;;;;;;;;;;;
+(define-public ((marked-up-headfoot what-odd what-even) layout scopes page-number last?)
+
+ "Read variables WHAT-ODD, WHAT-EVEN from LAYOUT, and interpret them
+as markup. The PROPS argument will include variables set in SCOPES and
+page:last?, page:page-number-string and page:page-number
+"
+
+ (define (get sym)
+ (ly:output-def-lookup layout sym))
+
+ (define (interpret-in-page-env potential-markup)
+ (if (markup? potential-markup)
+ (let*
+ ((alists (map ly:module->alist scopes))
+ (prefixed-alists
+ (map (lambda (alist)
+ (map (lambda (entry)
+ (cons
+ (string->symbol
+ (string-append
+ "header:"
+ (symbol->string (car entry))))
+ (cdr entry)
+ ))
+ alist))
+ alists))
+ (pgnum-alist (list
+ (cons 'page:last? last?)
+ (cons 'page:page-number-string
+ (number->string page-number))
+ (cons 'page:page-number page-number)))
+ (props (append
+ (list pgnum-alist)
+ prefixed-alists
+ (page-properties layout)))
+ )
+
+ (interpret-markup layout props potential-markup))
+
+ empty-stencil))
+
+ (interpret-in-page-env
+ (if (and (even? page-number)
+ (markup? (get what-even)))
+ (get what-even)
+ (get what-odd))))
(define-public ((marked-up-title what) layout scopes)
"Read variables WHAT from SCOPES, and interpret it as markup. The
(props (append prefixed-alist
(page-properties layout)))
- (markup (get what))
+ (markup (ly:output-def-lookup layout what))
)
(if (markup? markup)
(ly:make-stencil '() '(1 . -1) '(1 . -1)))
))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; old
- ; titling.
-(define-public (default-book-title layout scopes)
- "Generate book title from header strings."
-
-
- (define (get sym)
- (let ((x (ly:modules-lookup scopes sym)))
- (if (markup? x) x "")))
- (define (has sym)
- (markup? (ly:modules-lookup scopes sym)))
-
- (let ((props (page-properties layout)))
-
- (interpret-markup
- layout props
- (make-override-markup
- '(baseline-skip . 4)
- (make-column-markup
- (append
- (if (has 'dedication)
- (list (markup #:fill-line
- (#:normalsize (get 'dedication))))
- '())
- (if (has 'title)
- (list
- (markup (#:fill-line
- (#:huge #:bigger #:bigger #:bigger #:bigger #:bold
- (get 'title)))))
- '())
- (if (or (has 'subtitle) (has 'subsubtitle))
- (list
- (make-override-markup
- '(baseline-skip . 3)
- (make-column-markup
- (list
- (markup #:fill-line
- (#:large #:bigger #:bigger #:bold (get 'subtitle)))
- (markup #:fill-line (#:bigger #:bigger #:bold
- (get 'subsubtitle)))
- (markup #:override '(baseline-skip . 5)
- #:column ("")))
-
- ))
- )
- '())
-
- (list
- (make-override-markup
- '(baseline-skip . 2.5)
- (make-column-markup
- (append
- (if (or (has 'poet) (has 'composer))
- (list (markup #:fill-line
- (#:bigger (get 'poet)
- #:large #:bigger #:caps
- (get 'composer))))
- '())
- (if (or (has 'texttranslator) (has 'opus))
- (list
- (markup
- #:fill-line
- (#:bigger (get 'texttranslator) #:bigger (get 'opus))))
- '())
- (if (or (has 'meter) (has 'arranger))
- (list
- (markup #:fill-line
- (#:bigger (get 'meter) #:bigger (get 'arranger))))
- '())
- (if (has 'instrument)
- (list
- ""
- (markup #:fill-line (#:large #:bigger (get 'instrument))))
- '())
-;;; piece is done in the score-title
-;;; (if (has 'piece)
-;;; (list ""
-;;; (markup #:fill-line (#:large #:bigger #:caps (get 'piece) "")))
-;;; '())
- ))))))))))
-
-
-(define-public (default-user-title layout markup)
- "Generate book title from header markup."
- (if (markup? markup)
- (let ((props (page-properties layout))
- (baseline-skip (chain-assoc-get 'baseline-skip props 2)) )
- (stack-lines DOWN 0 BASELINE-SKIP
- (list (interpret-markup layout props markup))))))
-
-(define-public (default-score-title layout scopes)
- "Generate score title from header strings."
-
- (define (get sym)
- (let ((x (ly:modules-lookup scopes sym)))
- (if (markup? x) x "")))
-
- (define (has sym)
- (markup? (ly:modules-lookup scopes sym)))
-
- (let ((props (page-properties layout)))
- (interpret-markup
- layout props
- (make-override-markup
- '(baseline-skip . 4)
- (make-column-markup
- (append
- (if (has 'opus)
- ;; opus, again?
- '()
-
- ;; todo: figure out if and what should be here?
- ;;(list (markup #:fill-line ("" (get 'opus))))
- '())
- (if (has 'piece)
- (list
- (markup #:fill-line (#:large #:bigger (get 'piece) "")))
- '())))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
''))
+def conv (str):
+ str = re.sub (r'ly:import-module',
+ r'ly:module-copy', str)
+ return str
+
+conversions.append (((2, 5, 1),
+ conv,
+ 'ly:import-module -> ly:module-copy'))
+
+
################################
# END OF CONVERSIONS