]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
release: 1.3.71
[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 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include "score-element.hh"
10 #include "molecule.hh"
11 #include "lookup.hh"
12 #include "string.hh"
13
14 // update comment --hwn 
15 /*
16   Urg.
17   This is almost text
18   Problem is:
19     * we have no kerning
20     * symbols are at wrong place in font
21
22
23
24   Properties:
25
26   glyph -- text string (TODO:   make one large glyph of the Ped symbol, removes need for member_brew_molecule ())
27
28 */
29
30 struct Sustain_pedal
31 {
32 public:
33    static SCM brew_molecule (SCM);
34 };
35
36
37 MAKE_SCHEME_CALLBACK(Sustain_pedal,brew_molecule);
38
39 SCM
40 Sustain_pedal::brew_molecule (SCM smob) 
41 {
42   Score_element * e = unsmob_element (smob);
43   
44   Molecule mol;
45   SCM glyph = e->get_elt_property ("text");
46   if (!gh_string_p (glyph))
47     return mol.create_scheme();
48   String text = ly_scm2string (glyph);
49
50   for (int i = 0; i < text.length_i (); i++)
51     {
52       String idx ("pedal-");
53       if (text.cut_str (i, 3) == "Ped")
54         {
55           idx += "Ped";
56           i += 2;
57         }
58       else
59         idx += String (&text.byte_C ()[i], 1);
60       Molecule m = e->lookup_l ()->afm_find (idx);
61       if (!m.empty_b ())
62         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
63     }
64     
65   return mol.create_scheme ();
66 }
67