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
19 #include "direction.hh"
20 #include "staff-symbol-referencer.hh"
24 #include "note-head.hh"
26 #include "font-interface.hh"
27 #include "math.h" // rint
29 MAKE_SCHEME_CALLBACK (Custos,print,1);
31 Custos::print (SCM smob)
33 Item *me = (Item *)unsmob_grob (smob);
35 SCM scm_style = me->get_property ("style");
37 if (gh_symbol_p (scm_style))
39 style = ly_symbol2string (scm_style);
47 * Shall we use a common custos font character regardless if on
48 * staffline or not, or shall we use individual font characters
53 int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0);
54 Direction neutral_direction =
55 to_dir (me->get_property ("neutral-direction"));
57 int pos = Staff_symbol_referencer::get_rounded_position (me);
58 int sz = Staff_symbol_referencer::line_count (me)-1;
60 String font_char = "custodes-" + style + "-";
61 if (pos < neutral_pos)
63 else if (pos > neutral_pos)
65 else if (neutral_direction == UP)
67 else if (neutral_direction == DOWN)
69 else // auto direction; not yet supported -> use "d"
74 font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
82 = Font_interface::get_default_font (me)->find_by_name (font_char);
83 if (stencil.is_empty ())
85 me->warning (_f ("custos `%s' not found", font_char));
91 int pos = Staff_symbol_referencer::get_rounded_position (me);
92 int interspaces = Staff_symbol_referencer::line_count (me)-1;
93 if (abs (pos) - interspaces > 1)
95 Stencil ledger_lines =
96 Note_head::brew_ledger_lines (me, pos, interspaces,
97 stencil.extent (X_AXIS), 0, true);
98 stencil.add_stencil (ledger_lines);
100 return stencil.smobbed_copy ();
104 ADD_INTERFACE (Custos, "custos-interface",
106 "style neutral-position neutral-direction");