]> git.donarmstrong.com Git - lilypond.git/commitdiff
Optimizes note-heads.cc and introduces robust_symbol2string.
authorBertrand Bordage <bordage.bertrand@gmail.com>
Sat, 8 Oct 2011 22:57:00 +0000 (00:57 +0200)
committerBertrand Bordage <bordage.bertrand@gmail.com>
Tue, 18 Oct 2011 12:51:21 +0000 (14:51 +0200)
Fixes issue 1926.

lily/include/lily-guile.hh
lily/lily-guile.cc
lily/note-head.cc

index 5b766251030b901a1c515b6ac41135be9ebf583d..80842438f5aead3023f53b626b43723d07675d42 100644 (file)
@@ -54,6 +54,7 @@ string gulp_file_to_string (string fn, bool must_exist, int size);
 SCM ly_string2scm (string const &s);
 string ly_scm2string (SCM s);
 string ly_symbol2string (SCM);
+string robust_symbol2string (SCM, string);
 Rational ly_scm2rational (SCM);
 SCM ly_rational2scm (Rational);
 SCM ly_offset2scm (Offset);
index ff3f7064bf62d4666d8cc4c8193ea6b2cc8b33af..040ec45dc6a9ff5ae034a0ebd1be401118890730 100644 (file)
@@ -71,8 +71,13 @@ ly_symbol2string (SCM s)
   /*
     Ugh. this is not very efficient.
   */
-  SCM str = scm_symbol_to_string (s);
-  return ly_scm2string (str);
+  return ly_scm2string (scm_symbol_to_string (s));
+}
+
+string
+robust_symbol2string (SCM sym, string str)
+{
+  return scm_is_symbol (sym) ? ly_symbol2string (sym) : str;
 }
 
 string
index de22c1c8cd3960b829e1b04e10b607de7415ae20..b17812f98f4adc2d707877718d060a196861b116 100644 (file)
@@ -36,17 +36,11 @@ using namespace std;
 static Stencil
 internal_print (Grob *me, string *font_char)
 {
-  SCM style = me->get_property ("style");
-  if (!scm_is_symbol (style))
-    style = ly_symbol2scm ("default");
+  string style = robust_symbol2string (me->get_property ("style"), "default");
 
   string suffix = to_string (min (robust_scm2int (me->get_property ("duration-log"), 2), 2));
-  if (style != ly_symbol2scm ("default"))
-    {
-      SCM gn = me->get_property ("glyph-name");
-      if (scm_is_string (gn))
-        suffix = ly_scm2string (gn);
-    }
+  if (style != "default")
+    suffix = robust_scm2string (me->get_property ("glyph-name"), "");
 
   Font_metric *fm = Font_interface::get_default_font (me);
 
@@ -63,18 +57,29 @@ internal_print (Grob *me, string *font_char)
       if (stem_dir == CENTER)
         programming_error ("must have stem dir for note head");
 
-      idx_either = idx_directed = prefix + ((stem_dir == UP) ? "u" : "d");
+      idx_either = idx_directed = prefix + (stem_dir == UP ? "u" : "d");
+      out = fm->find_by_name (idx_either + suffix);
     }
 
-  out = fm->find_by_name (idx_either + "r" + suffix);
-  if (!out.is_empty ()
-        && !Staff_symbol_referencer::on_line
-             (me,
-              robust_scm2int (me->get_property ("staff-position"), 0)))
-      idx_either += "r";
+  if (style == "mensural"
+      || style == "neomensural"
+      || style == "petrucci"
+      || style == "baroque")
+    {
+      if (!Staff_symbol_referencer::on_line
+          (me,
+           robust_scm2int (me->get_property ("staff-position"), 0)))
+        {
+          Stencil test = fm->find_by_name (idx_either + "r" + suffix);
+          if (!test.is_empty ())
+            {
+              idx_either += "r";
+              out = test;
+            }
+        }
+    }
 
   idx_either += suffix;
-  out = fm->find_by_name (idx_either);
   if (out.is_empty ())
     {
       me->warning (_f ("none of note heads `%s' or `%s' found",