[Top][All Lists]

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

Re: Spannerize glyphs, markups etc. ?

From: Dimitris Marinakis
Subject: Re: Spannerize glyphs, markups etc. ?
Date: Thu, 4 Feb 2021 21:12:16 +0200

Hi David,

Thank you very much! The problem you described is innate with spanners such as trills etc. 
All software I've encountered including Lilypond work exactly as you described. Perhaps the calculation could extend the overall Spanner length to allow for the last appearance of the glyph if the number doesn't allow for it to appear normally.

Yeah, line breaks would be a logical next step but I'm in no particular rush. I'm sure someone will figure it out eventually.

On Thu, Feb 4, 2021 at 8:12 PM David Nalesnik <> wrote:
Hi Dimitris,

On Thu, Feb 4, 2021 at 10:36 AM Dimitris Marinakis <> wrote:
> Thank you. This certainly works for simple scenarios.
> Here is my incomplete take. I just need to find out how to automatically change the number that repeats the stencil based on the spanner length.
> Sorry if this doesn't make sense. I just started learning bit by bit how to make things work in Scheme.
> trillsymb = \markup {
> \concat
> {
> \scale #'(1.5 . 1)
> \musicglyph #"scripts.trillelement"
> \musicglyph #"scripts.turn"
>  }
> }
>  #(define (alterspan grob)
>    (if (ly:stencil? (ly:line-spanner::print grob))
>      (let* ((stencil (ly:line-spanner::print grob))
>             (dot (ly:font-get-glyph (ly:grob-default-font grob) "scripts.turn"))
>          (X-ext (ly:stencil-extent stencil X))
>             (Y-ext (ly:stencil-extent stencil Y))
>             (width 0.1)
>             (len (interval-length X-ext)))
>        (ly:stencil-translate
>          (grob-interpret-markup grob
>            (markup
> ; really crude method but I think it can work just fine
> ; spanner length / stencil extend ??
>        (#:pattern (inexact->exact (round (* len
>   ;need a way to automatically change this number based on the stencil dimensions
>                                            0.3 ))) X 0
>       (markup #:scale (cons 1 1) trillsymb)
>             )
> )
>            )
>           (cons (interval-start X-ext) (interval-start Y-ext))))
>      #f))
> {
> \override Score.TextSpanner.stencil = #alterspan
> <c' g'>4\startTextSpan
> <c' g'>4
> <c' g'>4
> c'4
> d'
> e'
> f'
> g'\stopTextSpan
> }

Here's a slight rewrite of your code which calculates the number of
pattern statements automatically.

One problem is that the right edge of the spanner will sometimes stop
short of the right end of the base spanner.  This could be improved by
adding dot, turn, dot, turn, dot, etc.--allowing for the possibility
of ending with a dot--rather than building the spanner from
indivisible dot-turn units.

(Ultimately I imagine you will want provision for line breaks too.  A
hassle, but doable.)

Hope this helps,

reply via email to

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