2008/9/14 Kieren MacMillan <[EMAIL PROTECTED]>: > But why wouldn't (i.e., doesn't) this work? > > \layout > { > \context > { > \Score > pedalSustainStrings = #'("Ped." "*Ped." (markup #:lower 0.45 > "*") ) > } > }
Unfortunately, the strings in this list are only used to build up the glyph names. Whenever there's a match, the glyph is retrieved from the font via lookup. For example, in the case of "Ped.", the string is parsed into "Ped" and ".", building up glyph names "pedal.Ped" and "pedal.." (the individual glyphs for the letters for "Ped" aren't used together since they have no kerning). It's pretty straightforward to hack support for markup, but I suspect the pedal code needs a complete rewrite to use markup exclusively. Attached is a patch which allows markup to be used, though I'm not sure that it's a satisfactory solution since it's a bit dubious having to check whether something's a string before checking for markup. The png was produced using the following override: pedalSustainStrings = #(list "Ped" (markup #:lower 0.45 (#:teeny #:musicglyph "pedal.*") #:bracket #:musicglyph "pedal.Ped") (markup #:lower 0.45 #:huge #:musicglyph "pedal.*")) Regards, Neil
From 064d3724b88e6a8b82dc2b5e0c4d9a3b50250fde Mon Sep 17 00:00:00 2001 From: Neil Puttock <[EMAIL PROTECTED]> Date: Sun, 14 Sep 2008 18:35:15 +0100 Subject: [PATCH] Piano pedal markup test --- lily/piano-pedal-engraver.cc | 3 ++- lily/sustain-pedal.cc | 38 ++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index b3021cb..d99fb54 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -22,6 +22,7 @@ #include "staff-symbol-referencer.hh" #include "stream-event.hh" #include "string-convert.hh" +#include "text-interface.hh" #include "warn.hh" #include "spanner.hh" #include "item.hh" @@ -322,7 +323,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) s = scm_car (strings); } - if (scm_is_string (s)) + if (Text_interface::is_markup (s)) { const char *propname = p->type_->pedal_c_str_; diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc index 8056ea8..6ca6c6e 100644 --- a/lily/sustain-pedal.cc +++ b/lily/sustain-pedal.cc @@ -8,6 +8,8 @@ #include "grob.hh" #include "stencil.hh" #include "font-interface.hh" +#include "output-def.hh" +#include "text-interface.hh" // update comment --hwn /* @@ -41,26 +43,34 @@ Sustain_pedal::print (SCM smob) Stencil mol; SCM glyph = e->get_property ("text"); - if (!scm_is_string (glyph)) - return mol.smobbed_copy (); + + if (scm_is_string (glyph)) + { - string text = ly_scm2string (glyph); + string text = ly_scm2string (glyph); - for (ssize i = 0; i < text.length (); i++) - { - string idx ("pedal."); - if (text.substr (i, 3) == "Ped") + for (ssize i = 0; i < text.length (); i++) { - idx += "Ped"; - i += 2; + string idx ("pedal."); + if (text.substr (i, 3) == "Ped") + { + idx += "Ped"; + i += 2; + } + else + idx += string (&text.c_str ()[i], 1); + Stencil m = Font_interface::get_default_font (e)->find_by_name (idx); + if (!m.is_empty ()) + mol.add_at_edge (X_AXIS, RIGHT, m, 0); } - else - idx += string (&text.c_str ()[i], 1); - Stencil m = Font_interface::get_default_font (e)->find_by_name (idx); - if (!m.is_empty ()) - mol.add_at_edge (X_AXIS, RIGHT, m, 0); } + else if (Text_interface::is_markup (glyph)) + { + SCM chain = Font_interface::text_font_alist_chain (e); + return Text_interface::interpret_markup (e->layout ()->self_scm (), + chain, glyph); + } return mol.smobbed_copy (); } -- 1.5.4.3
<<attachment: pedal_markup.png>>
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user