]> git.donarmstrong.com Git - lilypond.git/blob - lily/scaled-font-metric.cc
release: 1.5.29
[lilypond.git] / lily / scaled-font-metric.cc
1 /*   
2      scaled-font-metric.cc -- declare Scaled_font_metric
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "scaled-font-metric.hh"
11 #include "string.hh"
12 #include "molecule.hh"
13
14
15 Scaled_font_metric::Scaled_font_metric (Font_metric* m, Real magn)
16 {
17   magnification_f_ = magn;
18   SCM desc = m->description_;
19
20   Real total_mag = magn * gh_scm2double (ly_cdr (desc));
21   description_ = gh_cons (ly_car (desc), gh_double2scm (total_mag));
22   orig_l_ = m;
23 }
24
25 SCM
26 Scaled_font_metric::make_scaled_font_metric (Font_metric*m, Real s)
27 {
28   Scaled_font_metric *sfm = new Scaled_font_metric (m,s);
29   return sfm->self_scm ();
30 }
31
32 Molecule
33 Scaled_font_metric::find_by_name (String s) const
34 {
35   Molecule m = orig_l_->find_by_name (s);
36   Box b = m.extent_box ();
37   b.scale (magnification_f_);
38   Molecule q (b,fontify_atom ((Font_metric*) this, m.get_expr ()));
39
40   return q ;
41 }
42
43 Box 
44 Scaled_font_metric::get_char (int i) const
45 {
46   Box b = orig_l_->get_char (i);
47   b.scale (magnification_f_);
48   return b;  
49 }
50
51 Box
52 Scaled_font_metric::text_dimension (String t) const
53 {
54   Box b (orig_l_->text_dimension (t));
55
56   b.scale (magnification_f_);
57   return b;
58 }
59
60 int
61 Scaled_font_metric::count () const
62 {
63   return orig_l_->count ();
64 }