Hello all,

a few months ago in some forum I found the following snippet of a beautiful
G clef (I think by Pierre Perol-Schneider) that I've been extensively using
since then. Right now in the NR we have \clef G, \clef treble, \clef "G2"
and \clef violin, all producing what seems to be the exact same clef. To
name the exact same clef in so many ways ("G2" strikes me as unnecessary)
doesn't seem to have a reasonable explanation to me. Some clefs have
variants like the C clef (\clef varC). I wish Perol-Schneider's clef could
be considered for inclusion into standard Lilypond, possibly named as "G2"
(which would actually produce a "second" G clef) or as \clef varG. I hope
he doesn't mind that I "re-publish" his code in this mailing list:

\version "2.20.0"

%% New treble clef defs:
#(define-markup-command (G_Score layout props thk mlt) (number? number?)
  (interpret-markup layout props
   (markup
    (#:stencil
     (make-path-stencil
      '(M  1.117 -2.778
        C  0.730 -2.782  0.363 -2.364 0.484 -1.981
        C  0.566 -1.641  1.043 -1.540 1.285 -1.786
        C  1.504 -1.997  1.418 -2.395 1.141 -2.513
        C  0.996 -2.567  0.836 -2.583 1.090 -2.614
        C  1.379 -2.673  1.703 -2.559 1.828 -2.278
        C  1.969 -1.911  1.820 -1.395 1.766 -1.024
        C  1.031 -1.169  0.277 -0.903 0.031 -0.196
        C -0.129  0.323 -0.043  0.917 0.250  1.366
        C  0.492  1.737  0.832  1.999 1.152  2.300
        C  1.070  2.886  1.000  3.468 1.203  4.034
        C  1.297  4.292  1.484  4.503 1.680  4.687
        C  1.898  4.886  2.117  4.335 2.211  4.062
        C  2.398  3.601  2.227  2.839 1.934  2.323
        C  1.816  2.105  1.637  1.929 1.457  1.757
        C  1.500  1.523  1.539  1.288 1.586  1.054
        C  2.117  1.077  2.477  0.792 2.602  0.359
        C  2.766 -0.134  2.516 -0.766 1.953 -0.977
        C  2.004 -1.423  2.160 -1.927 2.004 -2.313
        C  1.902 -2.567  1.656 -2.766 1.379 -2.778
        C  1.293 -2.798  1.203 -2.790 1.117 -2.782
        M  1.734 -0.919
        C  1.621 -0.306  1.574  0.026 1.500  0.464
        C  1.164  0.433  0.973  0.066 1.090 -0.220
        C  1.141 -0.345  1.223 -0.407 1.359 -0.485
        C  1.492 -0.563  1.387 -0.657 1.297 -0.618
        C  1.031 -0.509  0.664 -0.188 0.758  0.269
        C  0.816  0.569  1.059  0.917 1.398  1.023
        C  1.359  1.261  1.332  1.378 1.297  1.612
        C  0.887  1.234  0.332  0.753 0.348  0.155
        C  0.363 -0.532  0.746 -1.071 1.734 -0.919
        M  1.688  0.480
        C  1.762  0.105  1.844 -0.509 1.926 -0.880
        C  2.656 -0.462  2.438  0.534 1.688  0.480
        M  2.016  3.776
        C  1.984  4.378  1.691  4.058 1.500  3.706
        C  1.313  3.366  1.273  2.894 1.352  2.468
        C  1.945  3.066  2.031  3.409 2.016  3.776
        Z)
       thk mlt mlt #t)))))

clefGScore = \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.G")
                       (grob-interpret-markup grob
                        (markup #:scale(cons mlt mlt)#:G_Score 0 1)))
                      ((equal? glyph "clefs.G_change")
                       (grob-interpret-markup grob
                        (markup #:scale(cons mlt mlt)#:G_Score .01 .8)))
                      (else (ly:clef::print grob)))))
           \override ClefModifier.clef-alignments = #'((G 0 . .4))
           % Optional:
           %\override ClefModifier.font-series = #'bold
        }
      }
%% defs end.

%% Test:
\clefGScore

This code effectively modifies Emmentaler's G Clef instead of having its
own separate glyph, so that using \clef treble or \clef french produces the
custom clef as output. When using this clef, the following music

{ \clef G
  c'1
  \clef "G2"
  c'1
  \clef violin
  c'1
  \clef french
  c'1
}

looks like this:

[image: image.png]

Cheers,
Martín.

-- 
www.martinrinconbotero.com

Reply via email to