From: Jan Nieuwenhuizen Date: Thu, 11 Mar 2004 15:42:34 +0000 (+0000) Subject: * ps/lilyponddefs.ps: Remove automatic page layout. X-Git-Tag: release/2.1.31~29 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=abd05b0ad0ccc4b63bb77ed128a8f28d5d48f330;p=lilypond.git * 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. * ps/lilyponddefs.ps: Bugfix. --- diff --git a/ChangeLog b/ChangeLog index 52b485a52b..5b66db5651 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-03-11 Jan Nieuwenhuizen + * 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. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index d5b77ced73..f22d13f10c 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -42,7 +42,10 @@ spaceTest = \markup { "two space chars" } %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" diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index 58c23e2464..fc59ec65bc 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -43,7 +43,7 @@ public: 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 */ diff --git a/lily/paper-book.cc b/lily/paper-book.cc index d75befab14..f9c13d4043 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -26,21 +26,15 @@ stencil2line (Stencil* stil) 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_; @@ -55,10 +49,12 @@ public: // 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 (); @@ -67,12 +63,17 @@ public: 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")); @@ -80,6 +81,8 @@ Page::Page (Paper_def *paper, int number) 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")); @@ -100,21 +103,22 @@ Page::Page (Paper_def *paper, int number) 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 @@ -228,6 +232,7 @@ Paper_book::get_pages () } 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); @@ -260,6 +265,7 @@ Paper_book::get_pages () 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; } @@ -282,7 +288,7 @@ Paper_book::classic_output (String outname) 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"); diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 0fe1330ba1..4797a837ec 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -95,20 +95,26 @@ Paper_outputter::output_header (Paper_def *paper) } 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)) diff --git a/ps/lilyponddefs.ps b/ps/lilyponddefs.ps index 37cfbf2dd6..b4116e2b21 100644 --- a/ps/lilyponddefs.ps +++ b/ps/lilyponddefs.ps @@ -1,4 +1,6 @@ %!PS-Adobe-2.0: lilyponddefs.ps +% TODO: +% * junk all magic, start-line/stop-line just: placebox @ x.y % % Functions for direct PostScript output @@ -11,9 +13,6 @@ /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. @@ -23,12 +22,6 @@ /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 @@ -80,10 +73,6 @@ /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 @@ -91,157 +80,28 @@ 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 @@ -250,9 +110,4 @@ 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 diff --git a/scm/font.scm b/scm/font.scm index b74d878dfd..6e9d409c05 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -27,19 +27,12 @@ or (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") diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 7f3953bc8d..8db25eb918 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -267,7 +267,7 @@ (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" @@ -378,12 +378,9 @@ (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")) @@ -392,12 +389,11 @@ (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)) @@ -429,4 +425,6 @@ "\nstart-page\n") (define (stop-page last?) - "\nstop-page\n") + (if last? + "\nstop-last-page\n" + "\nstop-page\n")) diff --git a/scm/page-layout.scm b/scm/page-layout.scm index fc86c8bb3f..eb0af1b928 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -30,7 +30,7 @@ (#: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)