]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.0.12.jcn2: opniewvisite
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 4 Oct 1998 18:47:50 +0000 (21:47 +0300)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 4 Oct 1998 18:47:50 +0000 (21:47 +0300)
pl 12.jcn2
- Lookup abstract base class
- Lookup/Symtable(s): separation of input/output

42 files changed:
NEWS
VERSION
lily/abbrev.cc
lily/atom.cc
lily/dynamic-engraver.cc
lily/header.cc
lily/identifier.cc
lily/include/atom.hh
lily/include/header.hh
lily/include/identifier.hh
lily/include/lily-proto.hh
lily/include/lookup.hh
lily/include/main.hh
lily/include/p-score.hh
lily/include/paper-def.hh
lily/include/paper-outputter.hh [new file with mode: 0644]
lily/include/paper-stream.hh [new file with mode: 0644]
lily/include/ps-lookup.hh [new file with mode: 0644]
lily/include/ps-outputter.hh [new file with mode: 0644]
lily/include/ps-stream.hh [new file with mode: 0644]
lily/include/symtable.hh
lily/include/tex-lookup.hh [new file with mode: 0644]
lily/include/tex-outputter.hh
lily/include/tex-stream.hh
lily/lookup.cc
lily/main.cc
lily/p-score.cc
lily/paper-def.cc
lily/paper-outputter.cc [new file with mode: 0644]
lily/paper-stream.cc [new file with mode: 0644]
lily/parser.yy
lily/ps-lookup.cc [new file with mode: 0644]
lily/ps-outputter.cc [new file with mode: 0644]
lily/ps-plet.cc
lily/ps-stream.cc [new file with mode: 0644]
lily/symtable.cc
lily/tex-beam.cc
lily/tex-lookup.cc [new file with mode: 0644]
lily/tex-outputter.cc
lily/tex-stream.cc
lily/time-signature.cc
make/STATE-VECTOR

diff --git a/NEWS b/NEWS
index 96802004bcb32d253832137ba090be52b0f0a886..0011d46a84ec683c1da7d83070cde18af7a5484e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,13 @@
+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";
diff --git a/VERSION b/VERSION
index abbd6eab86328abac92f19d0fa48abe9072c5968..6b5e3eac28b83963eae670b962264f6f7dd7a3b2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 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.
index 323bf8ddd8b4a09f8ec8942db190bf826d9040d0..b5cf16e37812278e01c9a3ef36af6df1d1ae2fd2 100644 (file)
@@ -33,7 +33,6 @@ Abbreviation::brew_molecule_p () const
   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;
index 48b5c737202b1b126d42d32321c13942750ebe57..ff2e75626aa6c0e45d4137d238d94ef55509d8d3 100644 (file)
@@ -29,12 +29,12 @@ Atom::check_infinity_b ()const
       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;
        }
     }
@@ -44,21 +44,21 @@ Atom::check_infinity_b ()const
 
 
 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_);
@@ -66,23 +66,30 @@ Atom::extent() const
 }
 
 
-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 () + "))";
 }
 
index 9fc4704f2c0ec5ebb5d440676c77d82b247e7d16..1b7107f80d3ddbbf6bbfdb3392939302c7cbac2d 100644 (file)
@@ -72,7 +72,7 @@ Dynamic_engraver::do_process_requests()
          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";
 
          
index 2a38c5e5976e751583d2ba9579bc16973e14f6c2..680245dc1acc8dfd6efe4dd2bbedac55ef476b1e 100644 (file)
@@ -4,6 +4,7 @@
   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;
 }
+
index c5dbee2c00efeb8ccd2389ffa551afd2515f2bef..bdd40f69a47a7995dca5204ef33622f4f84f0a80 100644 (file)
@@ -14,7 +14,6 @@
 #include "my-lily-lexer.hh"
 #include "debug.hh"
 #include "symtable.hh"
-#include "lookup.hh"
 #include "script-def.hh"
 #include "request.hh"
 #include "translator.hh"
@@ -85,7 +84,6 @@ Class ## _identifier::do_print () const { \
 
 
 DEFAULT_PRINT(General_script_def);
-DEFAULT_PRINT(Lookup);
 DEFAULT_PRINT(Translator);
 DEFAULT_PRINT(Symtables);
 DEFAULT_PRINT(Music);
@@ -104,7 +102,6 @@ Class ## _identifier::do_str () const { \
 
 DUMMY_STR(Notename_table);
 DUMMY_STR(General_script_def);
