lilypond-user
[Top][All Lists]
Advanced

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

Re: Custom clef horizontal adjustment.


From: Pierre Perol-Schneider
Subject: Re: Custom clef horizontal adjustment.
Date: Tue, 3 Jul 2018 09:25:38 +0200

Hi DFro,

How about :

%CODE START
%%%%% Valentin Villanave's macro for the French-style C clef %%%%%%%

\version "2.19.82" %% "2.18.2" 

altoClef =
#(ly:make-stencil
  `(path 0.001
    `(moveto  2.48 -3.06
     lineto   2.48 -4.92
     curveto  2.48 -4.96 2.45 -5.00 2.40 -5.00
     lineto   2.18 -5.00
     curveto  2.13 -5.00 2.10 -4.96 2.10 -4.92
     lineto   2.10 4.92
     curveto  2.10 4.96 2.13 5.00 2.18 5.00
     lineto   2.40 5.00
     curveto  2.45 5.00 2.48 4.96 2.48 4.92
     lineto   2.48 2.92
     curveto  2.74 2.70 3.48 2.42 3.70 2.42
     curveto  4.04 2.42 4.62 2.28 4.62 4.53
     curveto  4.62 5.60 4.76 6.70 5.76 6.70
     curveto  6.28 6.70 6.71 6.26 6.71 5.71
     curveto  6.71 5.16 6.28 4.71 5.76 4.71
     curveto  5.26 4.71 5.30 4.96 5.20 5.03
     curveto  5.13 5.02 5.10 4.78 5.10 4.37
     lineto   5.10 3.40
     curveto  5.10 1.92 4.90 0.94 4.77 0.79
     curveto  4.42 0.39 3.32 0.70 2.48 0.70
     lineto   2.48 -0.83
     curveto  3.32 -0.83 4.42 -0.53 4.77 -0.93
     curveto  4.90 -1.08 5.10 -2.06 5.10 -3.54
     lineto   5.10 -4.51
     curveto  5.10 -4.91 5.13 -5.16 5.20 -5.17
     curveto  5.30 -5.09 5.26 -4.85 5.76 -4.85
     curveto  6.28 -4.85 6.71 -5.30 6.71 -5.84
     curveto  6.71 -6.40 6.28 -6.84 5.76 -6.84
     curveto  4.76 -6.84 4.62 -5.74 4.62 -4.67
     curveto  4.62 -2.42 4.04 -2.56 3.70 -2.56
     curveto  3.48 -2.56 2.74 -2.83 2.48 -3.06
     closepath
     moveto   1.30 -5.00
     lineto   0.08 -5.00
     curveto  0.04 -5.00 0 -4.96 0 -4.92
     lineto   0 4.92
     curveto  0 4.96 0.04 5.00 0.08 5.00
     lineto   1.30 5.00
     curveto  1.34 5.00 1.38 4.96 1.38 4.92
     lineto   1.38 -4.92
     curveto  1.38 -4.96 1.34 -5.00 1.30 -5.00
      closepath)
     'round 'round #t)
   (cons  -0.1 5)
   (cons  -5   5))

\layout {
  \context {
    \Score
    \override Clef.stencil =
      #(lambda (grob)
         (let* ((sz (ly:grob-property grob 'font-size 0))
                (mlt (magstep sz))
                (glyph (ly:grob-property grob 'glyph-name)))
                 (cond
                  ((equal? glyph "clefs.C") 
                     (ly:stencil-scale altoClef (* .4 mlt) (* .4 mlt)))
                  ((equal? glyph "clefs.C_change") 
                    (ly:stencil-scale altoClef (* .3 mlt) (* .3 mlt)))
                  (else (ly:clef::print grob)))))
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%

\relative c' {

      \numericTimeSignature
      \clef "alto"

      | c4 c
      \set Staff.forceClef = ##t
      \clef "alto"

      c4 c \break
      \set Staff.forceClef = ##t
      \clef "alto"

      | c4 c c c

      \time 2/4
      \break
     
      \set Staff.forceClef = ##t
      \clef "alto"

      | c8 c
     
      \set Staff.forceClef = ##t
      \clef "alto"

      c c \break

      \set Staff.forceClef = ##t
      \clef "alto"

      | c8 c c c
}

\paper {
      ragged-right = ##t
}

%%%

(See LSR: See : http://lsr.di.unimi.it/LSR/Item?id=900 )
Cheers,
Pierre

2018-07-03 7:18 GMT+02:00 David Kastrup <address@hidden>:
dfro <address@hidden> writes:

> In the code snippet below, the custom glyph sometimes collides with
> the notes before it, and sometimes does not. Also, I cannot control
> the distance from notes immediately after the custom glyph, as I can
> with the standard "alto" glyph.
>
> I have tried to experiment and to understand the various Clef object
> properties, but I cannot figure it out. I am sure there is something
> basic about grob behavior that I don't understand, yet.
>
> %CODE START
> %%%%% Valentin Villanave's macro for the French-style C clef %%%%%%%
>
> altoClef = \markup \postscript #"
> gsave newpath
>    0.004 0.004 scale
>    -200 0 translate
[...]
> fill grestore"

Uh, that's opaque to LilyPond.  It has neither bounding box nor
outline.  Try rewriting in terms of the \path command.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user


reply via email to

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