lilypond-user
[Top][All Lists]
Advanced

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

Re: Parenthesized notehead


From: Mats Bengtsson
Subject: Re: Parenthesized notehead
Date: Thu, 24 Nov 2005 10:22:46 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

As a first step, put it in LSR.

  /Mats

Jonatan Liljedahl wrote:

People often asks how to get parenthesized noteheads. There is an
example: stencil-hacking.ly but that doesn't adjust the stencil extents
properly, so the parenthesis collides with accidentals and stuff like
that. I have made a version that does take care of this:

Perhaps this functionality should be included in lilypond, it's not so
uncommon to want parenthesis around noteheads... There could be a
\startParenthesizeNoteHeads and \stopParenthesizeNoteHeads command...
(or maybe some shorter names? ;) Or even something like "\override
NoteHead #'parenthesized = ##t" (merge the code below with the default
stencil proc for noteheads)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.7.15"

#(define (parenthesize-callback callback)
  (define (parenthesize-stencil grob)
    (let* ((fn (ly:grob-default-font grob))
            (pclose (ly:font-get-glyph fn "accidentals.rightparen"))
            (popen (ly:font-get-glyph fn "accidentals.leftparen"))
            (subject (callback grob))

                ; get position of stem
                (stem-pos (ly:grob-property grob 'stem-attachment))
                
            ; remember old size
            (subject-dim-x (ly:stencil-extent subject 0))
            (subject-dim-y (ly:stencil-extent subject 1)))

       ;; add parens
       (set! subject
(ly:stencil-combine-at-edge (ly:stencil-combine-at-edge subject 0 1 pclose 0)
              0 -1 popen  0))
; adjust stem position
                (ly:grob-set-property! grob 'stem-attachment
                        (cons (- (car stem-pos) 0.43) (cdr stem-pos)))

        ; adjust size
      (ly:make-stencil
       (ly:stencil-expr subject)
                  (cons (- (car subject-dim-x) 0.5) (+ (cdr
subject-dim-x) 0.5)) subject-dim-y)))
  parenthesize-stencil)
\layout { raggedright = ##t }
\relative c' {

   c4 e
   \override NoteHead  #'stencil = #(parenthesize-callback
Note_head::print) g bes a1
   \revert NoteHead #'stencil

   a8 gis8 a2.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/Jonatan    -=( http://kymatica.com )=-


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

--
=============================================
        Mats Bengtsson
        Signal Processing
        Signals, Sensors and Systems
        Royal Institute of Technology
        SE-100 44  STOCKHOLM
        Sweden
        Phone: (+46) 8 790 8463                         
       Fax:   (+46) 8 790 7260
        Email: address@hidden
        WWW: http://www.s3.kth.se/~mabe
=============================================





reply via email to

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