-DUMMY_STR(Lookup);
 DUMMY_STR(Translator);
 DUMMY_STR(Symtables);
 DUMMY_STR(Music);
@@ -179,7 +176,6 @@ IMPLEMENT_ID_CLASS(int);
 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);
@@ -196,7 +192,6 @@ DEFAULT_ACCESSOR(Duration);
 DEFAULT_ACCESSOR(int);
 DEFAULT_ACCESSOR(Real);
 DEFAULT_ACCESSOR(String);
-DEFAULT_ACCESSOR(Lookup);
 DEFAULT_ACCESSOR(Symtables);
 DEFAULT_ACCESSOR(Score);
 DEFAULT_ACCESSOR(Midi_def);
index d7c31ee35ce2589ef87f2bec24fe3c3680c478c5..774e185d364e959656236d0d8dee96c65cb11d17 100644 (file)
@@ -18,7 +18,7 @@
 class Atom {
   Offset off_;
 public:
-  String tex_;
+  String str_;
   String font_;
   Box dim_;
 
index a6b37dba9f521ae5ca8a8c6facf7e363b8185eb0..288ca7a671412a898977a961421124c9ffa043a0 100644 (file)
    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
index ab6f25edd764f969fba3ca0b87ffc2e689f7d2af..63083109f70151184848858ce8e2b45893785061 100644 (file)
@@ -22,7 +22,6 @@ class General_script_def_identifier;
 class Symtables_identifier;
 class Midi_def_identifier;
 class Paper_def_identifier;
-class Lookup_identifier;
 class Real_identifier;
 class int_identifier;
 class String_identifier;
@@ -61,7 +60,6 @@ struct Identifier : public Input {
   IDACCESSOR(Symtables)
   IDACCESSOR(Midi_def)
   IDACCESSOR(Paper_def)
-  IDACCESSOR(Lookup)
   IDACCESSOR(Real)
   IDACCESSOR(String)
   IDACCESSOR(Request)
@@ -99,7 +97,6 @@ DECLARE_ID_CLASS(Notename_table);
 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);
index f80f11dece588dc0c81a9070ed5e07922267c4aa..25682a4cc45fb4292f17edc31f2fa0a544aca9ab 100644 (file)
@@ -73,6 +73,7 @@ struct Dynamic;
 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;
@@ -145,6 +146,8 @@ struct Music_list;
 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;
@@ -154,28 +157,29 @@ struct Note_head;
 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;
@@ -223,6 +227,8 @@ struct Symtables;
 struct Super_element;
 struct Translation_property;
 struct Tempo_req;
+struct Tex_lookup;
+struct Tex_outputter;
 struct Tex_stream;
 struct Text_def;
 struct Text_gob;
@@ -231,7 +237,6 @@ struct Text_engraver;
 struct Text_req;
 struct Text_spanner;
 struct Tie;
-struct Tex_outputter;
 struct Tie_engraver;
 struct Tie_req;
 struct Time_description;
index 5dc56d279c4e1e388e7e45c0ff91acbecf2793ed..3993b9e9a7121f2e0d4533c28d102e58c16aec3c 100644 (file)
@@ -3,11 +3,12 @@
 
   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
index da5e0a53ef9822c32e46cc8167937a3ff02e3e24..f5be0ca9ab79fcea74d0d32bb1c7f810eb9fb08e 100644 (file)
@@ -24,6 +24,7 @@ extern bool no_timestamps_global_b;
 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;
 
index 6cdfc5cda3a1be5bd8a976ce1e932a9bcd0f2ed3..553cc893751d503538b7d372f1536d7c24fb215b 100644 (file)
     */
 
 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_;
@@ -37,7 +39,7 @@ public:
   /// other elements
   Pointer_list<Score_element*> elem_p_list_;
   
-  Outputter *outputter_l_;  
+  Paper_outputter *outputter_l_;  
   Line_of_score * line_l_;
   
   Paper_score ();
index 9c4a6b58fce69f2e52666a31c4a26f2b37ac0389..87bfe545731de4472bebe79619131a29990badc7 100644 (file)
@@ -38,6 +38,7 @@ class Paper_def : public Music_output_def
 {
   Assoc<int, Lookup *> *lookup_p_assoc_p_;
   static int default_count_i_;
+  bool ps_b_;
 
 protected:
   VIRTUAL_COPY_CONS(Paper_def,Music_output_def);
@@ -91,7 +92,9 @@ public:
   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*);
 };
diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh
new file mode 100644 (file)
index 0000000..5fa1204
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  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
diff --git a/lily/include/paper-stream.hh b/lily/include/paper-stream.hh
new file mode 100644 (file)
index 0000000..dc5b085
--- /dev/null
@@ -0,0 +1,37 @@
+#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
diff --git a/lily/include/ps-lookup.hh b/lily/include/ps-lookup.hh
new file mode 100644 (file)
index 0000000..3e2c5e0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+  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
diff --git a/lily/include/ps-outputter.hh b/lily/include/ps-outputter.hh
new file mode 100644 (file)
index 0000000..8cbcf18
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+  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
diff --git a/lily/include/ps-stream.hh b/lily/include/ps-stream.hh
new file mode 100644 (file)
index 0000000..a61be0a
--- /dev/null
@@ -0,0 +1,21 @@
+#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
index 12cf34b11e1fbb18f447b8ee52672781f30fd27a..2c19d3e9b0854a7d6d9adc70752c35f825258200 100644 (file)
@@ -22,14 +22,18 @@ struct  Symtable : public Dictionary<Atom> {
 };
 
 
-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_;  
 };
 
 
diff --git a/lily/include/tex-lookup.hh b/lily/include/tex-lookup.hh
new file mode 100644 (file)
index 0000000..fb306b9
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+  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
index ce9f772917ceeee0effbcffbe2d3ec2b84a1a319..d4461c2bacb36246171d5eeaa3286bcfe6da9c83 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  outputter.hh -- declare Outputter
+  tex-outputter.hh -- declare Tex_outputter
 
   source file of the GNU LilyPond music typesetter
 
@@ -7,38 +7,21 @@
 */
 
 
-#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
index e26c8328cb3edb102eba7a4e5158883d40630826..7f94aec2b192451770f36612116a297a6c8b27b1 100644 (file)
@@ -1,34 +1,21 @@
-#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
index b03cc59de93eb870e2001f9e2944a31e7a37b3c8..afb9ee10dcf0d50d8f5ad597d9bc7890224ec41e 100644 (file)
@@ -5,11 +5,11 @@
 
   (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 consts)
 {
   font_ = s.font_;
   font_path_ = s.font_path_;
@@ -38,119 +38,98 @@ Lookup::Lookup (Lookup const &s)
   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
@@ -160,140 +139,56 @@ Lookup::dynamic (String st) const
 }
 
 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
 {
@@ -301,10 +196,8 @@ 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)
     {
@@ -314,26 +207,55 @@ Lookup::stem (Real y1,Real y2) const
     }
   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
@@ -358,12 +280,12 @@ 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);
   }
 
@@ -372,53 +294,4 @@ Lookup::vbrace (Real &y) const
   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
-}
 
index 5467b79e21080151d91b05299eb290a48604e5c1..e07e46c7506d5978b870bf2227718b4e6884f1e0 100644 (file)
@@ -30,6 +30,7 @@ bool version_ignore_global_b = false;
 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;
@@ -234,6 +235,7 @@ main (int argc, char **argv)
        {
        case 't':
          experimental_features_global_b = true;
+         ps_output_global_b = true;
          break;
        case 'o':
          outname_str = oparser.optional_argument_ch_C_;
index df037f7a7d2a4267f10c6673e982a736076e2282..0ab995f15c11434d86afdf1a549f0cc6206ac240 100644 (file)
 #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"
@@ -203,8 +207,8 @@ Paper_score::process ()
       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++)
@@ -230,9 +234,14 @@ Paper_score::process ()
       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;
 }
 
@@ -267,7 +276,7 @@ Paper_score::remove_line (Line_of_score *l)
     }
 }
 
-Tex_stream *
+Paper_stream *
 Paper_score::open_output_stream ()
 {
   // output
@@ -284,36 +293,75 @@ Paper_score::open_output_stream ()
     }
 
   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)
index e6294c37406b608a7766ea6249504db07cdb42e1..2c006ad09798684bcc4e78ed34fdfae8e3fe214a 100644 (file)
@@ -13,6 +13,8 @@
 #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"
@@ -45,12 +47,11 @@ Paper_def::Paper_def (Paper_def const&s)
   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
@@ -212,7 +213,18 @@ Paper_def::lookup_l (int i) const
 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++)
diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc
new file mode 100644 (file)
index 0000000..2c47177
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+  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;
+    }
+}
diff --git a/lily/paper-stream.cc b/lily/paper-stream.cc
new file mode 100644 (file)
index 0000000..c878f4b
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+  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;
+}
+
index 45a5f2ba032555ecfba00acafffb6bae5b633728..99af0e5ec1d7b1ea3aaf9b22dc617179007ca82a 100644 (file)
@@ -16,6 +16,8 @@
 #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"
@@ -95,8 +97,6 @@ Paper_def* current_paper = 0;
     Score *score;
     Header *header;
     Interval *interval;
-    Lookup*lookup;
-
     Musical_req* musreq;
     Music_output_def * outputdef;
     Musical_pitch * pitch;
@@ -112,7 +112,7 @@ Paper_def* current_paper = 0;
     String *string;
     Atom * symbol;
     Symtable * symtable;
-    Symtables * symtables;
+    Symtables* symtables;
     Text_def * textdef;
     Tempo_req *tempo;
     char c;
@@ -234,7 +234,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %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
@@ -395,8 +395,7 @@ identifier_init:
 
        }
        | symtables {
-               $$ = new Lookup_identifier ($1, IDENTIFIER);
-
+               $$ = new Symtables_identifier ($1, IDENTIFIER);
        }
        | post_request {
                $$ = new Request_identifier ($1, POST_REQUEST_IDENTIFIER);
@@ -562,7 +561,9 @@ paper_def_body:
                $$ = 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);
@@ -1367,10 +1368,10 @@ symtables:
 
 symtables_body:
                        {
-               $$ = new Lookup;
+               $$ = new Symtables;
        }
        | IDENTIFIER            {
-               $$ = $1->access_Lookup (true);
+               $$ = $1->access_Symtables (true);
        }
        | symtables_body FONT STRING            {
                $$->font_ = *$3;
@@ -1440,3 +1441,4 @@ My_lily_parser::do_yyparse ()
        yyparse ((void*)this);
 }
 
+
diff --git a/lily/ps-lookup.cc b/lily/ps-lookup.cc
new file mode 100644 (file)
index 0000000..fd9d887
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+  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;
+}
+
+
+
diff --git a/lily/ps-outputter.cc b/lily/ps-outputter.cc
new file mode 100644 (file)
index 0000000..768270a
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+  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 ();
+}
index 47819d220317da655ad8730ec339b9122dc47d0b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,32 +0,0 @@
-/*
-  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;
-}
diff --git a/lily/ps-stream.cc b/lily/ps-stream.cc
new file mode 100644 (file)
index 0000000..970b75f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+  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);
+}
+
index a31477b5518f24f310e071c0362e25ade59d11f8..d09dbb0b44fc9c3e87eb1ce7dae1b282a94f71b8 100644 (file)
@@ -23,6 +23,8 @@ Symtables::Symtables()
 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 ()));
index 002154acc452e2ae2cd33c08c2621fd66cf17219..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,65 +0,0 @@
-/*
-  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;
-}
-
diff --git a/lily/tex-lookup.cc b/lily/tex-lookup.cc
new file mode 100644 (file)
index 0000000..480ff14
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+  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));
+}
+
index 67ea1fe0abbdc0ba3927da43425a3dbd28df9e3e..30aff3b9d048ff660573855ee3ba350be35a28a2 100644 (file)
@@ -4,6 +4,7 @@
   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;
 }
 
 /*
@@ -57,27 +62,9 @@ Tex_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
   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 ()
 {
index 9866c231ad07af68c163e4a13decf0885550b2f2..90764d289a87d830a16a99e318fd4e126603402f 100644 (file)
 #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";
@@ -50,78 +41,14 @@ Tex_stream::header()
     }
 }
 
-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);
 }
 
index 931766ccc815f3bcd9d69971de1e6e7ff835b802..50878c467905b469faada933b93c4cf3ea9530f8 100644 (file)
@@ -19,7 +19,7 @@ Time_signature::Time_signature ()
 }
 
 Molecule*
-Time_signature::brew_molecule_p() const
+Time_signature::brew_molecule_p () const
 {
   Atom s;
   if (time_sig_type_str_.length_i ())
@@ -28,7 +28,7 @@ Time_signature::brew_molecule_p() const
     }
   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));
 }
 
index 9cf5c4b8cf2e5ba72ca9241d8e6b7173acded0ea..5cc82d569969c9c5fc3fc09fc5a3b26865a8fc78 100644 (file)
@@ -93,3 +93,5 @@
 1.0.12.am1
 1.0.12.hwn1
 1.0.12.hwn2
+1.0.12.jcn1
+1.0.12.jcn2