2 lookup.cc -- implement simple Lookup methods.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 This doth suck. We should have PS output, and read spacing info from TFMs
17 #include "symtable.hh"
25 texsetting = "\\unknowntexsetting";
26 symtables_ = new Symtables;
29 Lookup::Lookup(Lookup const &s)
31 texsetting = s.texsetting;
32 symtables_ = new Symtables(*s.symtables_);
40 Lookup::add(String s, Symtable*p)
42 symtables_->add(s, p);
48 mtor << "Lookup: " << texsetting << " {\n";
54 Lookup::text(String style, String text, int dir) const
59 Symbol tsym = (*symtables_)("style")->lookup(style);
60 a[0] = substitute_args(tsym.tex,a);
62 Symbol s = (*symtables_)("align")->lookup(dir);
63 s.tex = substitute_args(s.tex,a);
70 Lookup::internote_f() const
72 return ball(4).dim.y.length()/2;
76 Lookup::interbeam_f() const
82 "french" style: interbeam = intenote;
83 "german" style: interbeam = 2/3 * interline
85 as lily's style is currently german, we'll hardcode german style
87 // it seems that "interline" means _between_ lines
88 // return ball(4).dim.y.length() * 2 / 3;
89 return ball(4).dim.y.length() * 2 / 3 + 0.4; //ugh
93 Lookup::ball(int j) const
98 Symtable * st = (*symtables_)("balls");
99 return st->lookup(String(j));
103 Lookup::rest(int j, bool o) const
105 return (*symtables_)("rests")->lookup(String(j) + (o ? "o" : "") );
109 Lookup::fill(Box b) const
111 Symbol s( (*symtables_)("param")->lookup("fill"));
117 Lookup::accidental(int j) const
119 return (*symtables_)("accidentals")->lookup(String(j));
124 Lookup::bar(String s) const
126 return (*symtables_)("bars")->lookup(s);
130 Lookup::script(String s) const
132 return (*symtables_)("scripts")->lookup(s);
136 Lookup::dynamic(String s) const
138 return (*symtables_)("dynamics")->lookup(s);
142 Lookup::clef(String s) const
144 return (*symtables_)("clefs")->lookup(s);
148 Lookup::dots(int j) const
152 warning("max 3 dots"); // todo
154 return (*symtables_)("dots")->lookup(j);
158 Lookup::flag(int j) const
160 return (*symtables_)("flags")->lookup(j);
164 Lookup::streepjes(int i) const
178 Symbol ret = (*symtables_)("streepjes")->lookup(idx);
182 ret.tex = substitute_args(ret.tex, a);
188 Lookup::hairpin(Real &wid, bool decresc) const
190 int idx = int(rint(wid / 6 PT));
193 String idxstr = (decresc)? "decrescendosym" : "crescendosym";
194 Symbol ret=(*symtables_)("param")->lookup(idxstr);
198 ret.tex = substitute_args(ret.tex, a);
199 ret.dim.x = Interval(0,wid);
204 Lookup::linestaff(int lines, Real wid) const
207 s.dim.x = Interval(0,wid);
208 Real dy = (lines >0) ? (lines-1)*internote_f()*2 : 0;
209 s.dim.y = Interval(0,dy);
213 a.push(print_dimen(wid));
215 s.tex = (*symtables_)("param")->lookup("linestaf").tex;
216 s.tex = substitute_args(s.tex, a);
223 Lookup::meter(Array<Scalar> a) const
226 s.dim.x = Interval( 0 PT, 10 PT);
227 s.dim.y = Interval(0, 20 PT); // todo
228 String src = (*symtables_)("param")->lookup("meter").tex;
229 s.tex = substitute_args(src,a);
235 Lookup::stem(Real y1,Real y2) const
244 s.dim.x = Interval(0,0);
245 s.dim.y = Interval(y1,y2);
248 a.push(print_dimen(y1));
249 a.push(print_dimen(y2));
251 String src = (*symtables_)("param")->lookup("stem").tex;
252 s.tex = substitute_args(src,a);
257 Lookup::vbrace(Real &y) const
260 warning ( "piano brace too small (" + print_dimen(y)+ ")");
264 warning ( "piano brace too big (" + print_dimen(y)+ ")");
268 int idx = int(rint((y/2.0 - 20 ) + 148));
270 Symbol s = (*symtables_)("param")->lookup("brace");
274 s.tex = substitute_args(s.tex,a);
275 s.dim.y = Interval(0,y);