]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/vaticana-ligature-engraver.cc: bugfix: fixed programming
authorJürgen Reuter <j@web.de>
Mon, 8 Sep 2003 23:08:10 +0000 (23:08 +0000)
committerJürgen Reuter <j@web.de>
Mon, 8 Sep 2003 23:08:10 +0000 (23:08 +0000)
error message "flexa-width undefined"

* lily/vaticana-ligature-engraver.cc, lily/gregorian-ligature.cc,
lily/include/gregorian-ligature.hh: print warning when ignoring
head prefixes on flexa shapes

* lily/vaticana-ligature-engraver.cc: bugfix: always add an extra
space before a series of inclinatum heads

* lily/vaticana-ligature-engraver.cc, lily/gregorian-ligature.cc,
lily/include/gregorian-ligature.hh: junked AFTER_VIRGA; small
cleanups

* mf/parmesan-custodes.mf: redesigned custos; fixed stem length
and char_box

ChangeLog
lily/gregorian-ligature-engraver.cc
lily/gregorian-ligature.cc
lily/include/gregorian-ligature.hh
lily/vaticana-ligature-engraver.cc
lily/vaticana-ligature.cc
mf/parmesan-custodes.mf

index 2da34855b2ffc1b2f951077a149661e900cc7617..f9b5f0ae2ca2d79cce1f7de355472b4f0eb14051 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-09-09  Juergen Reuter  <reuter@ipd.uka.de>
+
+       * lily/vaticana-ligature-engraver.cc: bugfix: fixed programming
+       error message "flexa-width undefined"
+
+       * lily/vaticana-ligature-engraver.cc, lily/gregorian-ligature.cc,
+       lily/include/gregorian-ligature.hh: print warning when ignoring
+       head prefixes on flexa shapes
+
+       * lily/vaticana-ligature-engraver.cc: bugfix: always add an extra
+       space before a series of inclinatum heads
+
+       * lily/vaticana-ligature-engraver.cc, lily/gregorian-ligature.cc,
+       lily/include/gregorian-ligature.hh: junked AFTER_VIRGA; small
+       cleanups
+
+       * mf/parmesan-custodes.mf: redesigned custos; fixed stem length
+       and char_box
+
 2003-09-08  Juergen Reuter  <reuter@ipd.uka.de>
 
        * input/regression/breathing-sign.ly: tiny fixes
index 7b79ac258ff373cd2c397e98ccc01aaaeea1604c..b1c1a826baf0ec230f51d050dabba46e3d1fb57c 100644 (file)
@@ -223,10 +223,6 @@ provide_context_info (Array<Grob_info> primitives)
          primitive->warning ("may not apply `\\~' on heads with "
                              "identical pitch; ignoring `\\~'");
        }
-    if (prev_prefix_set & VIRGA)
-      {
-       context_info |= AFTER_VIRGA;
-      }
     if (prev_prefix_set & DEMINUTUM)
       {
        context_info |= AFTER_DEMINUTUM;
index 7b5cfc221a266f4786284578f9495adb507619f9..8e6f7194c7aa9bf097b6bf5d30df3f161c331928 100644 (file)
@@ -6,15 +6,46 @@
   (c) 2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include "grob.hh"
+#include "gregorian-ligature.hh"
+#include "string.hh"
 
-class Gregorian_ligature {
-public:
-  static bool has_interface (Grob *);
-};
+void check_prefix (String name, int mask, int prefix_set, String *str)
+{
+  if (prefix_set & mask)
+    {
+      if (!str->empty_b ())
+       *str += ", ";
+      *str += name;
+    }
+}
 
+String
+Gregorian_ligature::prefixes_to_str (Grob *primitive)
+{
+  String str;
+  int prefix_set =
+    gh_scm2int (primitive->get_grob_property ("prefix-set"));
+  check_prefix ("virga", VIRGA, prefix_set, &str);
+  check_prefix ("stropha", STROPHA, prefix_set, &str);
+  check_prefix ("inclinatum", INCLINATUM, prefix_set, &str);
+  check_prefix ("auctum", AUCTUM, prefix_set, &str);
+  check_prefix ("descendens", DESCENDENS, prefix_set, &str);
+  check_prefix ("ascendens", ASCENDENS, prefix_set, &str);
+  check_prefix ("oriscus", ORISCUS, prefix_set, &str);
+  check_prefix ("quilisma", QUILISMA, prefix_set, &str);
+  check_prefix ("deminutum", DEMINUTUM, prefix_set, &str);
+  check_prefix ("cavum", CAVUM, prefix_set, &str);
+  check_prefix ("linea", LINEA, prefix_set, &str);
+  return str;
+}
 
 /*
-  CHECK ME -- does prefix-set come from here ? 
+  CHECK ME -- does prefix-set come from here ?
+
+  In a way, yes.  Actually, prefix-set is a property that is written
+  by code of GregorianLigatureEngraver that is virtually invoked by a
+  subclass like VaticanaLigatureEngraver.  The property is lateron
+  read by the associated item class, such as VaticanaLigature.--jr
  */
 ADD_INTERFACE (Gregorian_ligature, "gregorian-ligature-interface",
               "A gregorian ligature",
index 299c37833c9c9ac5c215cbfe5e1f6d2c41744f2e..2540f1bf71be4b414a7ae7bfb3d538770cf7a90c 100644 (file)
@@ -9,6 +9,12 @@
 #ifndef GREGORIAN_LIGATURE_HH
 #define GREGORIAN_LIGATURE_HH
 
+class Gregorian_ligature {
+public:
+  static bool has_interface (Grob *);
+  static String prefixes_to_str (Grob *);
+};
+
 /*
  * Head prefixes: these bit-mask constants are used to represent
  * attributes immediately derived from user input (e.g. by the user
@@ -46,7 +52,6 @@
                               // descending melody
 #define FLEXA_RIGHT     0x0008 // this is a head after "\~" in a
                               // descending melody
-#define AFTER_VIRGA     0x0010 // previous head was a virga
 #define AFTER_DEMINUTUM 0x0020 // previous head was a deminutum
 
 #endif /* GREGORIAN_LIGATURE_HH */
index 9e655406c4a2499e91ca3ab780d5427a64b57f65..cf960ca8bf00ca5af6eafb05d181d2744c0557f2 100644 (file)
@@ -92,20 +92,48 @@ Vaticana_ligature_engraver::is_stacked_head (int prefix_set,
       return is_stacked_b;
 }
 
-inline int get_context_info (Item *primitive)
+/*
+ * When aligning the heads, sometimes extra space is needed, e.g. to
+ * avoid clashing with the appendix of an adjacent notehead or with an
+ * adjacent notehead itself if it has the same pitch.  Extra space is
+ * added at most once between to heads.
+ */
+bool
+need_extra_space (int prev_prefix_set, int prefix_set,
+                 int context_info, int delta_pitch)
 {
-  SCM context_info_scm = primitive->get_grob_property ("context-info");
-  if (context_info_scm != SCM_EOL)
-    {
-      return gh_scm2int (context_info_scm);
-    }
-  else
-    {
-      primitive->programming_error ("Vaticana_ligature:"
-                                   "context-info undefined -> "
-                                   "aborting ligature");
-      return -1;
-    }
+  if (prev_prefix_set & VIRGA)
+    /*
+     * After a virga, make a an additional small space such that the
+     * appendix on the right side of the head does not touch the
+     * following head.
+     */
+    return true;
+
+  if ((prefix_set & INCLINATUM) &&
+          !(prev_prefix_set & INCLINATUM))
+    /*
+     * Always start a series of inclinatum heads with an extra space.
+     */
+    return true;
+
+  if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER))
+    /*
+     * Before a flexa (but not within a torculus), make a an
+     * additional small space such that the appendix on the left side
+     * of the flexa does not touch the this head.
+     */
+    return true;
+
+  if (delta_pitch == 0)
+    /*
+     * If there are two adjacent noteheads with the same pitch, add
+     * additional small space between them, such that they do not
+     * touch each other.
+     */
+    return true;
+
+  return false;
 }
 
 Real
