]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
*** empty log message ***
[lilypond.git] / lily / sustain-pedal.cc
1 /*   
2   sustain-pedal.cc --  implement Sustain_pedal
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include "grob.hh"
10 #include "stencil.hh"
11 #include "font-interface.hh"
12
13 // update comment --hwn 
14 /*
15   Urg.
16   This is almost text
17   Problem is:
18     * we have no kerning
19     * symbols are at wrong place in font
20
21
22
23   Properties:
24
25   glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
26
27 */
28
29
30 /*
31   FIXME. Need to use markup. 
32  */
33 struct Sustain_pedal
34 {
35 public:
36   DECLARE_SCHEME_CALLBACK (print, (SCM));
37 };
38
39
40 MAKE_SCHEME_CALLBACK (Sustain_pedal,print,1);
41 SCM
42 Sustain_pedal::print (SCM smob) 
43 {
44   Grob * e = unsmob_grob (smob);
45   
46   Stencil mol;
47   SCM glyph = e->get_property ("text");
48   if (!scm_is_string (glyph))
49     return mol.smobbed_copy ();
50   
51   String text = ly_scm2string (glyph);
52
53   for (int i = 0; i < text.length (); i++)
54     {
55       String idx ("pedal.");
56       if (text.cut_string (i, 3) == "Ped")
57         {
58           idx += "Ped";
59           i += 2;
60         }
61       else
62         idx += String (&text.to_bytes ()[i], 1);
63       Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
64       if (!m.is_empty ())
65         mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
66     }
67     
68   return mol.smobbed_copy ();
69 }
70