From: Han-Wen Nienhuys Date: Sun, 30 May 2004 09:31:40 +0000 (+0000) Subject: * lily/paper-book.cc (split_string): new function X-Git-Tag: release/2.3.3~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=46ef5daa401f06c6beeb996a00854e1310501dc1;p=lilypond.git * lily/paper-book.cc (split_string): new function (output): output multiple formats, i.e. --format=ps,tex * scm/output-ps.scm (output-scopes): dump variables directly. (define-fonts): rewrite for new interface * ps/lilyponddefs.ps: remove lilypondpaper redefinitions. * lily/paper-outputter.cc (Paper_outputter): take format argument. * lily/main.cc (parse_argv): don't set extension for output. * lily/clef-engraver.cc (create_clef): remove Staff_symbol_referencer::set_position() call. --- diff --git a/ChangeLog b/ChangeLog index 1955b018e2..abd9c68e7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-05-30 Han-Wen Nienhuys + + * lily/paper-book.cc (split_string): new function + (output): output multiple formats, i.e. --format=ps,tex + + * scm/output-ps.scm (output-scopes): dump variables directly. + (define-fonts): rewrite for new interface + + * ps/lilyponddefs.ps: remove lilypondpaper redefinitions. + + * lily/paper-outputter.cc (Paper_outputter): take format argument. + + * lily/main.cc (parse_argv): don't set extension for output. + + * lily/clef-engraver.cc (create_clef): remove + Staff_symbol_referencer::set_position() call. + 2004-05-29 Han-Wen Nienhuys * lily/staff-symbol-engraver.cc (acknowledge_grob): remove item -> diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index fb5daa0402..c22408b300 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -93,7 +93,7 @@ Clef_engraver::create_clef () SCM cpos = get_property ("clefPosition"); if (ly_c_number_p (cpos)) - Staff_symbol_referencer::set_position (clef_, ly_scm2int (cpos)); + clef_->set_property ("staff-position", cpos); SCM oct = get_property ("clefOctavation"); if (ly_c_number_p (oct) && ly_scm2int (oct)) diff --git a/lily/grob.cc b/lily/grob.cc index 79152064b4..4775770663 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -138,9 +138,6 @@ Grob::Grob (Grob const&s) Grob::~Grob () { - /* - do nothing scm-ish and no unprotecting here. - */ } @@ -164,13 +161,22 @@ Grob::get_paper () const return pscore_ ? pscore_->paper_ : 0; } + +/* + Recursively track all dependencies of this Grob. The + status_ field is used as a mark-field. It is marked with + BUSY during execution of this function, and marked with FINAL + when finished. + + FUNCPTR is the function to call to update this element. +*/ void Grob::calculate_dependencies (int final, int busy, SCM funcname) { if (status_ >= final) return; - if (status_== busy) + if (status_ == busy) { programming_error ("Element is busy, come back later"); return; @@ -190,7 +196,7 @@ Grob::calculate_dependencies (int final, int busy, SCM funcname) if (ly_c_procedure_p (proc)) scm_call_1 (proc, this->self_scm ()); - status_= final; + status_ = final; } Stencil * @@ -281,7 +287,6 @@ Grob::add_dependency (Grob*e) programming_error ("Null dependency added"); } - void Grob::handle_broken_dependencies () { @@ -592,7 +597,7 @@ Grob::has_offset_callback (SCM cb, Axis a)const void Grob::set_extent (SCM dc, Axis a) { - dim_cache_[a].dimension_ =dc; + dim_cache_[a].dimension_ = dc; } void diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 2be13c6c24..ad0ae53136 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -40,17 +40,13 @@ protected: friend class Spanner; void substitute_mutable_properties(SCM,SCM); - + char status_; public: Grob *original_; - /** - Administration: Where are we?. This is mainly used by Super_element and - Grob::calcalute_dependencies () - - 0 means ORPHAN, + /* + TODO: junk this member. */ - char status_; Paper_score *pscore_; Dimension_cache dim_cache_[NO_AXES]; @@ -69,25 +65,10 @@ public: void warning (String)const; void programming_error (String)const; - /* - related classes. - */ Output_def *get_paper () const; - - /** - add a dependency. It may be the 0 pointer, in which case, it is ignored. - */ void add_dependency (Grob*); - virtual System * get_system () const; + virtual System *get_system () const; - /** - Recursively track all dependencies of this Grob. The - status_ field is used as a mark-field. It is marked with - #busy# during execution of this function, and marked with #final# - when finished. - - #funcptr# is the function to call to update this element. - */ void calculate_dependencies (int final, int busy, SCM funcname); diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index dca083ffa8..cffab8cfb8 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -36,7 +36,7 @@ class Paper_outputter void output_music_output_def (Output_def* odef); public: - Paper_outputter (String nm); + Paper_outputter (String nm, String format); ~Paper_outputter (); void dump_scheme (SCM); @@ -47,6 +47,6 @@ public: void output_page (Page*, bool); }; -Paper_outputter* get_paper_outputter (String); +Paper_outputter* get_paper_outputter (String,String); #endif /* PAPER_OUTPUTTER_HH */ diff --git a/lily/main.cc b/lily/main.cc index c8811fdc04..4fc6dfb1f1 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -329,8 +329,6 @@ parse_argv (int argc, char **argv) { String s = option_parser->optional_argument_str0_; File_name file_name (s); - if (s != "-" && file_name.ext_.is_empty ()) - file_name.ext_ = output_format_global; output_name_global = file_name.to_string (); } break; diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 365e64694c..f5a54cc885 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -239,8 +239,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", write output to cwd; do not use root and directory parts of input file name. */ File_name out_file_name (file_name); - if (file_name != "-") - out_file_name.ext_ = output_format_global; + out_file_name.ext_ = ""; out_file_name.root_ = ""; out_file_name.dir_ = ""; diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 04759a3b1c..c379fb090c 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -82,6 +82,31 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*) return 1; } +Array +split_string (String s, char c) +{ + Array rv; + while (s.length ()) + { + int i = s.index (c); + + if (i == 0) + { + s = s.nomid_string (0, 1); + continue; + } + + if (i < 0) + i = s.length () ; + + rv.push (s.cut_string (0, i)); + s = s.nomid_string (0, i); + } + + return rv; +} + + /* TODO: there is too much code dup, and the interface is not @@ -97,28 +122,33 @@ Paper_book::output (String outname) /* Generate all stencils to trigger font loads. */ SCM pages = this->pages (); - Paper_outputter *out = get_paper_outputter (outname); - int page_count = scm_ilength (pages); + Array output_formats = split_string (output_format_global, ','); - SCM scopes = SCM_EOL; - if (ly_c_module_p (header_)) - scopes = scm_cons (header_, scopes); + for (int i = 0; i < output_formats.size (); i++) + { + String format = output_formats[i]; + Paper_outputter *out = get_paper_outputter (outname + "." + output_formats[i], format); + int page_count = scm_ilength (pages); + + SCM scopes = SCM_EOL; + if (ly_c_module_p (header_)) + scopes = scm_cons (header_, scopes); - out->output_header (bookpaper_, scopes, page_count, false); + out->output_header (bookpaper_, scopes, page_count, false); - for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s)) - { - Page *p = unsmob_page (ly_car (s)); - progress_indication ("[" + to_string (p->number_)); - out->output_page (p, ly_cdr (s) == SCM_EOL); - progress_indication ("]"); - } + for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s)) + { + Page *p = unsmob_page (ly_car (s)); + progress_indication ("[" + to_string (p->number_)); + out->output_page (p, ly_cdr (s) == SCM_EOL); + progress_indication ("]"); + } - out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output"))); - progress_indication ("\n"); + out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output"))); + progress_indication ("\n"); + } } - Stencil Paper_book::title (int i) { @@ -157,7 +187,8 @@ Paper_book::title (int i) void Paper_book::classic_output (String outname) { - Paper_outputter *out = get_paper_outputter (outname); + String format = "tex"; + Paper_outputter *out = get_paper_outputter (outname + "." + format, format); Output_def * p = bookpaper_; while (p && p->parent_) @@ -187,7 +218,7 @@ Paper_book::classic_output (String outname) FIXME: vague... why is TeX is different from other ouput backends, why not fix the TeX backend? -- jcn */ - if (output_format_global == "tex") + if (format == "tex") o = Offset (0, 0); out->output_line (scm_vector_ref (top_lines, scm_int2num (i)), @@ -296,6 +327,7 @@ Paper_book::pages () SCM pages = SCM_EOL; int page_count = SCM_VECTOR_LENGTH ((SCM) breaks); int line = 1; + for (int i = 0; i < page_count; i++) { if (i) diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 5e5bc659a5..9eb5f1c3dd 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -67,7 +67,7 @@ Paper_column::get_column () const Paper_column::Paper_column (SCM l) : Item (l) // guh.? { - system_=0; + system_ = 0; rank_ = -1; } diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index ec1f3f9f8d..f091341def 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -33,13 +33,13 @@ // JUNKME extern SCM stencil2line (Stencil* stil, bool is_title = false); -Paper_outputter::Paper_outputter (String filename) +Paper_outputter::Paper_outputter (String filename, String format) { filename_ = filename; file_ = scm_open_file (scm_makfrom0str (filename.to_str0 ()), scm_makfrom0str ("w")); - String module_name = "scm output-" + output_format_global; + String module_name = "scm output-" + format; output_module_ = scm_c_resolve_module (module_name.to_str0 ()); } @@ -168,10 +168,10 @@ Paper_outputter::output_stencil (Stencil stil) } Paper_outputter* -get_paper_outputter (String outname) +get_paper_outputter (String outname, String f) { progress_indication (_f ("paper output to `%s'...", outname == "-" ? String ("") : outname)); - return new Paper_outputter (outname); + return new Paper_outputter (outname, f); } diff --git a/lily/script-column.cc b/lily/script-column.cc index 52e5adcd0d..b7a70bd462 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -48,6 +48,9 @@ Script_column::before_line_breaking (SCM smob) { Grob *sc = unsmob_grob (ly_car (s)); + /* + Don't want to consider scripts horizontally next to notes. + */ if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)) staff_sided.push (sc); diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 556381419a..896bbb2b33 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -255,14 +255,11 @@ Side_position_interface::get_axis (Grob*me) if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS) || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS)) return X_AXIS; - return Y_AXIS; } - - ADD_INTERFACE (Side_position_interface,"side-position-interface", "Position a victim object (this one) next to other objects (the " "support). The property @code{direction} signifies where to put the " diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index bdb3212023..fdc5bacad4 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -368,6 +368,9 @@ Spacing_spanner::set_springs (SCM smob) { Grob *me = unsmob_grob (smob); + /* + can't use get_system() ? --hwn. + */ Link_array all (me->pscore_->system_->columns ()); set_explicit_neighbor_columns (all); diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index 160576caae..4ef9fbe9be 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -120,7 +120,7 @@ Staff_symbol_referencer::callback (SCM element_smob, SCM) /* This sets the position relative to the center of the staff symbol. -The function is hairy, because it can be callled in two situations: +The function is hairy, because it can be called in two situations: 1. There is no staff yet; we must set staff-position @@ -142,9 +142,7 @@ Staff_symbol_referencer::set_position (Grob *me, Real p) else me->set_property ("staff-position", scm_make_real (p)); - if (!me->has_offset_callback (Staff_symbol_referencer::callback_proc, - Y_AXIS)) - me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS); + me->add_offset_callback (Staff_symbol_referencer::callback_proc, Y_AXIS); } /* Half of the height, in staff space, i.e. 2.0 for a normal staff. */ diff --git a/ps/lilyponddefs.ps b/ps/lilyponddefs.ps index b4116e2b21..60252c745c 100644 --- a/ps/lilyponddefs.ps +++ b/ps/lilyponddefs.ps @@ -9,18 +9,9 @@ % To let gs load fonts from builddir, do: % export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm -/staff-line-thickness lilypondpaperlinethickness def -/staff-height lilypondpaperstaffheight def -/line-width lilypondpaperlinewidth def - -/lily-output-units 2.83464 def %% milimeter -% /lily-output-units 0.996264 def %% true points. - -/output-scale lilypondpaperoutputscale lily-output-units mul def /set-ps-scale-to-lily-scale { output-scale output-scale scale } bind def -/paper-size { lilypondpaperpapersize } bind def /init-paper { gsave diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 537b5f0330..e9ad248e45 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -169,8 +169,9 @@ "m" (string-encode-integer (inexact->exact (round (* 1000 magnify)))) (if (not coding-command) "" (string-append "e" coding-command))))) -(define (define-fonts paper font-list) - +(define (define-fonts bookpaper) + + (define font-list (ly:bookpaper-fonts bookpaper)) (define (define-font command fontname scaling) (string-append "/" command " { /" fontname " findfont " @@ -192,7 +193,7 @@ (else (string-append basename ".pfa")) )) - (define (font-load-command paper font) + (define (font-load-command font) (let* ((specced-font-name (ly:font-name font)) (fontname (if specced-font-name specced-font-name @@ -206,7 +207,7 @@ (plain (font-command font #f)) (designsize (ly:font-design-size font)) (magnification (* (ly:font-magnification font))) - (ops (ly:output-def-lookup paper 'outputscale)) + (ops (ly:output-def-lookup bookpaper 'outputscale)) (scaling (* ops magnification designsize))) (string-append @@ -234,7 +235,7 @@ (string-append (apply string-append (map font-load-encoding encodings)) (apply string-append - (map (lambda (x) (font-load-command paper x)) font-list))))) + (map (lambda (x) (font-load-command x)) font-list))))) (define (define-origin file line col) "") @@ -281,12 +282,11 @@ ;; FIXME: duplicated in every backend (ps-string-def "lilypond" 'tagline - (string-append "Engraved by LilyPond (version " (lilypond-version) ")")))) + (string-append "Engraved by LilyPond (version " (lilypond-version) ")")) + )) (define (header-end) - (string-append - (ly:gulp-file "lilyponddefs.ps") - (ly:gulp-file "music-drawing-routines.ps"))) + "") ;; WTF is this in every backend? (define (horizontal-line x1 x2 th) @@ -326,21 +326,34 @@ (let ((prefix "lilypond")) ;; FIXME: duplicates output-paper's scope-entry->string, mostly - (define (scope-entry->string key var) - (if (variable-bound? var) - (let ((val (variable-ref var))) - (if (and (memq key fields) (string? val)) - (header-to-file basename key val)) - (cond - ((string? val) (ps-string-def prefix key val)) - ((number? val) (ps-number-def prefix key val)) - (else ""))) - "")) - - (define (output-scope scope) - (apply string-append (module-map scope-entry->string scope))) + (define (value->string val) + (cond + ((string? val) (string-append "(" val ")")) + ((symbol? val) (symbol->string val)) + ((number? val) (number->string val)) + (else ""))) + + (define (output-entry ps-key ly-key) + (string-append + "/" ps-key " " (value->string (ly:output-def-lookup paper ly-key)) " def \n")) - (string-append (apply string-append (map output-scope scopes))))) + + (string-append + "/lily-output-units 2.83464 def %% milimeter \n" + "% /lily-output-units 0.996264 def %% true points.\n" + (output-entry "staff-line-thickness" 'linethickness) + (output-entry "line-width" 'linewidth) + (output-entry "paper-size" 'papersize) + (output-entry "staff-height" 'staffheight) ;junkme. + "/output-scale " + (number->string (ly:output-def-lookup paper 'outputscale)) + " lily-output-units mul def \n" + + (ly:gulp-file "music-drawing-routines.ps") + (ly:gulp-file "lilyponddefs.ps") + + ))) + (define (placebox x y s) (string-append