]> git.donarmstrong.com Git - lilypond.git/blob - lily/sustain-pedal.cc
release: 1.3.69
[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
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_brew_molecule ())
26
27 */
28
29 struct Sustain_pedal
30 {
31 public:
32    static SCM brew_molecule (SCM);
33 };
34
35
36 MAKE_SCHEME_CALLBACK(Sustain_pedal,brew_molecule);
37
38 SCM
39 Sustain_pedal::brew_molecule (SCM smob) 
40 {
41   Score_element * e = unsmob_element (smob);
42   
43   Molecule mol;
44   SCM glyph = e->get_elt_property ("text");
45   if (!gh_string_p (glyph))
46     return mol.create_scheme();
47   String text = ly_scm2string (glyph);
48
49   for (int i = 0; i < text.length_i (); i++)
50     {
51       String idx ("pedal-");
52       if (text.cut_str (i, 3) == "Ped")
53         {
54           idx += "Ped";
55           i += 2;
56         }
57       else
58         idx += String (&text.byte_C ()[i], 1);
59       Molecule m = e->lookup_l ()->afm_find (idx);
60       if (!m.empty_b ())
61         mol.add_at_edge (X_AXIS, RIGHT, m, 0);
62     }
63     
64   return mol.create_scheme ();
65 }
66