From 991ae63f004c2d5ca5620371ef633ca6db4ef82f Mon Sep 17 00:00:00 2001
From: reuter <reuter>
Date: Wed, 27 Apr 2005 23:45:43 +0000
Subject: [PATCH] 	* lily/vaticana-ligature-engraver.cc
 (need_extra_space): renamed 	to need_extra_horizontal_space; bugfix: use
 class scope to avoid 	global namespace pollution

	* Documentation/user/instrument-notation.itely (ligatures): added
	comment on possible future syntax change and how to work around

	* lily/vaticana-ligature-engraver.cc, mf/parmesan-heads.mf
	(epiphonus, cephalicus): fine-tune shape of plica head for narrow
	intervals (fixes agnus dei example)

	* lily/include/mensural-ligature.hh: make comments clearer

	* lily/mensural-ligature.cc: line thickness of flexa shape
	(originally by Pal Benko; slightly modified)

	* Documentation/user/instrument-notation.itely (white mensural
	ligatures): selected a more illustrative example
---
 ChangeLog                                    | 21 ++++++++
 Documentation/user/instrument-notation.itely | 37 +++++++++++----
 lily/include/mensural-ligature.hh            | 15 +++---
 lily/mensural-ligature.cc                    | 38 ++++++++++-----
 lily/vaticana-ligature-engraver.cc           | 39 +++++++++++----
 mf/parmesan-heads.mf                         | 50 +++++++++++++-------
 6 files changed, 145 insertions(+), 55 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1dc5a5fb16..3e18532e9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2005-04-28  Jürgen Reuter  <reuter@ipd.uka.de>
+
+	* lily/vaticana-ligature-engraver.cc (need_extra_space): renamed
+	to need_extra_horizontal_space; bugfix: use class scope to avoid
+	global namespace pollution
+
+	* Documentation/user/instrument-notation.itely (ligatures): added
+	comment on possible future syntax change and how to work around
+
+	* lily/vaticana-ligature-engraver.cc, mf/parmesan-heads.mf
+	(epiphonus, cephalicus): fine-tune shape of plica head for narrow
+	intervals (fixes agnus dei example)
+
+	* lily/include/mensural-ligature.hh: make comments clearer
+
+	* lily/mensural-ligature.cc: line thickness of flexa shape
+	(originally by Pal Benko; slightly modified)
+
+	* Documentation/user/instrument-notation.itely (white mensural
+	ligatures): selected a more illustrative example
+
 2005-04-28  Heikki Junes <hjunes@cc.hut.fi>
 
 	* Documentation/index.html.in: specify utf-8 charset in meta content.
diff --git a/Documentation/user/instrument-notation.itely b/Documentation/user/instrument-notation.itely
index 4f42e35b41..88accd1769 100644
--- a/Documentation/user/instrument-notation.itely
+++ b/Documentation/user/instrument-notation.itely
@@ -2682,6 +2682,15 @@ be collected and printed in front of it.
 
 Augmentum dots within ligatures are not handled correctly.
 
+The syntax still uses the deprecated infix style @code{\[ music expr
+\]}.  For consistency reasons, it will eventually be changed to
+postfix style @code{note\[ ... note\]}.  Alternatively, the file
+@file{gregorian@/-init@/.ly} can be included; it provides a scheme
+function
+@example
+\ligature @var{music expr}
+@end example
+with the same effect and is believed to be stable.
 
 @menu
 * White mensural ligatures::    
@@ -2727,9 +2736,13 @@ For example,
 \override NoteHead #'style = #'neomensural
 \override Staff.TimeSignature #'style = #'neomensural
 \clef "petrucci-g"
