[Top][All Lists]

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

Re: markup-command rounded-box is broken

From: Lukas-Fabian Moser
Subject: Re: markup-command rounded-box is broken
Date: Sun, 10 Oct 2021 10:05:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Hi Harm,

I noticed a bug with recent master:

\markup \rounded-box "foo"

prints completely black.

First bad commit is:
commit 0772e38398972d6c2b4ba9e6f42e7725d973e08b
Author: Han-Wen Nienhuys <>
Date:   Sun Aug 1 11:15:02 2021 +0200

     Stop passing color names to output backends

Well, comparing that version pre- and post-change

 (define-public (rounded-box-stencil stencil thickness padding blot)
   "Add a rounded box around @var{stencil}, producing a new stencil."

   (let* ((xext (interval-widen (ly:stencil-extent stencil 0) padding))
          (yext (interval-widen (ly:stencil-extent stencil 1) padding))
          (min-ext (min (-(cdr xext) (car xext)) (-(cdr yext) (car yext))))
          (ideal-blot (min blot (/ min-ext 2)))
          (ideal-thickness (min thickness (/ min-ext 2)))
          (outer (ly:round-filled-box
                  (interval-widen xext ideal-thickness)
                  (interval-widen yext ideal-thickness)
-         (inner (ly:make-stencil (list 'color (x11-color 'white)
-                                       (ly:stencil-expr (ly:round-filled-box -                                                         xext yext (- ideal-blot ideal-thickness)))))))
+         (inner (ly:make-stencil (ly:stencil-in-color
+                                  (ly:round-filled-box
+                                   xext yext (- ideal-blot ideal-thickness))
+                                   "white"))))
     (set! stencil (ly:stencil-add outer inner))

it seems to me that before Han-Wen's change, ly:make-stencil was necessary since the code manipulated the stencil expression of the round-filled-box directly, thus returning a stencil expression. Now, with the use of ly:stencil-in-color, we get an actual stencil immediately, so the call ly:make-stencil (which expects a stencil expression) is superfluous and (I think) wrong.

But to be honest, rounded-box-stencil seems to me to be broken anyway:

If you compare it with ellipse-stencil directly above (and looking at the docstrings), one should expect to get the original stencil with an added rounded box. But rounded-box-stencil
a) doesn't use the original stencil in stencil-add,
b) overwrites the original stencil with set!

Hence, the markup command \rounded-box has to take care to add the original markup:

  (let ((th (* (ly:output-def-lookup layout 'line-thickness)
        (pad (* (magstep font-size) box-padding))
        (m (interpret-markup layout props arg)))
    (ly:stencil-add (rounded-box-stencil m th pad corner-radius)

So in my impression, rounded-box-stencil might deserve a refactoring anyway?


reply via email to

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