]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-size-engraver.cc
Web-ja: update introduction
[lilypond.git] / lily / font-size-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2001--2015  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   void acknowledge_font (Grob_info);
29   void process_music ();
30   Real size;
31 private:
32 };
33
34 Font_size_engraver::Font_size_engraver (Context *c)
35   : Engraver (c)
36 {
37   size = 0.0;
38 }
39
40 void
41 Font_size_engraver::process_music ()
42 {
43   size = robust_scm2double (get_property ("fontSize"), 0.0);
44 }
45
46 void
47 Font_size_engraver::acknowledge_font (Grob_info gi)
48 {
49   /*
50     We only want to process a grob once.
51   */
52   if (!size)
53     return;
54
55   if (gi.context () != context ())
56     return;
57
58   Real font_size = size
59                    + robust_scm2double (gi.grob ()->get_property ("font-size"), 0);
60   gi.grob ()->set_property ("font-size", scm_from_double (font_size));
61 }
62
63 #include "translator.icc"
64
65 void
66 Font_size_engraver::boot ()
67 {
68   ADD_ACKNOWLEDGER (Font_size_engraver, font);
69 }
70
71 ADD_TRANSLATOR (Font_size_engraver,
72                 /* doc */
73                 "Put @code{fontSize} into @code{font-size} grob property.",
74
75                 /* create */
76                 "",
77
78                 /* read */
79                 "fontSize ",
80
81                 /* write */
82                 ""
83                );