2 ps-lookup.cc -- implement Ps_lookup
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "ps-lookup.hh"
11 #include "dimensions.hh"
12 #include "symtable.hh"
14 #include "paper-def.hh"
15 #include "string-convert.hh"
17 #include "file-results.hh"
19 #include "paper-stream.hh"
20 #include "ps-stream.hh"
21 #include "ps-outputter.hh"
23 #include "dictionary-iter.hh"
24 #include "identifier.hh"
26 Ps_lookup::Ps_lookup ()
31 Ps_lookup::Ps_lookup (Lookup const& s)
36 Ps_lookup::Ps_lookup (Symtables const& s)
41 Ps_lookup::~Ps_lookup ()
46 Ps_lookup::afm_find (String s, bool warn) const
48 return Lookup::afm_find (s, String ("(\\%03o) show "), warn);
52 Ps_lookup::atom_p (String s, int n, Box b) const
54 for (int i = 0; i < n; i++)
56 return new Atom (s, b);
60 Ps_lookup::character_str (int i) const
62 return to_str (i, "(\\%03o)");
66 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
69 Real height = paper_l_->staffheight_f () / 6;
71 ps += to_str (width) + " "
72 + to_str (height) + " "
73 + to_str (continued ? height/2 : 0) +
74 + " draw_" + String (decresc ? "de" : "") + "cresc\n";
78 a.dim_.x () = Interval (0, width);
79 a.dim_.y () = Interval (-2*height, 2*height);
85 Ps_lookup::lookup_p (Lookup const& l) const
87 return new Ps_lookup (l);
91 Ps_lookup::lookup_p (Symtables const& s) const
93 return new Ps_lookup (s);
95 extern char const *lily_version_number_sz ();
98 header_to_ps_string (Scope *head)
101 String lily_id_str = "Lily was here, " +
102 String (lily_version_number_sz ());
104 s+= "/lily_id_string\n{" + lily_id_str + "} bind def\n";
106 for (Dictionary_iter<Identifier*> i (*head); i.ok (); i++)
108 if (!i.val ()->access_String_identifier ())
111 String val = *i.val()->access_String_identifier ()->data_p_;
113 s += "/mudela" + i.key () + "{" + val + "} bind def\n";
120 Ps_lookup::paper_outputter_p (Paper_stream* os_p, Paper_def* paper_l, Header* header_l, String origin_str) const
123 *os_p << header_to_ps_string (header_global_p);
125 *os_p << _ ("\n% outputting Score, defined at: ") << origin_str << '\n';
129 *os_p << header_to_ps_string (header_l);
132 *os_p << paper_l->ps_output_settings_str ();
134 if (experimental_features_global_b)
135 *os_p << "turnOnExperimentalFeatures\n";
137 return new Ps_outputter (os_p);
141 Ps_lookup::paper_stream_p () const
143 String outname = base_output_str ();
147 *mlog << _f ("PostScript output to %s...",
148 outname == "-" ? String ("<stdout>") : outname ) << endl;
149 target_str_global_array.push (outname);
150 return new Ps_stream (outname);
154 Ps_lookup::plet (Real dy , Real dx, Direction dir) const
158 ps += String_convert::double_str (dx) + " "
159 + String_convert::double_str (dy) + " "
160 + String_convert::int_str ( (int)dir) +
169 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
172 ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
181 Ps_lookup::slur (Array<Offset> controls) const
183 assert (controls.size () == 8);
187 Real dx = controls[3].x () - controls[0].x ();
188 Real dy = controls[3].y () - controls[0].y ();
190 for (int i = 5; i < 8; i++)
191 ps += String_convert::double_str (controls[i].x ()) + " "
192 + String_convert::double_str (controls[i].y ()) + " ";
194 ps += String_convert::double_str (controls[4].x ()) + " "
195 + String_convert::double_str (controls[4].y ()) + " ";
197 for (int i = 1; i < 4; i++)
198 ps += String_convert::double_str (controls[i].x ()) + " "
199 + String_convert::double_str (controls[i].y ()) + " ";
201 ps += String_convert::double_str (controls[0].x ()) + " "
202 + String_convert::double_str (controls[0].y ()) + " ";
209 s.dim_[X_AXIS] = Interval (0, dx);
210 s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
216 Ps_lookup::stem (Real y1, Real y2) const
218 return Lookup::stem (y1, y2, "\n% % % % draw_stem ");
222 Ps_lookup::text (String style, String text) const
224 return Lookup::text (style, "(" + text + ")");
228 Ps_lookup::unknown_str () const
234 Ps_lookup::vbracket (Real &y) const
237 Real min_y = paper_l_->staffheight_f ();
240 warning (_ ("bracket")
241 + " " + _ ("too small") + " (" + print_dimen (y) + ")");
244 psbracket.str_ = to_str (y) + " draw_bracket ";
245 psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
246 psbracket.dim_[X_AXIS] = Interval (0,4 PT);