From: Han-Wen Nienhuys Date: Sun, 30 May 2004 17:42:11 +0000 (+0000) Subject: * lily/my-lily-lexer.cc (My_lily_lexer): copy keytable. X-Git-Tag: release/2.3.3~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f57a54ca625b333b8c3580edb337dc70b0150bf6;p=lilypond.git * lily/my-lily-lexer.cc (My_lily_lexer): copy keytable. * lily/include/paper-book.hh (class Paper_book): remove height_ member. * input/test/coriolan-margin.ly (texidoc): remove latex macros. * lily/paper-book.cc (book_title): separate function for the book title. * scm/page-layout.scm (default-book-title): only account for markup fields. * scm/framework-tex.scm (dump-line): new file. High level interface for output (pages, systems, header). * lily/paper-book.cc (split_string): new function (output): output multiple formats, i.e. --format=ps,tex --- diff --git a/ChangeLog b/ChangeLog index 96a8fe44a7..96adb64a41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2004-05-30 Han-Wen Nienhuys + * lily/my-lily-lexer.cc (My_lily_lexer): copy keytable. + + * lily/include/paper-book.hh (class Paper_book): remove height_ + member. + + * input/test/coriolan-margin.ly (texidoc): remove latex macros. + * lily/ly-module.cc (LY_DEFINE): bugfix. * lily/paper-book.cc (book_title): separate function for the book diff --git a/input/test/coriolan-margin.ly b/input/test/coriolan-margin.ly index 26b302fb1a..f9c1fe29ba 100644 --- a/input/test/coriolan-margin.ly +++ b/input/test/coriolan-margin.ly @@ -4,11 +4,11 @@ % Ugh, we need to override some LaTeX titling stuff \header { - title = "Ouvertüre\\vrule width0pt height 0pt depth 1ex" - subtitle = "\\normalsize Zu Heinrich Joseph v. Collins Trauerspiel\\vrule width0pt height 0pt depth 1ex" - subsubtitle = "\\Large\\bf Coriolan" + title = "Ouvertüre" + subtitle = "Zu Heinrich Joseph v. Collins Trauerspiel" + subsubtitle = \markup { \large \bold "Coriolan" } opus = "Op. 62" - piece = "\\hspace*{30mm}\\normalfont\\large Allegro con brio" + piece = \markup { \large Allegro con brio } composer = "Ludwig van Beethoven (1770-1827)" texidoc = "@cindex Orchestra Score diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index b1c8a5a5fc..3eca0424c2 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -33,9 +33,6 @@ class Paper_book SCM lines_; SCM pages_; - - - Real height_; // what is this variable for? SCM copyright_; SCM tagline_; public: @@ -50,7 +47,6 @@ public: Stencil book_title (); Stencil score_title (int); void classic_output (String); - void init (); void output (String); }; diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 68300b00f7..2738602bbc 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -102,7 +102,7 @@ My_lily_lexer::My_lily_lexer (Sources *sources) My_lily_lexer::My_lily_lexer (My_lily_lexer const &src) : Includable_lexer () { - keytable_ = src.keytable_; + keytable_ = new Keyword_table (*src.keytable_); encoding_ = src.encoding_; chordmodifier_tab_ = src.chordmodifier_tab_; pitchname_tab_stack_ = src.pitchname_tab_stack_; @@ -112,6 +112,13 @@ My_lily_lexer::My_lily_lexer (My_lily_lexer const &src) main_input_b_ = src.main_input_b_; } +My_lily_lexer::~My_lily_lexer () +{ + delete keytable_; +} + + + SCM My_lily_lexer::encoding () const { @@ -205,11 +212,6 @@ My_lily_lexer::set_identifier (SCM name, SCM s) } } -My_lily_lexer::~My_lily_lexer () -{ - delete keytable_; -} - void diff --git a/lily/paper-book.cc b/lily/paper-book.cc index dfbb55d6e5..acc87f61ab 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -18,6 +18,12 @@ #include "warn.hh" +/* + Ugh. the Function of the Paper_book class is unclear. Trim this + file. + + */ + // JUNKME SCM stencil2line (Stencil stil, bool is_title = false) @@ -129,7 +135,6 @@ void Paper_book::output (String outname) { if (!score_lines_.size ()) - // FIXME: no end-output? return; /* Generate all stencils to trigger font loads. */ @@ -296,55 +301,6 @@ Paper_book::score_title (int i) - -/* calculate book height, #lines, stencils. */ -void -Paper_book::init () -{ - int score_count = score_lines_.size (); - - /* Calculate the full book height. Hmm, can't we cache system - heights while making stencils? */ - height_ = 0; - Stencil btitle = book_title (); - if (!btitle.is_empty ()) - height_ += btitle.extent (Y_AXIS).length (); - - for (int i = 0; i < score_count; i++) - { - Stencil title = score_title (i); - if (!title.is_empty ()) - height_ += title.extent (Y_AXIS).length (); - - int line_count = SCM_VECTOR_LENGTH (score_lines_[i].lines_); - for (int j = 0; j < line_count; j++) - { - SCM s = scm_vector_ref ((SCM) score_lines_[i].lines_, scm_int2num (j)); - height_ += unsmob_paper_line (s)->dim ()[Y_AXIS]; - } - } - - Output_def *paper = bookpaper_; - - SCM scopes = SCM_EOL; - if (ly_c_module_p (header_)) - scopes = scm_cons (header_, scopes); - - SCM make_tagline = paper->c_variable ("make-tagline"); - tagline_ = scm_call_2 (make_tagline, paper->self_scm (), scopes); - Real tag_height = 0; - if (Stencil *s = unsmob_stencil (tagline_)) - tag_height = s->extent (Y_AXIS).length (); - height_ += tag_height; - - SCM make_copyright = paper->c_variable ("make-copyright"); - copyright_ = scm_call_2 (make_copyright, paper->self_scm (), scopes); - Real copy_height = 0; - if (Stencil *s = unsmob_stencil (copyright_)) - copy_height = s->extent (Y_AXIS).length (); - height_ += copy_height; -} - SCM Paper_book::lines () { @@ -374,13 +330,29 @@ Paper_book::lines () return lines_; } + +SCM +make_tagline (Output_def*paper, SCM scopes) +{ + SCM make_tagline = paper->c_variable ("make-tagline"); + SCM tagline = scm_call_2 (make_tagline, paper->self_scm (), scopes); + return tagline; +} + +SCM +make_copyright (Output_def *paper, SCM scopes) +{ + SCM make_copyright = paper->c_variable ("make-copyright"); + SCM copyright = scm_call_2 (make_copyright, paper->self_scm (), scopes); + return copyright; +} + SCM Paper_book::pages () { if (ly_c_pair_p (pages_)) return pages_; - init (); Output_def *paper = bookpaper_; Page *page = new Page (paper, 1); @@ -396,15 +368,23 @@ Paper_book::pages () SCM all = lines (); SCM proc = paper->c_variable ("page-breaking"); - SCM breaks = scm_apply_0 (proc, scm_list_n (all, scm_make_real (height_), + SCM breaks = scm_apply_0 (proc, scm_list_n (all, + self_scm (), scm_make_real (text_height), scm_make_real (-copy_height), scm_make_real (-tag_height), SCM_UNDEFINED)); - /* Copyright on first page. */ - if (unsmob_stencil (copyright_)) - page->copyright_ = copyright_; + + /* + UGH - move this out of C++. + */ + SCM scopes = SCM_EOL; + if (ly_c_module_p (header_)) + scopes = scm_cons (header_, scopes); + + tagline_ = make_tagline (bookpaper_, scopes); + copyright_ = make_tagline (bookpaper_, scopes); int page_count = SCM_VECTOR_LENGTH ((SCM) breaks); int line = 1; @@ -431,25 +411,52 @@ Paper_book::pages () pages_ = scm_cons (page->self_scm (), pages_); } - /* Tagline on last page. */ - if (unsmob_stencil (tagline_)) - page->tagline_ = tagline_; - pages_ = scm_reverse (pages_); return pages_; } + + static SCM -c_ragged_page_breaks (SCM lines, Real book_height, Real text_height, +c_ragged_page_breaks (SCM lines, + Paper_book *book, + Real text_height, Real first, Real last) { int page_number = 0; - int page_count = int (book_height / text_height + 0.5); + + Real book_height =0.; + for (SCM s = lines ; ly_c_pair_p (s); s = ly_cdr (s)) + { + book_height += unsmob_paper_line (s)->dim ()[Y_AXIS]; + } + + /* + UGH. + */ + SCM scopes = SCM_EOL; + if (ly_c_module_p (book->header_)) + scopes = scm_cons (book->header_, scopes); + + + SCM tag = make_tagline (book->bookpaper_, scopes); + if (unsmob_stencil (tag)) + { + book_height += unsmob_stencil (tag)->extent (Y_AXIS).length (); + } + + SCM cr = make_copyright (book->bookpaper_, scopes); + if (unsmob_stencil (cr)) + { + book_height += unsmob_stencil (cr)->extent (Y_AXIS).length (); + } + + 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; s != SCM_EOL; s = ly_cdr (s)) + 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) @@ -473,14 +480,16 @@ 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 (ly_c_number_p (book), book, SCM_ARG2, __FUNCTION__, "real"); - SCM_ASSERT_TYPE (ly_c_number_p (text), text, SCM_ARG2, __FUNCTION__, "real"); - SCM_ASSERT_TYPE (ly_c_number_p (first), first, SCM_ARG2, __FUNCTION__, "real"); - SCM_ASSERT_TYPE (ly_c_number_p (last), last, SCM_ARG2, __FUNCTION__, "real"); + 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, - ly_scm2double (book), ly_scm2double (text), + return c_ragged_page_breaks (lines, b, + ly_scm2double (text), ly_scm2double (first), ly_scm2double (last)); } diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 1c1b897de6..16682df3db 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -167,7 +167,7 @@ (lambda (x) (ly:outputter-dump-string outputter x)) (list - (header "creator" + (header "creator" ;FIXME "timestamp" bookpaper (length lines) diff --git a/scm/page-layout.scm b/scm/page-layout.scm index 15c14fcc0f..5312e1a3b5 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -96,7 +96,9 @@ ;; max density % (define MAX-CRAMP 0.05) -(define-public (ly:optimal-page-breaks lines book-height text-height +(define-public (ly:optimal-page-breaks lines + paper-book + text-height first-diff last-diff) "DOCME" ;; FIXME: may need some tweaking: square, cubic @@ -119,7 +121,6 @@ (if (= page-number 1) (set! h (+ h first-diff))) (if (= page-number page-count) - ;;(> page-number (/ book-height text-height)) (set! h (+ h last-diff))) h)) @@ -206,12 +207,11 @@ (if (ly:get-option 'verbose) (begin - (format (current-error-port) "Estimated page count: ~S\n" - (/ book-height text-height)) - (format (current-error-port) "breaks: ~S\n" breaks) - (force-output (current-error-port)))) - ;; TODO: if solution is bad return no breaks and revert to - ;; ragged bottom + (format (current-error-port) "breaks: ~S\n" breaks) + (force-output (current-error-port)))) + + ;; TODO: if solution is bad return no breaks and revert to + ;; ragged bottom (list->vector breaks)))