2 tex-lookup.cc -- implement Tex_lookup
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "tex-lookup.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 "tex-stream.hh"
21 #include "tex-outputter.hh"
22 #include "dictionary-iter.hh"
23 #include "identifier.hh"
25 Tex_lookup::Tex_lookup ()
30 Tex_lookup::Tex_lookup (Lookup const& s)
35 Tex_lookup::Tex_lookup (Symtables const& s)
40 Tex_lookup::~Tex_lookup()
45 Tex_lookup::afm_find (String s) const
47 return Lookup::afm_find (s, String ("\\char%d"));
51 Tex_lookup::atom_p (String s, int n, Box b) const
55 for (int i = 0; i < n; i++)
57 return new Atom (s, b);
61 Tex_lookup::character_str (int i) const
63 return Lookup::character_str (i);
67 Tex_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
69 return embed (Ps_lookup::dashed_slur (controls, thick, dash));
73 Tex_lookup::embed (Atom a) const
75 a.str_ = "\\embeddedps{\n" + a.str_ + "}";
80 Tex_lookup::hairpin (Real width, bool decresc, bool continued) const
82 return embed (Ps_lookup::hairpin (width, decresc, continued));
86 Tex_lookup::plet (Real dy , Real dx, Direction dir) const
88 return embed (Ps_lookup::plet (dy, dx, dir));
92 Tex_lookup::lookup_p (Lookup const& l) const
94 return new Tex_lookup (l);
98 Tex_lookup::lookup_p (Symtables const& s) const
100 return new Tex_lookup (s);
103 extern char const *lily_version_number_sz ();
106 header_to_tex_string (Scope *head)
109 String lily_id_str = "Lily was here, " +
110 String (lily_version_number_sz ());
111 s+= "\\def\\LilyIdString{" + lily_id_str + "}\n";
113 for (Dictionary_iter<Identifier*> i(*head); i.ok (); i++)
115 if (!i.val ()->access_String_identifier ())
118 String val = *i.val()->access_String_identifier ()->data_p_;
119 s += "\\def\\mudela" + i.key () + "{" + val + "}\n";
126 Tex_lookup::paper_outputter_p (Paper_stream* os_p, Paper_def* paper_l, Scope* header_l, String origin_str) const
129 *os_p << header_to_tex_string(header_global_p);
131 *os_p << _ ("\n% outputting Score, defined at: ") << origin_str << '\n';
134 *os_p << header_to_tex_string (header_global_p);
137 *os_p << paper_l->tex_output_settings_str ();
139 if (experimental_features_global_b)
140 *os_p << "\\turnOnExperimentalFeatures%\n";
142 *os_p << "\\turnOnPostScript%\n";
144 return new Tex_outputter (os_p);
148 Tex_lookup::paper_stream_p () const
150 String outname = base_output_str ();
155 *mlog << _f ("TeX output to %s...",
156 outname == "-" ? String ("<stdout>") : outname ) << endl;
157 p = new Tex_stream (outname);
158 target_str_global_array.push (outname);
163 Tex_lookup::print_dimen (Real r) const
165 String s = to_str (r, "%.3f");
166 if (s.index_i ("NaN") != -1)
171 return Lookup::print_dimen (r) + "pt";
175 Tex_lookup::ps_beam (Real slope, Real width, Real thick) const
177 return embed (Ps_lookup::ps_beam (slope, width, thick));
181 Tex_lookup::slur (Array<Offset> controls) const
183 return embed (Ps_lookup::slur (controls));
187 Tex_lookup::stem (Real y1, Real y2) const
189 return Lookup::stem (y1, y2, "\\kern %\\vrule width % height % depth %");
193 Tex_lookup::text (String style, String text) const
195 return Lookup::text (style, text);
199 Tex_lookup::unknown_str () const
205 Tex_lookup::vbracket (Real &y) const
207 return embed (Ps_lookup::vbracket (y));