@@ -143,13 +171,14 @@ Vaticana_ligature_engraver::align_heads (Array<Grob_info> primitives,
   Real ligature_width = 0.0;
 
   Item *prev_primitive = 0;
+  int prev_prefix_set = 0;
   for (int i = 0; i < primitives.size (); i++)
     {
       Item *primitive = dynamic_cast<Item*> (primitives[i].grob_);
-      int context_info;
-
-      if ((context_info = get_context_info (primitive)) < 0)
-       break; // programming error
+      int prefix_set =
+       gh_scm2int (primitive->get_grob_property ("prefix-set"));
+      int context_info =
+       gh_scm2int (primitive->get_grob_property ("context-info"));
 
       /*
        * Get glyph_name, delta_pitch and context_info for this head.
@@ -267,37 +296,9 @@ Vaticana_ligature_engraver::align_heads (Array<Grob_info> primitives,
           */
        }
 
-      /* Sometimes, extra space is needed, e.g. to avoid clashing with
-        the appendix of an adjacent notehead or with an adjacent
-        notehead itself if it has the same pitch. */
-
-      if (context_info & AFTER_VIRGA)
-       {
-         /*
-          * After a virga, make a an additional small space such that
-          * the appendix on the right side of the head does not touch
-          * the following head.
-          */
-         ligature_width += extra_space;
-       }
-      else if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER))
-       {
-         /*
-          * Before a flexa (but not within a torculus), make a an
-          * additional small space such that the appendix on the left
-          * side of the flexa does not touch the this head.
-          */
-         ligature_width += extra_space;
-       }
-      else if (delta_pitch == 0)
-       {
-         /*
-          * If there are two adjacent noteheads with the same pitch,
-          * add additional small space between them, such that they
-          * do not touch each other.
-          */
-         ligature_width += extra_space;
-       }
+      if (need_extra_space (prev_prefix_set, prefix_set,
+                           context_info, delta_pitch))
+       ligature_width += extra_space;
 
       /*
        * Horizontally line-up this head to form a ligature.
@@ -307,6 +308,7 @@ Vaticana_ligature_engraver::align_heads (Array<Grob_info> primitives,
       ligature_width += head_width;
 
       prev_primitive = primitive;
+      prev_prefix_set = prefix_set;
     }
 
   /*
@@ -318,6 +320,31 @@ Vaticana_ligature_engraver::align_heads (Array<Grob_info> primitives,
   return ligature_width;
 }
 
+/*
+ * Depending on the typographical features of a particular ligature
+ * style, some prefixes may be ignored.  In particular, if a curved
+ * flexa shape is produced, any prefixes to either of the two
+ * contributing heads that would select a head other than punctum, is
+ * by definition ignored.
+ *
+ * This function prints a warning, if the given primitive is prefixed
+ * such that a head other than punctum would be chosen, if this
+ * primitive were engraved as a stand-alone head.
+ */
+void
+check_for_prefix_loss (Item *primitive)
+{
+  int prefix_set =
+    gh_scm2int (primitive->get_grob_property ("prefix-set"));
+  if (prefix_set & ~PES_OR_FLEXA)
+    {
+      String prefs = Gregorian_ligature::prefixes_to_str (primitive);
+      primitive->warning (_f ("ignored prefix(es) `%s' of this head according "
+                             "to restrictions of the selected ligature style",
+                             prefs.to_str0 ()));
+    }
+}
+
 void
 Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
                                             Array<Grob_info> primitives)
@@ -498,7 +525,7 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
      */
     if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER))
       {
-       glyph_name = "";
+       check_for_prefix_loss (prev_primitive);
        prev_glyph_name = "flexa";
        prev_primitive->set_grob_property ("flexa-height",
                                           gh_int2scm (prev_delta_pitch));
@@ -507,6 +534,10 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
        bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA);
        prev_primitive->set_grob_property ("add-cauda",
                                           gh_bool2scm (add_cauda));
