Hello Lukas, hello Jean,

Using details works very well, thank you for that. I’ve appended an example I 
just did for Paolo Prete for overriding properties of different articulation 
types (although it is not limited to that) using this details property.

@Jean: I just don’t want to bother you developers with a feature request if by 
stupidity I request for something that does already exists, like the details 
property Lukas mentioned.

One use case is: We can have scores with multiple time signatures by moving 
some engravers from Score to Staff (or whatever). Now if we have a piece where 
we have a section with mixed time signatures, we might want to kind of switch 
between a Score engraver and a Staff engraver within the music. Of course as 
you said this would just need switching engraver on and off withing music. 
Maybe one could have an engraver property one can set to block the engraver 
from outputting stuff?

About the font-feature thing you’re probably right, I just thought that there 
is no reason to override anything if we do not change anything. Removing font 
features can be useful if we have activated some feature (e.g. by saying 
\override something.font-features #'(smcp)) but then we have one particular 
case where we do not want that feature.

Valentin
%%%  SNIPPET BEGINS


%%% if proc is a procedure evaluate (proc grob), else return proc as value
#(define (eval-if-proc proc grob)
   (if (procedure? proc)
       (proc grob)
       proc))


%%% retrieves overrides from grob.details.path.key where key is some key function or else from
%%% grob.path.default or default parameter if not exists
#(define ((override-by-details tag path . default) grob)
   (let* ((key (tag grob))
          (tweak (ly:assoc-get key (ly:assoc-get path (ly:grob-property grob 'details) '()) 'pass))
          (default (ly:assoc-get 'default
                                 (ly:assoc-get path (ly:grob-property grob 'details) '())
                                 (if (null? default) default (car default)))))
     (if (equal? tweak 'pass) default tweak)))
     

%%% articulation type as tag
#(define (articulation-type grob)
   (string->symbol (ly:prob-property (ly:grob-property grob 'cause) 'articulation-type)))


\layout {
  \context {
    \Score
    \override Script.font-size = #(override-by-details articulation-type 'font-size)
    \override Script.color = #(override-by-details articulation-type 'color)
    
    % This override is only nescessary as somehow if font-size is a procedure it is not evaluated automatically,
    % so we need to manually call (ly:grob-property grob 'font-size) once.
    \override Script.stencil = #(lambda (grob)
                                  (ly:grob-property grob 'font-size)
                                  (ly:script-interface::print grob))
  }
}

\score
{
  {
    \textLengthOn
    \override Script.details.font-size.tenuto = #2
    \override Script.details.font-size.accent = #-5
    \override Script.details.color.tenuto = #red
    \override Script.details.color.marcato = #blue
    c'4->^"-5" c'4--^"+2,red" c'4-\tweak #'font-size #-2 -- ^"manual tweak -2" c'-^^"blue" c'-\tweak #'color #green -^^"manual tweak green"
    s4*3 |
    c'8-- c'-> c'-! c'-^
    \temporary\override Script.details.font-size.default = #4
    c'8-- c'-> c'-! c'-^
    \temporary\override Script.details.color.default = #yellow
    c'8-- c'-> c'-! c'-^
    \revert Script.details.font-size.default
    \revert Script.details.color.default
    c'8-- c'-> c'-! c'-^
    \override Script.details.color.tenuto = #green
    c'8-- c'-> c'-! c'-^
  }
}
%%%  SNIPPET ENDS

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to