2004-06-13 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/paper-system.hh: move cc/hh file from paper-line.*
+
+ * lily/include/paper-line.hh: rename to Paper_system.
+
+ * lily/include/paper-book.hh: doc class.
+
+ * lily/paper-book.cc (c_ragged_page_breaks): remove functions.
+
+ * scm/page-layout.scm (plain-footer): add tagline/copyright.
+ (plain-header): add instrument-name.
+ (default-page-make-stencil): bugfixes.
+
+ * lily/parser.yy (book_body): allow \header anywhere in \book{}
+
* lily/paper-book.cc: remove copyright & tagline. Remove
interactions with Page
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=3
-PATCH_LEVEL=3
-MY_PATCH_LEVEL=hwn1
+PATCH_LEVEL=4
+MY_PATCH_LEVEL=
piece = "Piece"
}
+#(set-default-paper-size "a6")
+
pattern = { a b c d \break }
+\book {
+ \score {
+ \context Staff \notes \relative c' {
+ %% 16: ideally cramped
+ %% 17: very bad without density
+ % \repeat unfold 17 { a b c d \break }
-\score {
- \context Staff \notes \relative c' {
- %% 16: ideally cramped
- %% 17: very bad without density
-% \repeat unfold 17 { a b c d \break }
+ \pattern
+ \pattern
+ % \noPageBreak
+ \pattern
+
+ % the following changes the location of the break.
+ %
+ % \pageBreak
+
+ \pattern
+ \pattern
+ \pattern
+ \pattern
+ \repeat unfold 10 \pattern
+ }
- \pattern
- \pattern
- % \noPageBreak
- \pattern
-
- % the following changes the location of the break.
- %
- % \pageBreak
-
- \pattern
- \pattern
- \pattern
- \pattern
- \repeat unfold 10 \pattern
- }
- \paper {
- #(set-default-paper-size "a6")
- #(define page-breaking ly:optimal-page-breaks)
}
+
}
class Paper_book;
class Paper_column;
class Output_def;
-class Paper_line;
+class Paper_system;
class Paper_outputter;
class Paper_score;
class Paper_stream;
/*
- DOCME.
+This class is rather empty. It collects systems (Paper_system), and
+exports them to the output backend, either as systems or as completely
+formatted pages.
*/
class Paper_book
SCM lines_;
SCM pages_;
- SCM copyright_;
- SCM tagline_;
public:
SCM header_;
Array<Score_lines> score_lines_;
+++ /dev/null
-/*
- paper-line.hh -- declare Paper_line
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-#ifndef PAPER_LINE_HH
-#define PAPER_LINE_HH
-
-#include "lily-proto.hh"
-#include "smobs.hh"
-#include "offset.hh"
-#include "stencil.hh"
-
-class Paper_line
-{
- DECLARE_SMOBS (Paper_line, );
- Stencil stencil_;
- bool is_title_;
-
-public:
- Real penalty_;
- int number_;
-
- Paper_line (Stencil, bool);
-
- Offset dim () const;
- Stencil to_stencil () const;
- SCM stencils () const;
- bool is_title () const;
- Real penalty () const;
-};
-
-DECLARE_UNSMOB (Paper_line, paper_line);
-
-#endif /* PAPER_LINE_HH */
--- /dev/null
+/*
+ paper-system.hh -- declare Paper_system
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#ifndef PAPER_LINE_HH
+#define PAPER_LINE_HH
+
+#include "lily-proto.hh"
+#include "smobs.hh"
+#include "offset.hh"
+#include "stencil.hh"
+
+/*
+ A formatted "system" (A block of titling also is a Paper_system)
+
+ To save memory, we don't keep around the System grobs, but put the
+ formatted content of the grob is put into a Paper_system. Page-breaking handles
+ Paper_system objects.
+
+ */
+class Paper_system
+{
+ DECLARE_SMOBS (Paper_system, );
+ Stencil stencil_;
+ bool is_title_;
+
+public:
+ Real penalty_;
+ int number_;
+
+ Paper_system (Stencil, bool);
+
+ Offset dim () const;
+ Stencil to_stencil () const;
+ SCM stencils () const;
+ bool is_title () const;
+ Real penalty () const;
+};
+
+DECLARE_UNSMOB (Paper_system, paper_line);
+
+#endif /* PAPER_LINE_HH */
#include "paper-book.hh"
#include "output-def.hh"
#include "paper-outputter.hh"
-#include "paper-line.hh"
+#include "paper-system.hh"
#include "paper-score.hh"
#include "stencil.hh"
#include "warn.hh"
return lst;
}
-/*
- TODO: there is too much code dup, and the interface is not
- clear. FIXME.
- */
void
Paper_book::output (String outname)
{
/*
-TODO: resurrect more complex user-tweaks for titling .
+TODO: resurrect more complex user-tweaks for titling?
*/
Stencil
if (!title.is_empty ())
{
- Paper_line *pl = new Paper_line (title, true);
+ Paper_system *pl = new Paper_system (title, true);
lines_ = scm_cons (pl->self_scm (), lines_);
scm_gc_unprotect_object (pl->self_scm ());
Stencil title = score_title (i);
if (!title.is_empty ())
{
- Paper_line *pl = new Paper_line (title, true);
+ Paper_system *pl = new Paper_system (title, true);
lines_ = scm_cons (pl->self_scm (), lines_);
scm_gc_unprotect_object (pl->self_scm ());
}
lines_ = scm_reverse (lines_);
int i = 0;
- Paper_line * last = 0;
+ Paper_system * last = 0;
for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s))
{
- Paper_line * p = unsmob_paper_line (ly_car (s));
+ Paper_system * p = unsmob_paper_line (ly_car (s));
p->number_ = ++i;
if (last && last->is_title ())
-#if 0
-
-static SCM
-c_ragged_page_breaks (SCM lines,
- Paper_book *book,
- Real text_height,
- Real first, Real last)
-{
- int page_number = 0;
-
- Real book_height =0.;
- for (SCM s = lines ; ly_c_pair_p (s); s = ly_cdr (s))
- {
- book_height += unsmob_paper_line (ly_car (s))->dim ()[Y_AXIS];
- }
-
- int page_count = int (book_height / text_height + 0.5); // ceil?
- SCM breaks = SCM_EOL;
- Real page_height = text_height + first;
- Real h = 0;
- int number = 0;
- for (SCM s = lines; ly_c_pair_p (s); s = ly_cdr (s))
- {
- Paper_line *pl = unsmob_paper_line (ly_car (s));
- if (!pl->is_title () && h < page_height)
- number++;
- h += pl->dim ()[Y_AXIS];
- if (!pl->is_title () && h > page_height)
- {
- breaks = ly_snoc (scm_int2num (number), breaks);
- page_number++;
- page_height = text_height + (page_number == page_count) * last;
- h = 0;
- }
- if (ly_cdr (s) == SCM_EOL)
- breaks = ly_snoc (scm_int2num (pl->number_), breaks);
- }
-
- return scm_vector (breaks);
-}
-
-LY_DEFINE (ly_ragged_page_breaks, "ly:ragged-page-breaks",
- 5, 0, 0, (SCM lines, SCM book, SCM text, SCM first, SCM last),
- "Return a vector with line numbers of page breaks.")
-{
- Paper_book* b = unsmob_paper_book (book);
-
- SCM_ASSERT_TYPE (scm_pair_p (lines), lines, SCM_ARG1, __FUNCTION__, "list");
- SCM_ASSERT_TYPE (b, book, SCM_ARG2, __FUNCTION__, "Paper_book");
- SCM_ASSERT_TYPE (ly_c_number_p (text), text, SCM_ARG3, __FUNCTION__, "number");
- SCM_ASSERT_TYPE (ly_c_number_p (first), first, SCM_ARG4, __FUNCTION__, "number");
- SCM_ASSERT_TYPE (ly_c_number_p (last), last, SCM_ARG5, __FUNCTION__, "number");
-
- return c_ragged_page_breaks (lines, b,
- ly_scm2double (text),
- ly_scm2double (first), ly_scm2double (last));
-}
-#endif
-
-
/****************************************************************/
Score_lines::Score_lines ()
+++ /dev/null
-/*
- paper-line.cc -- implement Paper_line
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-#include "paper-line.hh"
-#include "stencil.hh"
-#include "string.hh"
-#include "virtual-methods.hh"
-
-#include "ly-smobs.icc"
-
-IMPLEMENT_SMOBS (Paper_line);
-IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
-IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);
-
-
-
-Paper_line::Paper_line (Stencil s, bool is_title)
-{
- is_title_ = is_title;
- number_ = 0;
- penalty_ = 0;
- smobify_self ();
- stencil_ = s;
-}
-
-Paper_line::~Paper_line ()
-{
-}
-
-SCM
-Paper_line::mark_smob (SCM smob)
-{
- Paper_line *line = (Paper_line*) ly_cdr (smob);
- return line-> stencil_.expr ();
-}
-
-int
-Paper_line::print_smob (SCM smob, SCM port, scm_print_state*)
-{
- Paper_line *p = (Paper_line*) ly_cdr (smob);
- scm_puts ("#<", port);
- scm_puts (classname (p), port);
- scm_puts (" ", port);
- scm_puts (to_string (p->number_).to_str0 (), port);
- scm_puts ("p ", port);
- scm_puts (to_string (p->penalty_).to_str0 (), port);
- if (p->is_title ())
- scm_puts (" t", port);
- scm_puts (" >", port);
- return 1;
-}
-
-bool
-Paper_line::is_title () const
-{
- return is_title_;
-}
-
-Real
-Paper_line::penalty () const
-{
- return penalty_;
-}
-
-Offset
-Paper_line::dim () const
-{
- return Offset (stencil_.extent (X_AXIS).length (),
- stencil_.extent (Y_AXIS).length ());
-}
-
-Stencil
-Paper_line::to_stencil () const
-{
- return stencil_;
-}
-
-LY_DEFINE (ly_paper_line_height, "ly:paper-line-extent",
- 2, 0, 0, (SCM line, SCM axis),
- "Return the extent of @var{line}.")
-{
- Paper_line *pl = unsmob_paper_line (line);
- SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
- Axis ax = (Axis)ly_scm2int (axis);
- return scm_make_real (pl->dim ()[ax]);
-}
-
-
-
-LY_DEFINE (ly_paper_line_title_p, "ly:paper-line-title?",
- 1, 0, 0, (SCM line),
- "Is @var{line} a title line?")
-{
- Paper_line *pl = unsmob_paper_line (line);
- SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- return SCM_BOOL (pl->is_title ());
-}
-
-LY_DEFINE (ly_paper_line_number, "ly:paper-line-number",
- 1, 0, 0, (SCM line),
- "Return the number of @var{line}.")
-{
- Paper_line *pl = unsmob_paper_line (line);
- SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- return scm_int2num (pl->number_);
-}
-
-LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-penalty",
- 1, 0, 0, (SCM line),
- "Return the score for page break after @var{line}.")
-{
- Paper_line *pl = unsmob_paper_line (line);
- SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- return scm_int2num (int (pl->penalty ()));
-}
-
-LY_DEFINE (ly_paper_line_stencil, "ly:paper-line-stencil",
- 1, 0, 0, (SCM line),
- "Return the height of @var{line}.")
-{
- Paper_line *pl = unsmob_paper_line (line);
- SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
- return pl->to_stencil ().smobbed_copy ();
-}
-
#include "array.hh"
#include "dimensions.hh"
+#include "file-name.hh"
#include "font-metric.hh"
#include "input-smob.hh"
#include "lily-guile.hh"
#include "lily-version.hh"
#include "ly-module.hh"
#include "main.hh"
-#include "paper-book.hh"
#include "output-def.hh"
-#include "paper-line.hh"
+#include "paper-book.hh"
#include "paper-outputter.hh"
-#include "file-name.hh"
+#include "paper-system.hh"
#include "scm-hash.hh"
#include "stencil.hh"
#include "string-convert.hh"
#include "warn.hh"
-// JUNKME
-extern SCM stencil2line (Stencil *stil, bool is_title = false);
+#include "ly-smobs.icc"
+
Paper_outputter::Paper_outputter (String filename, String format)
{
{
}
-#include "ly-smobs.icc"
IMPLEMENT_SMOBS (Paper_outputter);
IMPLEMENT_DEFAULT_EQUAL_P (Paper_outputter);
--- /dev/null
+/*
+ paper-system.cc -- implement Paper_system
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "paper-system.hh"
+#include "stencil.hh"
+#include "string.hh"
+#include "virtual-methods.hh"
+
+#include "ly-smobs.icc"
+
+IMPLEMENT_SMOBS (Paper_system);
+IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
+IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
+
+
+
+Paper_system::Paper_system (Stencil s, bool is_title)
+{
+ is_title_ = is_title;
+ number_ = 0;
+ penalty_ = 0;
+ smobify_self ();
+ stencil_ = s;
+}
+
+Paper_system::~Paper_system ()
+{
+}
+
+SCM
+Paper_system::mark_smob (SCM smob)
+{
+ Paper_system *line = (Paper_system*) ly_cdr (smob);
+ return line-> stencil_.expr ();
+}
+
+int
+Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
+{
+ Paper_system *p = (Paper_system*) ly_cdr (smob);
+ scm_puts ("#<", port);
+ scm_puts (classname (p), port);
+ scm_puts (" ", port);
+ scm_puts (to_string (p->number_).to_str0 (), port);
+ scm_puts ("p ", port);
+ scm_puts (to_string (p->penalty_).to_str0 (), port);
+ if (p->is_title ())
+ scm_puts (" t", port);
+ scm_puts (" >", port);
+ return 1;
+}
+
+bool
+Paper_system::is_title () const
+{
+ return is_title_;
+}
+
+Real
+Paper_system::penalty () const
+{
+ return penalty_;
+}
+
+Offset
+Paper_system::dim () const
+{
+ return Offset (stencil_.extent (X_AXIS).length (),
+ stencil_.extent (Y_AXIS).length ());
+}
+
+Stencil
+Paper_system::to_stencil () const
+{
+ return stencil_;
+}
+
+LY_DEFINE (ly_paper_line_height, "ly:paper-system-extent",
+ 2, 0, 0, (SCM line, SCM axis),
+ "Return the extent of @var{line}.")
+{
+ Paper_system *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
+ SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+ Axis ax = (Axis)ly_scm2int (axis);
+ return scm_make_real (pl->dim ()[ax]);
+}
+
+
+
+LY_DEFINE (ly_paper_line_title_p, "ly:paper-system-title?",
+ 1, 0, 0, (SCM line),
+ "Is @var{line} a title line?")
+{
+ Paper_system *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
+ return SCM_BOOL (pl->is_title ());
+}
+
+LY_DEFINE (ly_paper_line_number, "ly:paper-system-number",
+ 1, 0, 0, (SCM line),
+ "Return the number of @var{line}.")
+{
+ Paper_system *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
+ return scm_int2num (pl->number_);
+}
+
+LY_DEFINE (ly_paper_line_break_score, "ly:paper-system-break-penalty",
+ 1, 0, 0, (SCM line),
+ "Return the score for page break after @var{line}.")
+{
+ Paper_system *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
+ return scm_int2num (int (pl->penalty ()));
+}
+
+LY_DEFINE (ly_paper_line_stencil, "ly:paper-system-stencil",
+ 1, 0, 0, (SCM line),
+ "Return the height of @var{line}.")
+{
+ Paper_system *pl = unsmob_paper_line (line);
+ SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system");
+ return pl->to_stencil ().smobbed_copy ();
+}
+
$$->scores_.push (score);
scm_gc_unprotect_object (music->self_scm ());
}
- | lilypond_header {
- $$->header_ = $1;
+ | book_body lilypond_header {
+ $$->header_ = $2;
}
| book_body error {
#include "spacing-interface.hh"
#include "staff-symbol-referencer.hh"
#include "paper-book.hh"
-#include "paper-line.hh"
+#include "paper-system.hh"
System::System (SCM s)
: Spanner (s)
scm_cons (ly_symbol2scm ("combine-stencil"),
exprs));
- Paper_line *pl = new Paper_line (sys_stencil, false);
-
-
+ Paper_system *pl = new Paper_system (sys_stencil, false);
Item * break_point =this->get_bound(LEFT);
pl->penalty_ =
(baseline-skip . 2)
(word-space . 0.6)))
- % #(define page-breaking ly:ragged-page-breaks)
#(define page-breaking ly:optimal-page-breaks)
#(define page-music-height default-page-music-height )
#(define page-make-stencil default-page-make-stencil )
-
- #(define page-to-stencil ly:page-header-lines-footer-stencil)
#(define make-header plain-header)
#(define make-footer plain-footer)
- %%#(define make-footer empty-markup)
- #(define make-tagline TAGLINE-or-tagline-from-header)
- #(define make-copyright copyright-from-header)
}
(let*
((systems (ly:score-embedded-format score paper))
(1st (vector-ref systems 0))
- (stencil (ly:paper-line-stencil 1st)) )
+ (stencil (ly:paper-system-stencil 1st)) )
(ly:stencil-align-to! stencil Y CENTER)
(display (ly:stencil-extent stencil X))
(guile)
(lily))
+;; dump?
+(define (dump-page outputter page page-number page-count)
+ (ly:outputter-dump-stencil outputter page))
+
(define-public (output-framework-gnome outputter book scopes fields basename)
(let* ((bookpaper (ly:paper-book-book-paper book))
(pages (list->vector (map ly:page-stencil
(y 0.0)
(scale (* 2.83464 (ly:output-def-lookup bookpaper 'outputscale)))
(total-y
- (apply + (map (lambda (z) (ly:paper-line-extent z Y)) lines)))
+ (apply + (map (lambda (z) (ly:paper-system-extent z Y)) lines)))
(x-ext '(-8 . 0))
(lineno 0))
(define (dump-line outputter system)
- (let ((stil (ly:paper-line-stencil system)))
+ (let ((stil (ly:paper-system-stencil system)))
(ly:outputter-dump-string
outputter
" 0.0 "
(ly:number->string y)
" start-system {\n set-ps-scale-to-lily-scale\n"))
- (set! y (+ y (ly:paper-line-extent system Y)))
+ (set! y (+ y (ly:paper-system-extent system Y)))
(ly:outputter-dump-stencil outputter stil)
(ly:outputter-dump-string
outputter
(for-each
(lambda (ell)
(set! x-ext (interval-union x-ext
- (cons 0.0 (ly:paper-line-extent ell X)))))
+ (cons 0.0 (ly:paper-system-extent ell X)))))
lines)
(for-each
(ly:outputter-dump-string
putter
(string-append "\\leavevmode\n\\lybox{0}{0}{0}{"
- (ly:number->string (ly:paper-line-extent line Y))
+ (ly:number->string (ly:paper-system-extent line Y))
"}{"))
- (ly:outputter-dump-stencil putter (ly:paper-line-stencil line))
+ (ly:outputter-dump-stencil putter (ly:paper-system-stencil line))
(ly:outputter-dump-string
putter
(if last?
"define-grobs.scm"
"define-grob-interfaces.scm"
"page-layout.scm"
+ "titling.scm"
"paper.scm"
;; TODO: take <optimally-broken-page-node> iso. page-number
;; for all of these functions ?
-(define-public (TAGLINE-or-tagline-from-header paper scopes)
- (let* ((props (page-properties paper))
- (tagline-var (ly:modules-lookup scopes 'tagline))
- (tagline (if (markup? tagline-var) tagline-var TAGLINE)))
+(define-public (plain-header paper scopes page-number last?)
+ "Standard header for a part: page number --outside-- and instrument--centered."
- (cond ((string? tagline)
- (if (not (equal? tagline ""))
- (interpret-markup paper props
- (markup #:fill-line (tagline "")))))
- ((markup? tagline) (interpret-markup paper props tagline)))))
+ (let* ((props (page-properties paper) )
+ (pnum (markup #:bold (number->string page-number)))
+ (instr (ly:modules-lookup scopes 'instrument))
+ (line (list "" (if (markup? instr) instr "") pnum)))
-(define-public (copyright-from-header paper scopes)
- (let ((props (page-properties paper))
- (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)))))
+ (if (even? page-number)
+ (set! line (reverse line)))
+ (if (< 1 page-number)
+ (interpret-markup
+ paper props (make-fill-line-markup line))
+ '())
+ ))
-;; TODO: add instrument name.
-(define-public (plain-header paper scopes page-number)
- (let ((props (page-properties paper) ))
- (interpret-markup paper props
- (markup #:fill-line
- ("" #:bold (number->string page-number))))))
+;; TODO: add publisher ID on non-first page.
+(define-public (plain-footer paper scopes page-number last?)
+ "Standard footer. Empty, save for first (copyright) and last (tagline) page."
+
+ (let*
+ ((props (page-properties paper))
+ (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 paper props tagline)
+ 0.0
+ )))
-; TODO: insert tagline and/or copyright
-(define-public (plain-footer paper scopes page-number)
- (let ((props (page-properties paper)))
+ (if (and (= 1 page-number)
+ (markup? copyright))
+ (set! stencil
+ (ly:stencil-combine-at-edge
+ stencil Y DOWN (interpret-markup paper props copyright)
+ 0.0
+ )))
- ;; page number already in header.
- '()
-
- ))
+ stencil))
-
-(define (page-headfoot paper scopes number sym sepsym dir)
+(define (page-headfoot paper scopes number sym sepsym dir last?)
+ "Create a stencil including separating space."
(let*
((header-proc (ly:output-def-lookup paper sym))
(sep (ly:output-def-lookup paper sepsym))
(stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
(head-stencil
(if (procedure? header-proc)
- (header-proc paper scopes number)
+ (header-proc paper scopes number last?)
#f)))
(if (and (number? sep) (ly:stencil? head-stencil))
head-stencil))
(define-public (default-page-music-height paper scopes number last?)
+ "Printable area for music and titles; matches default-page-make-stencil."
(let*
((h (- (ly:output-def-lookup paper 'vsize)
(ly:output-def-lookup paper 'top-margin)
(ly:output-def-lookup paper 'bottom-margin)))
- (head (page-headfoot paper scopes number 'make-header 'head-sep UP))
- (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN))
- )
+ (head (page-headfoot paper scopes number 'make-header 'head-sep UP last?))
+ (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN last?)))
(- h (if (ly:stencil? head)
(interval-length (ly:stencil-extent head Y))
0)
(define-public (default-page-make-stencil lines paper scopes number last? )
+ "Construct a stencil representing the page from LINES. "
(let*
- (
- (top-margin (ly:output-def-lookup paper 'top-margin))
+ ((top-margin (ly:output-def-lookup paper 'top-margin))
- ;; TODO: naming vsize/hsize not analogous to TeX.
+ ;; TODO: naming vsize/hsize not analogous to TeX.
(hsize (ly:output-def-lookup paper 'hsize))
- (left-margin (- hsize
- (/ (ly:output-def-lookup paper 'linewidth) 2)))
+ (left-margin (/ (- hsize
+ (ly:output-def-lookup paper 'linewidth)) 2))
(vsize (ly:output-def-lookup paper 'vsize))
(bottom-edge (- vsize
(ly:output-def-lookup paper 'bottom-margin)))
- (head (page-headfoot paper scopes number 'make-header 'head-sep UP))
- (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN))
- (line-stencils (map ly:paper-line-stencil lines))
+ (head (page-headfoot paper scopes number 'make-header 'head-sep UP last?))
+ (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN last?))
+ (line-stencils (map ly:paper-system-stencil lines))
(height-proc (ly:output-def-lookup paper 'page-music-height))
(music-height (height-proc paper scopes number last?))
(spc-left (- music-height
(apply + (map (lambda (x)
(interval-length (ly:stencil-extent x Y)))
line-stencils))))
- (stretchable-lines (remove ly:paper-line-title? (cdr lines)))
+ (stretchable-lines (remove ly:paper-system-title? (cdr lines)))
(stretch (if (null? stretchable-lines)
0.0
(/ spc-left (length stretchable-lines))))
(lambda (l)
(set! page-stencil
(ly:stencil-combine-at-edge
- page-stencil Y DOWN (ly:paper-line-stencil l)
+ page-stencil Y DOWN (ly:paper-system-stencil l)
(if was-title
0.0
stretch)
))
- (set! was-title (ly:paper-line-title? l)))
+ (set! was-title (ly:paper-system-title? l)))
lines)
(if (ly:stencil? foot)
(ly:stencil-translate
foot
(cons 0
- (+ bottom-edge (- (car (ly:stencil-extent foot Y)))))
+ (+ (- bottom-edge) (- (car (ly:stencil-extent foot Y)))))
))))
- page-stencil
+
+ (ly:stencil-translate page-stencil (cons left-margin 0))
))
; TODO:
;
; - density scoring
-;
+; - separate function for word-wrap style breaking?
+; - raggedbottom? raggedlastbottom?
-;; TODO: first-diff and last-diff are slightly arbitrary interface
-;; For the future, we might want to invoke a function from PAPER-BOOK to
-;; determine available height given
(define-public (ly:optimal-page-breaks
lines paper-book)
"Return pages as a list starting with 1st page. Each page is a list
-of lines.
-
-TEXT-HEIGHT is the height of the printable area, FIRST-DIFF and
-LAST-DIFF are decrements for the 1st and last page. PAPER-BOOK is
-unused, at the moment."
+of lines. "
(define (make-node prev lines page-num penalty)
(make <optimally-broken-page-node>
(define bookpaper (ly:paper-book-book-paper paper-book))
(define scopes (ly:paper-book-scopes paper-book))
(define (line-height line)
- (ly:paper-line-extent line Y))
+ (ly:paper-system-extent line Y))
;; FIXME: may need some tweaking: square, cubic
(define (height-penalty available used)
(define (page-height page-number last?)
(let
- ((p (ly:output-def-lookup bookpaper 'page-height-function)))
+ ((p (ly:output-def-lookup bookpaper 'page-music-height)))
(if (procedure? p)
(p bookpaper scopes page-number last?)
(page-height (page-height this-page-num last?))
(space-used (cumulative-height current-lines))
(this-page-penalty (height-penalty page-height space-used))
- (user-penalty (ly:paper-line-break-penalty (car current-lines)))
+ (user-penalty (ly:paper-system-break-penalty (car current-lines)))
(total-penalty (combine-penalties
user-penalty this-page-penalty prev-penalty))
(better? (or
(cdr todo)))))
(define (line-number node)
- (ly:paper-line-number (car (node-lines node))))
+ (ly:paper-system-number (car (node-lines node))))
(let* ((best-break-node (walk-lines '() '() lines))
(break-nodes (get-path best-break-node '()))
(node-page-number node)
(eq? node best-break-node)))
break-nodes)))
+
+
ly:output-def-clone
ly:output-def-scope
ly:output-description
- ly:page-header-lines-footer-stencil
- ly:page-paper-lines
- ly:page?
ly:paper-book?
ly:paper-def?
ly:paper-get-font
ly:paper-get-number
- ly:paper-line-break-penalty
- ly:paper-line-extent
- ly:paper-line-number
- ly:paper-line-stencil
- ly:paper-line?
+ ly:paper-system-break-penalty
+ ly:paper-system-extent
+ ly:paper-system-number
+ ly:paper-system-stencil
+ ly:paper-system?
ly:output-def-lookup
ly:parse-string
ly:parser-parse-string