lilypond-user
[Top][All Lists]
Advanced

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

Re: Custom clef horizontal adjustment.


From: dfro
Subject: Re: Custom clef horizontal adjustment.
Date: Thu, 5 Jul 2018 22:54:57 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

David and Pierre,

Thank you for the suggestions. I appreciate you making a code example for me. I saw this method earlier in the LSR, but could not make sense of it at the time. Pierre, your example helps me to see the difference between the "\path" way of doing things and the "\markup \postscript" way of doing things.

I have several questions that are arising as I play with the code and try to understand its behavior.

The \path-like version shifts the glyph over 2 units from the postscript method. Is there a way to do some kind of 'translate' equivalent with the \path commands in Scheme? Do I need to do something like make a spreadsheet that recalculates all the numbers and then retype them; or, could some different Scheme code be added to move the glyph left or right without having to manually reenter the numbers? For example:

Sudo-code:

(moveto
(
... moveto,
    lineto,
    curveto,
    closepath commands....
))

(I am sure my noobiness is very apparent with this question!)

I intend to make glyphs in FontForge or Inkscape and export them as an eps. If I just copy and past the postscript numbers into the \path-like code and then change the code:                      (ly:stencil-scale altoClef (* .4 mlt) (* .4 mlt)))
To:                         (ly:stencil-scale altoClef (* .004 mlt) (* .004 mlt)))

... it does not compile and I get an error message. Why? (The postscript numbers with the .004 scale and the \path numbers with the .4 scale calculate to the same numbers.) Also, what is 'mlt' an abbreviation for?

At my level of understanding, I see using a spreadsheet to translate the postscript numbers into \path numbers. Is there a better way of doing this?

I am beginning to understand how Scheme functions work, but I wonder - What do these commands do?:

   (cons  -0.1 5)
   (cons  -5   5)

I found out in 'Extending 1.1.4' that 'cons' is a Scheme way of creating value pairs. But, what parameters are they effecting? While playing with them I got the spacing of the glyph and the various barlines, notes, and time signature spacing to change, but I could not discover any logical pattern and it often caused note clashing.

Also, how could one add the "filled #t" or "filled #f" property into the "altoClef = " Scheme function?

The main question I am wondering is - How does LilyPond determine the size of a grob, and can it be configured manually? Can the leftmost or rightmost extent be configured? Or, is this the wrong way to think of things? For example, I notice that if I change the value in the code:
         (let* ((sz (ly:grob-property grob 'font-size 0))

so that the font is very large, then the notes will nicely nest inside the glyph and reestablish the same spacing. If I do the same kind of rescaling with the postscript way, it just expands over the notes.

I appreciate any thoughts that anyone would enjoy sharing. I want to better understand this amazing program and make my manuscript writing process smoother.

LilyPond is a work of art.

Peace,
David Froseth



On 7/3/18 3:25 AM, Pierre Perol-Schneider wrote:
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
}

%%%

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]