]> git.donarmstrong.com Git - lilypond.git/blob - lily/tex-outputter.cc
df6a43268a56d5d49f3546a3241bfded5a5327a5
[lilypond.git] / lily / tex-outputter.cc
1 /*
2   tex-outputter.cc -- implement Tex_outputter
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "tex-outputter.hh"
11 #include "tex-stream.hh"
12 #include "molecule.hh"
13 #include "atom.hh"
14 #include "array.hh"
15 #include "string-convert.hh"
16 #include "debug.hh"
17
18 Tex_outputter::Tex_outputter (Paper_stream *s)
19   :Paper_outputter (s)
20 {
21 }
22
23 Tex_outputter::~Tex_outputter ()
24 {
25 }
26
27 /*
28    26 fonts ought to be enough for anyone.
29 */
30 static String
31 tex_font_command(int i)
32 {
33   return "\\font"  +String_convert::form_str ("%c",  'A' + i) ;
34 }
35
36 void
37 Tex_outputter::switch_to_font (String fontname)
38 {
39   if (!fontname.length_i () || fontname == current_font_)
40     return;
41
42   current_font_ = fontname;
43   int i=0;
44   for (; i< font_arr_.size (); i++)
45     if (font_arr_[i] == fontname)
46       {
47         *outstream_l_ <<tex_font_command (i) << "\n";
48         return ;
49       }
50
51   
52   font_arr_.push (fontname);
53   *outstream_l_ << "\\font"  + tex_font_command (i) << "=" + fontname << "\n";
54   *outstream_l_<< tex_font_command (i);
55 }
56
57 void
58 Tex_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
59 {
60   if (check_debug)
61     *outstream_l_ << String ("\n%start: ") << nm << "\n";
62
63   Paper_outputter::output_molecule (m, o, nm, "\\placebox{%}{%}{%}", "'tex");
64 }
65
66 void
67 Tex_outputter::start_line ()
68 {
69   *outstream_l_ << "\\hbox{%\n";
70 }
71
72 void
73 Tex_outputter::stop_line ()
74 {
75   *outstream_l_ << "}";
76   *outstream_l_ << "\\interscoreline";
77   current_font_ = "";
78   font_arr_.clear ();
79 }