Hi,

I'm using Aaron's excellent overlayMarkup function from this thread: 
https://lists.gnu.org/archive/html/lilypond-user/2021-09/msg00052.html and am 
seeing different behaviour for Script objects depending if they are attached to 
notes or to multimeasure rests. See the following example. Any ideas how to 
deal with this?

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.23.3"

overlayMarkup =
#(define-scheme-function
 (self-x self-y parent-x parent-y markup)
 ((number? 0) (number? 0) (number? 0) (number? 0) markup?)
 (grob-transformer 'stencil
  (lambda (grob orig)
   (let* ((xex (ly:stencil-extent orig X))
          (yex (ly:stencil-extent orig Y))
          (xoff (interval-index xex parent-x))
          (yoff (interval-index yex parent-y))
          (sten (grob-interpret-markup grob markup)))
    (set! sten (ly:stencil-aligned-to sten X self-x))
    (set! sten (ly:stencil-aligned-to sten Y self-y))
    (ly:stencil-add orig
     (ly:stencil-translate sten (cons xoff yoff)))))))

{
 %% this usage works
 R1
 -\tweak stencil \overlayMarkup 0 0 0 3 "test"
 \fermata

 %% this usage fails
 %%    programming error: Cannot get a text stencil from this font
 %%    continuing, cross fingers
 g'1
 -\tweak stencil \overlayMarkup 0 0 0 3 "test"
 \fermata
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

--
Mark Knoop
m...@markknoop.com
https://markknoop.com/

Reply via email to