+       check_for_prefix_loss (primitive);
+       glyph_name = "";
+       primitive->set_grob_property ("flexa-width",
+                                     gh_double2scm (flexa_width));
       }
 
     /*
index d4b3b66089c70ee12234c7fbf4a00bf7d4338410..d712bfcd86ccab4d5bbcb91058773f2ddd5288b1 100644 (file)
@@ -100,7 +100,7 @@ vaticana_brew_flexa (Grob *me,
     }
   else
     {
-      me->warning ("Vaticana_ligature:"
+      me->warning ("Vaticana_ligature: "
                   "flexa-width undefined; assuming 2.0");
       width = 2.0 * staff_space;
     }
@@ -229,8 +229,8 @@ vaticana_brew_primitive (Grob *me, bool ledger_take_space)
   SCM glyph_name_scm = me->get_grob_property ("glyph-name");
   if (glyph_name_scm == SCM_EOL)
     {
-      programming_error ("Vaticana_ligature:"
-                        "undefined glyph-name -> ignoring grob");
+      me->programming_error ("Vaticana_ligature: "
+                            "undefined glyph-name -> ignoring grob");
       return Molecule ();
     }
 
@@ -275,9 +275,8 @@ vaticana_brew_primitive (Grob *me, bool ledger_take_space)
     }
   else
     {
-      programming_error (_f ("Vaticana_ligature:"
-                            "x-offset undefined; assuming 0.0",
-                            me));
+      me->programming_error ("Vaticana_ligature: "
+                            "x-offset undefined; assuming 0.0");
     }
 
   bool add_stem = to_boolean (me->get_grob_property ("add-stem"));
@@ -302,7 +301,7 @@ vaticana_brew_primitive (Grob *me, bool ledger_take_space)
        }
       else
        {
-         me->warning ("Vaticana_ligature:"
+         me->warning ("Vaticana_ligature: "
                       "flexa-width undefined; assuming 2.0");
          flexa_width = 2.0 * staff_space;
        }
index 6c763199574b15bb153a351ddf66d0d14d1efa06..50bd8da70cf079ef192db5a65e28e0e8e7abaa06 100644 (file)
@@ -201,29 +201,39 @@ def custos_vaticana(expr verbose_name, internal_name, ly_name,
                wd# = 0.4a# / a_w;
                black_notehead_width# := wd#;
 
-               save stem_size;
+               save offs, stem_size, stem_end, penwidth;
                if staffline_adjustment = between_staff_lines:
-                       stem_size = 0.60;
+                       stem_size# = 1.00;
                elseif staffline_adjustment = on_staff_line:
-                       stem_size = 1.10;
+                       stem_size# = 1.50;
                else: % staffline_adjustment = anywhere
-                       stem_size = 0.85;
+                       stem_size# = 0.85;
+               fi;
+               offs# = direction*0.05ht#;
+               stem_end# = direction*stem_size#*staff_space#;
+
+               define_pixels(offs, stem_end, ht, wd);
+
+               pickup pencircle scaled 0.6stafflinethickness;
+               z1 = (0, offs);
+               z2 = (0.7wd, -offs);
+               z3 = (wd, -offs);
+               penpos1(0.6ht, 90);
+               penpos2(0.6ht, 90);
+               penpos3(0.6ht, 90);
+               penstroke z1e{z2 - z1} .. {right}z2e .. z3e;
+
+               rt x4 = wd;
+               bot y4 = 0;
+               x5 = x4;
+               top y5 = stem_end;
+               draw z4 -- z5;
+
+               if direction > 0:
+                       set_char_box(0, wd#, offs#+0.3ht#, stem_end#);
+               else:
+                       set_char_box(0, wd#, -stem_end#, offs#+0.3ht#);
                fi;
-
-               define_pixels(ht, wd);
-               pickup pencircle scaled stafflinethickness;
-
-               z1 = (0.0wd, +direction*0.05ht);
-               z2 = (1.0wd + 0.5stafflinethickness, 0.0ht);
-               penpos1(0.5ht, 90);
-               penpos2(0.5ht, 90);
-               penstroke z1e{z2 - z1} .. {right}z2e;
-
-               z3=(1.0wd, +0.0ht);
-               z4=(1.0wd, +direction*stem_size*ht);
-               draw z3 -- z4;
-
-               set_char_box(0, wd#, 0.3 ht#, 0.3 ht#);
 
        fet_endchar;
 enddef;