From: Han-Wen Nienhuys Date: Sat, 30 Dec 2006 01:48:50 +0000 (+0100) Subject: Softcode alteration/accidental symbol link. X-Git-Tag: release/2.11.6-1~34 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9dad21216e9f843ae1cfe9ffae916e6ee379e1a6;p=lilypond.git Softcode alteration/accidental symbol link. This allows different microtonal conventions by overriding the 'glyph-name-alist property of accidental. Related changes: - Use rational for grob property 'alteration - Soft code alteration_pos function for key signatures. - Do away with systematized names for accidentals in MF font. Provide descriptive names instead. Convert-ly rule. - Add (mirrorflat+flat) and sharps with three beams for Makam notation - Remove 'style property of accidental. Rather, override glyph-name-alist instead. --- diff --git a/input/regression/key-clefs.ly b/input/regression/key-clefs.ly index 000f090827..8d68529ea1 100644 --- a/input/regression/key-clefs.ly +++ b/input/regression/key-clefs.ly @@ -11,13 +11,13 @@ \clef violin \key cis \major cis1 \key ces \major ces \clef soprano - \key cis \major cis \key ces \major ces + \key cis \major cis \key ces \major ces \break \clef mezzosoprano \key cis \major cis \key ces \major ces \clef alto - \key cis \major cis \key ces \major ces + \key cis \major cis \break \key ces \major ces \clef tenor - \key cis \major cis \key ces \major ces + \key cis \major cis \key ces \major ces \break \clef baritone \key cis \major cis \key ces \major ces \clef bass diff --git a/input/regression/markup-scheme.ly b/input/regression/markup-scheme.ly index e82b4b0ba3..af1b4f9121 100644 --- a/input/regression/markup-scheme.ly +++ b/input/regression/markup-scheme.ly @@ -25,7 +25,7 @@ For maintenance reasons, we don't excercise the entire markup command set. -\version "2.10.0" +\version "2.11.5" { \fatText @@ -39,7 +39,7 @@ For maintenance reasons, we don't excercise the entire markup command set. \override #'(font-encoding . fetaMusic) { \lookup #"noteheads-0" } - \musicglyph #"accidentals.-1" + \musicglyph #"accidentals.mirroredflat" \combine "X" "+" \combine "o" "/" \box \column { \line { "string 1" } \line { "string 2" } } @@ -62,7 +62,7 @@ For maintenance reasons, we don't excercise the entire markup command set. #:hspace 2.0 #:override '(font-encoding . fetaMusic) #:line (#:lookup "noteheads-0" ) - #:musicglyph "accidentals.-1" + #:musicglyph "accidentals.mirroredflat" #:combine "X" "+" #:combine "o" "/" #:box #:column ("string 1" "string 2") diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 502aeaea9f..1b9920673f 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -383,7 +383,6 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, a->set_property ("restore-first", SCM_BOOL_T); } - a->set_property ("alteration", scm_from_int (pitch->get_alteration () * Rational (4))); entry->accidental_ = a; } diff --git a/lily/accidental.cc b/lily/accidental.cc index f6672e815b..6b7c85ada7 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,44 @@ 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 glyph_name = ly_assoc_get (me->get_property ("alteration"), + alist, SCM_BOOL_F); + + if (!scm_is_string (glyph_name)) + { + me->warning ("Could not find glyph-name for alteration"); + 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,8 +168,8 @@ ADD_INTERFACE (Accidental_interface, "alteration " "avoid-slur " "forced " - "style " "parenthesized " "restore-first " + "glyph-name-alist " "tie " ); diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index ab2897f16d..8606e4c9c1 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -158,7 +158,7 @@ Ambitus_engraver::finalize () } else { - accidentals_[d]->set_property ("alteration", scm_from_int (int (Real (Rational (4) * p.get_alteration ())))); + accidentals_[d]->set_property ("alteration", ly_rational2scm (p.get_alteration ())); } } while (flip (&d) != DOWN); diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 8bd0d1305f..b3e9d4bd98 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -53,23 +53,6 @@ Key_engraver::Key_engraver () } -SCM -make_qt_key (SCM rat_key) -{ - SCM qt_key = SCM_EOL; - SCM *tail = &qt_key; - - for (SCM s = rat_key; scm_is_pair (s); s = scm_cdr (s)) - { - *tail = scm_cons (scm_cons (scm_caar (s), - scm_from_int (Rational (4)* ly_scm2rational (scm_cdar (s)))), - SCM_EOL); - tail = SCM_CDRLOC (*tail); - } - - return qt_key; -} - void Key_engraver::create_key (bool is_default) { @@ -110,14 +93,13 @@ Key_engraver::create_key (bool is_default) key_event_ ? key_event_->self_scm () : SCM_EOL); - cancellation_->set_property ("alteration-alist", make_qt_key (restore)); + cancellation_->set_property ("alteration-alist", restore); cancellation_->set_property ("c0-position", get_property ("middleCPosition")); } } - - item_->set_property ("alteration-alist", make_qt_key (key)); + item_->set_property ("alteration-alist", key); } if (!is_default) diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index d6513efd84..8351696f30 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -23,64 +23,6 @@ struct Key_signature_interface DECLARE_GROB_INTERFACE(); }; -/* - FIXME: too much hardcoding here. -*/ -const int FLAT_TOP_PITCH = 2; /* fes, ges, as and bes typeset in lower octave */ -const int SHARP_TOP_PITCH = 4; /* ais and bis typeset in lower octave */ - -/* - TODO: look this up. I'm not sure where the naturals ought to go. - - COMMENT: Current implementation does not use the NATURAL_TOP_PITCH for anything, - always typesets naturals in the same place as the thing they cancel. -rz -*/ -const int NATURAL_TOP_PITCH = 4; - -/* - FIXME: key-item should just get a list of (position, acc), and leave - the thinking to other parties. - - - TODO: put this in Scheme - - TODO: can we do without c0pos? it's partly musical. -*/ -int -alteration_pos (SCM what, int alter, int c0p) -{ - if (scm_is_pair (what)) - return scm_to_int (scm_car (what)) * 7 + scm_to_int (scm_cdr (what)) + c0p; - - int p = scm_to_int (what); - - // Find the c in the range -4 through 2 - int from_bottom_pos = c0p + 4; - from_bottom_pos = from_bottom_pos % 7; - from_bottom_pos = (from_bottom_pos + 7) % 7; // Precaution to get positive. - int c0 = from_bottom_pos - 4; - - if ((alter < 0 && ((p > FLAT_TOP_PITCH) || (p + c0 > 4)) && (p + c0 > 1)) - || (alter > 0 && ((p > SHARP_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2)) - || (alter == 0 && ((p > NATURAL_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2))) - { - p -= 7; /* Typeset below c_position */ - } - - /* Provide for the four cases in which there's a glitch - it's a hack, but probably not worth - the effort of finding a nicer solution. - --dl. */ - if (c0 == 2 && alter > 0 && p == 3) - p -= 7; - if (c0==-3 && alter > 0 && p ==-1) - p += 7; - if (c0==-4 && alter < 0 && p ==-1) - p += 7; - if (c0==-2 && alter < 0 && p ==-3) - p += 7; - - return p + c0; -} /* TODO @@ -101,13 +43,9 @@ Key_signature_interface::print (SCM smob) else style = ""; - SCM newas = me->get_property ("alteration-alist"); Stencil mol; SCM c0s = me->get_property ("c0-position"); - int c0p = 0; - if (scm_is_number (c0s)) - c0p = scm_to_int (c0s); bool is_cancellation = me->internal_has_interface (ly_symbol2scm ("key-cancellation-interface")); @@ -119,22 +57,26 @@ Key_signature_interface::print (SCM smob) int last_pos = -1000; Font_metric *fm = Font_interface::get_default_font (me); - for (SCM s = newas; scm_is_pair (s); s = scm_cdr (s)) + SCM alist = me->get_property ("glyph-name-alist"); + + for (SCM s = me->get_property ("alteration-alist"); scm_is_pair (s); s = scm_cdr (s)) { - int alteration = scm_to_int (scm_cdar (s)); - string font_char - = Accidental_interface::get_fontcharname (style, - is_cancellation - ? 0 - : alteration); - Stencil acc (fm->find_by_name ("accidentals." + font_char)); + SCM alt = is_cancellation + ? scm_from_int (0) + : scm_cdar (s); + + SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F); + Stencil acc (fm->find_by_name (ly_scm2string (glyph_name))); if (acc.is_empty ()) - me->warning (_f ("accidental `%s' not found", font_char)); + me->warning (_ ("alteration not found")); else { SCM what = scm_caar (s); - int pos = alteration_pos (what, alteration, c0p); + + SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-position"); + + int pos = scm_to_int (scm_call_3 (proc, what, scm_cdar (s), c0s)); acc.translate_axis (pos * inter, Y_AXIS); /* @@ -161,7 +103,8 @@ Key_signature_interface::print (SCM smob) ADD_INTERFACE (Key_signature_interface, "A group of accidentals, to be printed as signature sign.", + "alteration-alist " "c0-position " + "glyph-name-alist " "style " - "alteration-alist " ); diff --git a/lily/note-column.cc b/lily/note-column.cc index ca85f08e12..fbb838523e 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -191,7 +191,6 @@ ADD_INTERFACE (Note_column, "Stem and noteheads combined", /* properties */ - "accidentals " "arpeggio " "force-hshift " "horizontal-shift " diff --git a/lily/pitch.cc b/lily/pitch.cc index 880dc79edf..da3a8a01dd 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -168,10 +168,10 @@ Pitch::to_string () const { int n = (notename_ + 2) % scale_->step_tones_.size (); string s = ::to_string (char (n + 'a')); - Rational qtones = alteration_ * Rational (4,1); - int qt = int (rint (Real (qtones))); + Rational qtones = alteration_ * Rational (4,1); + int qt = int (rint (Real (qtones))); - s += string (accname[qt + 4]); + s += string (accname[qt + 4]); if (octave_ >= 0) { int o = octave_ + 1; @@ -302,7 +302,9 @@ Pitch::transposed (Pitch d) const return p; } +Rational NATURAL_ALTERATION (0); Rational FLAT_ALTERATION (-1, 2); +Rational DOUBLE_FLAT_ALTERATION (-1); Rational SHARP_ALTERATION (1, 2); Pitch diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index 811decb67d..2816aa655e 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -110,8 +110,7 @@ Pitched_trill_engraver::make_trill (Stream_event *ev) trill_accidental_ = make_item ("TrillPitchAccidental", ev->self_scm ()); // fixme: naming -> alterations - trill_accidental_->set_property ("alteration", scm_from_int (Rational (4) - * p->get_alteration ())); + trill_accidental_->set_property ("alteration", ly_rational2scm (p->get_alteration ())); Side_position_interface::add_support (trill_accidental_, trill_head_); trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ()); diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 8752d704a0..bccee086c5 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -784,26 +784,20 @@ Slur_score_state::get_extra_encompass_infos () const { penalty = parameters_.accidental_collision_; - SCM alt = g->get_property ("alteration"); + Rational alt = ly_scm2rational (g->get_property ("alteration")); SCM scm_style = g->get_property ("style"); if (!scm_is_symbol (scm_style) && !to_boolean (g->get_property ("parenthesized")) && !to_boolean (g->get_property ("restore-first"))) { /* End copy accidental.cc */ - switch (scm_to_int (alt)) - { - case FLAT: - case DOUBLE_FLAT: - xp = LEFT; - break; - case SHARP: - xp = 0.5 * dir_; - break; - case NATURAL: - xp = -dir_; - break; - } + if (alt == FLAT_ALTERATION + || alt == DOUBLE_FLAT_ALTERATION) + xp = LEFT; + else if (alt == SHARP_ALTERATION) + xp = 0.5 * dir_; + else if (alt == NATURAL_ALTERATION) + xp = -dir_; } } diff --git a/mf/feta-test-generic.mf b/mf/feta-test-generic.mf index 552731486d..1ade03f2c3 100644 --- a/mf/feta-test-generic.mf +++ b/mf/feta-test-generic.mf @@ -4,9 +4,9 @@ % %input feta-eindelijk; -%input feta-toevallig; +input feta-toevallig; %input feta-puntje; -input feta-bolletjes; +%input feta-bolletjes; %input feta-arrow; %input feta-schrift; %input feta-schrift; diff --git a/mf/feta-toevallig.mf b/mf/feta-toevallig.mf index f473e236f0..9b69c5f0a0 100644 --- a/mf/feta-toevallig.mf +++ b/mf/feta-toevallig.mf @@ -1,12 +1,26 @@ % % feta-toevallig.mf -- implement Accidentals % -% source file of the Feta (Font-En-Tja) music font -% % (c) 1997--2006 Han-Wen Nienhuys % +% +% also show in other configuration wrt staff lines. +% +def draw_shifted_too = +if test > 0: + fet_beginchar ("shifted too", ""); + set_char_box (0, 0,0,0); + currentpicture := remember_pic; + + draw_staff (-2, 2, 0.5); + fet_endchar; +fi; +enddef; + + + % % Accidentals from various sources, notably % @@ -15,12 +29,27 @@ % +% +% Naming for microtonal +% +% BASES SLASHES STEMS +% +% mirroredflat.flat.slashslash +% + +% standard sharp: +% sharp.slashslash.stemstem +% sharp.slashslash.stem + + fet_begingroup ("accidentals"); save remember_pic; picture remember_pic; +save sharp_beamheight; +sharp_beamheight# := 0.3 staff_space# + stafflinethickness#; % % The beams of most sharps have horizontal endings (as if drawn with @@ -29,28 +58,27 @@ picture remember_pic; % def draw_meta_sharp (expr width, offset) = - save beamheight, beamwidth, beamslope; + save beamwidth, beamslope; save ne, nw_dist; pair ne, nw_dist; beamwidth := width; - beamheight# := 0.3 staff_space# + stafflinethickness#; - define_whole_vertical_blacker_pixels (beamheight); + define_whole_vertical_blacker_pixels (sharp_beamheight); clearxy; - beamslope = beamheight / beamwidth; + beamslope = sharp_beamheight / beamwidth; pickup pencircle scaled 2 blot_diameter; rt x2 - lft x1 = beamwidth; - y2 - y1 = beamheight; + y2 - y1 = sharp_beamheight; .5 [z1, z3] = (.5 w, offset); x3 = x2; - top y2 - bot y3 = beamheight; + top y2 - bot y3 = sharp_beamheight; x4 = x1; - top y1 - bot y4 = beamheight; + top y1 - bot y4 = sharp_beamheight; ne = unitvector (z2 - z1); nw_dist = (ne rotated 90) * blot_diameter; @@ -69,7 +97,7 @@ def draw_meta_sharp (expr width, offset) = enddef; -fet_beginchar ("Sharp", "2"); +fet_beginchar ("Sharp", "sharp"); save stem, stemx, stemwidth; save outer_space, interbeam; @@ -110,21 +138,9 @@ fet_beginchar ("Sharp", "2"); draw_staff (-2, 2, 0); fet_endchar; +draw_shifted_too; -if test > 0: - fet_beginchar ("Sharp", "2"); - - set_char_box (0, 1.1 staff_space#, - 1.5 staff_space#, 1.5 staff_space#); - - currentpicture := remember_pic; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; - - -fet_beginchar ("1/2 Sharp", "1"); +fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem"); save stem, stemwidth; save outer_space, interbeam; @@ -160,21 +176,100 @@ fet_beginchar ("1/2 Sharp", "1"); draw_staff (-2, 2, 0); fet_endchar; +draw_shifted_too; -if test > 0: - fet_beginchar ("1/2 Sharp", "1"); +fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem"); + save stem, stemx, stemwidth; + save outer_space, interbeam; + save sharp_beamheight; - set_char_box (0, 0.7 staff_space#, - 1.5 staff_space#, 1.5 staff_space#); + sharp_beamheight# := 0.22 staff_space# + stafflinethickness#; - currentpicture := remember_pic; - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; + stemwidth# := stafflinethickness# + .05 staff_space#; + define_whole_blacker_pixels (stemwidth); + interbeam := 1.2 staff_space_rounded; + + set_char_box (0, 1.1 staff_space#, + 1.5 staff_space#, 1.5 staff_space#); -fet_beginchar ("3/4 Sharp", "3"); + stem := 7 / 16 * w; + stemx := hround stem; + outer_space := hround ((w - stemx - stemwidth) / 2); + + w := 2 outer_space + stemx + stemwidth; + d := d - feta_space_shift; + + draw_meta_sharp (.88 w, -.5 interbeam); + draw_meta_sharp (w, 0); + draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam); + + pickup pencircle scaled stemwidth; + + lft x5 = lft x6 = outer_space; + lft x7 = lft x8 = outer_space + stemx; + bot y5 = -d; + top y6 = vround (1.5 staff_space - stem * beamslope); + bot y7 = -top y6 + feta_space_shift; + top y8 = h; + + labels (5, 6, 7, 8); + + draw_gridline (z5, z6, stemwidth); + draw_gridline (z7, z8, stemwidth); + + remember_pic := currentpicture; + + draw_staff (-2, 2, 0); +fet_endchar; + +draw_shifted_too; + +fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem"); + save stem, stemx, stemwidth; + save outer_space, interbeam; + save sharp_beamheight; + + sharp_beamheight# := 0.22 staff_space# + stafflinethickness#; + + stemwidth# := stafflinethickness# + .05 staff_space#; + define_whole_blacker_pixels (stemwidth); + + interbeam := 1.2 staff_space_rounded; + + set_char_box (0, 0.95 staff_space#, + 1.3 staff_space#, 1.3 staff_space#); + + stem := 7 / 16 * w; + outer_space := hround ((w - stemwidth) / 2); + w := 2 outer_space + stemwidth; + d := d - feta_space_shift; + + draw_meta_sharp (.8 w, -.5 interbeam); + draw_meta_sharp (w, 0); + draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam); + + pickup pencircle scaled stemwidth; + + lft x5 = lft x6 = outer_space; + top y6 = vround (1.5 staff_space - .5 stem); + bot y5 = -top y6 + feta_space_shift; + labels (5, 6); + + + draw_gridline (z5, z6, stemwidth); + + + remember_pic := currentpicture; + + draw_staff (-2, 2, 0); +fet_endchar; + +draw_shifted_too; + + +fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem"); save stem, stemx, stemwidth; save outer_space, interbeam; @@ -219,25 +314,15 @@ fet_beginchar ("3/4 Sharp", "3"); draw_staff (-2, 2, 0); fet_endchar; +draw_shifted_too; -if test > 0: - fet_beginchar ("3/4 Sharp", "3"); - - set_char_box (0, 1.6 staff_space#, - 1.5 staff_space#, 1.5 staff_space#); - - currentpicture := remember_pic; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; % % The stems of the natural are brushed (at least, in Barenreiter SCS) % -fet_beginchar ("Natural", "0"); +fet_beginchar ("Natural", "natural"); save stemwidth, top_stem_thick; save ne, pat_top, pat_bottom; pair ne; @@ -324,17 +409,7 @@ fet_beginchar ("Natural", "0"); draw_staff (-2, 2, 0); fet_endchar; - -if test > 0: - fet_beginchar ("Natural", "0"); - set_char_box (0, 2/3 staff_space#, - 1.5 staff_space#, 1.5 staff_space#); - - currentpicture := remember_pic; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; +draw_shifted_too; % @@ -455,7 +530,7 @@ enddef; % unfortunately, 600dpi is not enough to show the brush of the stem. % -fet_beginchar ("Flat", "-2"); +fet_beginchar ("Flat", "flat"); set_char_box (1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#); @@ -467,20 +542,74 @@ fet_beginchar ("Flat", "-2"); draw_staff (-2, 2, 0); fet_endchar; +draw_shifted_too; -if test > 0: - fet_beginchar ("Flat", "-2"); - set_char_box (1.2 stafflinethickness#, .8 staff_space#, - 0.6 staff_space#, 1.9 staff_space#); +fet_beginchar ("Flat (slashed)", "flat.slash"); + set_char_box (1.2 stafflinethickness#, .8 staff_space#, + 0.6 staff_space#, 1.9 staff_space#); - currentpicture := remember_pic; + draw_meta_flat (0, w, 0.31 staff_space); + clearxy; + save slope, slash_width; + slope = 0.5; + slash_width = w; + z1 = (0, h / 2); + z2 = z1 - (slash_width, slash_width * slope)/2; + z3 = z1 + (slash_width, slash_width * slope)/2; + + pickup pencircle scaled 1.5 stafflinethickness; + draw z2 .. z3; + labels (1, 2, 3); + remember_pic := currentpicture; - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; + draw_staff (-2, 2, 0); +fet_endchar; + +fet_beginchar ("Flat (slashed twice)", "flat.slashslash"); + set_char_box (1.2 stafflinethickness#, .8 staff_space#, + 0.6 staff_space#, 1.9 staff_space#); + + draw_meta_flat (0, w, 0.31 staff_space); + clearxy; + save slope, slash_width; + + slope = 0.5; + slash_width = w; + pickup pencircle scaled 1.5 stafflinethickness; + + z1 = (0, 5/12 h); + z2 = (0, 2/3 h); + draw z1 - (slash_width, slash_width * slope)/2 + .. z1 + (slash_width, slash_width * slope)/2; + draw z2 - (slash_width, slash_width * slope)/2 + .. z2 + (slash_width, slash_width * slope)/2; + labels (1, 2); + remember_pic := currentpicture; + + draw_staff (-2, 2, 0); +fet_endchar; + +fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat"); + set_char_box (0, 1.6 staff_space#, + 0.6 staff_space#, 1.9 staff_space#); + draw_meta_flat (0, w/2, 0.31 staff_space); + currentpicture := currentpicture xscaled -1; + draw_meta_flat (0, w/2, 0.31 staff_space); + + currentpicture := currentpicture shifted (w/2,0); + penlabels (range 0 thru 11); -fet_beginchar ("Semi flat", "-1"); + remember_pic := currentpicture; + + draw_staff (-2, 2, 0); +fet_endchar; + +draw_shifted_too; + + + +fet_beginchar ("Semi flat", "mirroredflat"); set_char_box (1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 1.9 staff_space#); @@ -489,7 +618,7 @@ fet_beginchar ("Semi flat", "-1"); fet_endchar; -fet_beginchar ("Double Flat", "-4"); +fet_beginchar ("Double Flat", "flatflat"); save left_wid, overlap, right_wid; left_wid = .7; @@ -505,7 +634,7 @@ fet_beginchar ("Double Flat", "-4"); fet_endchar; -fet_beginchar ("3/4 Flat", "-3"); +fet_beginchar ("3/4 Flat", "flatflat.slash"); save left_wid, overlap, right_wid; left_wid = .7; @@ -549,27 +678,9 @@ fet_beginchar ("3/4 Flat", "-3"); draw_staff (-2, 2, 0); fet_endchar; +draw_shifted_too; -if test > 0: - fet_beginchar ("3/4 Flat", "-3"); - save left_wid, overlap, right_wid; - - left_wid = .7; - right_wid = .8; - overlap = .05; - - set_char_box (1.2 stafflinethickness#, - (left_wid + right_wid - overlap) * staff_space#, - .6 staff_space#, 1.9 staff_space#); - - currentpicture := remember_pic; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; - - -fet_beginchar ("Double Sharp", "4"); +fet_beginchar ("Double Sharp", "doublesharp"); save klaverblad, klaversteel; save pat; path pat; @@ -622,18 +733,7 @@ fet_beginchar ("Double Sharp", "4"); draw_staff (-2, 2, 0); fet_endchar; - -if test > 0: - fet_beginchar ("Double Sharp", "4"); - set_char_box (0, staff_space#, - .5 staff_space#, .5 staff_space#); - - currentpicture := remember_pic; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; - +draw_shifted_too; def draw_paren = save leftindent; @@ -671,17 +771,7 @@ fet_beginchar ("Right Parenthesis", "rightparen"); draw_staff (-2, 2, 0); fet_endchar; - -if test > 0: - fet_beginchar ("Right Parenthesis", "rightparen"); - draw_paren; - penlabels (1, 2, 3); - - remember_pic := currentpicture; - - draw_staff (-2, 2, 0.5); - fet_endchar; -fi; +draw_shifted_too; fet_beginchar ("Left Parenthesis", "leftparen"); @@ -692,5 +782,4 @@ fet_beginchar ("Left Parenthesis", "leftparen"); set_char_box (charwd, charbp, chardp, charht); fet_endchar; - fet_endgroup ("accidentals"); diff --git a/python/convertrules.py b/python/convertrules.py index 165e0a52d8..5d6e8b48fb 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -2898,7 +2898,25 @@ def conv (str): str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller", r"\1 #'font-size = #-2", str) + def sub_acc_name (m): + idx = int (m.group (1).replace ('M','-')) + + return ["accidentals.doublesharp", + "accidentals.sharp.slashslash.stemstemstem", + "accidentals.sharp", + "accidentals.sharp.slashslash.stem", + "accidentals.natural", + "accidentals.mirroredflat", + "accidentals.flat", + "accidentals.mirroredflat.flat", + "accidentals.flatflat"][4-idx] + + str = re.sub (r"accidentals[.](M?[-0-9]+)", + sub_acc_name, str) + return str -conversions.append (((2, 11, 5), conv, """ly:clone-parser -> ly:parser-clone""")) +conversions.append (((2, 11, 5), conv, """deprecate cautionary-style. Use AccidentalCautionary properties""")) + + diff --git a/scm/chord-name.scm b/scm/chord-name.scm index 33f82c9501..c941d50bda 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -21,8 +21,7 @@ 0.3 0.6) (make-musicglyph-markup - (format "accidentals.~a" - (inexact->exact (* 4 alteration))))))) + (assoc-get alteration standard-alteration-glyph-name-alist ""))))) (define (accidental->markup alteration) "Return accidental markup for ALTERATION." diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index fe584ad40d..4936710172 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -135,7 +135,8 @@ (ly:add-interface 'trill-pitch-accidental-interface "An accidental for trill pitch" - '(accidentals)) + '() + ) (ly:add-interface 'rhythmic-grob-interface diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 7ae1a0e4fe..e224bfaee4 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -186,6 +186,7 @@ typeset. Valid choices depend on the function that is reading this property.") (gap ,ly:dimension? "Size of a gap in a variable symbol.") (gap-count ,integer? "Number of gapped beams for tremolo.") + (glyph-name-alist ,list? "Alist of key-string pairs.") (grow-direction ,ly:dir? "Crescendo or decrescendo?") (hair-thickness ,number? "Thickness of the thin line in a bar line.") (head-direction ,ly:dir? "Are the note heads left or right in a semitie?") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 6080fb021b..da5bdcd100 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -20,8 +20,9 @@ (Accidental . ( (avoid-slur . inside) + (glyph-name-alist . ,standard-alteration-glyph-name-alist) + (alteration . ,accidental-interface::calc-alteration) (stencil . ,ly:accidental-interface::print) - (stencils . ,ly:accidental-interface::calc-stencils) (after-line-breaking . ,ly:accidental-interface::after-line-breaking) (meta . ((class . Item) @@ -31,8 +32,9 @@ . ( (avoid-slur . inside) (parenthesized . #t) + (glyph-name-alist . ,standard-alteration-glyph-name-alist) + (alteration . ,accidental-interface::calc-alteration) (stencil . ,ly:accidental-interface::print) - (stencils . ,ly:accidental-interface::calc-stencils) (after-line-breaking . ,ly:accidental-interface::after-line-breaking) (meta . ((class . Item) @@ -49,12 +51,13 @@ ,(ly:make-simple-closure (list ly:self-alignment-interface::x-aligned-on-self))))) (self-alignment-X . ,CENTER) (font-size . -2) + (glyph-name-alist . ,standard-alteration-glyph-name-alist) + (alteration . ,accidental-interface::calc-alteration) (Y-offset . ,ly:side-position-interface::y-aligned-side) (direction . ,UP) (staff-padding . 0.25) (outside-staff-priority . 0) (script-priority . 0) - (stencils . ,ly:accidental-interface::calc-stencils) (side-axis . ,X) (meta . ((class . Item) (interfaces . (side-position-interface @@ -117,8 +120,7 @@ (X-offset . ,ly:side-position-interface::x-aligned-side) (direction . ,LEFT) (stencil . ,ly:accidental-interface::print) - (stencils . ,ly:accidental-interface::calc-stencils) - + (glyph-name-alist . ,standard-alteration-glyph-name-alist) (after-line-breaking . ,ly:accidental-interface::after-line-breaking) (side-axis . ,X) (meta . ((class . Item) @@ -814,6 +816,7 @@ . ( (stencil . ,ly:key-signature-interface::print) (avoid-slur . inside) + (glyph-name-alist . ,standard-alteration-glyph-name-alist) (space-alist . ( (time-signature . (extra-space . 1.15)) (staff-bar . (extra-space . 1.1)) @@ -1881,7 +1884,7 @@ (font-size . -4) (side-axis . ,X) (stencil . ,ly:accidental-interface::print) - (stencils . ,ly:accidental-interface::calc-stencils) + (glyph-name-alist . ,standard-alteration-glyph-name-alist) (meta . ((class . Item) (interfaces . (item-interface trill-pitch-accidental-interface diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 5d96ecb179..f65cb8675f 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1032,39 +1032,40 @@ recommend font for this is bold and italic" (define-markup-command (doublesharp layout props) () "Draw a double sharp symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.4"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 1 standard-alteration-glyph-name-alist "")))) (define-markup-command (sesquisharp layout props) () "Draw a 3/2 sharp symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.3"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist "")))) + (define-markup-command (sharp layout props) () "Draw a sharp symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.2"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 1/2 standard-alteration-glyph-name-alist "")))) (define-markup-command (semisharp layout props) () "Draw a semi sharp symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.1"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 1/4 standard-alteration-glyph-name-alist "")))) (define-markup-command (natural layout props) () "Draw a natural symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.0"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 0 standard-alteration-glyph-name-alist "")))) (define-markup-command (semiflat layout props) () "Draw a semiflat." - (interpret-markup layout props (markup #:musicglyph "accidentals.M1"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get -1/4 standard-alteration-glyph-name-alist "")))) (define-markup-command (flat layout props) () "Draw a flat symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.M2"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get -1/2 standard-alteration-glyph-name-alist "")))) (define-markup-command (sesquiflat layout props) () "Draw a 3/2 flat symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.M3"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get -3/4 standard-alteration-glyph-name-alist "")))) (define-markup-command (doubleflat layout props) () "Draw a double flat symbol." - (interpret-markup layout props (markup #:musicglyph "accidentals.M4"))) + (interpret-markup layout props (markup #:musicglyph (assoc-get -1 standard-alteration-glyph-name-alist "")))) (define-markup-command (with-color layout props color arg) (color? markup?) "Draw @var{arg} in color specified by @var{color}" @@ -1098,7 +1099,7 @@ recommend font for this is bold and italic" (define-markup-command (musicglyph layout props glyph-name) (string?) "This is converted to a musical symbol, e.g. @code{\\musicglyph -#\"accidentals.0\"} will select the natural sign from the music font. +#\"accidentals.natural\"} will select the natural sign from the music font. See @usermanref{The Feta font} for a complete listing of the possible glyphs." (ly:font-get-glyph (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 37f965d94f..3360fbb808 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -303,16 +303,112 @@ centered, X==1 is at the right, X == -1 is at the left." (define-public darkmagenta '(0.5 0.0 0.5)) (define-public darkyellow '(0.5 0.5 0.0)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; key signature + + +(define-public (key-signature-interface::alteration-position step alter c0-position) + ;; TODO: memoize - this is mostly constant. + + ;; fes, ges, as and bes typeset in lower octave + (define FLAT_TOP_PITCH 2) + + ;; ais and bis typeset in lower octave + (define SHARP_TOP_PITCH 4) + + (if (pair? step) + (+ (cdr step) (* (car step) 7) c0-position) + (let* + ((from-bottom-pos (modulo (+ 4 49 c0-position) 7)) + (p step) + (c0 (- from-bottom-pos 4))) + + (if + (or (and (< alter 0) (or (> p FLAT_TOP_PITCH) (> (+ p c0) 4)) (> (+ p c0) 1)) + (and (> alter 0) (or (> p SHARP_TOP_PITCH) (> (+ p c0) 5)) (> (+ p c0) 2)) + ) + + ;; Typeset below c_position + (set! p (- p 7))) + + ;; Provide for the four cases in which there's a glitch + ;; it's a hack, but probably not worth + ;; the effort of finding a nicer solution. + ;; --dl. + (cond + ((and (= c0 2) (= p 3) (> alter 0)) + (set! p (- p 7))) + ((and (= c0 -3) (= p -1) (> alter 0)) + (set! p (+ p 7))) + ((and (= c0 -4) (= p -1) (< alter 0)) + (set! p (+ p 7))) + ((and (= c0 -2) (= p -3) (< alter 0)) + (set! p (+ p 7)))) + + (+ c0 p)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; accidentals + +(define-public (accidental-interface::calc-alteration grob) + (ly:pitch-alteration (ly:event-property (event-cause grob) 'pitch))) + +(define-public standard-alteration-glyph-name-alist + '((1 . "accidentals.doublesharp") + (3/4 . "accidentals.sharp.slashslash.stemstemstem") + (1/2 . "accidentals.sharp") + (1/4 . "accidentals.sharp.slashslash.stem") + (0 . "accidentals.natural") + (-1/4 . "accidentals.mirroredflat") + (-1/2 . "accidentals.flat") + (-3/4 . "accidentals.mirroredflat.flat") + (-1 . "accidentals.flatflat") + )) + +(define-public makam-alteration-glyph-name-alist + '((1 . "accidentals.doublesharp") + (8/9 . "accidentals.sharp.slashslashslash.stemstem") + (5/9 . "accidentals.sharp.slashslashslash.stem") + (4/9 . "accidentals.sharp") + (1/9 . "accidentals.sharp.slashslash.stem") + (0 . "accidentals.natural") + (-1/9 . "accidentals.mirroredflat") + (-4/9 . "accidentals.flat.slash") + (-5/9 . "accidentals.flat") + (-8/9 . "accidentals.flat.slashslash") + (-1 . "accidentals.flatflat") + )) + +(define-public alteration-hufnagel-glyph-name-alist + '((1/2 . "accidentals.hufnagel-1") + (0 . "accidentals.vaticana0") + (-1/2 . "accidentals.mensural1"))) + +(define-public alteration-medicae-glyph-name-alist + '((1/2 . "accidentals.medicaea-1") + (0 . "accidentals.vaticana0") + (-1/2 . "accidentals.mensural1"))) + +(define-public alteration-vaticana-glyph-name-alist + '((1/2 . "accidentals.vaticana-1") + (0 . "accidentals.vaticana0") + (-1/2 . "accidentals.mensural1"))) + +(define-public alteration-mensural-glyph-name-alist + '((1/2 . "accidentals.mensural-1") + (0 . "accidentals.vaticana0") + (-1/2 . "accidentals.mensural1"))) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * Pitch Trill Heads ;; * Parentheses (define-public (parentheses-item::calc-parenthesis-stencils grob) - (let* ( - (font (ly:grob-default-font grob)) + (let* ((font (ly:grob-default-font grob)) (lp (ly:font-get-glyph font "accidentals.leftparen")) - (rp (ly:font-get-glyph font "accidentals.rightparen")) - ) + (rp (ly:font-get-glyph font "accidentals.rightparen"))) (list lp rp)))