lilypond-user
[Top][All Lists]
Advanced

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

Re: Change stem stencil


From: Thomas Morley
Subject: Re: Change stem stencil
Date: Tue, 23 May 2017 10:49:14 +0200

2017-05-23 4:19 GMT+02:00 Jon Arnold <address@hidden>:
> Hi-
>
> I am trying to notate a harp string muffle like here:
> https://s3.amazonaws.com/cdn.harpcenter.com/images/extras/MufflesEx10R10.jpg
>
> I found a script by Peter Bjuhr that successfully replaces the stem
> (modified for glyph I need):
> https://lists.gnu.org/archive/html/lilypond-user/2014-02/msg00665.html
>
> #(define (muffle-stem grob)
>     (if (ly:stencil? (ly:stem::print grob))
>       (let* ((stencil (ly:stem::print grob))
>              (X-ext (ly:stencil-extent stencil X))
>              (Y-ext (ly:stencil-extent stencil Y))
>              (width (interval-length X-ext))
>              (len (interval-length Y-ext)))
>
>         (ly:stencil-translate
>           (grob-interpret-markup grob
>             (markup #:smuflglyph "stemDamp"))
>           (cons 0 (interval-start Y-ext))))
>       #f))
>
> My only problem is that the Smufl glyph doesn't flip vertically with the
> stem, so it doesn't look right on down-stems. Can anyone help enhance the
> script to account for stem direction?
>
> Thanks so much-
>
> Jon Arnold



Probably:

%% works only if the font is properly made noticeable to LilyPond
%% include the needed files, for me:
%\include "fonts/definitions.ily"

#(define (muffle-stem grob)
  (if (ly:stencil? (ly:stem::print grob))
      (let* ((stencil (ly:stem::print grob))
             (Y-ext (ly:stencil-extent stencil Y))
             (dir (ly:grob-property grob 'direction)))

        (ly:stencil-translate
         (ly:stencil-scale
          (grob-interpret-markup grob
            (markup #:smuflglyph "stemDamp"))
         1 dir)
          (cons 0 ((if (> dir 0) interval-start interval-end) Y-ext))))
      #f))

\new Staff {
  \override Stem #'stencil = #muffle-stem
  c'4 d' e' c'
  \voiceTwo
  c'4 d' e' c'
}

Cheers,
  Harm



reply via email to

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