+2004-05-30 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * 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 <hanwen@xs4all.nl>
* lily/staff-symbol-engraver.cc (acknowledge_grob): remove item ->
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))
Grob::~Grob ()
{
- /*
- do nothing scm-ish and no unprotecting here.
- */
}
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;
if (ly_c_procedure_p (proc))
scm_call_1 (proc, this->self_scm ());
- status_= final;
+ status_ = final;
}
Stencil *
programming_error ("Null dependency added");
}
-
void
Grob::handle_broken_dependencies ()
{
void
Grob::set_extent (SCM dc, Axis a)
{
- dim_cache_[a].dimension_ =dc;
+ dim_cache_[a].dimension_ = dc;
}
void
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];
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);
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);
void output_page (Page*, bool);
};
-Paper_outputter* get_paper_outputter (String);
+Paper_outputter* get_paper_outputter (String,String);
#endif /* PAPER_OUTPUTTER_HH */
{
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;
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_ = "";
return 1;
}
+Array<String>
+split_string (String s, char c)
+{
+ Array<String> 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
/* 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<String> 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)
{
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_)
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)),
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)
Paper_column::Paper_column (SCM l)
: Item (l) // guh.?
{
- system_=0;
+ system_ = 0;
rank_ = -1;
}
// 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 ());
}
}
Paper_outputter*
-get_paper_outputter (String outname)
+get_paper_outputter (String outname, String f)
{
progress_indication (_f ("paper output to `%s'...",
outname == "-" ? String ("<stdout>") : outname));
- return new Paper_outputter (outname);
+ return new Paper_outputter (outname, f);
}
{
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);
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 "
{
Grob *me = unsmob_grob (smob);
+ /*
+ can't use get_system() ? --hwn.
+ */
Link_array<Grob> all (me->pscore_->system_->columns ());
set_explicit_neighbor_columns (all);
/* 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
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. */
% 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
"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 "
(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
(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
(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) "")
;; 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)
(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