]> git.donarmstrong.com Git - lilypond.git/blob - lily/ps-outputter.cc
patch::: 1.0.15.jcn3: guilig atoom
[lilypond.git] / lily / ps-outputter.cc
1 /*
2   ps-outputter.cc -- implement Ps_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 "ps-outputter.hh"
11 #include "ps-stream.hh"
12 #include "molecule.hh"
13 #include "atom.hh"
14 #include "array.hh"
15 #include "string-convert.hh"
16 #include "debug.hh"
17 #include "lookup.hh"
18 #include "main.hh"
19
20 Ps_outputter::Ps_outputter (Paper_stream *s)
21   :Paper_outputter (s)
22 {
23 }
24
25 Ps_outputter::~Ps_outputter ()
26 {
27 }
28
29 /*
30    26 fonts ought to be enough for anyone.
31 */
32 static String
33 ps_font_command(int i)
34 {
35 // urg
36 //  return "%\\font" + String_convert::form_str ("%c",  'A' + i) + "\n";
37   return "\n/feta20 findfont 12 scalefont setfont ";
38 }
39
40 void
41 Ps_outputter::switch_to_font (String fontname)
42 {
43   if (!fontname.length_i () || fontname == current_font_)
44     return;
45
46   current_font_ = fontname;
47   int i=0;
48   for (; i< font_arr_.size (); i++)
49     if (font_arr_[i] == fontname)
50       {
51         *outstream_l_ <<ps_font_command (i) << "\n";
52         return ;
53       }
54
55   
56   font_arr_.push (fontname);
57   *outstream_l_ << "%\\font"  + ps_font_command (i) << "% =" + fontname << "\n";
58   *outstream_l_<< ps_font_command (i) << "\n";
59 }
60
61 void
62 Ps_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
63 {
64   if (check_debug)
65     *outstream_l_ << String ("\n%start: ") << nm << "\n";
66
67 #if 0
68   Paper_outputter::output_molecule (m, o, nm, "% % {%}placebox \n");
69 #else
70   String s = "% % {%}placebox \n";
71
72   if (check_debug)
73     *outstream_l_ << String ("\n%start: ") << nm << "\n";
74
75   for (PCursor <Atom*> i (m->atoms_); i.ok (); i++)
76     {
77       Offset a_off = i->offset ();
78       a_off += o;
79
80       switch_to_font (i->font_);
81
82       Array<String> a;
83       String r;
84   
85       a.push (global_lookup_l->print_dimen (a_off.y()));
86       a.push (global_lookup_l->print_dimen (a_off.x()));
87       if (i->lambda_)
88         {
89           gh_call1 (i->lambda_, gh_eval_str ("'ps"));
90           // char* c = gh_scm2newstr (gh_call1 (i->lambda_, gh_eval_str ("'ps")), NULL);
91           // a.push (String (c));
92           // free (c);
93         }
94       else
95         a.push (i->str_);
96       r += global_lookup_l->substitute_args (s, a);
97       *outstream_l_ << r;
98     }
99 #endif
100 }
101
102 void
103 Ps_outputter::start_line ()
104 {
105   *outstream_l_ << "\nstart_line {\n";
106 }
107
108 void
109 Ps_outputter::stop_line ()
110 {
111   *outstream_l_ << "}\nstop_line\n";
112   current_font_ = "";
113   font_arr_.clear ();
114 }