]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
efefae39b4890c91351d7ab677bc985c72a55163
[lilypond.git] / lily / sustain-pedal.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2014 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 #include "grob.hh"
20 #include "stencil.hh"
21 #include "font-interface.hh"
22
23 // update comment --hwn
24 /*
25   Urg.
26   This is almost text
27   Problem is:
28   * we have no kerning
29   * symbols are at wrong place in font
30
31
32
33   Properties:
34
35   glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
36 */
37
38 /*
39   FIXME. Need to use markup.
40 */
41 struct Sustain_pedal
42 {
43 public:
44   DECLARE_SCHEME_CALLBACK (print, (SCM));
45 };
46
47 MAKE_SCHEME_CALLBACK (Sustain_pedal, print, 1);
48 SCM
49 Sustain_pedal::print (SCM smob)
50 {
51   Grob *e = unsmob_grob (smob);
52
53   Stencil mol;
54   SCM glyph = e->get_property ("text");
55   if (!scm_is_string (glyph))
56     return mol.smobbed_copy ();
57
58   string text = ly_scm2string (glyph);
59
60   for (ssize i = 0; i < text.length (); i++)
61     {
62       string idx ("pedal.");
63       if (text.substr (i, 3) == "Ped")
64         {
65           idx += "Ped";
66           i += 2;
67         }
68       else
69         idx += string (&text.c_str ()[i], 1);
70       Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
71       if (!m.is_empty ())
72         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
73     }
74
75   return mol.smobbed_copy ();
76 }
77