]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/mensural-ligature.cc
* lily/modified-font-metric.cc (text_dimension): try
[lilypond.git] / lily / mensural-ligature.cc
index 0866707bd188dac9e2d0dca82eef7a28ef137d7c..42d8d304005cba8e63ede018a95a0d80ae371cda 100644 (file)
@@ -6,15 +6,16 @@
   (c) 2002--2004 Juergen Reuter <reuter@ipd.uka.de>
 */
 
+#include "mensural-ligature.hh"
+
 #include <math.h>
+
 #include "item.hh"
-#include "mensural-ligature.hh"
 #include "font-interface.hh"
-#include "stencil.hh"
 #include "lookup.hh"
 #include "staff-symbol-referencer.hh"
 #include "note-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 
 /*
@@ -33,7 +34,7 @@ brew_flexa (Grob *me,
 {
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Real height = 0.6 * staff_space;
-  Stencil stencil = Stencil ();
+  Stencil stencil;
 
   if (add_cauda)
     {
@@ -54,7 +55,7 @@ brew_flexa (Grob *me,
       Real y_correction =
        (cauda_direction == UP) ?
        +0.5*height :
-       -0.5*height - cauda_box_y.length();
+       -0.5*height - cauda_box_y.length ();
 
       Box cauda_box (cauda_box_x, cauda_box_y);
       Stencil cauda = Lookup::filled_box (cauda_box);
@@ -66,8 +67,8 @@ brew_flexa (Grob *me,
 
   // Compensate optical illusion regarding vertical position of left
   // and right endings due to slope.
-  Real ypos_correction = -0.1*staff_space * sign(slope);
-  Real slope_correction = 0.2*staff_space * sign(slope);
+  Real ypos_correction = -0.1*staff_space * sign (slope);
+  Real slope_correction = 0.2*staff_space * sign (slope);
   Real corrected_slope = slope + slope_correction/width;
 
   if (solid)
@@ -80,13 +81,13 @@ brew_flexa (Grob *me,
     {
       Stencil left_edge =
        Lookup::beam (corrected_slope, thickness, height, 0.0);
-      stencil.add_stencil(left_edge);
+      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);
-      stencil.add_stencil(right_edge);
+      stencil.add_stencil (right_edge);
 
       Stencil bottom_edge =
        Lookup::beam (corrected_slope, width, thickness, 0.0);
@@ -102,32 +103,10 @@ brew_flexa (Grob *me,
   return stencil;
 }
 
-void
-add_ledger_lines (Grob *me, Stencil *out, int pos, Real offs,
-                 bool ledger_take_space)
-{
-  int interspaces = Staff_symbol_referencer::line_count (me)-1;
-  if (abs (pos) - interspaces > 1)
-    {
-      Interval hd = out->extent (X_AXIS);
-      Real left_ledger_protusion = hd.length ()/4;
-      Real right_ledger_protusion = left_ledger_protusion;
-
-      Interval l_extents = Interval (hd[LEFT] - left_ledger_protusion,
-                                    hd[RIGHT] + right_ledger_protusion);
-      Stencil ledger_lines =
-       Note_head::brew_ledger_lines (me, pos, interspaces,
-                                     l_extents,0,
-                                     ledger_take_space);
-      ledger_lines.translate_axis (offs, Y_AXIS);
-      out->add_stencil (ledger_lines);
-    }
-}
-
 Stencil
-internal_brew_primitive (Grob *me, bool ledger_take_space)
+internal_brew_primitive (Grob *me)
 {
-  SCM primitive_scm = me->get_grob_property ("primitive");
+  SCM primitive_scm = me->get_property ("primitive");
   if (primitive_scm == SCM_EOL)
     {
       programming_error ("Mensural_ligature:"
@@ -136,40 +115,40 @@ internal_brew_primitive (Grob *me, bool ledger_take_space)
     }
 
   Stencil out;
-  int primitive = gh_scm2int (primitive_scm);
+  int primitive = scm_to_int (primitive_scm);
   int delta_pitch = 0;
   Real thickness = 0.0;
   Real flexa_width = 0.0;
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   if (primitive & MLP_ANY)
     {
-      thickness = robust_scm2double ( me->get_grob_property ("thickness"), .14);
+      thickness = robust_scm2double ( me->get_property ("thickness"), .14);
     }
 
   if (primitive & MLP_FLEXA)
     {
-      delta_pitch = robust_scm2int (me->get_grob_property ("delta-pitch"),
+      delta_pitch = robust_scm2int (me->get_property ("delta-pitch"),
                                    0);
 
-      flexa_width = robust_scm2double (me->get_grob_property ("flexa-width"), 2.0 * staff_space);
+      flexa_width = robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space);
     }
 
   switch (primitive)
     {
       case MLP_NONE:
-       return Stencil();
+       return Stencil ();
       case MLP_BB:
        out = brew_flexa (me, delta_pitch, false,
                          flexa_width, thickness, true, DOWN);
        break;
-      case MLP_sc:
-       out = Font_interface::get_default_font (me)->find_by_name ("noteheads--2mensural");
+      case MLP_sc: // mensural brevis head with right cauda
+       out = Font_interface::get_default_font (me)->find_by_name ("noteheads.-2mensural");
        break;
-      case MLP_ss:
-       out = Font_interface::get_default_font (me)->find_by_name ("noteheads--1mensural");
+      case MLP_ss: // mensural brevis head
+       out = Font_interface::get_default_font (me)->find_by_name ("noteheads.-1mensural");
        break;
-      case MLP_cs:
-       out = Font_interface::get_default_font (me)->find_by_name ("noteheads-lmensural");
+      case MLP_cs: // mensural brevis head with left cauda
+       out = Font_interface::get_default_font (me)->find_by_name ("noteheads.lmensural");
        break;
       case MLP_SS:
        out = brew_flexa (me, delta_pitch, false,
@@ -185,13 +164,13 @@ internal_brew_primitive (Grob *me, bool ledger_take_space)
        return Stencil ();
     }
 
-  SCM join_left_scm = me->get_grob_property ("join-left-amount");
+  SCM join_left_scm = me->get_property ("join-left-amount");
   if (join_left_scm != SCM_EOL)
     {
-      int join_left = gh_scm2int (join_left_scm);
+      int join_left = scm_to_int (join_left_scm);
       if (!join_left)
        programming_error (_f ("Mensural_ligature: (join_left == 0)"));
-      Real blotdiameter = (me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter")));
+      Real blotdiameter = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
       Interval x_extent = Interval (0, thickness);
       Interval y_extent = (join_left > 0) ?
        Interval (-join_left * 0.5 * staff_space, 0) :
@@ -202,12 +181,10 @@ internal_brew_primitive (Grob *me, bool ledger_take_space)
       out.add_stencil (join);
     }
 
-  int pos = (int)rint (Staff_symbol_referencer::get_position (me));
-  add_ledger_lines(me, &out, pos, 0, ledger_take_space);
+  int pos = Staff_symbol_referencer::get_rounded_position (me);
   if (primitive & MLP_FLEXA)
     {
       pos += delta_pitch;
-      add_ledger_lines(me, &out, pos, 0.5*delta_pitch, ledger_take_space);
     }
 
   return out;
@@ -218,7 +195,7 @@ SCM
 Mensural_ligature::brew_ligature_primitive (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-  return internal_brew_primitive (me, false).smobbed_copy ();
+  return internal_brew_primitive (me).smobbed_copy ();
 }
 
 MAKE_SCHEME_CALLBACK (Mensural_ligature, print, 1);