2 notehead.cc -- implement Note_head
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "staff-symbol.hh"
14 #include "note-head.hh"
16 #include "font-interface.hh"
19 #include "rhythmic-head.hh"
20 #include "staff-symbol-referencer.hh"
22 #include "output-def.hh"
25 clean up the mess left by ledger line handling.
28 internal_print (Grob *me)
30 SCM style = me->get_property ("style");
31 if (!scm_is_symbol (style))
36 SCM log = scm_int2num (Note_head::get_balltype (me));
37 SCM proc = me->get_property ("glyph-name-procedure");
38 SCM scm_font_char = scm_call_2 (proc, log, style);
39 String font_char = "noteheads-" + ly_scm2string (scm_font_char);
41 Font_metric * fm = Font_interface::get_default_font (me);
42 Stencil out = fm->find_by_name (font_char);
45 me->warning (_f ("note head `%s' not found", font_char.to_str0 ()));
52 MAKE_SCHEME_CALLBACK (Note_head,print,1);
54 Note_head::print (SCM smob)
56 Grob *me = unsmob_grob (smob);
58 return internal_print (me).smobbed_copy ();
62 MAKE_SCHEME_CALLBACK (Note_head,brew_ez_stencil,1);
64 Note_head::brew_ez_stencil (SCM smob)
66 Grob *me = unsmob_grob (smob);
67 int l = Note_head::get_balltype (me);
71 SCM cause = me->get_property ("cause");
72 SCM spitch = unsmob_music (cause)->get_property ("pitch");
73 Pitch* pit = unsmob_pitch (spitch);
75 SCM idx = scm_int2num (pit->get_notename ());
76 SCM names = me->get_property ("note-names");
77 SCM charstr = SCM_EOL;
78 if (ly_c_vector_p (names))
79 charstr = scm_vector_ref (names, idx);
83 s[0] = (pit->get_notename () + 2)%7 + 'a';
84 s[0] = toupper (s[0]);
85 charstr = scm_makfrom0str (s);
88 SCM at = scm_list_n (ly_symbol2scm ("ez-ball"),
93 Box bx (Interval (0, 1.0), Interval (-0.5, 0.5));
96 return m.smobbed_copy ();
101 Note_head::stem_attachment_coordinate (Grob *me, Axis a)
103 SCM brewer = me->get_property ("print-function");
104 Font_metric * fm = Font_interface::get_default_font (me);
106 if (brewer == Note_head::print_proc)
108 SCM style = me->get_property ("style");
109 if (!scm_is_symbol (style))
114 SCM log = scm_int2num (Note_head::get_balltype (me));
115 SCM proc = me->get_property ("glyph-name-procedure");
116 SCM scm_font_char = scm_call_2 (proc, log, style);
117 String font_char = "noteheads-" + ly_scm2string (scm_font_char);
119 int k = fm->name_to_index (font_char) ;
123 Box b = fm->get_indexed_char (k);
124 Offset wxwy = fm->get_indexed_wxwy (k);
127 return 2 * (wxwy[a] - v.center ()) / v.length ();
134 SCM v = me->get_property ("stem-attachment-function");
135 if (!ly_c_procedure_p (v))
138 SCM result = scm_call_2 (v, me->self_scm (), scm_int2num (a));
139 if (!scm_is_pair (result))
142 result = (a == X_AXIS) ? scm_car (result) : scm_cdr (result);
144 return robust_scm2double (result,0);
148 Note_head::get_balltype (Grob*me)
150 SCM s = me->get_property ("duration-log");
151 return scm_is_number (s) ? scm_to_int (s) <? 2 : 0;
154 ADD_INTERFACE (Note_head,"note-head-interface",
156 "note-names glyph-name-procedure accidental-grob style stem-attachment-function");