[Top][All Lists]

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

Re: Size of the arpeggio's arrow

From: Thomas Morley
Subject: Re: Size of the arpeggio's arrow
Date: Fri, 6 Dec 2019 12:04:51 +0100

Am Fr., 6. Dez. 2019 um 01:39 Uhr schrieb Paolo Pr <address@hidden>:
> Thomas,
> thank you for your help. Unfortunately the snippet produces two errors that 
> are visible with a size bigger than 1.2.
> Have a look at:
> 1)   A collision between the arrow and the notehead that cannot be removed 
> properly by overriding  Arpeggio.padding
> 2) A graphical mismatch between the arrow and the stem
> About 1), I can't find another property that can fix the issue.

Well, this is indeed a bug. We forgot to adjust X-extent for the
enlarged stencil.
Fixed in the code at the bottom of this mail.
Probably we need to adjust the stencil itself as well. Not sure,
though. In the code it's commented.

> About 2), Instead of the default symbol, I would use a simple triangle, so to 
> avoid any mismatch. Which is the way to add it?

So far it's more due to the changed calculation:

I wrote:

>>                  (/
>>                   (- (interval-length stil-x-ext)
>>                      (interval-length red-arrow-x-ext))
>>                   2)

The lilybin-file reads:

                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))

Which causes the problem. Go back to `2ยด and all is fine.

If you want another stencil for the arrow-head then the method is
already demonstrated.
Get the stencil from the font (there are other arrows available) or
construct it. Using markup would be the most simple. Add it to the
default line. Move the arrow accordingly.
Take care of properties positions and X-extent.

Here the changed code, additionally I did some clean up, avoiding
multiple calculations of the same things adding comments etc.

biggerArrow =
#(define-music-function (scale)(number?)
"Returns an override for @code{Arpeggio.stencil}, with arrow-heads scaled by
  \override Arpeggio.stencil =
  #(lambda (grob)
    (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction)))
      ;; If 'arpeggio-direction is unset use default-stencil
      (if (null? arp-dir)
          (ly:arpeggio::print grob)
          (let* ((arrow-glyph
                   (format #f
                     (if (negative? arp-dir) "M" "")))
                 (font (ly:grob-default-font grob))
                 (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
                 (arrow (ly:stencil-scale arrow-head-stil scale scale))
                 (arrow-y-ext (ly:stencil-extent arrow Y))
                 (arrow-x-ext (ly:stencil-extent arrow X))
                 (arrow-width (interval-length arrow-x-ext))
                 (pos (ly:grob-property grob 'positions)))

            ;; 'positions modified to reflect the height of the arrow-head
            (ly:grob-set-property! grob 'positions
              (if (positive? arp-dir)
                  (cons (car pos) (- (cdr pos) arrow-width))
                  (cons (+ (car pos) arrow-width) (cdr pos))))

            ;; unset 'arpeggio-direction to get the default trill-line stencil
            (ly:grob-set-property! grob 'arpeggio-direction '())

            (let* ((stil (ly:arpeggio::print grob))
                   (stil-y-ext (ly:stencil-extent stil Y))
                   (stil-x-ext (ly:stencil-extent stil X))
                   (stil-width (interval-length stil-x-ext))
                   ;; A scaled arrow-head will be slightly off, find the value
                   ;; to compensate for x-axis, before adding it to the
                   ;; arpeggio-line
                   (scale-compensate-x (/ (- stil-width arrow-width) 2))
                           (if (negative? arp-dir)
                               ;; For a down pointing arrow, it's top will be at
                               ;; arpeggio-line-bottom, move by it's height to
                               ;; let the arrow-basis match with the line-bottom
                               (- (car stil-y-ext)
                                  (interval-length arrow-y-ext))
                               (cdr stil-y-ext))))

               ;; We need to adjust 'X-extent to reflect the enlarged arrow,
               ;; in order to avoid spacing issues
               (ly:grob-set-property! grob 'X-extent
                   (ly:arpeggio::width grob)
                   (* scale-compensate-x -2)))

               ;; Do we need to resize the stencil? For now commented
               ;  (ly:stencil-expr new-stil)
               ;  (interval-widen stil-x-ext (* scale-compensate-x -2))
               ;  (ly:stencil-extent new-stil Y))

%% default
  <b d' f' b'>4\arpeggio

  <b d' f' b'>\arpeggio

  <b d' f' b'>\arpeggio

%% enlarged
my-scale = 2

  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio


reply via email to

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