lilypond-0.1.35
[lilypond.git] / lily / text-def.cc
blobc41bfeb58a404bc90c42f019826a98bee6727b62
1 /*
2 text-def.cc -- implement Text_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "debug.hh"
10 #include "lookup.hh"
11 #include "paper-def.hh"
12 #include "molecule.hh"
13 #include "text-def.hh"
14 #include "dimen.hh"
16 Interval
17 Text_def::width (Paper_def * p) const
19 Atom a = get_atom (p,CENTER);
21 Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
22 Interval i (0, guess_width_f);
23 i += - (align_i_ + 1)* i.center();
24 return i;
27 void
28 Text_def::do_print() const
30 #ifndef NPRINT
31 DOUT << "align " <<align_i_ << " `" << text_str_ << "'";
32 #endif
35 Text_def::Text_def()
37 align_i_ = 1; // right
38 style_str_ = "roman";
41 bool
42 Text_def::do_equal_b (General_script_def const *gdef) const
44 Text_def const *def= (Text_def*)gdef;
45 return align_i_ == def->align_i_ && text_str_ == def->text_str_
46 && style_str_ == def->style_str_;
49 Atom
50 Text_def::get_atom (Paper_def *p, Direction) const
52 return p->lookup_l()->text (style_str_, text_str_, -align_i_);
55 void
56 Text_def::print() const
58 DOUT << "Text `" << text_str_ << "\', style " <<
59 style_str_ << "align " << align_i_ << '\n';
63 IMPLEMENT_IS_TYPE_B1(Text_def,General_script_def);