lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1] Issue 3778: Use bounding box as skylines for markup in svg ba


From: Kevin Barry
Subject: [PATCH v1] Issue 3778: Use bounding box as skylines for markup in svg backend
Date: Fri, 24 Apr 2020 22:09:04 +0100

As there is no routine for determining skylines for utf-8-string
stencils, they normally fall back to the grob's bounding box, which is
fine. However, when there is a mixture of utf-8-string and other types
of stencil (which have associated skyline functions) in a single grob,
the entire grob gets a skyline determined only from the non-utf-8-string
stencils. This sometimes causes the text portion of such mixed grobs
(e.g.  metronome marks) to collide with other grobs.

While looping over the stencils, check for utf-8-string and if found,
clear the skylines and break out of the loop. Empty skylines forces a
fallback to the grob's bounding box, which restores the behaviour from
before the patch to improve skyline approximations (issue 2148). This
does not fix the issue that there is no routine for determining skylines
for utf-8-strings when the backend is svg, but it does at least remove
the collisions without changing the behaviour in non-broken situations.

Add a suitable (svg backend) regression test.
---
 input/regression/svg-metronome-mark-skylines.ly | 15 +++++++++++++++
 lily/stencil-integral.cc                        | 10 +++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 input/regression/svg-metronome-mark-skylines.ly

diff --git a/input/regression/svg-metronome-mark-skylines.ly 
b/input/regression/svg-metronome-mark-skylines.ly
new file mode 100644
index 0000000000..844e4a8081
--- /dev/null
+++ b/input/regression/svg-metronome-mark-skylines.ly
@@ -0,0 +1,15 @@
+\header {
+texidoc = "In svg output, a @code{MetronomeMark} or any grob mixing text
+and other glyphs does not collide with other grobs.
+"
+}
+
+\version "2.21.1"
+
+#(ly:set-option 'backend 'svg)
+
+{
+  \tempo "Allegro" 4 = 120
+  r1
+  r4 f''' e''' b''
+}
diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc
index 7b12eaf17b..8ac386a10e 100644
--- a/lily/stencil-integral.cc
+++ b/lily/stencil-integral.cc
@@ -1097,7 +1097,15 @@ Stencil::skylines_from_stencil (SCM sten, Real pad, SCM 
rot, Axis a)
   vector<Box> boxes;
   vector<Drul_array<Offset> > buildings;
   for (SCM s = scm_reverse_x (data, SCM_EOL); scm_is_pair (s); s = scm_cdr (s))
-    stencil_dispatcher (boxes, buildings, scm_caar (s), scm_cdar (s));
+    {
+      // If any stencils are utf-8-string, fall back on the bounding box
+      if (scm_is_eq (scm_cadar (s), ly_symbol2scm ("utf-8-string")))
+        {
+          boxes.clear();
+          break;
+        }
+      stencil_dispatcher (boxes, buildings, scm_caar (s), scm_cdar (s));
+    }
 
   // we use the bounding box if there are no boxes
   // FIXME: Rotation?
-- 
2.25.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]