Le 17/08/2022 à 10:25, Jean Abou Samra a écrit :
Le 16 août 2022 à 21:14, lilyp...@lists.johnteskemusic.com a écrit :
Of course, happy to give more context. I primarily write graphic
scores (but with western notation symbols). The score isn't always
static, so I want to be able to manipulate fragments of music after
generation.
In the past I have used my own program to place glyphs
programmatically, which requires that I create my own notation<>glyph
mappings and to have the engraving font installed/available to
whoever views it.
When I saw that Lilypond produces shapes in SVG output, not glyphs, I
was intrigued--and leveraging Lilypond's input over my own mapping is
appealing as well.
I suppose one answer is keep my current system and outline the glyphs
like Lilypond may be doing under the hood. Another is to make and
group selections based on position, not an id attribute, from the
current Lilypond output.
Thanks both for your explanations. Is it not possible to use
attributes without collapsing different <g> tags into one? John, you
have a command that does not work in a comment in your original
example, and it does not work because markups are a standalone system
for creating any graphics you like, where there are no grobs, but it
is possible to implement a markup command that sets attributes as
well. Untested (I’m on vacation), but I think this should work:
#(define-markup-command (with-output-attributes attrs arg) (list? markup?)
(let ((stil (interpret-markup layout props arg)))
(ly:make-stencil (list 'output-attributes attrs (ly:stencil-expr
stil))
(ly:stencil-extent stil X)
(ly:stencil-extent stil Y))))
\markup \combine a \with-output-attributes #'((mylayer . 4)) { b c }
Now tested, and I was missing "layout props":
\version "2.23.11"
#(define-markup-command (with-output-attributes layout props attrs arg)
(list? markup?)
(let ((stil (interpret-markup layout props arg)))
(ly:make-stencil (list 'output-attributes attrs (ly:stencil-expr
stil))
(ly:stencil-extent stil X)
(ly:stencil-extent stil Y))))
\markup { a \with-output-attributes #'((mylayer . 4)) { b c } }