]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-size-engraver.cc
* lily/include/translator.icc: new file.
[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.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 #include "translator.icc"
46
47 ADD_TRANSLATOR (Font_size_engraver,
48                 /* descr */ "Puts fontSize into font-relative-size grob property.",
49                 /* creats*/ "",
50                 /* accepts */ "",
51                 /* acks  */ "font-interface",
52                 /* reads */ "fontSize",
53                 /* write */ "");