]> git.donarmstrong.com Git - lilypond.git/blob - lily/clef.cc
*** empty log message ***
[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--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "clef.hh"
10
11 #include "string.hh"
12 #include "stencil.hh"
13 #include "item.hh"
14 #include "font-interface.hh"
15
16 /*
17  FIXME: should use symbol for #'style.
18 */
19 MAKE_SCHEME_CALLBACK (Clef, before_line_breaking, 1);
20 SCM
21 Clef::before_line_breaking (SCM smob)
22 {
23   Item *s = unsmob_item (smob);
24   SCM glyph = s->get_property ("glyph-name");
25
26   if (!scm_is_string (glyph))
27     s->suicide ();
28   else
29     {
30       String str = ly_scm2string (glyph);
31
32       if (to_boolean (s->get_property ("non-default"))
33           && s->break_status_dir () != RIGHT
34           && !to_boolean (s->get_property ("full-size-change")))
35         {
36           str += "_change";
37           s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ()));     
38         }
39     }
40
41   return SCM_UNSPECIFIED;
42 }
43
44 MAKE_SCHEME_CALLBACK (Clef, print, 1)
45 SCM
46 Clef::print (SCM smob)
47 {
48   Grob *me = unsmob_grob (smob);
49   SCM glyph_scm = me->get_property ("glyph-name");
50   if (!scm_is_string (glyph_scm))
51     return SCM_EOL;
52
53   String glyph = String (ly_scm2string (glyph_scm));
54   Font_metric *fm = Font_interface::get_default_font (me);
55   Stencil out = fm->find_by_name (glyph);
56   if (out.is_empty ())
57     me->warning (_f ("clef `%s' not found", glyph.to_str0 ()));
58   return out.smobbed_copy ();
59 }
60
61 ADD_INTERFACE (Clef, "clef-interface",
62   "A clef sign",
63   "non-default full-size-change glyph-name");
64