]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add -dmusic-strings-to-paths and enable for SVG backend.
authorPatrick McCarty <pnorcks@gmail.com>
Sun, 10 Jan 2010 03:25:34 +0000 (19:25 -0800)
committerPatrick McCarty <pnorcks@gmail.com>
Sun, 10 Jan 2010 19:51:22 +0000 (11:51 -0800)
* 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
lily/program-option-scheme.cc
lily/text-interface.cc
scm/lily.scm

index 1b90dcfed37be657483adf359f40d8687305b0d2..86affcd7823275492618b76fecb88719ad16b957 100644 (file)
@@ -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"),
index 86c57226d1ed734abe32c4431bac40db656bdefd..a7de8218634ccd8419106b3761efbff26b635cf2 100644 (file)
@@ -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);
 }
index 58067cffc91d016d24a0de68e6d94921d5d77e6e..3bf81c4643e31715e6fac27e1652bc2a2ac71f4a 100644 (file)
@@ -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,
index 9a152ed0aa66f3384f32644b3c16fc080f9eccc3..b72878f61b9f170ce39c0cce3cde1bac6d404148 100644 (file)
@@ -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)