2 custos.cc -- implement Custos
4 source file of the GNU LilyPond music typesetter
6 (C) 2000, 2002 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"
22 #include "molecule.hh"
24 #include "note-head.hh"
26 #include "font-interface.hh"
27 #include "math.h" // rint
29 MAKE_SCHEME_CALLBACK (Custos,brew_molecule,1);
31 Custos::brew_molecule (SCM smob)
33 Item *me = (Item *)unsmob_grob (smob);
35 SCM scm_style = me->get_grob_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
52 to_boolean (me->get_grob_property ("adjust-if-on-staffline"));
55 SCM ntr_pos = me->get_grob_property ("neutral-position");
56 if (gh_number_p (ntr_pos))
57 neutral_pos = gh_scm2int (ntr_pos);
61 Direction neutral_direction =
62 to_dir (me->get_grob_property ("neutral-direction"));
64 int pos = (int)rint (Staff_symbol_referencer::get_position (me));
65 int sz = Staff_symbol_referencer::line_count (me)-1;
67 String font_char = "custodes-" + style + "-";
68 if (pos < neutral_pos)
70 else if (pos > neutral_pos)
72 else if (neutral_direction == UP)
74 else if (neutral_direction == DOWN)
76 else // auto direction; not yet supported -> use "d"
81 font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
89 = Font_interface::get_default_font (me)->find_by_name (font_char);
90 if (molecule.empty_b ())
92 me->warning (_f ("custos `%s' not found", font_char));
98 int pos = (int)rint (Staff_symbol_referencer::get_position (me));
99 int interspaces = Staff_symbol_referencer::line_count (me)-1;
100 if (abs (pos) - interspaces > 1)
102 Molecule ledger_lines =
103 Note_head::brew_ledger_lines (me, pos, interspaces,
104 molecule.extent (X_AXIS), true);
105 molecule.add_molecule (ledger_lines);
107 return molecule.smobbed_copy ();
111 ADD_INTERFACE (Custos, "custos-interface",
112 "A custos is a staff context symbol that appears at the end of a
113 staff line with monophonic musical contents (i.e. with a single
114 voice). It anticipates the pitch of the first note of the following
115 line and thus helps the player or singer to manage line breaks
116 during performance, thus enhancing readability of a score.
118 Custodes were frequently used in music notation until the 16th
119 century. There were different appearences for different notation
120 styles. Nowadays, they have survived only in special forms of
121 musical notation such as via the editio vaticana dating back to the
122 beginning of the 20th century.
124 [TODO: add to glossary]",
125 "style adjust-if-on-staffline neutral-direction neutral-position");