]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef.cc
166956052acb6e582b4e4c7871ec8a7d083f9b81
[lilypond.git] / lily / clef.cc
1 /*
2   clef.cc -- implement Clef_item
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "clef.hh"
10
11 #include "font-interface.hh"
12 #include "international.hh"
13 #include "item.hh"
14 #include "stencil.hh"
15
16 MAKE_SCHEME_CALLBACK (Clef, calc_glyph_name, 1);
17 SCM
18 Clef::calc_glyph_name (SCM smob)
19 {
20   Item *s = unsmob_item (smob);
21   SCM glyph = s->get_property ("glyph");
22
23   if (scm_is_string (glyph))
24     {
25       string str = ly_scm2string (glyph);
26
27       if (to_boolean (s->get_property ("non-default"))
28           && s->break_status_dir () != RIGHT
29           && !to_boolean (s->get_property ("full-size-change")))
30         {
31           str += "_change";
32         }
33
34       return ly_string2scm (str);
35     }
36
37   s->suicide ();
38   return SCM_UNSPECIFIED;
39 }
40
41 MAKE_SCHEME_CALLBACK (Clef, print, 1)
42 SCM
43 Clef::print (SCM smob)
44 {
45   Grob *me = unsmob_grob (smob);
46   SCM glyph_scm = me->get_property ("glyph-name");
47   if (!scm_is_string (glyph_scm))
48     return SCM_EOL;
49
50   string glyph = string (ly_scm2string (glyph_scm));
51   Font_metric *fm = Font_interface::get_default_font (me);
52   Stencil out = fm->find_by_name (glyph);
53   if (out.is_empty ())
54     me->warning (_f ("clef `%s' not found", glyph.c_str ()));
55   return out.smobbed_copy ();
56 }
57
58 ADD_INTERFACE (Clef,
59                "A clef sign.",
60
61                /* properties */
62                "full-size-change "
63                "glyph "
64                "glyph-name "
65                "non-default "
66                );
67