2 custos.cc -- implement Custos
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 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
18 #include <math.h> // rint
21 #include "direction.hh"
22 #include "staff-symbol-referencer.hh"
24 #include "note-head.hh"
26 #include "font-interface.hh"
28 MAKE_SCHEME_CALLBACK (Custos,print,1);
30 Custos::print (SCM smob)
32 Item *me = (Item *)unsmob_grob (smob);
34 SCM scm_style = me->get_property ("style");
36 if (scm_is_symbol (scm_style))
38 style = ly_symbol2string (scm_style);
46 * Shall we use a common custos font character regardless if on
47 * staffline or not, or shall we use individual font characters
52 int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0);
53 Direction neutral_direction =
54 to_dir (me->get_property ("neutral-direction"));
56 int pos = Staff_symbol_referencer::get_rounded_position (me);
57 int sz = Staff_symbol_referencer::line_count (me)-1;
59 String font_char = "custodes." + style + ".";
60 if (pos < neutral_pos)
62 else if (pos > neutral_pos)
64 else if (neutral_direction == UP)
66 else if (neutral_direction == DOWN)
68 else // auto direction; not yet supported -> use "d"
73 font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
81 = Font_interface::get_default_font (me)->find_by_name (font_char);
82 if (stencil.is_empty ())
84 me->warning (_f ("custos `%s' not found", font_char));
88 return stencil.smobbed_copy ();
91 ADD_INTERFACE (Custos, "custos-interface",
93 "style neutral-position neutral-direction");