1 #include "font-interface.hh"
4 #include "accidental-interface.hh"
7 TODO: insert support for smaller cautionaries, tie-break-reminders.
8 Either here or in new-accidental-engraver.
10 'accidentals should go, for a single 'accidental property -- see
11 accidental-placement.cc
17 parenthesize (Grob*me, Molecule m)
19 Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-leftparen"));
20 Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-rightparen"));
21 m.add_at_edge (X_AXIS, LEFT, Molecule (open), 0);
22 m.add_at_edge (X_AXIS, RIGHT, Molecule (close), 0);
28 MAKE_SCHEME_CALLBACK (Accidental_interface,after_line_breaking,1);
30 Accidental_interface::after_line_breaking (SCM smob)
32 Grob *me = unsmob_grob (smob);
33 Grob *tie = unsmob_grob (me->get_grob_property ("tie"));
35 if (tie && !tie->original_)
39 return SCM_UNSPECIFIED;
43 Accidental_interface::accurate_boxes (Grob *a,Grob**common)
46 b[X_AXIS] = a->extent (a, X_AXIS);
47 b[Y_AXIS] = a->extent (a, Y_AXIS);
52 if (to_boolean (a->get_grob_property ("cautionary")))
54 SCM cstyle = a->get_grob_property ("cautionary-style");
55 parens = gh_equal_p (cstyle, ly_symbol2scm ("parentheses"));
59 SCM accs = a->get_grob_property ("accidentals");
60 SCM scm_style = a->get_grob_property ("style");
61 if (!gh_symbol_p (scm_style)
63 && scm_ilength (accs) == 1)
65 if (gh_scm2int (gh_car (accs)) == -1)
71 we could make the stem thinner, but that places the flats
74 stem[X_AXIS][RIGHT] *= .5;
75 bulb[Y_AXIS][UP] *= .35;
81 TODO: add support for natural, double flat.
88 Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
89 a->relative_coordinate (common[Y_AXIS], Y_AXIS));
90 for(int i = boxes.size(); i--;)
92 boxes[i].translate(o);
99 * Some styles do not provide all flavours of accidentals, e.g. there
100 * is currently no sharp accidental in vaticana style. In these cases
101 * this function falls back to one of the other styles.
104 Accidental_interface::get_fontcharname(String style, int alteration)
106 if (style == "hufnagel")
109 case -2: return "-2";
110 case -1: return "hufnagel-1";
111 case 0: return "vaticana0";
112 case 1: return "mensural1";
115 if (style == "medicaea")
118 case -2: return "-2";
119 case -1: return "medicaea-1";
120 case 0: return "vaticana0";
121 case 1: return "mensural1";
124 if (style == "vaticana")
127 case -2: return "-2";
128 case -1: return "vaticana-1";
129 case 0: return "vaticana0";
130 case 1: return "mensural1";
133 if (style == "mensural")
136 case -2: return "-2";
137 case -1: return "mensural-1";
138 case 0: return "vaticana0";
139 case 1: return "mensural1";
142 if (style == "neo_mensural")
143 style = ""; // currently same as default
144 if (style == "default")
146 return style + to_string (alteration);
149 MAKE_SCHEME_CALLBACK (Accidental_interface,brew_molecule,1);
151 Accidental_interface::brew_molecule (SCM smob)
153 Grob *me = unsmob_grob (smob);
154 bool smaller = false;
157 bool caut = to_boolean (me->get_grob_property ("cautionary"));
160 SCM cstyle = me->get_grob_property ("cautionary-style");
161 parens = gh_equal_p (cstyle, ly_symbol2scm ("parentheses"));
162 smaller = gh_equal_p (cstyle, ly_symbol2scm ("smaller"));
165 SCM scm_style = me->get_grob_property ("style");
167 if (gh_symbol_p (scm_style))
169 style = ly_symbol2string (scm_style);
174 preferably no name for the default style.
182 SCM ac = Font_interface::font_alist_chain (me);
183 ac = gh_cons (gh_cons (gh_cons
184 (ly_symbol2scm ("font-relative-size"),
185 scm_int2num (-1)), SCM_EOL),
187 fm = Font_interface::get_font (me, ac);
190 fm = Font_interface::get_default_font (me);
193 for (SCM s = me->get_grob_property ("accidentals");
194 gh_pair_p (s); s = gh_cdr (s))
196 int alteration = gh_scm2int (gh_car (s));
197 String font_char = get_fontcharname (style, alteration);
198 Molecule acc (fm->find_by_name ("accidentals-" + font_char));
202 me->warning (_f ("accidental `%s' not found", font_char));
206 mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1);
211 mol = parenthesize (me, mol);
213 return mol.smobbed_copy();
218 ADD_INTERFACE (Accidental_interface, "accidental-interface",
219 "a single accidental",
220 "cautionary cautionary-style style tie accidentals");