From a38e1cd80471b41ba2cd0f52608db031472d4867 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 30 Dec 2006 13:43:32 +0100 Subject: [PATCH] Use glyph-name-alist in cancellations, more verbose error message. --- lily/key-signature-interface.cc | 11 +++++++++-- scm/define-grobs.scm | 1 + scm/output-lib.scm | 18 +++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 8351696f30..bea2aafbc7 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -15,11 +15,11 @@ #include "lookup.hh" #include "output-def.hh" #include "staff-symbol-referencer.hh" +#include "rational.hh" struct Key_signature_interface { DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); }; @@ -62,10 +62,17 @@ Key_signature_interface::print (SCM smob) for (SCM s = me->get_property ("alteration-alist"); scm_is_pair (s); s = scm_cdr (s)) { SCM alt = is_cancellation - ? scm_from_int (0) + ? scm_from_int (0) : scm_cdar (s); SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F); + if (!scm_is_string (glyph_name)) + { + me->warning (_f ("No glyph found for alteration: %s", + ly_scm2rational (alt).to_string ().c_str ())); + continue; + } + Stencil acc (fm->find_by_name (ly_scm2string (glyph_name))); if (acc.is_empty ()) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index da5bdcd100..c4246b6589 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -797,6 +797,7 @@ (KeyCancellation . ( (stencil . ,ly:key-signature-interface::print) + (glyph-name-alist . ,cancellation-glyph-name-alist) (space-alist . ( (time-signature . (extra-space . 1.25)) (staff-bar . (extra-space . 0.6)) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 3360fbb808..42ec6932e7 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -354,16 +354,24 @@ centered, X==1 is at the right, X == -1 is at the left." (define-public (accidental-interface::calc-alteration grob) (ly:pitch-alteration (ly:event-property (event-cause grob) 'pitch))) + +(define-public cancellation-glyph-name-alist + '((0 . "accidentals.natural"))) + (define-public standard-alteration-glyph-name-alist - '((1 . "accidentals.doublesharp") - (3/4 . "accidentals.sharp.slashslash.stemstemstem") + '( + ;; ordered for optimal performance. + (0 . "accidentals.natural") + (-1/2 . "accidentals.flat") (1/2 . "accidentals.sharp") + + (1 . "accidentals.doublesharp") + (-1 . "accidentals.flatflat") + + (3/4 . "accidentals.sharp.slashslash.stemstemstem") (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 -- 2.39.5