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::plet (Real dy , Real dx, Direction dir) const
120 ps += String_convert::double_str (dx) + " "
121 + String_convert::double_str (dy) + " "
122 + String_convert::int_str ( (int)dir) +
131 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
134 ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
143 Ps_lookup::slur (Array<Offset> controls) const
145 assert (controls.size () == 8);
149 Real dx = controls[3].x () - controls[0].x ();
150 Real dy = controls[3].y () - controls[0].y ();
152 for (int i = 5; i < 8; i++)
153 ps += String_convert::double_str (controls[i].x ()) + " "
154 + String_convert::double_str (controls[i].y ()) + " ";
156 ps += String_convert::double_str (controls[4].x ()) + " "
157 + String_convert::double_str (controls[4].y ()) + " ";
159 for (int i = 1; i < 4; i++)
160 ps += String_convert::double_str (controls[i].x ()) + " "
161 + String_convert::double_str (controls[i].y ()) + " ";
163 ps += String_convert::double_str (controls[0].x ()) + " "
164 + String_convert::double_str (controls[0].y ()) + " ";
171 s.dim_[X_AXIS] = Interval (0, dx);
172 s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
178 Ps_lookup::stem (Real y1, Real y2) const
180 return Lookup::stem (y1, y2, "\n% % % % draw_stem ");
184 Ps_lookup::text (String style, String text) const
186 return Lookup::text (style, "(" + text + ")");
190 Ps_lookup::vbracket (Real &y) const
193 Real min_y = paper_l_->staffheight_f ();
196 warning (_ ("bracket")
197 + " " + _ ("too small") + " (" + print_dimen (y) + ")");
200 psbracket.str_ = to_str (y) + " draw_bracket ";
201 psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
202 psbracket.dim_[X_AXIS] = Interval (0,4 PT);