]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-size-engraver.cc
a5f7848c7f455063899787b15ba332d2fe94b7a4
[lilypond.git] / lily / font-size-engraver.cc
1 /*
2   font-size-engraver.cc -- implement Font_size_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "grob.hh"
10 #include "engraver.hh"
11
12 class Font_size_engraver : public Engraver
13 {
14
15   TRANSLATOR_DECLARATIONS (Font_size_engraver);
16 protected:
17   virtual void acknowledge_grob (Grob_info gi);
18 private:
19 };
20
21 Font_size_engraver::Font_size_engraver ()
22 {
23 }
24
25 void
26 Font_size_engraver::acknowledge_grob (Grob_info gi)
27 {
28   SCM sz = get_property ("fontSize");
29
30   /*
31     We only want to process a grob once.
32   */
33   if (gi.origin_trans_->context () != context ())
34     return;
35
36   if (scm_is_number (sz) && scm_to_double (sz))
37     {
38       Real font_size = scm_to_double (sz);
39
40       font_size += robust_scm2double (gi.grob_->get_property ("font-size"), 0);
41       gi.grob_->set_property ("font-size", scm_make_real (font_size));
42     }
43 }
44
45 ADD_TRANSLATOR (Font_size_engraver,
46                 /* descr */ "Puts fontSize into font-relative-size grob property.",
47                 /* creats*/ "",
48                 /* accepts */ "",
49                 /* acks  */ "font-interface",
50                 /* reads */ "fontSize",
51                 /* write */ "");