2 custos.cc -- implement Custos
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Juergen Reuter <reuter@ipd.uka.de>
11 - do not show if a clef change immediately follows in the next line
13 - decide: do or do not print custos if the next line starts with a rest
17 #include <math.h> // rint
20 #include "direction.hh"
21 #include "staff-symbol-referencer.hh"
23 #include "note-head.hh"
25 #include "font-interface.hh"
27 MAKE_SCHEME_CALLBACK (Custos, print, 1);
29 Custos::print (SCM smob)
31 Item *me = (Item *)unsmob_grob (smob);
33 SCM scm_style = me->get_property ("style");
35 if (scm_is_symbol (scm_style))
36 style = ly_symbol2string (scm_style);
41 * Shall we use a common custos font character regardless if on
42 * staffline or not, or shall we use individual font characters
47 int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0);
48 Direction neutral_direction
49 = to_dir (me->get_property ("neutral-direction"));
51 int pos = Staff_symbol_referencer::get_rounded_position (me);
52 int sz = Staff_symbol_referencer::line_count (me) - 1;
54 String font_char = "custodes." + style + ".";
55 if (pos < neutral_pos)
57 else if (pos > neutral_pos)
59 else if (neutral_direction == UP)
61 else if (neutral_direction == DOWN)
63 else // auto direction; not yet supported -> use "d"
67 font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
72 = Font_interface::get_default_font (me)->find_by_name (font_char);
73 if (stencil.is_empty ())
75 me->warning (_f ("custos `%s' not found", font_char));
79 return stencil.smobbed_copy ();
82 ADD_INTERFACE (Custos, "custos-interface",
84 "style neutral-position neutral-direction");