lilypond-user
[Top][All Lists]
Advanced

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

Re: \vshape and custom curve-stencil for TextSpanner


From: Thomas Morley
Subject: Re: \vshape and custom curve-stencil for TextSpanner
Date: Sat, 23 Jul 2022 20:35:35 +0200

Am Sa., 23. Juli 2022 um 16:06 Uhr schrieb Jean Abou Samra <jean@abou-samra.fr>:
>
> Hi Harm,
>
>
> Le 23/07/2022 à 10:59, Thomas Morley a écrit :
> > I'm attempting to create a s-curve stencil for TextSpanner.
> > While so far all works as wished and it is possibel to use \shape,
> > \vshape doesn't print the control-points.
> >
> > What am I missing?
>
>
> \shape works because it's an override/tweak to the control-points
> property, and your code reads this property.
>
> \vshape is implemented with separate grobs, ControlPoint and
> ControlPolygon. This is so that you can override their basic
> properties (color, layer, thickness, ...) independently from the
> bezier grob. They are created by the Show_control_points_engraver,
> which acknowledges bezier curve grobs and reads their
> show-control-points-property. Your custom TextSpanner isn't
> recognized because it doesn't have the bezier-curve-interface,
> and this is what Show_control_points_engraver acknowledges.

Thanks, for your detailed explanation.
To get around it one could do:

#(define (add-to-interfaces iface name grob-descriptions-alist)
  (map
    (lambda (x)
      (if (eq? (car x) name)
          (let* (;; Use `list-copy' like `completize-grob-entry' in
                 ;; scm/define-grobs.scm
                 (grob-entry (map list-copy (cdr x)))
                 ;; Though why here again?
                 (meta-entry (map list-copy (assoc-get 'meta grob-entry)))
                 ;; and not here?
                 (ifaces-entry
                  (assoc-get 'interfaces meta-entry)))
            (set! ifaces-entry (cons iface ifaces-entry))
            (set! meta-entry (assoc-set! meta-entry 'interfaces ifaces-entry))
            (set! grob-entry (assoc-set! grob-entry 'meta meta-entry))
            (cons name grob-entry))
          x))
   grob-descriptions-alist))

\layout {
  \context {
    \Global
    \grobdescriptions
      #(add-to-interfaces
        'bezier-curve-interface
        'TextSpanner
        all-grob-descriptions)
  }
}

> Do you have a specific reason to use a TextSpanner? How
> about using a Slur?

Well, I need to directly connect two notes/rests, probably with a lot
of other stuff in between.
For this connection several styles are possible
(1) A straight line (maybe dashed or dotted)
    Thus TextSpanner was my first thought. Alas, in most cases the line will
    not be horizontal so I need some stencil override anyway.
    Pretty simple, though, can be made to work automatically.
(2) A curve, probably a s-curve.
    Thus current thread topic
(3) A multiple kneed line:
         ________
|_______|        |
                 v
(the graphic will likely not survive mail delivery unchanged, though
maybe you can imagine it)

To summarize, all three possibilities will need other stencils.
If control-points are available (Slur) it is probably not hard to get to (1).
For (2), a Slur may be good out of the box, otherwise vshape will always work.
For kneed lines (3), make connected-path-stencil may work.

All three possibilities can be made to work with TextSpanner and Slur.
I think I have to experiment, what works out better.

Thanks,
  Harm



reply via email to

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