+pl 12.jcn2
+ - Lookup abstract base class
+ - Lookup/Symtable(s): separation of input/output
+pl 12.jcn1
+ - applied to 12.hwn2 patch
+ - redo of 11.jcn2's lookup/identifier
+
+pl 11.jcn2
+ - preparations for braindead PostScript output
pl 12.hwn1
- \remove "Engraver_type";
MAJOR_VERSION=1
MINOR_VERSION=0
PATCH_LEVEL=12
-MY_PATCH_LEVEL=hwn2
+MY_PATCH_LEVEL=jcn2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
Real interbeam_f = paper ()->interbeam_f (stem_l_->mult_i_);
Real w = 1.5 * lookup_l ()->ball (2).dim_.x ().length ();
Real internote_f = paper ()->internote_f ();
- Real interline_f = paper ()->interline_f ();
Real beam_f = paper ()->beam_thickness_f ();
int beams_i = 0;
if (abs (off_[ax]) >= 100 CM)
{
warning (_f ("ridiculous dimension: %s, %s", axis_name_str (ax),
- print_dimen(off_[ax])));
+ print_dimen (off_[ax])));
if (experimental_features_global_b)
assert (false);
- ((Atom*)this)->off_[ax] = 0.0;
+ ( (Atom*)this)->off_[ax] = 0.0;
ridiculous = true;
}
}
void
-Atom::print() const
+Atom::print () const
{
#ifndef NPRINT
- DOUT << "texstring: " << tex_ << '\n';
+ DOUT << "string: " << str_ << '\n';
DOUT << "dim:";
- for (Axis i=X_AXIS; i < NO_AXES; incr(i))
- DOUT << axis_name_str(i) << " = " << dim_[i].str();
+ for (Axis i=X_AXIS; i < NO_AXES; incr (i))
+ DOUT << axis_name_str (i) << " = " << dim_[i].str ();
DOUT << "\noffset: " << off_.str ();
#endif
}
Box
-Atom::extent() const
+Atom::extent () const
{
Box b (dim_);
b.translate (off_);
}
-Atom::Atom()
+Atom::Atom ()
: dim_ (Interval (0,0),Interval (0,0))
{
- tex_ = "\\unknown";
+ /*
+ urg
+ We should probably make Atom an abstract base class to
+ derive Ps_atom and Tex_atom from.
+ But Atom is used as a simple type *everywhere*,
+ and we don't have virtual contructors.
+ */
+ str_ = ps_output_global_b ? "unknown" : "\\unknown";
}
Atom::Atom (String s, Box b)
: dim_ (b)
{
- tex_ = s;
+ str_ = s;
}
String
-Atom::str() const
+Atom::str () const
{
- return String ("Atom (\'") + tex_ + "\', (" + dim_.x().str () + ", "
+ return String ("Atom (\'") + str_ + "\', (" + dim_.x ().str () + ", "
+ dim_.y ().str () + "))";
}
Text_def * td_p = new Text_def;
td_p->align_dir_ = CENTER;
String loud = dreq_l->access_Absolute_dynamic_req ()->loudness_str ();
- td_p->text_str_ = paper ()->lookup_l (0)->dynamic (loud).tex_;
+ td_p->text_str_ = paper ()->lookup_l (0)->dynamic (loud).str_;
td_p->style_str_ = "dynamic";
source file of the GNU LilyPond music typesetter
(c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "string.hh"
#include "header.hh"
#include "main.hh"
-extern char const *lily_version_number_sz();
+extern char const *lily_version_number_sz ();
+Header::Header ()
+{
+ lily_id_str_ = "Lily was here, " +
+ String (lily_version_number_sz ());
+}
+//urg
String
-Header::TeX_string() const
+Header::tex_string () const
{
String s;
s+= "\\def\\LilyIdString{" + lily_id_str_ + "}";
- for (Dictionary_iter<String> i(*this); i.ok(); i++)
- {
- s += "\\def\\mudela" + i.key() + "{" + i.val() + "}";
- }
+ for (Dictionary_iter<String> i (*this); i.ok (); i++)
+ s += "\\def\\mudela" + i.key () + "{" + i.val () + "}";
return s;
}
-Header::Header ()
+String
+Header::ps_string () const
{
- lily_id_str_ = "Lily was here, " +
- String (lily_version_number_sz ());
+ String s;
+
+ s+= "/lily_id_string\n{" + lily_id_str_ + "} bind def\n";
+
+ for (Dictionary_iter<String> i (*this); i.ok (); i++)
+ s += "/mudela" + i.key () + "{" + i.val () + "} bind def";
+ return s;
}
+
#include "my-lily-lexer.hh"
#include "debug.hh"
#include "symtable.hh"
-#include "lookup.hh"
#include "script-def.hh"
#include "request.hh"
#include "translator.hh"
DEFAULT_PRINT(General_script_def);
-DEFAULT_PRINT(Lookup);
DEFAULT_PRINT(Translator);
DEFAULT_PRINT(Symtables);
DEFAULT_PRINT(Music);
DUMMY_STR(Notename_table);
DUMMY_STR(General_script_def);
-DUMMY_STR(Lookup);
DUMMY_STR(Translator);
DUMMY_STR(Symtables);
DUMMY_STR(Music);
IMPLEMENT_ID_CLASS(Real);
IMPLEMENT_ID_CLASS(String);
IMPLEMENT_ID_CLASS(General_script_def);
-IMPLEMENT_ID_CLASS(Lookup);
IMPLEMENT_ID_CLASS(Symtables);
IMPLEMENT_ID_CLASS(Music);
IMPLEMENT_ID_CLASS(Score);
DEFAULT_ACCESSOR(int);
DEFAULT_ACCESSOR(Real);
DEFAULT_ACCESSOR(String);
-DEFAULT_ACCESSOR(Lookup);
DEFAULT_ACCESSOR(Symtables);
DEFAULT_ACCESSOR(Score);
DEFAULT_ACCESSOR(Midi_def);
class Atom {
Offset off_;
public:
- String tex_;
+ String str_;
String font_;
Box dim_;
information. */
struct Header : Dictionary<String>
{
- String lily_id_str_;
- String TeX_string() const;
Header ();
+
+ String tex_string () const;
+ String ps_string () const;
+
+ String lily_id_str_;
};
#endif // HEADER_HH
class Symtables_identifier;
class Midi_def_identifier;
class Paper_def_identifier;
-class Lookup_identifier;
class Real_identifier;
class int_identifier;
class String_identifier;
IDACCESSOR(Symtables)
IDACCESSOR(Midi_def)
IDACCESSOR(Paper_def)
- IDACCESSOR(Lookup)
IDACCESSOR(Real)
IDACCESSOR(String)
IDACCESSOR(Request)
DECLARE_ID_CLASS(Real);
DECLARE_ID_CLASS(String);
DECLARE_ID_CLASS(General_script_def);
-DECLARE_ID_CLASS(Lookup);
DECLARE_ID_CLASS(Symtables);
DECLARE_ID_CLASS(Music);
DECLARE_ID_CLASS(int);
struct Dynamic_req;
struct Element_group;
struct Element_group_item;
+struct Engraver_group_engraver;
struct General_script_def;
struct Graphical_element;
struct Graphical_axis_group;
struct Musical_req;
struct Music;
struct Music_sequence;
+struct Music_wrapper_iterator;
+struct Music_wrapper;
struct My_lily_parser;
struct Note_column;
struct Note_column_engraver;
struct Note_head_engraver;
struct Notename_table;
struct Offset;
-struct Outputter;
-struct Performer;
struct Paper_column;
-struct Paper_score;
struct Paper_def;
+struct Paper_outputter;
+struct Paper_score;
+struct Paper_stream;
struct Partial_measure_req;
+struct Performer;
struct Plet;
struct Plet_engraver;
struct Plet_req;
struct Plet_spanner;
struct Rational;
-struct Music_wrapper_iterator;
-struct Music_wrapper;
-struct Relative_octave_music;
-struct Engraver_group_engraver;
struct Piano_brace;
struct Performer;
struct Performer_group_performer;
struct Property_iterator;
+struct Ps_lookup;
+struct Ps_outputter;
+struct Ps_stream;
struct Request;
struct Request_column;
struct Engraver;
+struct Relative_octave_music;
struct Rest;
struct Rest_collision;
struct Rest_collision_engraver;
struct Super_element;
struct Translation_property;
struct Tempo_req;
+struct Tex_lookup;
+struct Tex_outputter;
struct Tex_stream;
struct Text_def;
struct Text_gob;
struct Text_req;
struct Text_spanner;
struct Tie;
-struct Tex_outputter;
struct Tie_engraver;
struct Tie_req;
struct Time_description;
source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#ifndef LOOKUPSYMS_HH
-#define LOOKUPSYMS_HH
+#ifndef LOOKUP_HH
+#define LOOKUP_HH
#include "atom.hh"
#include "fproto.hh"
#include "direction.hh"
#include "curve.hh"
#include "afm.hh"
+#include "symtable.hh"
/** handy interface to symbol table
*/
-struct Lookup {
- Paper_def * paper_l_;
- Symtables *symtables_p_;
- String font_;
- String font_path_;
- Adobe_font_metric * afm_p_;
+class Lookup
+{
+public:
+ Lookup ();
+ Lookup (Lookup const&);
+ Lookup (Symtables const&);
+ virtual ~Lookup ();
-
- Lookup();
- Lookup (Lookup const &);
- ~Lookup();
-
- void add (String, Symtable*);
- void print() const;
- Atom afm_find (String) const;
-
- Atom fill (Box b) const;
- Atom beam (Real,Real, Real) const;
- Atom ps_beam (Real, Real, Real) const;
- Atom streepje (int type) const;
- Atom vbrace (Real &dy) const;
- Atom vbracket (Real &dy) const;
- Atom time_signature (Array<Scalar>) const;
- Atom special_time_signature (String) const;
- Atom stem (Real y1_pos, Real y2_pos) const;
- Atom rule_symbol (Real height, Real width) const;
Atom accidental (int) const;
+ void add (String, Symtable*);
+ virtual Atom afm_find (String s) const = 0;
+ Atom afm_find (String, String) const;
Atom ball (int) const;
- Atom flag (int, Direction) const;
- Atom rest (int, bool outside) const;
- Atom clef (String) const;
Atom bar (String, Real height) const;
+ Atom beam (Real,Real, Real) const;
+ Atom clef (String) const;
+ virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const = 0;
Atom dots () const;
- Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
- Atom slur (Array<Offset> controls) const;
- Atom plet (Real dy, Real dx, Direction dir) const;
- Atom text (String style, String text) const;
- Atom script (String idx) const;
- Atom hairpin (Real width, bool decresc, bool continued) const;
Atom dynamic (String) const;
+ Atom fill (Box b) const;
+ Atom flag (int, Direction) const;
+ virtual Atom hairpin (Real width, bool decresc, bool continued) const = 0;
+ virtual Atom plet (Real dy, Real dx, Direction dir) const = 0;
+ void print () const;
+ virtual Atom ps_beam (Real slope, Real width, Real thick) const = 0;
+ Atom rest (int, bool outside) const;
+ Atom rule_symbol (Real height, Real width) const;
+ Atom script (String idx) const;
+ virtual Atom stem (Real y1_pos, Real y2_pos) const = 0;
+ Atom stem (Real y1_pos, Real y2_pos, String) const;
+ virtual Atom slur (Array<Offset> controls) const = 0;
+ Atom streepje (int type) const;
+ Atom text (String style, String text) const;
+ Atom vbrace (Real &dy) const;
+ virtual Atom vbracket (Real &dy) const = 0;
+ Atom special_time_signature (String) const;
+ Atom time_signature (Array<Scalar>) const;
+
+ Paper_def * paper_l_;
+ Symtables *symtables_p_;
+ String font_;
+ String font_path_;
+ Adobe_font_metric * afm_p_;
};
-#endif // LOOKUPSYMS_HH
+#endif // LOOKUP_HH
extern bool find_quarts_global_b;
extern int exit_status_i_;
extern bool experimental_features_global_b;
+extern bool ps_output_global_b;
extern bool dependency_global_b;
extern bool version_ignore_global_b;
*/
class Paper_score : public Music_output {
- Tex_outputter *open_tex_outputter (Tex_stream*);
- Tex_stream *open_output_stream ();
+ Paper_outputter *open_paper_outputter (Paper_stream*);
+ Paper_outputter *open_ps_outputter (Ps_stream*);
+ Paper_outputter *open_tex_outputter (Tex_stream*);
+ Paper_stream *open_output_stream ();
public:
Paper_def *paper_l_;
/// other elements
Pointer_list<Score_element*> elem_p_list_;
- Outputter *outputter_l_;
+ Paper_outputter *outputter_l_;
Line_of_score * line_l_;
Paper_score ();
{
Assoc<int, Lookup *> *lookup_p_assoc_p_;
static int default_count_i_;
+ bool ps_b_;
protected:
VIRTUAL_COPY_CONS(Paper_def,Music_output_def);
Real arithmetic_constant (Moment minimal_mom) const;
Real arithmetic_spacing (Moment mom,Real constant) const;
virtual int get_next_default_count () const;
- String TeX_output_settings_str () const;
+ //urg
+ String tex_output_settings_str () const;
+ String ps_output_settings_str () const;
// urg
friend int yyparse (void*);
};
--- /dev/null
+/*
+ paper-outputter.hh -- declare Paper_outputter
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef PAPER_OUTPUTTER_HH
+#define PAPER_OUTPUTTER_HH
+
+#include "lily-proto.hh"
+#include "array.hh"
+#include "string.hh"
+
+/**
+ Abstract interface for a Score_element to output itself.
+ */
+class Paper_outputter
+{
+public:
+ Paper_outputter (Paper_stream *);
+ virtual ~Paper_outputter ();
+
+ virtual void output_molecule (Molecule const *, Offset, char const *)=0;
+ void output_molecule (Molecule const *, Offset, char const *, String);
+ virtual void start_line ()=0;
+ virtual void stop_line ()=0;
+ virtual void switch_to_font (String fontname)=0;
+
+ Array<String> font_arr_;
+ String current_font_;
+ Paper_stream* outstream_l_;
+};
+
+#endif // PAPER_OUTPUTTER_HH
--- /dev/null
+#ifndef PAPER_STREAM_HH
+#define PAPER_STREAM_HH
+
+#include <iostream.h>
+#include "string.hh"
+
+/** Paper output
+ Baseclass for writing to a PostScript or TeX file.
+ It counts braces to prevent nesting errors, and
+ it will add a comment sign before each newline.
+ */
+
+class Paper_stream
+{
+public:
+ bool outputting_comment;
+ ostream *os;
+ int nest_level;
+ /// to check linelen in output. TeX has limits.
+ int line_len_i_;
+
+ /// open a file for writing
+ Paper_stream (String filename);
+ virtual void header () = 0;
+
+ /// delegate conversion to scalar class
+ virtual Paper_stream &operator <<(Scalar);
+
+ /// close the file
+ virtual ~Paper_stream();
+
+private:
+ Paper_stream (Paper_stream const&);
+ void break_line();
+};
+
+#endif // PAPER_STREAM_HH
--- /dev/null
+/*
+ tex-lookup.hh -- declare Tex_lookup
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef PS_LOOKUP_HH
+#define PS_LOOKUP_HH
+
+#include "lookup.hh"
+
+class Ps_lookup : public Lookup
+{
+public:
+ Ps_lookup ();
+ Ps_lookup (Lookup const& s);
+ Ps_lookup (Symtables const& s);
+ virtual ~Ps_lookup ();
+
+ virtual Atom afm_find (String s) const;
+ virtual Atom Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
+ virtual Atom Ps_lookup::hairpin (Real width, bool decresc, bool continued) const;
+ virtual Atom Ps_lookup::plet (Real dy , Real dx, Direction dir) const;
+ virtual Atom Ps_lookup::ps_beam (Real slope, Real width, Real thick) const;
+ virtual Atom Ps_lookup::slur (Array<Offset> controls) const;
+ virtual Atom stem (Real y1, Real y2) const;
+ virtual Atom Ps_lookup::vbracket (Real &y) const;
+};
+
+#endif // PS_LOOKUP_HH
--- /dev/null
+/*
+ ps-outputter.hh -- declare Ps_outputter
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef PS_OUTPUTTER_HH
+#define PS_OUTPUTTER_HH
+
+#include "paper-outputter.hh"
+
+class Ps_outputter : public Paper_outputter
+{
+public:
+ Ps_outputter (Paper_stream *);
+ virtual ~Ps_outputter ();
+
+ void switch_to_font (String);
+ virtual void output_molecule (Molecule const*, Offset, char const*);
+ virtual void start_line ();
+ virtual void stop_line ();
+};
+
+#endif // PS_OUTPUTTER_HH
--- /dev/null
+#ifndef PS_STREAM_HH
+#define PS_STREAM_HH
+
+#include "paper-stream.hh"
+
+/** PS output.
+ Use this class for writing to a PS file.
+ It counts braces to prevent nesting errors, and
+ it will add a comment sign before each newline.
+ */
+class Ps_stream : public Paper_stream
+{
+public:
+ Ps_stream (String filename);
+ virtual ~Ps_stream();
+
+ virtual void header();
+ virtual Paper_stream &operator <<(Scalar);
+};
+
+#endif // PS_STREAM_HH
};
-struct Symtables : private Dictionary<Symtable*> {
-
- Symtable* operator()(String s);
- ~Symtables();
- Symtables();
- Symtables (Symtables const&);
- void add (String, Symtable*);
- void print() const;
+struct Symtables : private Dictionary<Symtable*>
+{
+ Symtables();
+ Symtables (Symtables const&);
+ ~Symtables();
+
+ Symtable* operator()(String s);
+ void add (String, Symtable*);
+ void print() const;
+
+ String font_;
+ String font_path_;
};
--- /dev/null
+/*
+ tex-lookup.hh -- declare Tex_lookup
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef TEX_LOOKUP_HH
+#define TEX_LOOKUP_HH
+
+#include "ps-lookup.hh"
+
+class Tex_lookup : public Ps_lookup
+{
+public:
+ Tex_lookup ();
+ Tex_lookup (Lookup const& s);
+ Tex_lookup (Symtables const& s);
+ virtual ~Tex_lookup();
+
+ virtual Atom afm_find (String s) const;
+ virtual Atom dashed_slur (Array<Offset> controls, Real thick, Real dash) const;
+ Atom embed (Atom a) const;
+ virtual Atom hairpin (Real width, bool decresc, bool continued) const;
+ virtual Atom plet (Real dy , Real dx, Direction dir) const;
+ virtual Atom ps_beam (Real slope, Real width, Real thick) const;
+ virtual Atom slur (Array<Offset> controls) const;
+ virtual Atom stem (Real y1, Real y2) const;
+ virtual Atom vbracket (Real &y) const;
+};
+
+#endif // TEX_LOOKUP_HH
/*
- outputter.hh -- declare Outputter
+ tex-outputter.hh -- declare Tex_outputter
source file of the GNU LilyPond music typesetter
*/
-#ifndef OUTPUTTER_HH
-#define OUTPUTTER_HH
+#ifndef TEX_OUTPUTTER_HH
+#define TEX_OUTPUTTER_HH
-#include "lily-proto.hh"
-#include "array.hh"
-#include "string.hh"
+#include "paper-outputter.hh"
-/**
- Abstract interface for a Score_element to output itself.
- */
-struct Outputter
+class Tex_outputter : public Paper_outputter
{
- virtual ~Outputter(){}
- virtual void start_line ()=0;
- virtual void output_molecule (Molecule const *, Offset, char const *)=0;
- virtual void stop_line ()=0;
-};
+public:
+ Tex_outputter (Paper_stream *);
+ virtual ~Tex_outputter ();
-/**
- Output a line of score using TeX strings
- */
-struct Tex_outputter : Outputter
-{
- Array<String> font_arr_;
- String current_font_;
-
- Tex_outputter (Tex_stream *);
- Tex_stream * outstream_l_;
void switch_to_font (String);
virtual void output_molecule (Molecule const*, Offset, char const*);
virtual void start_line ();
virtual void stop_line ();
};
-#endif // OUTPUTTER_HH
+#endif // TEX_OUTPUTTER_HH
-#ifndef TSTREAM__HH
-#define TSTREAM__HH
-
-#include <iostream.h>
-#include "string.hh"
+#ifndef TEX_STREAM_HH
+#define TEX_STREAM_HH
+#include "paper-stream.hh"
/** TeX output.
Use this class for writing to a TeX file.
It counts braces to prevent nesting errors, and
it will add a comment sign before each newline.
*/
-class Tex_stream {
- void break_line();
+class Tex_stream : public Paper_stream
+{
public:
- bool outputting_comment;
- ostream *os;
- int nest_level;
- /// to check linelen in output. TeX has limits.
- int line_len_i_;
-
- /// open a file for writing
Tex_stream (String filename);
- void header();
-
- /// delegate conversion to scalar class
- Tex_stream &operator <<(Scalar);
+ virtual ~Tex_stream();
- /// close the file
- ~Tex_stream();
-private:
- Tex_stream (Tex_stream const&);
+ virtual void header();
+ virtual Paper_stream &operator <<(Scalar);
};
-#endif
+
+#endif // TEX_STREAM_HH
(c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- TODO
- This doth suck. We should have PS output, and read spacing info from AFMs
-
- Glissando,
+ Jan Nieuwenhuizen <janneke@gnu.org>
+ TODO
+ Read spacing info from AFMs
+ Glissando
*/
#include "lookup.hh"
#include "string-convert.hh"
#include "main.hh"
-Lookup::Lookup()
+Lookup::Lookup ()
{
paper_l_ = 0;
symtables_p_ = new Symtables;
afm_p_ =0;
}
-Lookup::Lookup (Lookup const &s)
+Lookup::Lookup (Lookup const& s)
{
font_ = s.font_;
font_path_ = s.font_path_;
afm_p_ = 0;
}
-Lookup::~Lookup()
+Lookup::Lookup (Symtables const& s)
+{
+ font_ = s.font_;
+ font_path_ = s.font_path_;
+ paper_l_ = 0;
+ symtables_p_ = new Symtables (s);
+ afm_p_ = 0;
+}
+
+Lookup::~Lookup ()
{
delete afm_p_;
delete symtables_p_;
}
Atom
-Lookup::afm_find (String s) const
+Lookup::accidental (int j) const
+{
+ return afm_find (String ("accidentals") + String ("-") + to_str (j));
+}
+
+void
+Lookup::add (String s, Symtable*p)
+{
+ symtables_p_->add (s, p);
+}
+
+Atom
+Lookup::afm_find (String s, String str) const
{
if (!afm_p_)
{
*mlog << "[" << font_path_;
- ((Lookup*)this)->afm_p_ = new Adobe_font_metric (read_afm (font_path_));
+ ( (Lookup*)this)->afm_p_ = new Adobe_font_metric (read_afm (font_path_));
*mlog << "]" << flush ;
DOUT << this->afm_p_->str ();
}
Adobe_font_char_metric m = afm_p_->find_char (s);
Atom a;
- a.tex_ = String_convert::form_str ("\\char%d", m.code ());
a.dim_ = m.B_;
a.dim_[X_AXIS] *= 1 / 1000.0;
a.dim_[Y_AXIS] *= 1 / 1000.0;
+ a.str_ = String_convert::form_str (str.ch_C (), m.code ());
a.font_ = font_;
return a;
}
-void
-Lookup::add (String s, Symtable*p)
-{
- symtables_p_->add (s, p);
-}
-
-void
-Lookup::print() const
-{
-#ifndef NPRINT
- DOUT << "Lookup {\n";
- symtables_p_->print();
- DOUT << "}\n";
-#endif
-}
-
-Atom
-Lookup::text (String style, String text) const
-{
- Array<String> a;
-
- a.push (text);
- Atom tsym = (*symtables_p_)("style")->lookup (style);
- tsym.tex_ = substitute_args (tsym.tex_,a);
- tsym.font_ = font_;
-
- return tsym;
-}
-
-
-
Atom
Lookup::ball (int j) const
{
if (j > 2)
j = 2;
- Atom s = afm_find (String ("balls") + String ("-") + to_str (j));
- return s;
+ return afm_find (String ("balls") + String ("-") + to_str (j));
}
Atom
-Lookup::rest (int j, bool o) const
+Lookup::bar (String str, Real h) const
{
- Atom s =afm_find (String ("rests")
- + String ("-") + to_str (j) + (o ? "o" : ""));
-
+ Array<String> a;
+ a.push (print_dimen (h));
+ Atom s = (*symtables_p_) ("bars")->lookup (str);
+ s.str_ = substitute_args (s.str_, a);
+ s.dim_.y () = Interval (-h/2, h/2);
+ s.font_ = font_;
return s;
}
-Atom
-Lookup::fill (Box b) const
+Atom
+Lookup::beam (Real slope, Real width, Real thick) const
{
- Atom s;
- s.tex_ = "";
- s.dim_ = b;
-
- return s;
+ Atom a (ps_beam (slope, width, thick));
+ Real height = slope * width;
+ Real min_y = (0 <? height) - thick/2;
+ Real max_y = (0 >? height) + thick/2;
+
+ a.dim_[X_AXIS] = Interval (0, width);
+ a.dim_[Y_AXIS] = Interval (min_y, max_y);
+ return a;
}
Atom
-Lookup::accidental (int j) const
+Lookup::clef (String st) const
{
- Atom s= afm_find (String ("accidentals") + String ("-") + to_str (j));
- return s;
+ return afm_find (String ("clefs") + String ("-") + st);
}
-
Atom
-Lookup::bar (String s, Real h) const
+Lookup::dots () const
{
- Array<String> a;
- a.push (print_dimen (h));
- Atom ret=(*symtables_p_)("bars")->lookup (s);
- ret.tex_ = substitute_args (ret.tex_, a);
- ret.dim_.y() = Interval (-h/2, h/2);
- ret.font_ = font_;
- return ret;
-}
-
-Atom
-Lookup::script (String st) const
-{
- Atom s= afm_find (String ("scripts") + String ("-") + st);
-
- return s;
+ return afm_find (String ("dots") + String ("-") + String ("dot"));
}
Atom
}
Atom
-Lookup::clef (String st) const
-{
- Atom s=afm_find (String ("clefs") + String ("-") + st);
-
- return s;
-}
-
-Atom
-Lookup::dots () const
+Lookup::fill (Box b) const
{
- Atom s=afm_find (String ("dots") + String ("-") + String("dot"));
-
- return s;
+ Atom a;
+ a.dim_ = b;
+ return a;
}
Atom
Lookup::flag (int j, Direction d) const
{
char c = (d == UP) ? 'u' : 'd';
- Atom s=afm_find (String ("flags") + String ("-") + to_str (c) + to_str (j));
-
- return s;
-}
-
-Atom
-Lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
-{
- assert (controls.size () == 8);
-
- String ps = "\\embeddedps{\n";
-
- Real dx = controls[3].x () - controls[0].x ();
- Real dy = controls[3].y () - controls[0].y ();
-
- for (int i = 1; i < 4; i++)
- ps += String_convert::double_str (controls[i].x ()) + " "
- + String_convert::double_str (controls[i].y ()) + " ";
-
- ps += String_convert::double_str (controls[0].x ()) + " "
- + String_convert::double_str (controls[0].y ()) + " ";
-
- ps += String_convert::double_str (thick) + " ";
- Real on = dash > 1? thick * dash - thick : 0;
- Real off = 2 * thick;
- ps += "[" + String_convert::double_str (on) + " ";
- ps += String_convert::double_str (off) + "] ";
- ps += String_convert::int_str (0) + " ";
- ps += " draw_dashed_slur}";
-
- Atom s;
- s.tex_ = ps;
-
- s.dim_[X_AXIS] = Interval (0, dx);
- s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
- s.font_ = font_;
- return s;
+ return afm_find (String ("flags") + String ("-") + to_str (c) + to_str (j));
}
-Atom
-Lookup::slur (Array<Offset> controls) const
+void
+Lookup::print () const
{
- assert (controls.size () == 8);
-
- String ps = "\\embeddedps{\n";
-
- Real dx = controls[3].x () - controls[0].x ();
- Real dy = controls[3].y () - controls[0].y ();
-
- for (int i = 5; i < 8; i++)
- ps += String_convert::double_str (controls[i].x ()) + " "
- + String_convert::double_str (controls[i].y ()) + " ";
-
- ps += String_convert::double_str (controls[4].x ()) + " "
- + String_convert::double_str (controls[4].y ()) + " ";
-
- for (int i = 1; i < 4; i++)
- ps += String_convert::double_str (controls[i].x ()) + " "
- + String_convert::double_str (controls[i].y ()) + " ";
-
- ps += String_convert::double_str (controls[0].x ()) + " "
- + String_convert::double_str (controls[0].y ()) + " ";
-
- ps += " draw_slur}";
-
- Atom s;
- s.tex_ = ps;
-
- s.dim_[X_AXIS] = Interval (0, dx);
- s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
- s.font_ = font_;
- return s;
-
+#ifndef NPRINT
+ DOUT << "Lookup {\n";
+ symtables_p_->print ();
+ DOUT << "}\n";
+#endif
}
Atom
-Lookup::streepje (int type) const
+Lookup::rest (int j, bool o) const
{
- if (type > 2)
- type = 2;
-
- return afm_find ("balls-" + to_str (type) + "l");
+ return afm_find (String ("rests")
+ + String ("-") + to_str (j) + (o ? "o" : ""));
}
Atom
-Lookup::hairpin (Real width, bool decresc, bool continued) const
+Lookup::rule_symbol (Real height, Real width) const
{
- String embed;
- Atom ret;
- Real height = paper_l_->staffheight_f () / 6;
- embed = "\\embeddedps{\n" ;
- embed += to_str (width) + " "
- + to_str (height) + " "
- + to_str (continued ? height/2 : 0) +
- + " draw_" + String(decresc ? "de" : "") + "cresc}\n";
- ret.tex_ = embed;
-
-
- ret.dim_.x () = Interval (0, width);
- ret.dim_.y () = Interval (-2*height, 2*height);
- ret.font_ = font_;
- return ret;
+ Atom bs= (*symtables_p_) ("param")->lookup ("rule");
+ Array<String> args;
+ args.push (print_dimen (height));
+ args.push (print_dimen (width));
+ bs.str_ = substitute_args (bs.str_,args);
+ bs.dim_.x () = Interval (0,width);
+ bs.dim_.y () = Interval (0,height);
+ return bs;
}
Atom
-Lookup::time_signature (Array<Scalar> a) const
+Lookup::script (String str) const
{
- Atom s((*symtables_p_)("param")->lookup ("time_signature"));
- s.tex_ = substitute_args (s.tex_,a);
-
- return s;
+ return afm_find (String ("scripts") + String ("-") + str);
}
-
-
Atom
Lookup::special_time_signature (String s) const
{
return a;
}
-
-
Atom
-Lookup::stem (Real y1,Real y2) const
+Lookup::stem (Real y1, Real y2, String str) const
{
if (y1 > y2)
{
}
Atom s;
- s.dim_.x() = Interval (0,0);
- s.dim_.y() = Interval (y1,y2);
+ s.dim_.x () = Interval (0,0);
+ s.dim_.y () = Interval (y1,y2);
Array<String> a;
-
Real stem_width = paper_l_->get_var ("stemthickness");
a.push (print_dimen (-stem_width /2));
a.push (print_dimen (stem_width));
a.push (print_dimen (y2));
a.push (print_dimen (-y1));
- String src = "\\kern %\\vrule width % height % depth %";
- s.tex_ = substitute_args (src,a);
+ s.str_ = substitute_args (str, a);
s.font_ = font_;
return s;
}
+Atom
+Lookup::streepje (int type) const
+{
+ if (type > 2)
+ type = 2;
+
+ return afm_find ("balls" + String ("-") +to_str (type) + "l");
+}
+
+Atom
+Lookup::text (String style, String text) const
+{
+ Array<String> a;
+
+ a.push (text);
+ Atom s = (*symtables_p_) ("style")->lookup (style);
+ s.str_ = substitute_args (s.str_,a);
+ s.font_ = font_;
+
+ return s;
+}
+
+Atom
+Lookup::time_signature (Array<Scalar> a) const
+{
+ Atom s ((*symtables_p_) ("param")->lookup ("time_signature"));
+ s.str_ = substitute_args (s.str_, a);
+
+ return s;
+}
+
/*
- should be handled via Tex_ code and Lookup::bar()
+ should be handled via Tex_ code and Lookup::bar ()
*/
Atom
Lookup::vbrace (Real &y) const
}
- int idx = int (rint ((y- min_y)/step)) + 1;
+ int idx = int (rint ( (y- min_y)/step)) + 1;
{
Array<String> a;
a.push (to_str (idx));
- brace.tex_ = substitute_args (brace.tex_,a);
+ brace.str_ = substitute_args (brace.str_,a);
brace.dim_[Y_AXIS] = Interval (-y/2,y/2);
}
return brace;
}
-Atom
-Lookup::vbracket (Real &y) const
-{
- Atom psbracket;
- Real min_y = paper_l_->staffheight_f ();
- if (y < min_y)
- {
- warning (_ ("bracket")
- + " " + _ ("too small") + "(" + print_dimen (y) + ")");
-// y = min_y;
- }
- psbracket.tex_ = String ("\\embeddedps{ ") + to_str (y) + " draw_bracket}";
- psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
- psbracket.dim_[X_AXIS] = Interval (0,4 PT);
- return psbracket;
-#if 0
- Atom bracket = afm_find (String ("param") + "bracket");
- Interval ydims = bracket.dim_[Y_AXIS];
-
- Real min_y = ydims[LEFT];
- Real max_y = ydims[RIGHT];
- Real step = 1.0 PT;
-
- if (y < min_y)
- {
- warning (_ ("bracket")
- + " " + _ ("too small") + " (" + print_dimen (y) + ")");
- y = min_y;
- }
- if (y > max_y)
- {
- warning (_ ("bracket")
- + " " + _ ("too big") + " (" + print_dimen (y) + ")");
- y = max_y;
- }
-
-
- int idx = int (rint ((y- min_y)/step)) + 1;
-
- {
- Array<String> a;
- a.push (to_str (idx));
- bracket.tex_ = substitute_args (bracket.tex_,a);
- bracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
- }
-
- return bracket;
-#endif
-}
bool no_paper_global_b = false;
bool no_timestamps_global_b = false;
bool find_quarts_global_b = false;
+bool ps_output_global_b = false;
String default_outname_base_global = "lelie";
int default_count_global;
File_path global_path;
{
case 't':
experimental_features_global_b = true;
+ ps_output_global_b = true;
break;
case 'o':
outname_str = oparser.optional_argument_ch_C_;
#include "plist.hh"
#include "p-col.hh"
#include "p-score.hh"
-#include "tex-stream.hh"
#include "p-col.hh"
#include "header.hh"
#include "word-wrap.hh"
#include "gourlay-breaking.hh"
+#include "paper-stream.hh"
+#include "ps-stream.hh"
+#include "tex-stream.hh"
+#include "paper-outputter.hh"
+#include "ps-outputter.hh"
#include "tex-outputter.hh"
#include "file-results.hh"
#include "misc.hh"
line_l_->space_processing ();
Array<Column_x_positions> breaking = calc_breaking ();
- Tex_stream *tex_stream_p = open_output_stream ();
- outputter_l_=open_tex_outputter (tex_stream_p);
+ Paper_stream *paper_stream_p = open_output_stream ();
+ outputter_l_ = open_paper_outputter (paper_stream_p);
Link_array<Line_of_score> lines;
for (int i=0; i < breaking.size (); i++)
remove_line (line_l);
}
- *tex_stream_p << "\n\\EndLilyPondOutput";
+
+ if (ps_output_global_b)
+ *paper_stream_p << "\nshowpage\n";
+ else
+ *paper_stream_p << "\n\\EndLilyPondOutput";
+
delete outputter_l_;
- delete tex_stream_p;
+ delete paper_stream_p;
outputter_l_ = 0;
}
}
}
-Tex_stream *
+Paper_stream *
Paper_score::open_output_stream ()
{
// output
}
String outname = base_outname;
- if (outname != "-")
- outname += ".tex";
- target_str_global_array.push (outname);
- *mlog << _f ("TeX output to %s...",
- outname == "-" ? String ("<stdout>") : outname ) << endl;
+ Paper_stream* p;
+ if (ps_output_global_b)
+ {
+ if (outname != "-")
+ outname += ".ps";
+ *mlog << _f ("PostScript output to %s...",
+ outname == "-" ? String ("<stdout>") : outname ) << endl;
+ p = new Ps_stream (outname);
+ }
+ else
+ {
+ if (outname != "-")
+ outname += ".tex";
+ *mlog << _f ("TeX output to %s...",
+ outname == "-" ? String ("<stdout>") : outname ) << endl;
+ p = new Tex_stream (outname);
+ }
+ target_str_global_array.push (outname);
+ return p;
+}
- return new Tex_stream (outname);
+// urg
+Paper_outputter*
+Paper_score::open_paper_outputter (Paper_stream* paper_stream_p)
+{
+ if (ps_output_global_b)
+ return open_ps_outputter ((Ps_stream*)paper_stream_p);
+ else
+ return open_tex_outputter ((Tex_stream*)paper_stream_p);
}
+// urg urg urg
+Paper_outputter*
+Paper_score::open_ps_outputter (Ps_stream *ps_out_p)
+{
+ Ps_outputter *interfees_p = new Ps_outputter (ps_out_p);
+
+ if (header_global_p)
+ *ps_out_p << header_global_p->ps_string ();
+
+ *ps_out_p << _ ("% outputting Score, defined at: ") << origin_str_ << '\n';
+ // urg
+ if (header_l_)
+ *ps_out_p << header_l_->ps_string ();
+ //aaarg
+ *ps_out_p << paper_l_->ps_output_settings_str ();
-Tex_outputter *
+ if (experimental_features_global_b)
+ *ps_out_p << "turnOnExperimentalFeatures\n";
+
+ return interfees_p;
+}
+
+Paper_outputter*
Paper_score::open_tex_outputter (Tex_stream *tex_out_p)
{
Tex_outputter *interfees_p= new Tex_outputter (tex_out_p);
if (header_global_p)
- {
- *tex_out_p << header_global_p->TeX_string ();
- }
+ *tex_out_p << header_global_p->tex_string ();
*tex_out_p << _ ("% outputting Score, defined at: ") << origin_str_ << '\n';
if (header_l_)
- {
- *tex_out_p << header_l_->TeX_string();
- }
- *tex_out_p << paper_l_->TeX_output_settings_str ();
+ *tex_out_p << header_l_->tex_string();
+ *tex_out_p << paper_l_->tex_output_settings_str ();
if (experimental_features_global_b)
#include "paper-def.hh"
#include "debug.hh"
#include "lookup.hh"
+#include "ps-lookup.hh"
+#include "tex-lookup.hh"
#include "dimension.hh"
#include "assoc-iter.hh"
#include "score-engraver.hh"
lookup_p_assoc_p_ = new Assoc<int, Lookup*>;
for (Assoc_iter<int, Lookup*> ai(*s.lookup_p_assoc_p_); ai.ok (); ai++)
{
- Lookup * l=new Lookup (*ai.val ());
+ Lookup * l = ps_output_global_b ? new Ps_lookup (*ai.val ())
+ : new Tex_lookup (*ai.val ());
l->paper_l_ = this;
set_lookup (ai.key(), l);
}
-
-
}
Real
IMPLEMENT_IS_TYPE_B1 (Paper_def, Music_output_def);
String
-Paper_def::TeX_output_settings_str () const
+Paper_def::ps_output_settings_str () const
+{
+ String s ("\n ");
+ for (Assoc_iter<String,Identifier*> i (*scope_p_); i.ok (); i++)
+ s += String ("/mudelapaper") + i.key ()
+ + "{" + i.val ()->str () + "} bind def\n";
+ s += *scope_p_->elem ("texsetting")->access_String ();
+ return s;
+}
+
+String
+Paper_def::tex_output_settings_str () const
{
String s ("\n ");
for (Assoc_iter<String,Identifier*> i (*scope_p_); i.ok (); i++)
--- /dev/null
+/*
+ paper-outputter.cc -- implement Paper_outputter
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "paper-outputter.hh"
+#include "paper-stream.hh"
+#include "molecule.hh"
+#include "atom.hh"
+#include "array.hh"
+#include "dimension.hh"
+// urg, silly name
+#include "tex.hh"
+#include "string-convert.hh"
+#include "debug.hh"
+
+Paper_outputter::Paper_outputter (Paper_stream *s)
+{
+ outstream_l_ = s;
+}
+
+Paper_outputter::~Paper_outputter ()
+{
+}
+
+void
+Paper_outputter::output_molecule (Molecule const*m, Offset o, char const *nm, String s)
+{
+ if (check_debug)
+ *outstream_l_ << String ("\n%start: ") << nm << "\n";
+
+ for (PCursor <Atom*> i (m->atoms_); i.ok (); i++)
+ {
+ Offset a_off = i->offset ();
+ a_off += o;
+
+ switch_to_font (i->font_);
+
+ Array<String> a;
+ String r;
+
+ a.push (print_dimen (a_off.y()));
+ a.push (print_dimen (a_off.x()));
+ a.push (i->str_);
+ r += substitute_args (s, a);
+ *outstream_l_ << r;
+ }
+}
--- /dev/null
+/*
+ paper-stream.cc -- implement Paper_stream
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include <fstream.h>
+#include <time.h>
+
+//#include "tex.hh"
+#include "main.hh"
+#include "paper-stream.hh"
+#include "debug.hh"
+
+const int MAXLINELEN = 200;
+
+Paper_stream::Paper_stream (String filename)
+{
+ if (filename.length_i () && (filename != "-"))
+ os = new ofstream (filename.ch_C ());
+ else
+// os = new ostream (cout.ostreambuf ());
+ os = new ostream (cout._strbuf);
+ if (!*os)
+ error (_f ("can't open file: `%s\'", filename));
+ nest_level = 0;
+ line_len_i_ = 0;
+ outputting_comment=false;
+ // header ();
+}
+
+Paper_stream::~Paper_stream ()
+{
+ *os << flush;
+ if (!*os)
+ {
+ warning (_ ("error syncing file (disk full?)"));
+ exit_status_i_ = 1;
+ }
+ delete os;
+ assert (nest_level == 0);
+}
+
+// print string. don't forget indent.
+Paper_stream&
+Paper_stream::operator << (Scalar s)
+{
+ for (char const *cp = s.ch_C (); *cp; cp++)
+ {
+ if (outputting_comment)
+ {
+ *os << *cp;
+ if (*cp == '\n')
+ {
+ outputting_comment=false;
+
+ }
+ continue;
+ }
+ line_len_i_ ++;
+ switch (*cp)
+ {
+ case '%':
+ outputting_comment = true;
+ *os << *cp;
+ break;
+ case '{':
+ nest_level++;
+ *os << *cp;
+ break;
+ case '}':
+ nest_level--;
+ *os << *cp;
+
+ if (nest_level < 0)
+ {
+ delete os; // we want to see the remains.
+ assert (nest_level>=0);
+ }
+ /* FALLTHROUGH */
+
+ case '\n':
+ break_line ();
+ break;
+ case ' ':
+ *os << ' ';
+ if (line_len_i_ > MAXLINELEN)
+ break_line ();
+
+ break;
+ default:
+ *os << *cp;
+ break;
+ }
+ }
+ return *this;
+}
+
+void
+Paper_stream::break_line ()
+{
+ *os << "%\n";
+ *os << to_str (' ', nest_level);
+ line_len_i_ = 0;
+}
+
#include "script-def.hh"
#include "symtable.hh"
#include "lookup.hh"
+#include "ps-lookup.hh"
+#include "tex-lookup.hh"
#include "misc.hh"
#include "my-lily-lexer.hh"
#include "paper-def.hh"
Score *score;
Header *header;
Interval *interval;
- Lookup*lookup;
-
Musical_req* musreq;
Music_output_def * outputdef;
Musical_pitch * pitch;
String *string;
Atom * symbol;
Symtable * symtable;
- Symtables * symtables;
+ Symtables* symtables;
Text_def * textdef;
Tempo_req *tempo;
char c;
%type <duration> entered_notemode_duration explicit_duration
%type <interval> dinterval
%type <intvec> intastint_list int_list
-%type <lookup> symtables symtables_body
+%type <symtables> symtables symtables_body
%type <pitch> explicit_musical_pitch steno_musical_pitch musical_pitch absolute_musical_pitch
%type <notereq> steno_notepitch
}
| symtables {
- $$ = new Lookup_identifier ($1, IDENTIFIER);
-
+ $$ = new Symtables_identifier ($1, IDENTIFIER);
}
| post_request {
$$ = new Request_identifier ($1, POST_REQUEST_IDENTIFIER);
$$ = p;
}
| paper_def_body int '=' symtables { // ugh, what a syntax
- $$->set_lookup ($2, $4);
+ Lookup * l = ps_output_global_b ? new Ps_lookup (*$4)
+ : new Tex_lookup (*$4);
+ $$->set_lookup ($2, l);
}
| paper_def_body STRING '=' simple_identifier_init ';' {
THIS->lexer_p_->set_identifier (*$2, $4);
symtables_body:
{
- $$ = new Lookup;
+ $$ = new Symtables;
}
| IDENTIFIER {
- $$ = $1->access_Lookup (true);
+ $$ = $1->access_Symtables (true);
}
| symtables_body FONT STRING {
$$->font_ = *$3;
yyparse ((void*)this);
}
+
--- /dev/null
+/*
+ ps-lookup.cc -- implement Ps_lookup
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "ps-lookup.hh"
+#include "debug.hh"
+#include "symtable.hh"
+#include "dimension.hh"
+#include "tex.hh"
+#include "scalar.hh"
+#include "paper-def.hh"
+#include "string-convert.hh"
+#include "main.hh"
+
+Ps_lookup::Ps_lookup ()
+ : Lookup ()
+{
+}
+
+Ps_lookup::Ps_lookup (Lookup const& s)
+ : Lookup (s)
+{
+}
+
+Ps_lookup::Ps_lookup (Symtables const& s)
+ : Lookup (s)
+{
+}
+
+Ps_lookup::~Ps_lookup ()
+{
+}
+
+Atom
+Ps_lookup::afm_find (String s) const
+{
+ return Lookup::afm_find (s, String ("(%d)"));
+}
+
+Atom
+Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
+{
+ assert (controls.size () == 8);
+
+ String ps;
+
+ Real dx = controls[3].x () - controls[0].x ();
+ Real dy = controls[3].y () - controls[0].y ();
+
+ for (int i = 1; i < 4; i++)
+ ps += String_convert::double_str (controls[i].x ()) + " "
+ + String_convert::double_str (controls[i].y ()) + " ";
+
+ ps += String_convert::double_str (controls[0].x ()) + " "
+ + String_convert::double_str (controls[0].y ()) + " ";
+
+ ps += String_convert::double_str (thick) + " ";
+ Real on = dash > 1? thick * dash - thick : 0;
+ Real off = 2 * thick;
+ ps += "[" + String_convert::double_str (on) + " ";
+ ps += String_convert::double_str (off) + "] ";
+ ps += String_convert::int_str (0) + " ";
+ ps += " draw_dashed_slur";
+
+ Atom a;
+ a.str_ = ps;
+
+ a.dim_[X_AXIS] = Interval (0, dx);
+ a.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
+ a.font_ = font_;
+ return a;
+}
+
+Atom
+Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
+{
+ Atom a;
+ Real height = paper_l_->staffheight_f () / 6;
+ String ps;
+ ps += to_str (width) + " "
+ + to_str (height) + " "
+ + to_str (continued ? height/2 : 0) +
+ + " draw_" + String (decresc ? "de" : "") + "cresc\n";
+ a.str_ = ps;
+
+
+ a.dim_.x () = Interval (0, width);
+ a.dim_.y () = Interval (-2*height, 2*height);
+ a.font_ = font_;
+ return a;
+}
+
+Atom
+Ps_lookup::plet (Real dy , Real dx, Direction dir) const
+{
+ String ps;
+
+ ps += String_convert::double_str (dx) + " "
+ + String_convert::double_str (dy) + " "
+ + String_convert::int_str ( (int)dir) +
+ " draw_plet";
+
+ Atom s;
+ s.str_ = ps;
+ return s;
+}
+
+Atom
+Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
+{
+ String ps;
+ ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
+ + " draw_beam";
+
+ Atom s;
+ s.str_ = ps;
+ return s;
+}
+
+Atom
+Ps_lookup::slur (Array<Offset> controls) const
+{
+ assert (controls.size () == 8);
+
+ String ps;
+
+ Real dx = controls[3].x () - controls[0].x ();
+ Real dy = controls[3].y () - controls[0].y ();
+
+ for (int i = 5; i < 8; i++)
+ ps += String_convert::double_str (controls[i].x ()) + " "
+ + String_convert::double_str (controls[i].y ()) + " ";
+
+ ps += String_convert::double_str (controls[4].x ()) + " "
+ + String_convert::double_str (controls[4].y ()) + " ";
+
+ for (int i = 1; i < 4; i++)
+ ps += String_convert::double_str (controls[i].x ()) + " "
+ + String_convert::double_str (controls[i].y ()) + " ";
+
+ ps += String_convert::double_str (controls[0].x ()) + " "
+ + String_convert::double_str (controls[0].y ()) + " ";
+
+ ps += " draw_slur";
+
+ Atom s;
+ s.str_ = ps;
+
+ s.dim_[X_AXIS] = Interval (0, dx);
+ s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
+ s.font_ = font_;
+ return s;
+}
+
+Atom
+Ps_lookup::stem (Real y1, Real y2) const
+{
+ // return Lookup::stem (y1, y2, "\\kern %\\vrule width % height % depth %");
+ return Lookup::stem (y1, y2, "% % moveto % % lineto");
+}
+
+Atom
+Ps_lookup::vbracket (Real &y) const
+{
+ Atom psbracket;
+ Real min_y = paper_l_->staffheight_f ();
+ if (y < min_y)
+ {
+ warning (_ ("bracket")
+ + " " + _ ("too small") + " (" + print_dimen (y) + ")");
+// y = min_y;
+ }
+ psbracket.str_ = to_str (y) + " draw_bracket";
+ psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
+ psbracket.dim_[X_AXIS] = Interval (0,4 PT);
+ return psbracket;
+}
+
+
+
--- /dev/null
+/*
+ ps-outputter.cc -- implement Ps_outputter
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "ps-outputter.hh"
+#include "ps-stream.hh"
+#include "molecule.hh"
+#include "atom.hh"
+#include "array.hh"
+#include "dimension.hh"
+#include "tex.hh"
+#include "string-convert.hh"
+#include "debug.hh"
+
+Ps_outputter::Ps_outputter (Paper_stream *s)
+ :Paper_outputter (s)
+{
+}
+
+Ps_outputter::~Ps_outputter ()
+{
+}
+
+/*
+ 26 fonts ought to be enough for anyone.
+*/
+static String
+ps_font_command(int i)
+{
+ return "\\font" +String_convert::form_str ("%c", 'A' + i) ;
+}
+
+void
+Ps_outputter::switch_to_font (String fontname)
+{
+ if (!fontname.length_i () || fontname == current_font_)
+ return;
+
+ current_font_ = fontname;
+ int i=0;
+ for (; i< font_arr_.size (); i++)
+ if (font_arr_[i] == fontname)
+ {
+ *outstream_l_ <<ps_font_command (i) << "\n";
+ return ;
+ }
+
+
+ font_arr_.push (fontname);
+ *outstream_l_ << "\\font" + ps_font_command (i) << "=" + fontname << "\n";
+ *outstream_l_<< ps_font_command (i);
+}
+
+void
+Ps_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
+{
+ if (check_debug)
+ *outstream_l_ << String ("\n%start: ") << nm << "\n";
+
+ Paper_outputter::output_molecule (m, o, nm, "% % % placebox");
+}
+
+void
+Ps_outputter::start_line ()
+{
+ *outstream_l_ << "\\hbox{%\n";
+}
+
+void
+Ps_outputter::stop_line ()
+{
+ *outstream_l_ << "}";
+ *outstream_l_ << "\\interscoreline";
+ current_font_ = "";
+ font_arr_.clear ();
+}
-/*
- ps-plet.cc -- implement Lookup::*plet
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-#include <math.h>
-#include "main.hh"
-#include "misc.hh"
-#include "lookup.hh"
-#include "molecule.hh"
-#include "dimension.hh"
-#include "debug.hh"
-#include "paper-def.hh"
-#include "string-convert.hh"
-
-Atom
-Lookup::plet (Real dy , Real dx, Direction dir) const
-{
- String ps = "\\embeddedps{\n";
-
- ps += String_convert::double_str (dx) + " "
- + String_convert::double_str (dy) + " "
- + String_convert::int_str ((int)dir) +
- " draw_plet}";
-
- Atom s;
- s.tex_ = ps;
- return s;
-}
--- /dev/null
+/*
+ tex-stream.cc -- implement Ps_stream
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include <fstream.h>
+#include <time.h>
+
+#include "main.hh"
+#include "ps-stream.hh"
+#include "debug.hh"
+
+Ps_stream::Ps_stream (String filename)
+ : Paper_stream (filename)
+{
+ header ();
+}
+
+void
+Ps_stream::header ()
+{
+ *os << _ ("%%!PS Adobe\n");
+ // urg, merge with Tex
+ *os << _ ("% Creator: ");
+ if (no_timestamps_global_b)
+ *os << "GNU LilyPond\n";
+ else
+ *os << get_version_str () << '\n';
+ *os << _ ("% Automatically generated");
+ if (no_timestamps_global_b)
+ *os << ".\n";
+ else
+ {
+ *os << _ (", at ");
+ time_t t (time (0));
+ *os << ctime (&t) << "%\n";
+ }
+}
+
+Ps_stream::~Ps_stream ()
+{
+}
+
+// print string. don't forget indent.
+Paper_stream&
+Ps_stream::operator << (Scalar s)
+{
+ return Paper_stream::operator << (s);
+}
+
Symtables::Symtables (Symtables const &s)
: Dictionary<Symtable*> (s)
{
+ font_ = s.font_;
+ font_path_ = s.font_path_;
for (Assoc_iter<String, Symtable*> i (s); i.ok(); i++)
{
add (i.key(), new Symtable (*i.val ()));
-/*
- tex-beam.cc -- implement Lookup::beam
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-/*
- Code to generate beams for TeX
- */
-
-#include <math.h>
-#include "atom.hh"
-#include "molecule.hh"
-#include "tex.hh"
-#include "symtable.hh"
-#include "dimension.hh"
-#include "debug.hh"
-#include "lookup.hh"
-#include "misc.hh"
-#include "paper-def.hh"
-#include "string-convert.hh"
-#include "main.hh"
-
-
-Atom
-Lookup::rule_symbol (Real height, Real width) const
-{
- Atom bs=(*symtables_p_)("param")->lookup ("rule");
- Array<String> args;
- args.push (print_dimen (height));
- args.push (print_dimen (width));
- bs.tex_ = substitute_args (bs.tex_,args);
- bs.dim_.x() = Interval (0,width);
- bs.dim_.y() = Interval (0,height);
- return bs;
-}
-
-Atom
-Lookup::beam(Real slope, Real width, Real thick) const
-{
-
- Atom a (ps_beam (slope, width, thick));
- Real height = slope * width;
- Real min_y = (0 <? height) - thick/2;
- Real max_y = (0 >? height) + thick/2;
-
- a.dim_[X_AXIS] = Interval(0, width);
- a.dim_[Y_AXIS] = Interval(min_y, max_y);
- return a;
-}
-
-Atom
-Lookup::ps_beam (Real slope, Real width, Real thick) const
-{
- String ps = "\\embeddedps{\n";
- ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
- + " draw_beam}";
-
- Atom s;
- s.tex_ = ps;
- return s;
-}
-
--- /dev/null
+/*
+ tex-lookup.cc -- implement Tex_lookup
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "tex-lookup.hh"
+#include "debug.hh"
+#include "symtable.hh"
+#include "dimension.hh"
+#include "tex.hh"
+#include "scalar.hh"
+#include "paper-def.hh"
+#include "string-convert.hh"
+#include "main.hh"
+
+Tex_lookup::Tex_lookup ()
+ : Ps_lookup ()
+{
+}
+
+Tex_lookup::Tex_lookup (Lookup const& s)
+ : Ps_lookup (s)
+{
+}
+
+Tex_lookup::Tex_lookup (Symtables const& s)
+ : Ps_lookup (s)
+{
+}
+
+Tex_lookup::~Tex_lookup()
+{
+}
+
+Atom
+Tex_lookup::afm_find (String s) const
+{
+ return Lookup::afm_find (s, String ("\\char%d"));
+}
+
+Atom
+Tex_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
+{
+ return embed (Ps_lookup::dashed_slur (controls, thick, dash));
+}
+
+Atom
+Tex_lookup::embed (Atom a) const
+{
+ a.str_ = "\\embeddedps{\n" + a.str_ + "}";
+ return a;
+}
+
+Atom
+Tex_lookup::hairpin (Real width, bool decresc, bool continued) const
+{
+ return embed (Ps_lookup::hairpin (width, decresc, continued));
+}
+
+Atom
+Tex_lookup::plet (Real dy , Real dx, Direction dir) const
+{
+ return embed (Ps_lookup::plet (dy, dx, dir));
+}
+
+Atom
+Tex_lookup::ps_beam (Real slope, Real width, Real thick) const
+{
+ return embed (Ps_lookup::ps_beam (slope, width, thick));
+}
+
+Atom
+Tex_lookup::slur (Array<Offset> controls) const
+{
+ return embed (Ps_lookup::slur (controls));
+}
+
+Atom
+Tex_lookup::stem (Real y1, Real y2) const
+{
+ return Lookup::stem (y1, y2, "\\kern %\\vrule width % height % depth %");
+}
+
+Atom
+Tex_lookup::vbracket (Real &y) const
+{
+ return embed (Ps_lookup::vbracket (y));
+}
+
source file of the GNU LilyPond music typesetter
(c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "tex-outputter.hh"
#include "string-convert.hh"
#include "debug.hh"
-Tex_outputter::Tex_outputter (Tex_stream *s)
+Tex_outputter::Tex_outputter (Paper_stream *s)
+ :Paper_outputter (s)
+{
+}
+
+Tex_outputter::~Tex_outputter ()
{
- outstream_l_ = s;
}
/*
if (check_debug)
*outstream_l_ << String ("\n%start: ") << nm << "\n";
- for (PCursor <Atom*> i (m->atoms_); i.ok (); i++)
- {
- Offset a_off = i->offset ();
- a_off += o;
-
- switch_to_font (i->font_);
-
- Array<String> a;
- String r;
-
-
- String s ("\\placebox{%}{%}{%}");
- a.push (print_dimen (a_off.y()));
- a.push (print_dimen (a_off.x()));
- a.push (i->tex_);
- r += substitute_args (s, a);
- *outstream_l_ << r;
- }
+ Paper_outputter::output_molecule (m, o, nm, "\\placebox{%}{%}{%}");
}
-
void
Tex_outputter::start_line ()
{
#include "tex-stream.hh"
#include "debug.hh"
-const int MAXLINELEN = 200;
-
Tex_stream::Tex_stream (String filename)
+ : Paper_stream (filename)
{
- if (filename.length_i () && (filename != "-"))
- os = new ofstream (filename.ch_C ());
- else
-// os = new ostream (cout.ostreambuf ());
- os = new ostream (cout._strbuf);
- if (!*os)
- error (_f ("can't open file: `%s\'", filename));
- nest_level = 0;
- line_len_i_ = 0;
- outputting_comment=false;
- header();
+ header ();
}
+
void
-Tex_stream::header()
+Tex_stream::header ()
{
+ // urg, merge with Ps
*os << _ ("% Creator: ");
if (no_timestamps_global_b)
*os << "GNU LilyPond\n";
else
- *os << get_version_str() << '\n';
+ *os << get_version_str () << '\n';
*os << _ ("% Automatically generated");
if (no_timestamps_global_b)
*os << ".\n";
}
}
-Tex_stream::~Tex_stream()
+Tex_stream::~Tex_stream ()
{
- *os << flush;
- if (!*os)
- {
- warning(_ ("error syncing file (disk full?)"));
- exit_status_i_ = 1;
- }
- delete os;
- assert (nest_level == 0);
}
// print string. don't forget indent.
-Tex_stream&
+Paper_stream&
Tex_stream::operator << (Scalar s)
{
- for (char const *cp = s.ch_C (); *cp; cp++)
- {
- if (outputting_comment)
- {
- *os << *cp;
- if (*cp == '\n')
- {
- outputting_comment=false;
-
- }
- continue;
- }
- line_len_i_ ++;
- switch (*cp)
- {
- case '%':
- outputting_comment = true;
- *os << *cp;
- break;
- case '{':
- nest_level++;
- *os << *cp;
- break;
- case '}':
- nest_level--;
- *os << *cp;
-
- if (nest_level < 0)
- {
- delete os; // we want to see the remains.
- assert (nest_level>=0);
- }
- /* FALLTHROUGH */
-
- case '\n':
- break_line();
- break;
- case ' ':
- *os << ' ';
- if (line_len_i_ > MAXLINELEN)
- break_line();
-
- break;
- default:
- *os << *cp;
- break;
- }
- }
- return *this;
-}
-
-void
-Tex_stream::break_line()
-{
- *os << "%\n";
- *os << to_str (' ', nest_level);
- line_len_i_ = 0;
+ return Paper_stream::operator << (s);
}
}
Molecule*
-Time_signature::brew_molecule_p() const
+Time_signature::brew_molecule_p () const
{
Atom s;
if (time_sig_type_str_.length_i ())
}
else
s = lookup_l ()->time_signature (args_);
- s.translate_axis (-s.extent()[Y_AXIS].center (), Y_AXIS);
+ s.translate_axis (-s.extent ()[Y_AXIS].center (), Y_AXIS);
return new Molecule (Atom (s));
}
1.0.12.am1
1.0.12.hwn1
1.0.12.hwn2
+1.0.12.jcn1
+1.0.12.jcn2