]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-size-engraver.cc
* lily/accidental-engraver.cc: formatting fixes.
[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   DECLARE_ACKNOWLEDGER (font);
18   virtual void process_music ();
19   Real size;
20 private:
21 };
22
23 Font_size_engraver::Font_size_engraver ()
24 {
25   size = 0.0;
26 }
27
28
29 void
30 Font_size_engraver::process_music ()
31 {
32   size = robust_scm2double  (get_property ("fontSize"), 0.0);
33 }
34
35 void
36 Font_size_engraver::acknowledge_font (Grob_info gi)
37 {
38   /*
39     We only want to process a grob once.
40   */
41   if (!size)
42     return ;
43
44   if (gi.context () != context ())
45     return ;
46
47   Real font_size = size
48     + robust_scm2double (gi.grob ()->get_property ("font-size"), 0);
49   gi.grob ()->set_property ("font-size", scm_from_double (font_size));
50 }
51
52 #include "translator.icc"
53
54 ADD_ACKNOWLEDGER (Font_size_engraver,font);
55 ADD_TRANSLATOR (Font_size_engraver,
56                 /* descr */ "Puts fontSize into font-relative-size grob property.",
57                 /* creats*/ "",
58                 /* accepts */ "",
59                 /* reads */ "fontSize",
60                 /* write */ "");