]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-def.cc
release: 0.0.61
[lilypond.git] / lily / text-def.cc
1 #include "debug.hh"
2 #include "lookup.hh"
3 #include "paper-def.hh"
4 #include "molecule.hh"
5 #include "text-def.hh"
6 #include "dimen.hh"
7
8 Interval
9 Text_def::width() const
10 {
11     Atom a = create_atom();
12
13     Real guess_width_f = text_str_.length_i() * a.sym.dim.x.length(); // ugh
14     Interval i(0, guess_width_f);
15     i += - (align_i_ + 1)* i.center();
16     return i;
17 }
18
19
20 Text_def::Text_def()
21 {   
22     align_i_ = 1;                       // right
23     pdef_l_ = 0;
24     style_str_ = "roman";
25 }
26 bool
27 Text_def::compare(Text_def const &def)
28 {
29     return align_i_ == def.align_i_ && text_str_ == def.text_str_
30         && style_str_ == def.style_str_;
31 }
32
33 Atom
34 Text_def::create_atom() const
35 {
36     return pdef_l_->lookup_l()->text(style_str_, text_str_, -align_i_);
37 }
38
39 void
40 Text_def::print() const
41 {
42     mtor << "Text `" << text_str_ << "\', style " <<
43         style_str_ << "align " << align_i_ << '\n';
44 }