* lily/paper-book.cc: remove copyright & tagline. Remove
[lilypond.git] / lily / sustain-pedal.cc
blobf57ba09a9eb8568bbcc48898a7805cb448d2a11b
1 /*
2 sustain-pedal.cc -- implement Sustain_pedal
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9 #include "grob.hh"
10 #include "stencil.hh"
11 #include "font-interface.hh"
12 #include "string.hh"
14 // update comment --hwn
16 Urg.
17 This is almost text
18 Problem is:
19 * we have no kerning
20 * symbols are at wrong place in font
24 Properties:
26 glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
30 struct Sustain_pedal
32 public:
33 DECLARE_SCHEME_CALLBACK (print, (SCM));
37 MAKE_SCHEME_CALLBACK (Sustain_pedal,print,1);
38 SCM
39 Sustain_pedal::print (SCM smob)
41 Grob * e = unsmob_grob (smob);
43 Stencil mol;
44 SCM glyph = e->get_property ("text");
45 if (!ly_c_string_p (glyph))
46 return mol.smobbed_copy ();
48 String text = ly_scm2string (glyph);
50 for (int i = 0; i < text.length (); i++)
52 String idx ("pedal-");
53 if (text.cut_string (i, 3) == "Ped")
55 idx += "Ped";
56 i += 2;
58 else
59 idx += String (&text.to_bytes ()[i], 1);
60 Stencil m = Font_interface::get_default_font (e)->find_by_name (idx);
61 if (!m.is_empty ())
62 mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
65 return mol.smobbed_copy ();