X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faccidental.cc;h=a54a87efbc3c31e6cf07f1af9902038122439d10;hb=0bdd29149c655aa7da952269a5cbd80825d2f16f;hp=8359c553d0ab4648a5944d34bcead556588ac2fb;hpb=883e317d51c5e50011bc0e764a785631e5ea8689;p=lilypond.git diff --git a/lily/accidental.cc b/lily/accidental.cc index 8359c553d0..a54a87efbc 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -65,53 +65,48 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common) && !to_boolean (me->get_property ("restore-first")) && !parens) { - int acc = scm_to_int (me->get_property ("alteration")); - switch (acc) + Rational alteration = ly_scm2rational (me->get_property ("alteration")); + if (alteration == FLAT_ALTERATION) { - case FLAT: - { - Box stem = b; - Box bulb = b; + Box stem = b; + Box bulb = b; - /* - we could make the stem thinner, but that places the flats - really close. - */ - stem[X_AXIS][RIGHT] *= .5; - - /* - To prevent vertical alignment for 6ths - */ - stem[Y_AXIS] *= 1.1; - bulb[Y_AXIS][UP] *= .35; - - boxes.push_back (bulb); - boxes.push_back (stem); - } - break; - case NATURAL: - { - Box lstem = b; - Box rstem = b; - Box belly = b; - - lstem[Y_AXIS] *= 1.1; - rstem[Y_AXIS] *= 1.1; + /* + we could make the stem thinner, but that places the flats + really close. + */ + stem[X_AXIS][RIGHT] *= .5; - belly[Y_AXIS] *= 0.75; - lstem[X_AXIS][RIGHT] *= .33; - rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0 / 3.0); - lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; - rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; - boxes.push_back (belly); - boxes.push_back (lstem); - boxes.push_back (rstem); - } - break; /* - TODO: add support for, double flat. + To prevent vertical alignment for 6ths */ + stem[Y_AXIS] *= 1.1; + bulb[Y_AXIS][UP] *= .35; + + boxes.push_back (bulb); + boxes.push_back (stem); + } + else if (alteration == NATURAL_ALTERATION) + { + Box lstem = b; + Box rstem = b; + Box belly = b; + + lstem[Y_AXIS] *= 1.1; + rstem[Y_AXIS] *= 1.1; + + belly[Y_AXIS] *= 0.75; + lstem[X_AXIS][RIGHT] *= .33; + rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0 / 3.0); + lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; + rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; + boxes.push_back (belly); + boxes.push_back (lstem); + boxes.push_back (rstem); } + /* + TODO: add support for, double flat. + */ } if (!boxes.size ()) @@ -126,131 +121,45 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common) return boxes; } -/* - * Some styles do not provide all flavours of accidentals, e.g. there - * is currently no sharp accidental in vaticana style. In these cases - * this function falls back to one of the other styles. - */ - -/* - todo: this sort of stuff in Scheme. --hwn. -*/ -string -Accidental_interface::get_fontcharname (string style, int alteration) -{ - if (alteration == DOUBLE_FLAT - || alteration == DOUBLE_SHARP) - return to_string (alteration); - - if (style == "hufnagel") - switch (alteration) - { - case FLAT: return "hufnagel-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - if (style == "medicaea") - switch (alteration) - { - case FLAT: return "medicaea-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - if (style == "vaticana") - switch (alteration) - { - case FLAT: return "vaticana-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - if (style == "mensural") - switch (alteration) - { - case FLAT: return "mensural-1"; - case 0: return "vaticana0"; - case SHARP: return "mensural1"; - } - - if (style == "neomensural") - style = ""; // currently same as default - if (style == "default") - style = ""; - - return style + to_string (alteration); -} - MAKE_SCHEME_CALLBACK (Accidental_interface, print, 1); SCM Accidental_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); - bool parens = to_boolean (me->get_property ("parenthesized")); - - SCM scm_style = me->get_property ("style"); - string style; - if (scm_is_symbol (scm_style)) - style = ly_symbol2string (scm_style); - else - /* - preferably no name for the default style. - */ - style = ""; Font_metric *fm = Font_interface::get_default_font (me); - SCM stencils = me->get_property ("stencils"); - if (!scm_is_pair (stencils) - || !unsmob_stencil (scm_car (stencils))) - return SCM_EOL; + SCM alist = me->get_property ("glyph-name-alist"); + SCM alt = me->get_property ("alteration"); + SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F); + + if (!scm_is_string (glyph_name)) + { + me->warning (_f ("Could not find glyph-name for alteration %s", + ly_scm2rational (alt).to_string ().c_str ())); + return SCM_EOL; + } - Stencil mol (*unsmob_stencil (scm_car (stencils))); + Stencil mol (fm->find_by_name (scm_i_string_chars (glyph_name))); if (to_boolean (me->get_property ("restore-first"))) { - string font_char = get_fontcharname (style, 0); - Stencil acc (fm->find_by_name ("accidentals." + font_char)); + /* + this isn't correct for ancient accidentals, but they don't + use double flats/sharps anyway. + */ + Stencil acc (fm->find_by_name ("accidentals.natural")); if (acc.is_empty ()) - me->warning (_f ("accidental `%s' not found", font_char)); + me->warning (_ ("natural alteration glyph not found")); else mol.add_at_edge (X_AXIS, LEFT, acc, 0.1, 0); } - if (parens) + if (to_boolean (me->get_property ("parenthesized"))) mol = parenthesize (me, mol); return mol.smobbed_copy (); } - -MAKE_SCHEME_CALLBACK (Accidental_interface, calc_stencils, 1); -SCM -Accidental_interface::calc_stencils (SCM smob) -{ - Grob *me = unsmob_grob (smob); - - SCM scm_style = me->get_property ("style"); - string style; - if (scm_is_symbol (scm_style)) - style = ly_symbol2string (scm_style); - else - /* - preferably no name for the default style. - */ - style = ""; - - - Font_metric *fm = Font_interface::get_default_font (me); - SCM acc = me->get_property ("alteration"); - if (scm_is_number (acc)) - { - string font_char = get_fontcharname (style, scm_to_int (acc)); - - Stencil acc_stencil (fm->find_by_name ("accidentals." + font_char)); - - return scm_list_1 (acc_stencil.smobbed_copy ()); - } - else - return SCM_EOL; -} ADD_INTERFACE (Accidental_interface, @@ -260,7 +169,8 @@ ADD_INTERFACE (Accidental_interface, "alteration " "avoid-slur " "forced " - "style " - "parenthesized " + "parenthesized " + "restore-first " + "glyph-name-alist " "tie " );