*** empty log message ***
[lilypond.git] / lily / clef.cc
blob0b72e88a88da3622ae9b861b2b3570a3c09e7e19
1 /*
2 clef.cc -- implement Clef_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "clef.hh"
10 #include "string.hh"
11 #include "molecule.hh"
12 #include "item.hh"
13 #include "font-interface.hh"
16 FIXME: should use symbol for #'style.
18 MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1);
19 SCM
20 Clef::before_line_breaking (SCM smob)
22 Item *s = unsmob_item (smob);
24 SCM glyph = s->get_grob_property ("glyph-name");
26 if (gh_string_p (glyph))
28 String str = ly_scm2string (glyph);
30 if (to_boolean (s->get_grob_property ("non-default"))
31 && s->break_status_dir () != RIGHT
32 && !to_boolean (s->get_grob_property ("full-size-change")))
34 str += "_change";
35 s->set_grob_property ("glyph-name", scm_makfrom0str (str.to_str0 ()));
38 else
40 s->suicide ();
41 return SCM_UNSPECIFIED;
44 return SCM_UNSPECIFIED;
50 MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1)
51 SCM
52 Clef::brew_molecule (SCM smob)
54 Grob *me = unsmob_grob (smob);
55 SCM glyph_scm = me->get_grob_property ("glyph-name");
56 if (!gh_string_p (glyph_scm))
57 return SCM_EOL;
59 String glyph = String (ly_scm2string (glyph_scm));
60 Font_metric *fm = Font_interface::get_default_font (me);
61 Molecule out = fm->find_by_name (glyph);
62 if (out.empty_b())
64 me->warning (_f ("clef `%s' not found", glyph.to_str0 ()));
66 return out.smobbed_copy ();
70 ADD_INTERFACE (Clef, "clef-interface",
71 "A clef sign",
72 "non-default full-size-change glyph-name");