Nicolas Sceaux <[EMAIL PROTECTED]> writes:

> Han-Wen Nienhuys  <[EMAIL PROTECTED]> writes:
>
> [answers to questions]
>
> Thank you!
> I can go on.

Here is a second try. The parenthesization(!?) is naive, thus the
result is not terrific.

\version "2.3.13"

parenthesize=#(def-music-function (location grob-type music) (symbol? ly:music?)
                "Add parentheses around the grobs of type `grob-type' in `music'."
                (define (parenthesize-print-function print-function)
                  (lambda (grob)
                    (let* ((subject (print-function grob))
                           (subject-dim-x (ly:stencil-extent subject 0))
                           (subject-dim-y (ly:stencil-extent subject 1)))
                      (set! (ly:grob-property grob 'font-encoding) 'fetaMusic)
                      (let* ((fn (ly:get-default-font grob))
                             (pclose (ly:find-glyph-by-name fn 
"accidentals-rightparen"))
                             (popen (ly:find-glyph-by-name fn 
"accidentals-leftparen")))
                        ;; add parens
                        (set! subject
                        (ly:stencil-combine-at-edge 
                          (ly:stencil-combine-at-edge subject 0 1 pclose 0.2)
                            0 -1 popen  0.2))
                        ;; revert old size.
                        (ly:stencil-set-extent! subject 0 subject-dim-x)
                        (ly:stencil-set-extent! subject 1 subject-dim-y)
                        subject))))
                (make-sequential-music
                  (list (make-music 'ApplyContext
                                    'procedure (lambda (context)
                                                 (let ((print-function (cdr (assoc 
'print-function (ly:context-grob-definition context grob-type)))))
                                                   (ly:context-pushpop-property 
context grob-type 'print-function (parenthesize-print-function print-function)))))
                        music
                  (make-music 'ApplyContext
                              'procedure (lambda (context)
                                           (ly:context-pushpop-property context 
grob-type 'print-function))))))
\paper { raggedright = ##t }
\relative c' {
    \context Voice
    \parenthesize #'NoteHead { c^"NoteHead" d } e f
    \parenthesize #'DynamicText { c^"DynamicText"\mp d } e\mp f
}
nicolas
_______________________________________________
lilypond-devel mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to