Hi David!

What a steaming heap of something. So your code would likely have worked in LilyPond 2.16. I think it would make sense to create a new type of stencil expression explicitly intended to bypass outlining. Probably by just containing _two_ stencils: one for typesetting, one for outlining. That would make for a much more transparent manner of programming things like that.

There's no need for two stencils.  I propose to include  the attached code.

 Knut
>From ae50c298fee5f57c1200bd82b8f20783e74b4cd9 Mon Sep 17 00:00:00 2001
From: Knut Petersen <[email protected]>
Date: Tue, 24 Jan 2017 14:17:10 +0100
Subject: [PATCH] Implement no-outline-stencil backend command

Should be used instead of a transparent stencil / delayed
stencil evaluation construct where the delay is not needed.

Signed-off-by: Knut Petersen <[email protected]>
---
 lily/include/stencil.hh         | 1 +
 lily/stencil-integral.cc        | 3 +++
 lily/stencil-interpret.cc       | 5 +++++
 lily/stencil.cc                 | 6 ++++++
 scm/define-stencil-commands.scm | 1 +
 5 files changed, 16 insertions(+)

diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh
index 8af67c0f76..546b5a3bff 100644
--- a/lily/include/stencil.hh
+++ b/lily/include/stencil.hh
@@ -84,6 +84,7 @@ public:
   void align_to (Axis a, Real x);
   void translate_axis (Real, Axis);
   void scale (Real, Real);
+  void no_outline ();
 
   Interval extent (Axis) const;
   Box extent_box () const;
diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc
index 1b9aa5181b..583a454750 100644
--- a/lily/stencil-integral.cc
+++ b/lily/stencil-integral.cc
@@ -55,6 +55,7 @@ when this transforms a point (x,y), the point is written as matrix:
 #include "skyline.hh"
 #include "skyline-pair.hh"
 #include "spanner.hh"
+
 using namespace std;
 
 Real QUANTIZATION_UNIT = 0.2;
@@ -938,6 +939,8 @@ stencil_traverser (PangoMatrix trans, SCM expr)
   else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("delay-stencil-evaluation")))
     // should not use the place-holder text, but no need for the warning below
     return vector<Transform_matrix_and_expression> ();
+  else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("no-outline-stencil")))
+    return vector<Transform_matrix_and_expression> ();
   else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("grob-cause")))
     return stencil_traverser (trans, scm_caddr (expr));
   else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("color")))
diff --git a/lily/stencil-interpret.cc b/lily/stencil-interpret.cc
index 25fad0d842..6bf0671284 100644
--- a/lily/stencil-interpret.cc
+++ b/lily/stencil-interpret.cc
@@ -39,6 +39,11 @@ interpret_stencil_expression (SCM expr,
         }
       if (scm_is_eq (head, ly_symbol2scm ("transparent-stencil")))
         return;
+      if (scm_is_eq (head, ly_symbol2scm ("no-outline-stencil")))
+        {
+          interpret_stencil_expression (scm_cadr (expr), func, func_arg, o);
+          return;
+        }
       if (scm_is_eq (head, ly_symbol2scm ("footnote")))
         return;
       if (scm_is_eq (head, ly_symbol2scm ("translate-stencil")))
diff --git a/lily/stencil.cc b/lily/stencil.cc
index 5e568c98db..afc348d95f 100644
--- a/lily/stencil.cc
+++ b/lily/stencil.cc
@@ -193,6 +193,12 @@ Stencil::scale (Real x, Real y)
 }
 
 void
+Stencil::no_outline ()
+{
+    expr_ = scm_list_2 (ly_symbol2scm ("no-outline-stencil"), expr_);
+}
+
+void
 Stencil::add_stencil (Stencil const &s)
 {
   SCM cs = ly_symbol2scm ("combine-stencil");
diff --git a/scm/define-stencil-commands.scm b/scm/define-stencil-commands.scm
index 23c17abb9b..ddce5bd631 100644
--- a/scm/define-stencil-commands.scm
+++ b/scm/define-stencil-commands.scm
@@ -63,6 +63,7 @@ are used internally in @file{lily/@/stencil-interpret.cc}."
     combine-stencil
     delay-stencil-evaluation
     footnote
+    no-outline-stencil
     output-attributes
     rotate-stencil
     scale-stencil
-- 
2.11.0

_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to