From e5a20d8eb32e2ed42f8fecfae3b35df505552fea Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 13 Sep 2002 21:13:48 +0000 Subject: [PATCH] 2002-09-13 Juergen Reuter * lily/rests.ly: added comment on bogus warnings about missing flags * lily/clef.cc, lily/rests.cc: added warning when font character lookup fails. * lily/rests.cc: workaround: consider missing ledgered rests in ancient font. * lily/rests.cc: bugfix: cleaned up font lookup code that handles special cases of styles 'default' and 'classical'. This should also fix the behaviour of lily/multi-measure-rest.cc, which so far did not consider styles 'default' and 'classical'. --- ChangeLog | 15 ++++++++++ input/test/rests.ly | 6 +++- lily/clef.cc | 21 +++++++------ lily/rest.cc | 73 ++++++++++++++++++++++++++++++++------------- 4 files changed, 84 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8388bff455..1689e41a70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-09-13 Juergen Reuter + + * lily/rests.ly: added comment on bogus warnings about missing flags + + * lily/clef.cc, lily/rests.cc: added warning when font character + lookup fails. + + * lily/rests.cc: workaround: consider missing ledgered rests in + ancient font. + + * lily/rests.cc: bugfix: cleaned up font lookup code that handles + special cases of styles 'default' and 'classical'. This should + also fix the behaviour of lily/multi-measure-rest.cc, which so far + did not consider styles 'default' and 'classical'. + 2002-09-13 Rune Zedeler * scm/drums.scm: "set" the automatic properties instead of diff --git a/input/test/rests.ly b/input/test/rests.ly index 8b408d46ce..a1aa622d30 100644 --- a/input/test/rests.ly +++ b/input/test/rests.ly @@ -3,6 +3,10 @@ texidoc = "rests in various styles." } +% FIXME: Currently, this file produces "warning: flag `d-3' not found" +% errors (and similar for "d7") from Stem::flag(). This is should not +% happen, since there are no notes/stems in this example. + \score { \context Staff \notes\relative c { \property Staff.Rest \set #'style = #'mensural @@ -28,7 +32,7 @@ \paper { \translator { \StaffContext - %%%% The following looks good, but produces + %%%% FIXME: The following looks good, but produces %%%% lots of warnings: % \remove Bar_engraver } diff --git a/lily/clef.cc b/lily/clef.cc index 9a2eec2e3a..062d7b81ef 100644 --- a/lily/clef.cc +++ b/lily/clef.cc @@ -19,7 +19,7 @@ MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1); SCM Clef::before_line_breaking (SCM smob) { - Item * s = unsmob_item (smob); + Item *s = unsmob_item (smob); SCM glyph = s->get_grob_property ("glyph-name"); @@ -51,16 +51,19 @@ MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1) SCM Clef::brew_molecule (SCM smob) { - Grob * sc = unsmob_grob (smob); - SCM glyph = sc->get_grob_property ("glyph-name"); - if (gh_string_p (glyph)) - { - return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy (); - } - else + Grob *me = unsmob_grob (smob); + SCM glyph_scm = me->get_grob_property ("glyph-name"); + if (!gh_string_p (glyph_scm)) + return SCM_EOL; + + String glyph = String (ly_scm2string (glyph_scm)); + Font_metric *fm = Font_interface::get_default_font (me); + Molecule out = fm->find_by_name (glyph); + if (out.empty_b()) { - return SCM_EOL; + me->warning (_f ("clef `%s' not found", glyph.to_str0 ())); } + return out.smobbed_copy (); } diff --git a/lily/rest.cc b/lily/rest.cc index 9cdd9078c7..4f135a31ca 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -48,11 +48,10 @@ Rest::after_line_breaking (SCM smob) /* make this function easily usable in C++ */ - String -Rest::glyph_name (Grob * me, int balltype, String style) +Rest::glyph_name (Grob *me, int balltype, String style) { - bool ledger_b =false; + bool ledgered_b = false; if (balltype == 0 || balltype == 1) { @@ -63,18 +62,49 @@ Rest::glyph_name (Grob * me, int balltype, String style) Figure out when the rest is far enough outside the staff. This could bemore generic, but hey, we understand this even after dinner. - */ - ledger_b = ledger_b || (balltype == 0 && (pos >= rad +2 || pos < -rad )); - ledger_b = ledger_b || (balltype == 1 && - (pos <= -rad -2 || pos > rad)); + ledgered_b |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad); + ledgered_b |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad); } - return ("rests-") + to_string (balltype) - + (ledger_b ? "o" : "") + style; -} + String actual_style (style.to_str0 ()); + + if ((style == "mensural") || (style == "neo_mensural")) { + + /* + FIXME: Currently, ancient font does not provide ledgered rests; + hence the "o" suffix in the glyph name is bogus. But do we need + ledgered rests at all now that we can draw ledger lines with + variable width, length and blotdiameter? -- jr + */ + ledgered_b = 0; + + /* + There are no 32th/64th/128th mensural/neo_mensural rests. In + these cases, revert back to default style. + */ + if (balltype > 4) + actual_style = ""; + } + + if ((style == "classical") && (balltype != 2)) { + /* + classical style: revert back to default style for any rest other + than quarter rest + */ + actual_style = ""; + } + if (style == "default") { + /* + Some parts of lily still prefer style "default" over "". + Correct this here. -- jr + */ + actual_style = ""; + } + return ("rests-") + to_string (balltype) + (ledgered_b ? "o" : "") + actual_style; +} MAKE_SCHEME_CALLBACK (Rest,brew_molecule,1); @@ -91,20 +121,21 @@ Rest::brew_internal_molecule (SCM smob) int balltype = gh_scm2int (balltype_scm); String style; - SCM style_sym =me->get_grob_property ("style"); - if (gh_symbol_p (style_sym)) + SCM style_scm = me->get_grob_property ("style"); + if (gh_symbol_p (style_scm)) { - style = ly_scm2string (scm_symbol_to_string (style_sym)); + style = ly_scm2string (scm_symbol_to_string (style_scm)); } - for(;;) { - String idx = glyph_name (me, balltype, style); - Molecule res = Font_interface::get_default_font (me)->find_by_name (idx); - if(res.empty_b() && style!="") - style=""; - else - return res.smobbed_copy(); - } + Font_metric *fm = Font_interface::get_default_font (me); + String font_char = glyph_name (me, balltype, style); + Molecule out = fm->find_by_name (font_char); + if (out.empty_b()) + { + me->warning (_f ("rest `%s' not found, ", font_char.to_str0 ())); + } + + return out.smobbed_copy(); } SCM -- 2.39.5