From 3946ec28c96dfea91fb95946b340706c341e5169 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Sat, 9 Jan 2010 19:25:34 -0800 Subject: [PATCH] Add -dmusic-strings-to-paths and enable for SVG backend. * Using a -dmusic-strings-to-paths option generalizes the check (lily/pango-font.cc) to see if the "utf-8-string" stencil expression should be used for a backend. * Enable the new option only if it's found in a list of supported backends (scm/lily.scm). Currently, only the SVG backend supports this. In the future, more backends might support this option. * Update comments. --- lily/pango-font.cc | 28 ++++++++++++++++------------ lily/program-option-scheme.cc | 6 ++++++ lily/text-interface.cc | 7 +++---- scm/lily.scm | 8 ++++++++ 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 1b90dcfed3..86affcd782 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -300,20 +300,22 @@ Pango_font::physical_font_tab () const } Stencil -Pango_font::word_stencil (string str, bool feta) const +Pango_font::word_stencil (string str, bool music_string) const { - return text_stencil (str, feta, true); + return text_stencil (str, music_string, true); } Stencil -Pango_font::text_stencil (string str, bool feta) const +Pango_font::text_stencil (string str, bool music_string) const { - return text_stencil (str, feta, false); + return text_stencil (str, music_string, false); } +extern bool music_strings_to_paths; + Stencil Pango_font::text_stencil (string str, - bool feta, + bool music_string, bool tight) const { /* @@ -367,21 +369,23 @@ Pango_font::text_stencil (string str, SCM utf8_string = ly_module_lookup (mod, ly_symbol2scm ("utf-8-string")); /* has_utf8_string should only be true when utf8_string is a - variable that is bound to a *named* procedure. + variable that is bound to a *named* procedure, i.e. not a + lambda expression. */ if (utf8_string != SCM_BOOL_F && scm_procedure_name (SCM_VARIABLE_REF (utf8_string)) != SCM_BOOL_F) has_utf8_string = true; } - /* - The SVG backend only uses utf-8-string for the non-music - fonts, hence the check here. --pmccarty + bool to_paths = music_strings_to_paths; - TODO: use a program option (-dmusic-strings-to-paths) here - instead that is enabled only when -dbackend=svg. + /* + Backends with the utf-8-string expression use it when + 1) the -dmusic-strings-to-paths option is set + and `str' is not a music string, or + 2) the -dmusic-strings-to-paths option is not set. */ - if ((name == "svg" && !feta) || (name != "svg" && has_utf8_string)) + if (has_utf8_string && ((to_paths && !music_string) || !to_paths)) { // For Pango based backends, we take a shortcut. SCM exp = scm_list_3 (ly_symbol2scm ("utf-8-string"), diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 86c57226d1..a7de821863 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -34,6 +34,7 @@ bool debug_skylines; bool debug_property_callbacks; bool debug_page_breaking_scoring; +bool music_strings_to_paths; bool relative_includes; /* @@ -126,6 +127,11 @@ internal_set_option (SCM var, } else if (var == ly_symbol2scm ("warning-as-error")) val = scm_from_bool (to_boolean (val)); + else if (var == ly_symbol2scm ("music-strings-to-paths")) + { + music_strings_to_paths = to_boolean (val); + val = scm_from_bool (to_boolean (val)); + } scm_hashq_set_x (option_hash, var, val); } diff --git a/lily/text-interface.cc b/lily/text-interface.cc index 58067cffc9..3bf81c4643 100644 --- a/lily/text-interface.cc +++ b/lily/text-interface.cc @@ -66,10 +66,9 @@ Text_interface::interpret_string (SCM layout_smob, replace_whitespace (&str); /* - We want to use "glyph-string" in the SVG backend for all - music fonts (Emmentaler and Aybabtu) that pass through the - text interface. Here the font encoding is checked to see if - it matches one of the music font encodings. --pmccarty + We want to filter strings with a music font that pass through + the text interface. Here the font encoding is checked to see + if it matches one of the music font encodings. --pmccarty */ SCM encoding = ly_chain_assoc_get (ly_symbol2scm ("font-encoding"), props, diff --git a/scm/lily.scm b/scm/lily.scm index 9a152ed0aa..b72878f61b 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -115,6 +115,9 @@ output to log file `FOO.log'.") "midi") "Set the default file extension for MIDI output file to given string.") + (music-strings-to-paths #f +"Convert text strings to paths when glyphs belong +to a music font.") (old-relative #f "Make \\relative mode for simultaneous music work similar to chord syntax.") @@ -245,6 +248,11 @@ messages into errors.") (define-public parser #f) +(define music-string-to-path-backends + '(svg)) + +(if (memq (ly:get-option 'backend) music-string-to-path-backends) + (ly:set-option 'music-strings-to-paths #t)) ;; gettext wrapper for guile < 1.7.2 (if (defined? 'gettext) -- 2.39.5