-\[ g\longa c\breve a\breve f\breve d'\longa \]
+\[ c'\maxima g \]
+s4
+\[ d\longa c\breve f e d \]
+s4
+\[ c'\maxima d'\longa \]
 s4
-\[ e1 f1 a\breve g\longa \]
+\[ e'1 a g\breve \]
 @end example
 @lilypond[quote,raggedright]
 \score {
@@ -2739,9 +2752,13 @@ s4
     \override NoteHead #'style = #'neomensural
     \override Staff.TimeSignature #'style = #'neomensural
     \clef "petrucci-g"
-    \[ g\longa c\breve a\breve f\breve d'\longa \]
+    \[ c'\maxima g \]
     s4
-    \[ e1 f1 a\breve g\longa \]
+    \[ d\longa c\breve f e d \]
+    s4
+    \[ c'\maxima d'\longa \]
+    s4
+    \[ e'1 a g\breve \]
   }
   \layout {
     \context {
@@ -2764,16 +2781,20 @@ to the following
   \override NoteHead #'style = #'neomensural
   \override Staff.TimeSignature #'style = #'neomensural
   \clef "petrucci-g"
-  \[ g\longa c\breve a\breve f\breve d'\longa \]
+  \[ c'\maxima g \]
+  s4
+  \[ d\longa c\breve f e d \]
+  s4
+  \[ c'\maxima d'\longa \]
   s4
-  \[ e1 f1 a\breve g\longa \]
+  \[ e'1 a g\breve \]
 }
 @end lilypond
 
 @refbugs
 
-The implementation is experimental.  It may output strange warnings,
-incorrect results, and might even crash on more complex ligatures.
+The invisible rests (@code{s4}) in the example are used to compensate
+for the poor horizontal spacing.
 
 @node Gregorian square neumes ligatures
 @subsubsection Gregorian square neumes ligatures
diff --git a/lily/include/mensural-ligature.hh b/lily/include/mensural-ligature.hh
index 55c0625667..3146dfc3bf 100644
--- a/lily/include/mensural-ligature.hh
+++ b/lily/include/mensural-ligature.hh
@@ -16,14 +16,13 @@
 /*
  * These are all possible mensural ligature primitives.
  */
-
-#define MLP_NONE 0x00 // no output
-#define MLP_UP 0x01 // ligatura ascendens
-#define MLP_DOWN 0x02 // ligatura descendens
-#define MLP_BREVIS 0x04 // mensural brevis head
-#define MLP_LONGA 0x08 // mensural brevis head with right cauda
-#define MLP_MAXIMA 0x10 // mensural maxima head without stem
-#define MLP_FLEXA 0x20
+#define MLP_NONE	0x00 // no output
+#define MLP_UP		0x01 // upward left stem
+#define MLP_DOWN	0x02 // downward left stem
+#define MLP_BREVIS	0x04 // mensural brevis head
+#define MLP_LONGA	0x08 // mensural brevis head with right cauda
+#define MLP_MAXIMA	0x10 // mensural maxima head without stem
+#define MLP_FLEXA	0x20 // mensural flexa-like shape
 
 #define MLP_STEM (MLP_UP | MLP_DOWN)
 #define MLP_SINGLE_HEAD (MLP_BREVIS | MLP_LONGA | MLP_MAXIMA)
diff --git a/lily/mensural-ligature.cc b/lily/mensural-ligature.cc
index 3b73a54a91..a70eeaf113 100644
--- a/lily/mensural-ligature.cc
+++ b/lily/mensural-ligature.cc
@@ -28,12 +28,9 @@ brew_flexa (Grob *me,
 	    Real interval,
 	    bool solid,
 	    Real width,
-	    Real thickness)
+	    Real vertical_line_thickness)
 {
   Real staff_space = Staff_symbol_referencer::staff_space (me);
-  Real height = 0.6 * staff_space;
-  Stencil stencil;
-
   Real slope = (interval / 2.0 * staff_space) / width;
 
   // Compensate optical illusion regarding vertical position of left
@@ -42,31 +39,48 @@ brew_flexa (Grob *me,
   Real slope_correction = 0.2 * staff_space * sign (slope);
   Real corrected_slope = slope + slope_correction / width;
 
-  if (solid) // this will come handy for colorated flexae
+  Stencil stencil;
+  if (solid) // colorated flexae
     {
       Stencil solid_head
-	= Lookup::beam (corrected_slope, width, height, 0.0);
+	= Lookup::beam (corrected_slope, width, staff_space, 0.0);
       stencil.add_stencil (solid_head);
     }
   else // outline
     {
+      /*
+	The thickness of the horizontal lines of the flexa shape
+	should be equal to that of the horizontal lines of the
+	neomensural brevis note head (see mf/parmesan-heads.mf).
+      */
+      Real const horizontal_line_thickness = staff_space * 0.35;
+
+      // URGH!  vertical_line_thickness is adjustable (via thickness
+      // property), while horizontal_line_thickness is constant.
+      // Maybe both should be adjustable independently?
+
+      Real height = staff_space - horizontal_line_thickness;
+
       Stencil left_edge
-	= Lookup::beam (corrected_slope, thickness, height, 0.0);
+	= Lookup::beam (corrected_slope, vertical_line_thickness, height, 0.0);
       stencil.add_stencil (left_edge);
 
       Stencil right_edge
-	= Lookup::beam (corrected_slope, thickness, height, 0.0);
-      right_edge.translate_axis (width - thickness, X_AXIS);
-      right_edge.translate_axis (corrected_slope * (width - thickness), Y_AXIS);
+	= Lookup::beam (corrected_slope, vertical_line_thickness, height, 0.0);
+      right_edge.translate_axis (width - vertical_line_thickness, X_AXIS);
+      right_edge.translate_axis ((width - vertical_line_thickness) *
+				 corrected_slope, Y_AXIS);
       stencil.add_stencil (right_edge);
 
       Stencil bottom_edge
-	= Lookup::beam (corrected_slope, width, thickness, 0.0);
+	= Lookup::beam (corrected_slope, width,
+			horizontal_line_thickness, 0.0);
       bottom_edge.translate_axis (-0.5 * height, Y_AXIS);
       stencil.add_stencil (bottom_edge);
 
       Stencil top_edge
-	= Lookup::beam (corrected_slope, width, thickness, 0.0);
+	= Lookup::beam (corrected_slope, width,
+			horizontal_line_thickness, 0.0);
       top_edge.translate_axis (+0.5 * height, Y_AXIS);
       stencil.add_stencil (top_edge);
     }
diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc
index da0169237f..aef60cb2da 100644
--- a/lily/vaticana-ligature-engraver.cc
+++ b/lily/vaticana-ligature-engraver.cc
@@ -25,6 +25,9 @@ class Vaticana_ligature_engraver : public Gregorian_ligature_engraver
 {
 
 private:
+  static bool
+  need_extra_horizontal_space (int prev_prefix_set, int prefix_set,
+			       int context_info, int delta_pitch);
   bool is_stacked_head (int prefix_set,
 			int context_info);
   Real align_heads (Array<Grob_info> primitives,
@@ -98,8 +101,8 @@ Vaticana_ligature_engraver::is_stacked_head (int prefix_set,
  * added at most once between to heads.
  */
 bool
-need_extra_space (int prev_prefix_set, int prefix_set,
-		  int context_info, int delta_pitch)
+Vaticana_ligature_engraver::need_extra_horizontal_space (int prev_prefix_set, int prefix_set,
+							 int context_info, int delta_pitch)
 {
   if (prev_prefix_set & VIRGA)
     /*
@@ -295,8 +298,8 @@ Vaticana_ligature_engraver::align_heads (Array<Grob_info> primitives,
 	   */
 	}
 
-      if (need_extra_space (prev_prefix_set, prefix_set,
-			    context_info, delta_pitch))
+      if (need_extra_horizontal_space (prev_prefix_set, prefix_set,
+				       context_info, delta_pitch))
 	ligature_width += extra_space;
 
       /*
@@ -426,12 +429,17 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
 	    if (! (prev_context_info & FLEXA_RIGHT))
 	      /* correct head of previous primitive */
 	      if (prev_delta_pitch > 1)
-		prev_glyph_name = "svaticana.epiphonus";
+		{
+		  prev_glyph_name = "svaticana.epiphonus";
+		  glyph_name = "svaticana.plica";
+		}
 	      else
-		prev_glyph_name = "svaticana.vepiphonus";
-	    glyph_name = "svaticana.plica";
+		{
+		  prev_glyph_name = "svaticana.vepiphonus";
+		  glyph_name = "svaticana.vplica";
+		}
 	  }
-	else // (prev_delta_pitch <= 0)
+	else if (prev_delta_pitch < 0)
 	  {
 	    // cephalicus
 	    if (! (prev_context_info & FLEXA_RIGHT))
@@ -461,7 +469,20 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
 		prev_primitive->set_property ("add-cauda",
 					      ly_bool2scm (false));
 	      }
-	    glyph_name = "svaticana.reverse.plica";
+	      if (prev_delta_pitch < - 1)
+		{
+		  glyph_name = "svaticana.reverse.plica";
+		}
+	      else
+		{
+		  glyph_name = "svaticana.reverse.vplica";
+		}
+	  }
+	else // (prev_delta_pitch == 0)
+	  {
+	    primitive->programming_error ("Vaticana_ligature:"
+					  "deminutum head must have different "
+					  "pitch -> ignoring grob");
 	  }
       else if (prefix_set & (CAVUM | LINEA))
 	if ((prefix_set & CAVUM) && (prefix_set & LINEA))
diff --git a/mf/parmesan-heads.mf b/mf/parmesan-heads.mf
index 095c4c9c0f..72c6a155f4 100644
--- a/mf/parmesan-heads.mf
+++ b/mf/parmesan-heads.mf
@@ -312,7 +312,8 @@ fet_endchar;
 % parameterized punctum
 def punctum_char (expr verbose_name, internal_name,
 		  left_stem, right_stem, linea, cavum,
-		  straight, auctum, direction_up, excentric, up_shift, down_shift, mag) =
+		  straight, auctum, rev_auctum, direction_up,
+		  excentric, up_shift, down_shift, mag) =
 
 	fet_beginchar(verbose_name, "s" & internal_name)
 		save b_h, a_w;
@@ -346,6 +347,9 @@ def punctum_char (expr verbose_name, internal_name,
 		elseif auctum:
 			u_convexity# = -0.03ht#;
 			u_excentricity# = +0.25ht#;
+		elseif rev_auctum:
+			u_convexity# = -0.10ht#;
+			u_excentricity# = -0.12ht#;
 		else:
 			u_convexity# = -0.05ht#;
 			u_excentricity# = 0.0ht#; % dummy
@@ -381,7 +385,7 @@ def punctum_char (expr verbose_name, internal_name,
 
 		save box_top, box_bt;
 
-		if auctum:
+		if auctum or rev_auctum:
 			z1a = (0.00wd + linethickness/2, yoffs_bt);
 			z2a = (0.21wd, yoffs_bt + 1.0*convexity);
 			z3a = (0.42wd - linethickness/2,
@@ -511,22 +515,22 @@ enddef;
 % punctum
 punctum_char("Ed. Vat. punctum", "vaticana.punctum",
 	     false, false, false, false, false,
-	     false, false, false, false, false, 1.0);
+	     false, false, false, false, false, false, 1.0);
 
 % punctum cavum (for OpusTeX compatibility)
 punctum_char("Ed. Vat. punctum cavum", "vaticana.punctum.cavum",
 	     false, false, false, true, false,
-	     false, false, false, false, false, 1.0);
+	     false, false, false, false, false, false, 1.0);
 
 % linea punctum (for OpusTeX compatibility)
 punctum_char("Ed. Vat. linea punctum", "vaticana.linea.punctum",
 	     false, false, true, false, false,
-	     false, false, false, false, false, 1.0);
+	     false, false, false, false, false, false, 1.0);
 
 % linea punctum cavum (for OpusTeX compatibility)
 punctum_char("Ed. Vat. linea punctum cavum", "vaticana.linea.punctum.cavum",
 	     false, false, true, true, false,
-	     false, false, false, false, false, 1.0);
+	     false, false, false, false, false, false, 1.0);
 
 % punctum inclinatum
 inclinatum_char("Ed. Vat. inclinatum", "vaticana.inclinatum",
@@ -535,17 +539,17 @@ inclinatum_char("Ed. Vat. inclinatum", "vaticana.inclinatum",
 % pes lower punctum
 punctum_char("Ed. Vat. pes lower punctum", "vaticana.lpes",
 	     false, false, false, false, true,
-	     false, true, false, false, false, 1.0);
+	     false, false, true, false, false, false, 1.0);
 
 % pes lower punctum
 punctum_char("Ed. Vat. pes var lower punctum", "vaticana.vlpes",
 	     false, false, false, false, true,
-	     false, true, false, false, true, 1.0);
+	     false, false, true, false, false, true, 1.0);
 
 % pes upper punctum
 punctum_char("Ed. Vat. pes upper punctum", "vaticana.upes", 
 	     false, false, false, false, true,
-	     false, false, false, false, false, 1.0);
+	     false, false, false, false, false, false, 1.0);
 
 % pes upper punctum (shifted variation)
 %
@@ -555,17 +559,22 @@ punctum_char("Ed. Vat. pes upper punctum", "vaticana.upes",
 %
 punctum_char("Ed. Vat. var pes upper punctum", "vaticana.vupes",
 	     false, false, false, false, true,
-	     false, false, false, true, false, 1.0);
+	     false, false, false, false, true, false, 1.0);
 
 % small punctum as used in epiphonus
 punctum_char("Ed. Vat. plica", "vaticana.plica", 
 	     false, false, false, false, false,
-	     false, false, false, false, false, 0.6);
+	     false, false, false, false, false, false, 0.6);
+
+% small punctum as used in epiphonus
+punctum_char("Ed. Vat. var plica", "vaticana.vplica", 
+	     false, false, false, false, false,
+	     false, true, false, false, false, true, 0.6);
 
 % excentric punctum as used in epiphonus
 punctum_char("Ed. Vat. epiphonus", "vaticana.epiphonus", 
 	     false, false, false, false, false,
-	     false, true, true, false, false, 1.0);
+	     false, false, true, true, false, false, 1.0);
 
 % excentric punctum as used in epiphonus (shifted variation)
 %
@@ -575,22 +584,27 @@ punctum_char("Ed. Vat. epiphonus", "vaticana.epiphonus",
 %
 punctum_char("Ed. Vat. var epiphonus", "vaticana.vepiphonus",
 	     false, false, false, false, false,
-	     false, true, true, false, true, 1.0);
+	     false, false, true, true, false, true, 1.0);
 
 % small punctum as used in cephalicus
 punctum_char("Ed. Vat. rev. plica", "vaticana.reverse.plica",
 	     false, false, false, false, false,
-	     false, true, false, false, false, 0.6);
+	     false, false, true, false, false, false, 0.6);
+
+% small punctum as used in cephalicus
+punctum_char("Ed. Vat. rev. var plica", "vaticana.reverse.vplica",
+	     false, false, false, false, false,
+	     false, true, true, false, false, true, 0.6);
 
 % excentric punctum as used in cephalicus; without left stem
 punctum_char("Ed. Vat. cephalicus", "vaticana.inner.cephalicus",
 	     false, false, false, false, false,
-	     false, false, true, false, false, 1.0);
+	     false, false, false, true, false, false, 1.0);
 
 % excentric punctum as used in cephalicus; with left stem
 punctum_char("Ed. Vat. cephalicus", "vaticana.cephalicus",
 	     true, false, false, false, false,
-	     false, false, true, false, false, 1.0);
+	     false, false, false, true, false, false, 1.0);
 
 % quilisma
 fet_beginchar("Ed. Vat. quilisma", "svaticana.quilisma")
@@ -626,12 +640,12 @@ inclinatum_char("Solesmes punctum inclinatum parvum", "solesmes.incl.parvum",
 % solesmes punctum auctum ascendens
 punctum_char("Solesmes punctum auctum ascendens", "solesmes.auct.asc",
 	     false, false, false, false, false,
-	     true, true, false, false, false, 1.0);
+	     true, false, true, false, false, false, 1.0);
 
 % solesmes punctum auctum descendens
 punctum_char("Solesmes punctum auctum descendens", "solesmes.auct.desc",
 	     false, false, false, false, false,
-	     true, false, false, false, false, 1.0);
+	     true, false, false, false, false, false, 1.0);
 
 % solesmes punctum inclinatum auctum
 inclinatum_char("Solesmes punctum incl. auctum", "solesmes.incl.auctum",
-- 
2.39.5