]> git.donarmstrong.com Git - lilypond.git/blob - lily/text-def.cc
release: 0.0.68pre
[lilypond.git] / lily / text-def.cc
1 /*
2   text-def.cc -- implement Text_def
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
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"
15
16 Interval
17 Text_def::width(Paper_def * p) const
18 {
19     Atom a = get_atom(p,0);
20
21     Real guess_width_f = text_str_.length_i() * a.sym_.dim.x.length(); // ugh
22     Interval i(0, guess_width_f);
23     i += - (align_i_ + 1)* i.center();
24     return i;
25 }
26
27
28 Text_def::Text_def()
29 {   
30     align_i_ = 1;                       // right
31     style_str_ = "roman";
32 }
33 bool
34 Text_def::do_equal_b(Text_def const &def)const
35 {
36     return align_i_ == def.align_i_ && text_str_ == def.text_str_
37         && style_str_ == def.style_str_;
38 }
39
40 Atom
41 Text_def::get_atom(Paper_def *p, int ) const
42 {
43     return p->lookup_l()->text(style_str_, text_str_, -align_i_);
44 }
45
46 void
47 Text_def::print() const
48 {
49     mtor << "Text `" << text_str_ << "\', style " <<
50         style_str_ << "align " << align_i_ << '\n';
51 }
52 IMPLEMENT_STATIC_NAME(Text_def);
53 IMPLEMENT_IS_TYPE_B1(Text_def,General_script_def);