[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: SVG export - how might you add classes for all graphical objects?
From:       Matt Hood <matthood0 () gmail ! com>
Date:       2021-06-30 1:30:09
Message-ID: CAF+x7s3n_bEZy-8NdJ6rRKQFLZjZJMEQ9EPx4qi-rbiuP77xpQ () mail ! gmail ! com
[Download RAW message or body]

That's quite handy to know, thanks for your response Carl.

Cheers,
Matt.

On Wed, Jun 30, 2021 at 2:35 AM Carl Sorensen <c_sorensen@byu.edu> wrote:
> 
> 
> 
> On 6/29/21, 2:43 AM, "lilypond-user on behalf of Matt Hood" \
> <lilypond-user-bounces+carl.d.sorensen=gmail.com@gnu.org on behalf of \
> matthood0@gmail.com> wrote: 
> Hi everyone,
> 
> I'm working with lilypond output in the browser, using its SVG export
> function. Lilypond permits attaching attributes to particular kinds of
> grobs, e.g.:
> 
> {
> \override NoteHead.output-attributes =
> #'((class . "NoteHead"))
> c
> }
> 
> The above will cause all NoteHead objects to have the following SVG:
> 
> <g class="NoteHead">
> ...NoteHead grob SVG elements...
> </g>
> 
> My question is: how can I make it so that all graphical objects have
> their name in the class attribute?
> 
> I've tried using the following scheme function:
> 
> #(define (add-class grob grob-origin context)
> (let (name (cdr (assoc 'name
> (ly:grob-property grob 'meta))))
> (set! (ly:grob-property grob 'output-attributes) '((class
> . name)))))
> 
> This successfully (I believe) extracts the correct name, and assigns
> it to the output-attributes field. As per the instructions in the
> lilypond documentation, I then attempted to use \applyOutput Score
> #add-class to apply this function to all graphical objects, but it
> didn't supply all of the required objects. My attempted code is below:
> 
> \applyOutput Score #add-class
> \score {
> \new RhythmicStaff {
> c'2 c'16 c' c' c' \tuplet 5/4 { c'16 c' c' c' c' }
> }
> }
> 
> If I add a print call to the add-class function, I can see that it was
> called for the objects with the following names from which crucial
> objects such as NoteHead are missing:
> 
> NonMusicalPaperColumn
> PaperColumn
> Clef
> TimeSignature
> LedgerLineSpanner
> StaffSymbol
> VerticalAxisGroup
> SystemStartBar
> SpacingSpanner
> VerticalAlignment
> StaffSpacing
> BreakAlignment
> LeftEdge
> BreakAlignGroup
> BreakAlignGroup
> BreakAlignGroup
> 
> Matt, I'm not an expert on \applyOutput, but it appears to me these are all grobs \
> created by engravers that live in the Score context by default. 
> You may wish to try \applyOutput to Staff and Voice as well.
> 
> Haven't tried it, and don't know if it will work, but it's an idea.
> 
> HTH,
> 
> Carl
> 
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic