* scm/output-ps.scm (new-start-system): New interface function.
* lily/include/paper-outputter.hh (output_line): Add ORIGIN parameter.
* lily/paper-book.cc (output): Bugfix.
* ps/lilyponddefs.ps: Bugfix.
2004-03-11 Jan Nieuwenhuizen <janneke@gnu.org>
+ * ps/lilyponddefs.ps: Remove automatic page layout.
+
+ * scm/output-ps.scm (new-start-system): New interface function.
+
+ * lily/include/paper-outputter.hh (output_line): Add ORIGIN parameter.
+
+ * lily/paper-book.cc (output): Bugfix.
+
* Documentation/user/lilypond.tely: Bugfix: Remove './' from
direntries.
%dedication = "För my dør Lily"
% ugh: encoding char-size
- dedication = "For my öòóôõø so dear Lily"
+ %dedication = "For my öòóôõø so dear Lily"
+ dedication = \markup { "For my "
+ \latin-i { "öòóôõø" }
+ " so dear Lily" }
title = "Title"
subtitle = "(and (the) subtitle)"
subsubtitle = "Sub sub title"
void output_scheme (SCM scm);
void output_expr (SCM expr, Offset o);
void output_header (Paper_def*);
- void output_line (SCM, bool);
+ void output_line (SCM, Offset*, bool);
};
#endif /* PAPER_OUTPUTTER_HH */
scm_list_1 (scm_cons (z, stil->smobbed_copy ())));
}
-static SCM
-height2line (Real h)
-{
- static SCM z = ly_offset2scm (Offset (0, 0));
- return scm_cons (ly_offset2scm (Offset (0, h)),
- scm_list_1 (scm_cons (z, SCM_EOL)));
-}
-
// WIP -- simplistic page interface
// Do we need this at all? SCM, smob?
class Page
{
public:
Paper_def *paper_;
+ static int page_count_;
int number_;
+ int line_count_;
Protected_scm lines_;
Protected_scm header_;
// HMMM all this size stuff to paper/paper-outputter?
Real hsize_;
Real vsize_;
+ Real left_margin_;
Real top_margin_;
Real bottom_margin_;
Real foot_sep_;
Real head_sep_;
+ Real text_width_;
/* available area for text. */
Real text_height ();
void output (Paper_outputter*, bool);
};
+int Page::page_count_ = 0;
+
Page::Page (Paper_def *paper, int number)
{
paper_ = paper;
number_ = number;
+ page_count_++;
+
height_ = 0;
lines_ = SCM_EOL;
+ line_count_ = 0;
hsize_ = paper->get_realvar (ly_symbol2scm ("hsize"));
vsize_ = paper->get_realvar (ly_symbol2scm ("vsize"));
bottom_margin_ = paper->get_realvar (ly_symbol2scm ("bottom-margin"));
head_sep_ = paper->get_realvar (ly_symbol2scm ("head-sep"));
foot_sep_ = paper->get_realvar (ly_symbol2scm ("foot-sep"));
+ text_width_ = paper->get_realvar (ly_symbol2scm ("linewidth"));
+ left_margin_ = (hsize_ - text_width_) / 2;
SCM make_header = scm_primitive_eval (ly_symbol2scm ("make-header"));
SCM make_footer = scm_primitive_eval (ly_symbol2scm ("make-footer"));
void
Page::output (Paper_outputter *out, bool is_last)
{
+ Offset o (left_margin_, top_margin_);
+ Real vfill = line_count_ > 1 ? (text_height () - height_) / (line_count_ - 1)
+ : 0;
+ out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
if (get_header ())
+ out->output_line (stencil2line (get_header ()), &o, false);
+ for (SCM s = lines_; gh_pair_p (s); s = ly_cdr (s))
{
- out->output_line (stencil2line (get_header ()), false);
- out->output_line (height2line (head_sep_), false);
+ out->output_line (ly_car (s), &o, is_last && gh_pair_p (ly_cdr (s)));
+ if (gh_pair_p (ly_cdr (s)))
+ o[Y_AXIS] += vfill;
}
- out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
- for (SCM s = lines_; gh_pair_p (s); s = ly_cdr (s))
- out->output_line (ly_car (s), is_last && gh_pair_p (ly_cdr (s)));
+ if (get_footer ())
+ out->output_line (stencil2line (get_footer ()), &o, is_last);
out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
gh_bool2scm (is_last && !get_footer ())));
- if (get_footer ())
- {
- out->output_line (height2line (foot_sep_), false);
- out->output_line (stencil2line (get_footer ()), is_last);
- }
}
Real
}
Paper_def *paper = papers_[0];
+ Page::page_count_ = 0;
int page_number = 1;
Page *page = new Page (paper, page_number++);
fprintf (stderr, "book_height: %f\n", book_height);
if (j == 0 && title)
page->lines_ = ly_snoc (stencil2line (title), page->lines_);
page->lines_ = ly_snoc (line, page->lines_);
+ page->line_count_++;
page->height_ += h;
h = 0;
}
int line_count = SCM_VECTOR_LENGTH ((SCM) scores_.top ());
for (int i = 0; i < line_count; i++)
out->output_line (scm_vector_ref ((SCM) scores_.top (), scm_int2num (i)),
- i == line_count - 1);
+ 0, i == line_count - 1);
out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
progress_indication ("\n");
}
void
-Paper_outputter::output_line (SCM line, bool is_last)
+Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
{
Offset dim = ly_scm2offset (ly_car (line));
- Real width = dim[X_AXIS];
- Real height = dim[Y_AXIS];
-
- if (height > 50 CM)
+ if (dim[Y_AXIS] > 50 CM)
{
programming_error ("Improbable system height.");
- height = 50 CM;
+ dim[Y_AXIS] = 50 CM;
}
- output_scheme (scm_list_3 (ly_symbol2scm ("start-system"),
- gh_double2scm (width), gh_double2scm (height)));
+ if (output_format_global != PAGE_LAYOUT)
+ output_scheme (scm_list_3 (ly_symbol2scm ("start-system"),
+ gh_double2scm (dim[X_AXIS]),
+ gh_double2scm (dim[Y_AXIS])));
+ else
+ {
+ output_scheme (scm_list_3 (ly_symbol2scm ("new-start-system"),
+ ly_quote_scm (ly_offset2scm (*origin)),
+ ly_quote_scm (ly_offset2scm (dim))));
+ (*origin)[Y_AXIS] += dim[Y_AXIS];
+ }
SCM between = SCM_EOL;
for (SCM s = ly_cdr (line); gh_pair_p (s); s = ly_cdr (s))
%!PS-Adobe-2.0: lilyponddefs.ps
+% TODO:
+% * junk all magic, start-line/stop-line just: placebox @ x.y
%
% Functions for direct PostScript output
/staff-height lilypondpaperstaffheight def
/line-width lilypondpaperlinewidth def
-% FIXME: why isn't this set (by default) by lily?
-% /text-height lilypondpapertextheight def
-
/lily-output-units 2.83464 def %% milimeter
% /lily-output-units 0.996264 def %% true points.
/paper-size { lilypondpaperpapersize } bind def
-%% FIXME: base-line-skip is too big, is this RIGHT?
-%% /line-height 14 staff-space mul def
-%% /base-line-skip lilypondpaperlineheight def
-%%/base-line-skip lilypondpaperlineheight lilypondpaperoutputscale div def
-/base-line-skip 0 def
-
/init-paper {
gsave
.1 setlinewidth
/start-page
{
- %/line-x left-margin output-scale div def
- %/line-y vsize top-margin sub def
- /line-x 0 def
- /line-y vsize def
} bind def
/stop-page
showpage
} bind def
-% dump using baselineskip, fold to new page
-/start-system % height
-{
- dup base-line-skip gt {
- /line-height exch def
- }
- {
- pop /line-height base-line-skip def
- } ifelse
- line-y top-margin sub base-line-skip lt {
- showpage
- /line-y vsize top-margin sub def
- } if
- gsave
- line-x line-y translate
-} bind def
-
-/stop-system
-{
- /the-line exch def
- the-line
- stroke
- grestore
- line-y line-height output-scale mul sub /line-y exch def
-} bind def
-
-% FIXME: font definitions should come from LilyPond
-% built-in ps fonts are ugly
-/huge-bold-font {
- /Palatino-Bold findfont 20.7 scalefont setfont
-} bind def
-
-/Large-bold-font {
- /Palatino-Bold findfont 17.3 scalefont setfont
-} bind def
-
-/large-bold-font {
- /Palatino-Bold findfont 14.4 scalefont setfont
-} bind def
-
-/large-font {
- /Palatino-Roman findfont 14.4 scalefont setfont
-} bind def
-
-/large-smallcaps-font {
- % urg
- /Bookman-Light findfont 14.4 scalefont setfont
-} bind def
-
-/normal-font {
- /Palatino-Roman findfont 12 scalefont setfont
-} bind def
-
-/footnote-font {
- /Palatino-Roman findfont 10 scalefont setfont
-} bind def
-
-/get-text-dimensions % path .. width height
-{
- dup true charpath pathbbox
- newpath
- line-x line-y moveto
- exch 4 -1 roll
- sub
- 3 1 roll
- exch sub
-} bind def
-
-/set-centered
+/stop-last-page
{
- line-x line-y moveto
- get-text-dimensions
- neg line-y add /line-y exch def
- neg line-width add 2 div 0 rmoveto
- show
} bind def
-/set-left
+/start-system % x y
{
- line-x line-y moveto
- get-text-dimensions
- neg line-y add /line-y exch def
- pop
- show
+ gsave
+ exch output-scale mul exch
+ output-scale mul vsize exch sub translate
} bind def
-/set-right
-{
- line-x line-y moveto
- get-text-dimensions
- neg line-y add /line-y exch def
- neg line-width add 0 rmoveto
- show
-} bind def
-
-/make-lilypond-title
-{
- currentdict /lilyponddedication known {
- normal-font lilyponddedication set-centered
- line-y 10 sub /line-y exch def
- } if
- currentdict /lilypondtitle known {
- huge-bold-font lilypondtitle set-centered
- line-y 5 sub /line-y exch def
- } if
- currentdict /lilypondsubtitle known {
- Large-bold-font lilypondsubtitle set-centered
- line-y 5 sub /line-y exch def
- } if
- currentdict /lilypondsubsubtitle known {
- large-bold-font lilypondsubsubtitle set-centered
- } if
- line-y /mini-page exch def
- currentdict /lilypondcomposer known {
- large-smallcaps-font lilypondcomposer set-right
- line-y 2 sub /line-y exch def
- } if
- currentdict /lilypondopus known {
- normal-font lilypondopus set-right
- line-y 3 sub /line-y exch def
- } if
- currentdict /lilypondarranger known {
- normal-font lilypondarranger set-right
- line-y 3 sub /line-y exch def
- } if
- currentdict /lilypondpoet known {
- mini-page /line-y exch def
- normal-font lilypondpoet set-left
- line-y 3 sub /line-y exch def
- } if
- currentdict /lilypondtexttranslator known {
- normal-font lilypondtexttranslator set-left
- line-y 3 sub /line-y exch def
- } if
- currentdict /lilypondinstrument known {
- large-font lilypondinstrument set-centered
- } if
- currentdict /lilypondpiece known {
- large-smallcaps-font lilypondpiece set-left
- } if
+/stop-system
+{
+ /the-line exch def
+ the-line stroke grestore
} bind def
/end-lilypond-output
{
- /line-y top-margin def
- footnote-font lilypondtagline set-left
- showpage
+% showpage
} bind def
-/turnOnExperimentalFeatures { } bind def
-
staff-line-thickness setlinewidth
% set postscript paper size
% initialise paper dimensions
staff-height init-paper
-%/line-x left-margin output-scale div def
-%/line-y vsize top-margin sub def
-/line-x 0 def
-/line-y vsize def
-
% end lilyponddefs.ps
(define-public paper20-font-vector
'((#(medium upright number) .
- (10 . #(
- (4.0 . "feta-nummer4")
+ (10 . #((4.0 . "feta-nummer4")
(6.0 . "feta-nummer6")
(8.0 . "feta-nummer8")
(10.0 . "feta-nummer10")
(12.0 . "feta-nummer12")
- (16.0 . "feta-nummer16")
-
-
- )
-
-
- ))
+ (16.0 . "feta-nummer16"))))
(#(medium upright roman) .
(10.0 . #((6.0 . "cmr6")
(8.0 . "cmr8")
(string-append (select-font name-mag-pair) exp))
-(define (header creator time-stamp)
+(define (header creator time-stamp)
(string-append
"%!PS-Adobe-3.0\n"
"%%Creator: " creator " " time-stamp "\n"
(numbers->string
(list x y width height blotdiam)) " draw_round_box"))
-(define (start-system width height)
+(define (new-start-system origin dim)
(string-append
- "\n" (ly:number->string height)
- " start-system\n"
- ;; Show height of system
- (draw-line 1 0 0 (- 0 10) (- 0 (* OUTPUT-SCALE height)))
+ "\n" (number-pair->string origin) " start-system\n"
"{\n"
"set-ps-scale-to-lily-scale\n"))
(numbers->string (list breapth width depth height))
" draw_box" ))
-(define (stop-last-system)
- (stop-system))
-
(define (stop-system)
"}\nstop-system\n")
+(define stop-last-system stop-system)
+
(define (symmetric-x-triangle thick w h)
(string-append
(numbers->string (list h w thick))
"\nstart-page\n")
(define (stop-page last?)
- "\nstop-page\n")
+ (if last?
+ "\nstop-last-page\n"
+ "\nstop-page\n"))
(#:override '(baseline-skip . 4)
#:column
(#:fill-line
- (#:latin-i (get 'dedication))
+ (#:normalsize (get 'dedication))
#:fill-line
(#:huge #:bigger #:bigger #:bigger #:bigger #:bold (get 'title))
#:override '(baseline-skip . 3)