]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-size-engraver.cc
03802ac2ce2c94c354d5ae73602c2248707e87a7
[lilypond.git] / lily / font-size-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2001--2012  Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "grob.hh"
21 #include "engraver.hh"
22
23 class Font_size_engraver : public Engraver
24 {
25
26   TRANSLATOR_DECLARATIONS (Font_size_engraver);
27 protected:
28   DECLARE_ACKNOWLEDGER (font);
29   void process_music ();
30   Real size;
31 private:
32 };
33
34 Font_size_engraver::Font_size_engraver ()
35 {
36   size = 0.0;
37 }
38
39 void
40 Font_size_engraver::process_music ()
41 {
42   size = robust_scm2double (get_property ("fontSize"), 0.0);
43 }
44
45 void
46 Font_size_engraver::acknowledge_font (Grob_info gi)
47 {
48   /*
49     We only want to process a grob once.
50   */
51   if (!size)
52     return;
53
54   if (gi.context () != context ())
55     return;
56
57   Real font_size = size
58                    + robust_scm2double (gi.grob ()->get_property ("font-size"), 0);
59   gi.grob ()->set_property ("font-size", scm_from_double (font_size));
60 }
61
62 #include "translator.icc"
63
64 ADD_ACKNOWLEDGER (Font_size_engraver, font);
65 ADD_TRANSLATOR (Font_size_engraver,
66                 /* doc */
67                 "Put @code{fontSize} into @code{font-size} grob property.",
68
69                 /* create */
70                 "",
71
72                 /* read */
73                 "fontSize ",
74
75                 /* write */
76                 ""
77                );