lilypond-devel
[Top][All Lists]
Advanced

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

Re: Duplicate SVG attribute


From: Jean Abou Samra
Subject: Re: Duplicate SVG attribute
Date: Sun, 25 Dec 2022 19:02:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

Le 24/12/2022 à 15:38, Paolo Prete a écrit :
Hello,

I'm noting that the generated SVG of this...:

{
     \once \override DynamicText.output-attributes.val = "x"
     \once \override DynamicText.output-attributes.val = "y"
     c'\mf
}

... creates the following SVG tag, with a duplicate "val" attribute:
<g val="y" val="x">


I've opened https://gitlab.com/lilypond/lilypond/-/issues/6494

It is unusual, though, to do two \once \override for the same grob property at the same time.

I would say it's reasonable to expect this to work when the overrides are together in sequential music ({ ... }) like this, but it is preferable not to do it in parallel music like

\version "2.25.0"

\new Voice <<
  { \once \override NoteHead.color = red c' }
  { \once \override NoteHead.color = blue d' }
>>


because in more complex cases, it gets tricky for LilyPond to determine which override is meant to have precedence.


Is this a bug? Also note that the duplication doesn't happen if I use
"\override" instead of "\once \override".

In case of a bug, is there a workaround for it (I mean: is there a way to
call \once \override multiple times for the same attribute without
duplicating it)?



\version "2.25.0"

#(define* (my-uniq-list lst #:optional (cmp equal?))
  (reverse!
   (fold (lambda (x acc)
           (if (null? acc)
               (list x)
               (if (cmp x (car acc))
                   acc
                   (cons x acc))))
         '() lst) '()))


#(set! (@@ (lily output-svg) stencil-dispatch-alist)
       (assq-set!
        (@@ (lily output-svg) stencil-dispatch-alist)
        'start-group-node
        (lambda (attrs)
          (format
           #f
           "<g ~a>\n"
           (string-concatenate
            (map (match-lambda
                   ((attr . val) (ly:format " ~a=\"~a\"" attr val)))
                 (my-uniq-list
                  (sort attrs
                        (comparator-from-key car (comparator-from-key symbol->string string<?)))
                  (comparator-from-key car eq?))))))))

{
    \once \override DynamicText.output-attributes.val = "x"
    \once \override DynamicText.output-attributes.val = "y"
    c'\mf
}



With the usual warning when using @@ that you should not expect any sort of stability for this kind of code.

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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