From: Knut Petersen Date: Sat, 4 Mar 2017 18:10:19 +0000 (+0000) Subject: LyricHyphen whiteout X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=2dc76513c4edb8e18e6170069677eb0dd9b54209 LyricHyphen whiteout Issue 5033 A proper outline whiteout would be ideal, but it is not currently implemented. The current code fails because you need a relatively large whiteout area for a small object. A brute force fix is to increase the number of iterations, but the result would be a pdf with a high percentage of whiteout code. There is the case where a long melisma produces a single hyphen event that generates a lot of hyphens that cross a number of mensuration lines. Rectangular or roundedbox whiteout will produce gaps in all mensuration lines crossed, even if there is no collision. That's not acceptable. --- diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc index 029391f92f..a76ed9b2fa 100644 --- a/lily/lyric-hyphen.cc +++ b/lily/lyric-hyphen.cc @@ -67,6 +67,7 @@ Lyric_hyphen::print (SCM smob) Real dash_period = robust_scm2double (me->get_property ("dash-period"), 1.0); Real dash_length = robust_scm2double (me->get_property ("length"), .5); Real padding = robust_scm2double (me->get_property ("padding"), 0.1); + Real whiteout = robust_scm2double (me->get_property ("whiteout"), -1); if (dash_period < dash_length) dash_period = 1.5 * dash_length; @@ -103,8 +104,20 @@ Lyric_hyphen::print (SCM smob) for (int i = 0; i < n; i++) { Stencil m (dash_mol); - m.translate_axis (span_points[LEFT] + i * dash_period + space_left / 2, X_AXIS); + m = m.in_color (0.0, 0.0, 0.0); + m.translate_axis (span_points[LEFT] + i * dash_period + + space_left / 2, X_AXIS); total.add_stencil (m); + if (whiteout > 0.0 ) + { + Box c (Interval (0, dash_length + 2 * whiteout * lt), + Interval (h - whiteout * lt, h + th + whiteout * lt)); + Stencil w (Lookup::round_filled_box (c, 0.8 * lt)); + w = w.in_color (1.0, 1.0, 1.0); + w.translate_axis (span_points[LEFT] + i * dash_period + + space_left / 2 - whiteout * lt, X_AXIS); + total.add_stencil (w); + } } total.translate_axis (-me->relative_coordinate (common, X_AXIS), X_AXIS); @@ -148,4 +161,3 @@ ADD_INTERFACE (Lyric_hyphen, "padding " "thickness " ); - diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index e950d53b3a..fbcaa2b4bb 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -1167,11 +1167,15 @@ one below this grob.") printed over a white background to white-out underlying material, if the grob is visible. A number indicates how far the white background extends beyond the bounding box of the grob as a multiple of the -staff-line thickness. The shape of the background is determined by -@code{whiteout-style}. Usually @code{#f} by default.") +staff-line thickness. The @code{LyricHyphen} grob uses a special +implementation of whiteout: A positive number indicates how far the +white background extends beyond the bounding box in multiples of +@code{line-thickness}. The shape of the background is determined by +@code{whiteout-style}. Usually @code{#f} by default. ") (whiteout-style ,symbol? "Determines the shape of the @code{whiteout} background. Available are @code{'outline}, -@code{'rounded-box}, and the default @code{'box}.") +@code{'rounded-box}, and the default @code{'box}. There is one +exception: Use @code{'special} for @code{LyricHyphen}.") (width ,ly:dimension? "The width of a grob measured in staff space.") (word-space ,ly:dimension? "Space to insert between words in diff --git a/scm/stencil.scm b/scm/stencil.scm index 0fa79d4161..00f8503487 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -814,6 +814,7 @@ based on @var{style}." ((eq? style 'rounded-box) 3) (else 0)))))) (cond + ((eq? style 'special) stil) ((eq? style 'outline) (stencil-whiteout-outline stil thick)) ((eq? style 'rounded-box) (stencil-whiteout-box stil thick (* 2 thick))) (else (stencil-whiteout-box stil thick)))))