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 Ps_lookup::Ps_lookup ()
28 Ps_lookup::Ps_lookup (Lookup const& s)
33 Ps_lookup::Ps_lookup (Symtables const& s)
38 Ps_lookup::~Ps_lookup ()
43 Ps_lookup::afm_find (String s) const
45 return Lookup::afm_find (s, String ("(\\%03o) show "));
49 Ps_lookup::atom_p (String s, int n, Box b) const
51 for (int i = 0; i < n; i++)
53 return new Atom (s, b);
57 Ps_lookup::character_str (int i) const
59 return to_str (i, "(\\%03o)");
63 Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
65 assert (controls.size () == 8);
69 Real dx = controls[3].x () - controls[0].x ();
70 Real dy = controls[3].y () - controls[0].y ();
72 for (int i = 1; i < 4; i++)
73 ps += String_convert::double_str (controls[i].x ()) + " "
74 + String_convert::double_str (controls[i].y ()) + " ";
76 ps += String_convert::double_str (controls[0].x ()) + " "
77 + String_convert::double_str (controls[0].y ()) + " ";
79 ps += String_convert::double_str (thick) + " ";
80 Real on = dash > 1? thick * dash - thick : 0;
82 ps += "[" + String_convert::double_str (on) + " ";
83 ps += String_convert::double_str (off) + "] ";
84 ps += String_convert::int_str (0) + " ";
85 ps += "draw_dashed_slur ";
90 a.dim_[X_AXIS] = Interval (0, dx);
91 a.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
97 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
100 Real height = paper_l_->staffheight_f () / 6;
102 ps += to_str (width) + " "
103 + to_str (height) + " "
104 + to_str (continued ? height/2 : 0) +
105 + " draw_" + String (decresc ? "de" : "") + "cresc\n";
109 a.dim_.x () = Interval (0, width);
110 a.dim_.y () = Interval (-2*height, 2*height);
116 Ps_lookup::lookup_p (Lookup const& l) const
118 return new Ps_lookup (l);
122 Ps_lookup::lookup_p (Symtables const& s) const
124 return new Ps_lookup (s);
128 Ps_lookup::paper_outputter_p (Paper_stream* os_p, Paper_def* paper_l, Header* header_l, String origin_str) const
131 *os_p << header_global_p->ps_string ();
133 *os_p << _ ("\n% outputting Score, defined at: ") << origin_str << '\n';
136 *os_p << header_l->ps_string ();
137 *os_p << paper_l->ps_output_settings_str ();
139 if (experimental_features_global_b)
140 *os_p << "turnOnExperimentalFeatures\n";
142 return new Ps_outputter (os_p);
146 Ps_lookup::paper_stream_p () const
149 String outname = base_output_str ();
151 String outname = "lelie";
156 *mlog << _f ("PostScript output to %s...",
157 outname == "-" ? String ("<stdout>") : outname ) << endl;
158 target_str_global_array.push (outname);
159 return new Ps_stream (outname);
163 Ps_lookup::plet (Real dy , Real dx, Direction dir) const
167 ps += String_convert::double_str (dx) + " "
168 + String_convert::double_str (dy) + " "
169 + String_convert::int_str ( (int)dir) +
178 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
181 ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
190 Ps_lookup::slur (Array<Offset> controls) const
192 assert (controls.size () == 8);
196 Real dx = controls[3].x () - controls[0].x ();
197 Real dy = controls[3].y () - controls[0].y ();
199 for (int i = 5; i < 8; i++)
200 ps += String_convert::double_str (controls[i].x ()) + " "
201 + String_convert::double_str (controls[i].y ()) + " ";
203 ps += String_convert::double_str (controls[4].x ()) + " "
204 + String_convert::double_str (controls[4].y ()) + " ";
206 for (int i = 1; i < 4; i++)
207 ps += String_convert::double_str (controls[i].x ()) + " "
208 + String_convert::double_str (controls[i].y ()) + " ";
210 ps += String_convert::double_str (controls[0].x ()) + " "
211 + String_convert::double_str (controls[0].y ()) + " ";
218 s.dim_[X_AXIS] = Interval (0, dx);
219 s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
225 Ps_lookup::stem (Real y1, Real y2) const
227 return Lookup::stem (y1, y2, "\n% % % % draw_stem ");
231 Ps_lookup::text (String style, String text) const
233 return Lookup::text (style, "(" + text + ")");
237 Ps_lookup::unknown_str () const
243 Ps_lookup::vbracket (Real &y) const
246 Real min_y = paper_l_->staffheight_f ();
249 warning (_ ("bracket")
250 + " " + _ ("too small") + " (" + print_dimen (y) + ")");
253 psbracket.str_ = to_str (y) + " draw_bracket ";
254 psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
255 psbracket.dim_[X_AXIS] = Interval (0,4 PT);